@shopify/react-native-skia 1.11.1 → 1.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. package/android/CMakeLists.txt +0 -8
  2. package/android/cpp/jni/JniLoad.cpp +0 -2
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -1
  4. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerDelegate.java +4 -2
  5. package/cpp/jsi/ViewProperty.h +5 -16
  6. package/cpp/rnskia/RNSkManager.cpp +1 -7
  7. package/lib/commonjs/dom/nodes/index.d.ts +0 -1
  8. package/lib/commonjs/dom/nodes/index.js +0 -11
  9. package/lib/commonjs/dom/nodes/index.js.map +1 -1
  10. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -6
  11. package/lib/commonjs/external/reanimated/renderHelpers.js +0 -73
  12. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  13. package/lib/commonjs/index.d.ts +0 -1
  14. package/lib/commonjs/index.js +0 -12
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/renderer/Canvas.d.ts +10 -1
  17. package/lib/commonjs/renderer/Canvas.js +3 -1
  18. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  19. package/lib/commonjs/sksg/Container.d.ts +2 -0
  20. package/lib/commonjs/sksg/Container.js +10 -0
  21. package/lib/commonjs/sksg/Container.js.map +1 -1
  22. package/lib/commonjs/sksg/Elements.d.ts +65 -0
  23. package/lib/commonjs/sksg/Elements.js +6 -0
  24. package/lib/commonjs/sksg/Elements.js.map +1 -0
  25. package/lib/commonjs/sksg/Reconciler.d.ts +1 -0
  26. package/lib/commonjs/sksg/Reconciler.js +2 -0
  27. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  28. package/lib/commonjs/views/index.d.ts +0 -1
  29. package/lib/commonjs/views/index.js +0 -11
  30. package/lib/commonjs/views/index.js.map +1 -1
  31. package/lib/module/dom/nodes/index.d.ts +0 -1
  32. package/lib/module/dom/nodes/index.js +0 -1
  33. package/lib/module/dom/nodes/index.js.map +1 -1
  34. package/lib/module/external/reanimated/renderHelpers.d.ts +0 -6
  35. package/lib/module/external/reanimated/renderHelpers.js +0 -68
  36. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  37. package/lib/module/index.d.ts +0 -1
  38. package/lib/module/index.js +0 -1
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/renderer/Canvas.d.ts +10 -1
  41. package/lib/module/renderer/Canvas.js +1 -0
  42. package/lib/module/renderer/Canvas.js.map +1 -1
  43. package/lib/module/sksg/Container.d.ts +2 -0
  44. package/lib/module/sksg/Container.js +10 -0
  45. package/lib/module/sksg/Container.js.map +1 -1
  46. package/lib/module/sksg/Elements.d.ts +65 -0
  47. package/lib/module/sksg/Elements.js +2 -0
  48. package/lib/module/sksg/Elements.js.map +1 -0
  49. package/lib/module/sksg/Reconciler.d.ts +1 -0
  50. package/lib/module/sksg/Reconciler.js +2 -0
  51. package/lib/module/sksg/Reconciler.js.map +1 -1
  52. package/lib/module/views/index.d.ts +0 -1
  53. package/lib/module/views/index.js +0 -1
  54. package/lib/module/views/index.js.map +1 -1
  55. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -3
  56. package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +1 -0
  57. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +2 -0
  58. package/lib/typescript/lib/commonjs/sksg/Elements.d.ts +1 -0
  59. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +6 -0
  60. package/lib/typescript/lib/module/dom/nodes/index.d.ts +0 -1
  61. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +0 -3
  62. package/lib/typescript/lib/module/index.d.ts +0 -1
  63. package/lib/typescript/lib/module/mock/index.d.ts +0 -1
  64. package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -0
  65. package/lib/typescript/lib/module/sksg/Container.d.ts +2 -0
  66. package/lib/typescript/lib/module/sksg/Elements.d.ts +1 -0
  67. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +6 -0
  68. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  69. package/lib/typescript/src/dom/nodes/index.d.ts +0 -1
  70. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +0 -6
  71. package/lib/typescript/src/index.d.ts +0 -1
  72. package/lib/typescript/src/renderer/Canvas.d.ts +10 -1
  73. package/lib/typescript/src/sksg/Container.d.ts +2 -0
  74. package/lib/typescript/src/sksg/Elements.d.ts +65 -0
  75. package/lib/typescript/src/sksg/Reconciler.d.ts +1 -0
  76. package/lib/typescript/src/views/index.d.ts +0 -1
  77. package/package.json +1 -1
  78. package/src/dom/nodes/index.ts +0 -1
  79. package/src/external/reanimated/renderHelpers.ts +1 -78
  80. package/src/index.ts +0 -1
  81. package/src/renderer/Canvas.tsx +11 -1
  82. package/src/sksg/Container.ts +11 -0
  83. package/src/sksg/Elements.tsx +136 -0
  84. package/src/sksg/Reconciler.ts +2 -0
  85. package/src/views/index.ts +0 -1
  86. package/android/cpp/jni/include/JniSkiaDomView.h +0 -82
  87. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomView.java +0 -41
  88. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomViewManager.java +0 -32
  89. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +0 -34
  90. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +0 -18
  91. package/cpp/rnskia/RNSkDomView.cpp +0 -121
  92. package/cpp/rnskia/RNSkDomView.h +0 -97
  93. package/cpp/rnskia/dom/JsiDomApi.h +0 -165
  94. package/cpp/rnskia/dom/base/BaseNodeProp.h +0 -72
  95. package/cpp/rnskia/dom/base/ConcatablePaint.cpp +0 -117
  96. package/cpp/rnskia/dom/base/ConcatablePaint.h +0 -49
  97. package/cpp/rnskia/dom/base/Declaration.h +0 -86
  98. package/cpp/rnskia/dom/base/DeclarationContext.h +0 -79
  99. package/cpp/rnskia/dom/base/DerivedNodeProp.h +0 -203
  100. package/cpp/rnskia/dom/base/DrawingContext.cpp +0 -55
  101. package/cpp/rnskia/dom/base/DrawingContext.h +0 -104
  102. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +0 -119
  103. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +0 -71
  104. package/cpp/rnskia/dom/base/JsiDomNode.h +0 -572
  105. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +0 -262
  106. package/cpp/rnskia/dom/base/NodeProp.h +0 -139
  107. package/cpp/rnskia/dom/base/NodePropsContainer.h +0 -158
  108. package/cpp/rnskia/dom/nodes/JsiAtlasNode.h +0 -64
  109. package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +0 -49
  110. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +0 -94
  111. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +0 -75
  112. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +0 -94
  113. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +0 -33
  114. package/cpp/rnskia/dom/nodes/JsiCircleNode.h +0 -35
  115. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +0 -164
  116. package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +0 -37
  117. package/cpp/rnskia/dom/nodes/JsiFillNode.h +0 -22
  118. package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +0 -53
  119. package/cpp/rnskia/dom/nodes/JsiGroupNode.h +0 -25
  120. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +0 -361
  121. package/cpp/rnskia/dom/nodes/JsiImageNode.h +0 -43
  122. package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +0 -63
  123. package/cpp/rnskia/dom/nodes/JsiLayerNode.h +0 -74
  124. package/cpp/rnskia/dom/nodes/JsiLineNode.h +0 -38
  125. package/cpp/rnskia/dom/nodes/JsiOvalNode.h +0 -32
  126. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +0 -119
  127. package/cpp/rnskia/dom/nodes/JsiParagraphNode.h +0 -62
  128. package/cpp/rnskia/dom/nodes/JsiPatchNode.h +0 -50
  129. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +0 -268
  130. package/cpp/rnskia/dom/nodes/JsiPathNode.h +0 -181
  131. package/cpp/rnskia/dom/nodes/JsiPictureNode.h +0 -31
  132. package/cpp/rnskia/dom/nodes/JsiPointsNode.h +0 -48
  133. package/cpp/rnskia/dom/nodes/JsiRRectNode.h +0 -33
  134. package/cpp/rnskia/dom/nodes/JsiRectNode.h +0 -33
  135. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +0 -434
  136. package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +0 -44
  137. package/cpp/rnskia/dom/nodes/JsiTextNode.h +0 -51
  138. package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +0 -33
  139. package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +0 -41
  140. package/cpp/rnskia/dom/props/BezierProps.h +0 -65
  141. package/cpp/rnskia/dom/props/BlendModeProp.h +0 -103
  142. package/cpp/rnskia/dom/props/BoxShadowProps.h +0 -62
  143. package/cpp/rnskia/dom/props/CircleProp.h +0 -49
  144. package/cpp/rnskia/dom/props/ClipProp.h +0 -57
  145. package/cpp/rnskia/dom/props/ColorProp.h +0 -96
  146. package/cpp/rnskia/dom/props/FontProp.h +0 -42
  147. package/cpp/rnskia/dom/props/GlyphsProp.h +0 -55
  148. package/cpp/rnskia/dom/props/LayerProp.h +0 -52
  149. package/cpp/rnskia/dom/props/MatrixProp.h +0 -54
  150. package/cpp/rnskia/dom/props/NumbersProp.h +0 -67
  151. package/cpp/rnskia/dom/props/PaintProps.h +0 -133
  152. package/cpp/rnskia/dom/props/ParagraphProp.h +0 -45
  153. package/cpp/rnskia/dom/props/PathProp.h +0 -59
  154. package/cpp/rnskia/dom/props/PictureProp.h +0 -40
  155. package/cpp/rnskia/dom/props/PointProp.h +0 -65
  156. package/cpp/rnskia/dom/props/PointsProp.h +0 -81
  157. package/cpp/rnskia/dom/props/RRectProp.h +0 -222
  158. package/cpp/rnskia/dom/props/RSXformProp.h +0 -52
  159. package/cpp/rnskia/dom/props/RadiusProp.h +0 -43
  160. package/cpp/rnskia/dom/props/RectProp.h +0 -164
  161. package/cpp/rnskia/dom/props/SamplingProp.h +0 -54
  162. package/cpp/rnskia/dom/props/SkImageProps.h +0 -196
  163. package/cpp/rnskia/dom/props/StrokeProps.h +0 -79
  164. package/cpp/rnskia/dom/props/SvgProp.h +0 -45
  165. package/cpp/rnskia/dom/props/TextBlobProp.h +0 -133
  166. package/cpp/rnskia/dom/props/TileModeProp.h +0 -52
  167. package/cpp/rnskia/dom/props/TransformProp.h +0 -147
  168. package/cpp/rnskia/dom/props/TransformsProps.h +0 -66
  169. package/cpp/rnskia/dom/props/UniformsProp.h +0 -159
  170. package/cpp/rnskia/dom/props/VertexModeProp.h +0 -49
  171. package/cpp/rnskia/dom/props/VerticesProps.h +0 -63
  172. package/ios/RNSkia-iOS/SkiaDomView.h +0 -7
  173. package/ios/RNSkia-iOS/SkiaDomView.mm +0 -63
  174. package/ios/RNSkia-iOS/SkiaDomViewManager.h +0 -8
  175. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +0 -51
  176. package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +0 -64
  177. package/lib/commonjs/dom/nodes/JsiSkDOM.js +0 -196
  178. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +0 -1
  179. package/lib/commonjs/renderer/CanvasOld.d.ts +0 -11
  180. package/lib/commonjs/renderer/CanvasOld.js +0 -96
  181. package/lib/commonjs/renderer/CanvasOld.js.map +0 -1
  182. package/lib/commonjs/renderer/Container.d.ts +0 -10
  183. package/lib/commonjs/renderer/Container.js +0 -26
  184. package/lib/commonjs/renderer/Container.js.map +0 -1
  185. package/lib/commonjs/renderer/HostComponents.d.ts +0 -129
  186. package/lib/commonjs/renderer/HostComponents.js +0 -141
  187. package/lib/commonjs/renderer/HostComponents.js.map +0 -1
  188. package/lib/commonjs/renderer/HostConfig.d.ts +0 -18
  189. package/lib/commonjs/renderer/HostConfig.js +0 -157
  190. package/lib/commonjs/renderer/HostConfig.js.map +0 -1
  191. package/lib/commonjs/renderer/Reconciler.d.ts +0 -9
  192. package/lib/commonjs/renderer/Reconciler.js +0 -44
  193. package/lib/commonjs/renderer/Reconciler.js.map +0 -1
  194. package/lib/commonjs/specs/SkiaDomViewNativeComponent.d.ts +0 -6
  195. package/lib/commonjs/specs/SkiaDomViewNativeComponent.js +0 -11
  196. package/lib/commonjs/specs/SkiaDomViewNativeComponent.js.map +0 -1
  197. package/lib/commonjs/views/SkiaDomView.d.ts +0 -33
  198. package/lib/commonjs/views/SkiaDomView.js +0 -119
  199. package/lib/commonjs/views/SkiaDomView.js.map +0 -1
  200. package/lib/commonjs/views/SkiaDomView.web.d.ts +0 -0
  201. package/lib/commonjs/views/SkiaDomView.web.js +0 -2
  202. package/lib/commonjs/views/SkiaDomView.web.js.map +0 -1
  203. package/lib/module/dom/nodes/JsiSkDOM.d.ts +0 -64
  204. package/lib/module/dom/nodes/JsiSkDOM.js +0 -189
  205. package/lib/module/dom/nodes/JsiSkDOM.js.map +0 -1
  206. package/lib/module/renderer/CanvasOld.d.ts +0 -11
  207. package/lib/module/renderer/CanvasOld.js +0 -87
  208. package/lib/module/renderer/CanvasOld.js.map +0 -1
  209. package/lib/module/renderer/Container.d.ts +0 -10
  210. package/lib/module/renderer/Container.js +0 -19
  211. package/lib/module/renderer/Container.js.map +0 -1
  212. package/lib/module/renderer/HostComponents.d.ts +0 -129
  213. package/lib/module/renderer/HostComponents.js +0 -134
  214. package/lib/module/renderer/HostComponents.js.map +0 -1
  215. package/lib/module/renderer/HostConfig.d.ts +0 -18
  216. package/lib/module/renderer/HostConfig.js +0 -150
  217. package/lib/module/renderer/HostConfig.js.map +0 -1
  218. package/lib/module/renderer/Reconciler.d.ts +0 -9
  219. package/lib/module/renderer/Reconciler.js +0 -36
  220. package/lib/module/renderer/Reconciler.js.map +0 -1
  221. package/lib/module/specs/SkiaDomViewNativeComponent.d.ts +0 -6
  222. package/lib/module/specs/SkiaDomViewNativeComponent.js +0 -4
  223. package/lib/module/specs/SkiaDomViewNativeComponent.js.map +0 -1
  224. package/lib/module/views/SkiaDomView.d.ts +0 -33
  225. package/lib/module/views/SkiaDomView.js +0 -111
  226. package/lib/module/views/SkiaDomView.js.map +0 -1
  227. package/lib/module/views/SkiaDomView.web.d.ts +0 -0
  228. package/lib/module/views/SkiaDomView.web.js +0 -2
  229. package/lib/module/views/SkiaDomView.web.js.map +0 -1
  230. package/lib/typescript/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +0 -60
  231. package/lib/typescript/lib/commonjs/renderer/CanvasOld.d.ts +0 -3
  232. package/lib/typescript/lib/commonjs/renderer/Container.d.ts +0 -9
  233. package/lib/typescript/lib/commonjs/renderer/HostComponents.d.ts +0 -2
  234. package/lib/typescript/lib/commonjs/renderer/HostConfig.d.ts +0 -40
  235. package/lib/typescript/lib/commonjs/renderer/Reconciler.d.ts +0 -10
  236. package/lib/typescript/lib/commonjs/specs/SkiaDomViewNativeComponent.d.ts +0 -3
  237. package/lib/typescript/lib/commonjs/views/SkiaDomView.d.ts +0 -30
  238. package/lib/typescript/lib/commonjs/views/SkiaDomView.web.d.ts +0 -0
  239. package/lib/typescript/lib/module/dom/nodes/JsiSkDOM.d.ts +0 -59
  240. package/lib/typescript/lib/module/renderer/CanvasOld.d.ts +0 -3
  241. package/lib/typescript/lib/module/renderer/Container.d.ts +0 -9
  242. package/lib/typescript/lib/module/renderer/HostComponents.d.ts +0 -1
  243. package/lib/typescript/lib/module/renderer/HostConfig.d.ts +0 -39
  244. package/lib/typescript/lib/module/renderer/Reconciler.d.ts +0 -9
  245. package/lib/typescript/lib/module/specs/SkiaDomViewNativeComponent.d.ts +0 -2
  246. package/lib/typescript/lib/module/views/SkiaDomView.d.ts +0 -27
  247. package/lib/typescript/lib/module/views/SkiaDomView.web.d.ts +0 -0
  248. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +0 -64
  249. package/lib/typescript/src/renderer/CanvasOld.d.ts +0 -11
  250. package/lib/typescript/src/renderer/Container.d.ts +0 -10
  251. package/lib/typescript/src/renderer/HostComponents.d.ts +0 -129
  252. package/lib/typescript/src/renderer/HostConfig.d.ts +0 -18
  253. package/lib/typescript/src/renderer/Reconciler.d.ts +0 -9
  254. package/lib/typescript/src/specs/SkiaDomViewNativeComponent.d.ts +0 -6
  255. package/lib/typescript/src/views/SkiaDomView.d.ts +0 -33
  256. package/lib/typescript/src/views/SkiaDomView.web.d.ts +0 -0
  257. package/src/dom/nodes/JsiSkDOM.ts +0 -298
  258. package/src/renderer/CanvasOld.tsx +0 -126
  259. package/src/renderer/Container.tsx +0 -19
  260. package/src/renderer/HostComponents.ts +0 -399
  261. package/src/renderer/HostConfig.ts +0 -258
  262. package/src/renderer/Reconciler.tsx +0 -54
  263. package/src/specs/SkiaDomViewNativeComponent.ts +0 -9
  264. package/src/views/SkiaDomView.tsx +0 -124
  265. package/src/views/SkiaDomView.web.tsx +0 -0
@@ -1,54 +0,0 @@
1
- #pragma once
2
-
3
- #include "DerivedNodeProp.h"
4
- #include "JsiSkMatrix.h"
5
-
6
- #include <memory>
7
-
8
- namespace RNSkia {
9
-
10
- static PropId PropNameMatrix = JsiPropId::get("matrix");
11
-
12
- class MatrixProp : public DerivedProp<SkMatrix> {
13
- public:
14
- explicit MatrixProp(PropId name,
15
- const std::function<void(BaseNodeProp *)> &onChange)
16
- : DerivedProp<SkMatrix>(onChange) {
17
- _matrixProp = defineProperty<NodeProp>(name);
18
- }
19
-
20
- void updateDerivedValue() override {
21
- if (_matrixProp->isSet() &&
22
- _matrixProp->value().getType() == PropType::HostObject) {
23
- // Try reading as SkMatrix
24
- auto matrix = _matrixProp->value().getAs<JsiSkMatrix>();
25
- if (matrix != nullptr) {
26
- setDerivedValue(matrix->getObject());
27
- }
28
- } else if (_matrixProp->isSet()) {
29
- auto values = _matrixProp->value().getAsArray();
30
- auto m3 = std::make_shared<SkMatrix>();
31
- if (values.size() == 9) {
32
- for (size_t i = 0; i < values.size(); ++i) {
33
- auto a = values[i];
34
- m3->set(i, a.getAsNumber());
35
- }
36
- } else {
37
- SkM44 m4;
38
- for (size_t i = 0; i < values.size(); ++i) {
39
- auto obj = values[i];
40
- m4.setRC(i / 4, i % 4, obj.getAsNumber());
41
- }
42
- auto m = m4.asM33();
43
- m3->setAll(m.rc(0, 0), m.rc(0, 1), m.rc(0, 2), m.rc(1, 0), m.rc(1, 1),
44
- m.rc(1, 2), m.rc(2, 0), m.rc(2, 1), m.rc(2, 2));
45
- }
46
- setDerivedValue(m3);
47
- }
48
- }
49
-
50
- private:
51
- NodeProp *_matrixProp;
52
- };
53
-
54
- } // namespace RNSkia
@@ -1,67 +0,0 @@
1
- #pragma once
2
-
3
- #include "DerivedNodeProp.h"
4
-
5
- #include <memory>
6
- #include <string>
7
- #include <utility>
8
- #include <vector>
9
-
10
- namespace RNSkia {
11
-
12
- class NumbersProp : public DerivedProp<std::vector<SkScalar>> {
13
- public:
14
- explicit NumbersProp(PropId name,
15
- const std::function<void(BaseNodeProp *)> &onChange)
16
- : DerivedProp<std::vector<SkScalar>>(onChange) {
17
- _positionProp = defineProperty<NodeProp>(name);
18
- }
19
-
20
- void updateDerivedValue() override {
21
- if (_positionProp->isSet()) {
22
- auto positions = _positionProp->value().getAsArray();
23
- std::vector<SkScalar> derivedPositions;
24
- derivedPositions.reserve(positions.size());
25
-
26
- for (size_t i = 0; i < positions.size(); ++i) {
27
- derivedPositions.push_back(positions[i].getAsNumber());
28
- }
29
- setDerivedValue(std::move(derivedPositions));
30
- } else {
31
- setDerivedValue(nullptr);
32
- }
33
- }
34
-
35
- private:
36
- NodeProp *_positionProp;
37
- };
38
-
39
- class Numbers16Prop : public DerivedProp<std::vector<u_int16_t>> {
40
- public:
41
- explicit Numbers16Prop(PropId name,
42
- const std::function<void(BaseNodeProp *)> &onChange)
43
- : DerivedProp<std::vector<u_int16_t>>(onChange) {
44
- _prop = defineProperty<NodeProp>(name);
45
- }
46
-
47
- void updateDerivedValue() override {
48
- if (_prop->isSet()) {
49
- auto positions = _prop->value().getAsArray();
50
- std::vector<u_int16_t> derivedPositions;
51
- derivedPositions.reserve(positions.size());
52
-
53
- for (size_t i = 0; i < positions.size(); ++i) {
54
- derivedPositions.push_back(
55
- static_cast<u_int16_t>(positions[i].getAsNumber()));
56
- }
57
- setDerivedValue(std::move(derivedPositions));
58
- } else {
59
- setDerivedValue(nullptr);
60
- }
61
- }
62
-
63
- private:
64
- NodeProp *_prop;
65
- };
66
-
67
- } // namespace RNSkia
@@ -1,133 +0,0 @@
1
- #pragma once
2
-
3
- #include "BlendModeProp.h"
4
- #include "ColorProp.h"
5
- #include "NodeProp.h"
6
- #include "StrokeProps.h"
7
-
8
- #include "JsiSkPaint.h"
9
- #include "third_party/CSSColorParser.h"
10
-
11
- #include <memory>
12
-
13
- #pragma clang diagnostic push
14
- #pragma clang diagnostic ignored "-Wdocumentation"
15
-
16
- #include "include/core/SkPaint.h"
17
-
18
- #pragma clang diagnostic pop
19
-
20
- namespace RNSkia {
21
-
22
- class PaintProp : public DerivedProp<SkPaint> {
23
- public:
24
- explicit PaintProp(PropId name,
25
- const std::function<void(BaseNodeProp *)> &onChange)
26
- : DerivedProp<SkPaint>(onChange) {
27
- _paintProp = defineProperty<NodeProp>(name);
28
- }
29
-
30
- explicit PaintProp(const std::function<void(BaseNodeProp *)> &onChange)
31
- : PaintProp(JsiPropId::get("paint"), onChange) {}
32
-
33
- void updateDerivedValue() override {
34
- if (_paintProp->isSet()) {
35
- if (_paintProp->value().getType() == PropType::HostObject) {
36
- // Read paint property as Host Object - JsiSkPaint
37
- auto ptr = _paintProp->value().getAs<JsiSkPaint>();
38
- if (ptr != nullptr) {
39
- setDerivedValue(ptr->getObject());
40
- } else {
41
- throw std::runtime_error("Expected SkPaint object, got unknown "
42
- "object when reading paint property.");
43
- }
44
- } else {
45
- setDerivedValue(nullptr);
46
- }
47
- } else {
48
- setDerivedValue(nullptr);
49
- }
50
- }
51
-
52
- private:
53
- NodeProp *_paintProp;
54
- };
55
-
56
- class PaintDrawingContextProp : public DerivedProp<DrawingContext> {
57
- public:
58
- explicit PaintDrawingContextProp(
59
- PropId name, const std::function<void(BaseNodeProp *)> &onChange)
60
- : DerivedProp<DrawingContext>(onChange) {
61
- _paintProp = defineProperty<NodeProp>(name);
62
- }
63
-
64
- explicit PaintDrawingContextProp(
65
- const std::function<void(BaseNodeProp *)> &onChange)
66
- : PaintDrawingContextProp(JsiPropId::get("paint"), onChange) {}
67
-
68
- void updateDerivedValue() override {
69
- if (_paintProp->isSet()) {
70
- if (_paintProp->value().getType() == PropType::HostObject) {
71
- // Read paint property as Host Object - JsiSkPaint
72
- auto ptr = _paintProp->value().getAs<JsiSkPaint>();
73
- if (ptr != nullptr) {
74
- setDerivedValue(std::make_shared<DrawingContext>(ptr->getObject()));
75
- } else {
76
- throw std::runtime_error("Expected SkPaint object, got unknown "
77
- "object when reading paint property.");
78
- }
79
- } else {
80
- setDerivedValue(nullptr);
81
- }
82
- } else {
83
- setDerivedValue(nullptr);
84
- }
85
- }
86
-
87
- private:
88
- NodeProp *_paintProp;
89
- };
90
-
91
- class PaintProps : public BaseDerivedProp {
92
- public:
93
- explicit PaintProps(const std::function<void(BaseNodeProp *)> &onChange)
94
- : BaseDerivedProp(onChange) {
95
- _color = defineProperty<ColorProp>("color");
96
- _style = defineProperty<NodeProp>("style");
97
- _strokeWidth = defineProperty<NodeProp>("strokeWidth");
98
- _blendMode = defineProperty<BlendModeProp>("blendMode");
99
- _strokeJoin = defineProperty<StrokeJoinProp>("strokeJoin");
100
- _strokeCap = defineProperty<StrokeCapProp>("strokeCap");
101
- _strokeMiter = defineProperty<NodeProp>("strokeMiter");
102
- _antiAlias = defineProperty<NodeProp>("antiAlias");
103
- _dither = defineProperty<NodeProp>("dither");
104
- _opacity = defineProperty<NodeProp>("opacity");
105
- }
106
-
107
- void updateDerivedValue() override {}
108
-
109
- ColorProp *getColor() { return _color; }
110
- NodeProp *getStyle() { return _style; }
111
- NodeProp *getStrokeWidth() { return _strokeWidth; }
112
- BlendModeProp *getBlendMode() { return _blendMode; }
113
- StrokeJoinProp *getStrokeJoin() { return _strokeJoin; }
114
- StrokeCapProp *getStrokeCap() { return _strokeCap; }
115
- NodeProp *getStrokeMiter() { return _strokeMiter; }
116
- NodeProp *getAntiAlias() { return _antiAlias; }
117
- NodeProp *getDither() { return _dither; }
118
- NodeProp *getOpacity() { return _opacity; }
119
-
120
- private:
121
- ColorProp *_color;
122
- NodeProp *_style;
123
- NodeProp *_strokeWidth;
124
- BlendModeProp *_blendMode;
125
- StrokeJoinProp *_strokeJoin;
126
- StrokeCapProp *_strokeCap;
127
- NodeProp *_strokeMiter;
128
- NodeProp *_antiAlias;
129
- NodeProp *_dither;
130
- NodeProp *_opacity;
131
- };
132
-
133
- } // namespace RNSkia
@@ -1,45 +0,0 @@
1
- #pragma once
2
-
3
- #include "DerivedNodeProp.h"
4
-
5
- #include "JsiSkParagraph.h"
6
-
7
- #include <memory>
8
- #include <string>
9
-
10
- namespace RNSkia {
11
-
12
- class ParagraphProp : public DerivedProp<para::Paragraph *> {
13
- public:
14
- explicit ParagraphProp(PropId name,
15
- const std::function<void(BaseNodeProp *)> &onChange)
16
- : DerivedProp<para::Paragraph *>(onChange) {
17
- _paragraphProp = defineProperty<NodeProp>(name);
18
- }
19
-
20
- void updateDerivedValue() override {
21
- if (_paragraphProp->isSet()) {
22
- if (_paragraphProp->value().getType() != PropType::HostObject) {
23
- throw std::runtime_error("Expected Paragraph object for the " +
24
- std::string(getName()) + " property.");
25
- }
26
-
27
- auto ptr = std::dynamic_pointer_cast<JsiSkParagraph>(
28
- _paragraphProp->value().getAsHostObject());
29
-
30
- if (ptr == nullptr) {
31
- throw std::runtime_error("Expected paragraph object for the " +
32
- std::string(getName()) + " property.");
33
- }
34
-
35
- setDerivedValue(ptr->getParagraph());
36
- } else {
37
- setDerivedValue(nullptr);
38
- }
39
- }
40
-
41
- private:
42
- NodeProp *_paragraphProp;
43
- };
44
-
45
- } // namespace RNSkia
@@ -1,59 +0,0 @@
1
- #pragma once
2
-
3
- #include "DerivedNodeProp.h"
4
- #include "JsiSkPath.h"
5
-
6
- #include <memory>
7
-
8
- #pragma clang diagnostic push
9
- #pragma clang diagnostic ignored "-Wdocumentation"
10
-
11
- #include "include/core/SkPath.h"
12
-
13
- #pragma clang diagnostic pop
14
-
15
- namespace RNSkia {
16
-
17
- class PathProp : public DerivedProp<SkPath> {
18
- public:
19
- explicit PathProp(PropId name,
20
- const std::function<void(BaseNodeProp *)> &onChange)
21
- : DerivedProp<SkPath>(onChange) {
22
- _pathProp = defineProperty<NodeProp>(name);
23
- }
24
-
25
- static std::shared_ptr<SkPath> processPath(const JsiValue &value) {
26
- if (value.getType() == PropType::HostObject) {
27
- // Try reading as Path
28
- auto ptr = std::dynamic_pointer_cast<JsiSkPath>(value.getAsHostObject());
29
- if (ptr != nullptr) {
30
- return ptr->getObject();
31
- }
32
- } else if (value.getType() == PropType::String) {
33
- // Read as string
34
- auto pathString = value.getAsString();
35
- SkPath result;
36
-
37
- if (SkParsePath::FromSVGString(pathString.c_str(), &result)) {
38
- return std::make_shared<SkPath>(result);
39
- } else {
40
- throw std::runtime_error("Could not parse path from string.");
41
- }
42
- }
43
- return nullptr;
44
- }
45
-
46
- void updateDerivedValue() override {
47
- if (!_pathProp->isSet()) {
48
- setDerivedValue(nullptr);
49
- return;
50
- }
51
- auto value = _pathProp->value();
52
- setDerivedValue(PathProp::processPath(value));
53
- }
54
-
55
- private:
56
- NodeProp *_pathProp;
57
- };
58
-
59
- } // namespace RNSkia
@@ -1,40 +0,0 @@
1
- #pragma once
2
-
3
- #include "DerivedNodeProp.h"
4
-
5
- #include "JsiSkPicture.h"
6
-
7
- #include <memory>
8
- #include <string>
9
-
10
- namespace RNSkia {
11
-
12
- class PictureProp : public DerivedSkProp<SkPicture> {
13
- public:
14
- explicit PictureProp(PropId name,
15
- const std::function<void(BaseNodeProp *)> &onChange)
16
- : DerivedSkProp<SkPicture>(onChange) {
17
- _pictureProp = defineProperty<NodeProp>(name);
18
- }
19
-
20
- void updateDerivedValue() override {
21
- if (_pictureProp->value().getType() != PropType::HostObject) {
22
- throw std::runtime_error("Expected SkPicture object for the " +
23
- std::string(getName()) + " property.");
24
- }
25
-
26
- auto ptr = std::dynamic_pointer_cast<JsiSkPicture>(
27
- _pictureProp->value().getAsHostObject());
28
- if (ptr == nullptr) {
29
- throw std::runtime_error("Expected SkPicture object for the " +
30
- std::string(getName()) + " property.");
31
- }
32
-
33
- setDerivedValue(ptr->getObject());
34
- }
35
-
36
- private:
37
- NodeProp *_pictureProp;
38
- };
39
-
40
- } // namespace RNSkia
@@ -1,65 +0,0 @@
1
- #pragma once
2
-
3
- #include "DerivedNodeProp.h"
4
- #include "JsiSkPoint.h"
5
-
6
- #include <memory>
7
- #include <utility>
8
-
9
- #pragma clang diagnostic push
10
- #pragma clang diagnostic ignored "-Wdocumentation"
11
-
12
- #include "include/core/SkPoint.h"
13
-
14
- #pragma clang diagnostic pop
15
-
16
- namespace RNSkia {
17
-
18
- static PropId PropNameX = JsiPropId::get("x");
19
- static PropId PropNameY = JsiPropId::get("y");
20
-
21
- class PointProp : public DerivedProp<SkPoint> {
22
- public:
23
- explicit PointProp(PropId name,
24
- const std::function<void(BaseNodeProp *)> &onChange)
25
- : DerivedProp<SkPoint>(onChange) {
26
- _pointProp = defineProperty<NodeProp>(name);
27
- }
28
-
29
- void updateDerivedValue() override {
30
- if (_pointProp->isSet()) {
31
- // Check for JsiSkRect and JsiSkPoint
32
- setDerivedValue(processValue(_pointProp->value()));
33
- } else {
34
- setDerivedValue(nullptr);
35
- }
36
- }
37
-
38
- static SkPoint processValue(const JsiValue &value) {
39
- if (value.getType() == PropType::HostObject) {
40
- // Try reading as point
41
- auto ptr = std::dynamic_pointer_cast<JsiSkPoint>(value.getAsHostObject());
42
- if (ptr != nullptr) {
43
- return SkPoint::Make(ptr->getObject()->x(), ptr->getObject()->y());
44
- } else {
45
- // Try reading as rect
46
- auto ptr =
47
- std::dynamic_pointer_cast<JsiSkRect>(value.getAsHostObject());
48
- if (ptr != nullptr) {
49
- return SkPoint::Make(ptr->getObject()->x(), ptr->getObject()->y());
50
- }
51
- }
52
- } else if (value.getType() == PropType::Object &&
53
- value.hasValue(PropNameX) && value.hasValue(PropNameY)) {
54
- auto x = value.getValue(PropNameX);
55
- auto y = value.getValue(PropNameY);
56
- return SkPoint::Make(x.getAsNumber(), y.getAsNumber());
57
- }
58
- throw std::runtime_error("Expected point value.");
59
- }
60
-
61
- private:
62
- NodeProp *_pointProp;
63
- };
64
-
65
- } // namespace RNSkia
@@ -1,81 +0,0 @@
1
- #pragma once
2
-
3
- #include "DerivedNodeProp.h"
4
- #include "JsiSkPoint.h"
5
-
6
- #include <memory>
7
- #include <string>
8
- #include <utility>
9
- #include <vector>
10
-
11
- #pragma clang diagnostic push
12
- #pragma clang diagnostic ignored "-Wdocumentation"
13
-
14
- #include "include/core/SkPoint.h"
15
-
16
- #pragma clang diagnostic pop
17
-
18
- namespace RNSkia {
19
-
20
- class PointModeProp : public DerivedProp<SkCanvas::PointMode> {
21
- public:
22
- explicit PointModeProp(PropId name,
23
- const std::function<void(BaseNodeProp *)> &onChange)
24
- : DerivedProp<SkCanvas::PointMode>(onChange) {
25
- _pointModeProp = defineProperty<NodeProp>(name);
26
- }
27
-
28
- void updateDerivedValue() override {
29
- if (_pointModeProp->isSet()) {
30
- setDerivedValue(
31
- getPointModeFromStringValue(_pointModeProp->value().getAsString()));
32
- } else {
33
- setDerivedValue(nullptr);
34
- }
35
- }
36
-
37
- private:
38
- static SkCanvas::PointMode
39
- getPointModeFromStringValue(const std::string &value) {
40
- if (value == "points") {
41
- return SkCanvas::PointMode::kPoints_PointMode;
42
- } else if (value == "lines") {
43
- return SkCanvas::PointMode::kLines_PointMode;
44
- } else if (value == "polygon") {
45
- return SkCanvas::PointMode::kPolygon_PointMode;
46
- }
47
- throw std::runtime_error(
48
- "Expected valid point mode for Points node, got \"" + value + "\".");
49
- }
50
-
51
- NodeProp *_pointModeProp;
52
- };
53
-
54
- class PointsProp : public DerivedProp<std::vector<SkPoint>> {
55
- public:
56
- explicit PointsProp(PropId name,
57
- const std::function<void(BaseNodeProp *)> &onChange)
58
- : DerivedProp<std::vector<SkPoint>>(onChange) {
59
- _pointsProp = defineProperty<NodeProp>(name);
60
- }
61
-
62
- void updateDerivedValue() override {
63
- if (_pointsProp->isSet()) {
64
- auto pointsArray = _pointsProp->value().getAsArray();
65
- std::vector<SkPoint> points;
66
- points.reserve(pointsArray.size());
67
- for (size_t i = 0; i < pointsArray.size(); ++i) {
68
- auto p = pointsArray[i];
69
- points.push_back(PointProp::processValue(p));
70
- }
71
- setDerivedValue(std::move(points));
72
- } else {
73
- setDerivedValue(nullptr);
74
- }
75
- }
76
-
77
- private:
78
- NodeProp *_pointsProp;
79
- };
80
-
81
- } // namespace RNSkia