@shopify/react-native-skia 0.1.164 → 0.1.166

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +16 -5
  2. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +34 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomViewManager.java +2 -47
  4. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawViewManager.java +2 -44
  5. package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureViewManager.java +2 -47
  6. package/cpp/api/JsiSkRuntimeEffect.h +7 -2
  7. package/cpp/rnskia/RNSkDomView.cpp +1 -1
  8. package/cpp/rnskia/RNSkPlatformContext.h +2 -6
  9. package/cpp/rnskia/dom/base/DerivedNodeProp.h +4 -4
  10. package/cpp/rnskia/dom/base/DrawingContext.cpp +5 -38
  11. package/cpp/rnskia/dom/base/DrawingContext.h +3 -17
  12. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +4 -4
  13. package/cpp/rnskia/dom/nodes/JsiCircleNode.h +0 -2
  14. package/cpp/rnskia/dom/nodes/JsiCustomDrawingNode.h +1 -3
  15. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +2 -2
  16. package/cpp/rnskia/dom/nodes/JsiPathNode.h +12 -5
  17. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +17 -7
  18. package/cpp/rnskia/dom/props/CircleProp.h +2 -0
  19. package/cpp/rnskia/dom/props/ClipProp.h +6 -6
  20. package/cpp/rnskia/dom/props/ColorProp.h +9 -4
  21. package/cpp/rnskia/dom/props/ImageProps.h +6 -3
  22. package/cpp/rnskia/dom/props/PaintProps.h +15 -22
  23. package/cpp/rnskia/dom/props/RectProp.h +11 -4
  24. package/cpp/rnskia/dom/props/UniformsProp.h +86 -123
  25. package/cpp/rnskia/dom/props/VerticesProps.h +2 -2
  26. package/cpp/rnskia/values/RNSkReadonlyValue.h +2 -6
  27. package/lib/commonjs/dom/nodes/datatypes/Circle.js +6 -1
  28. package/lib/commonjs/dom/nodes/datatypes/Circle.js.map +1 -1
  29. package/lib/commonjs/dom/nodes/datatypes/Rect.js +3 -3
  30. package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
  31. package/lib/commonjs/dom/nodes/drawings/Box.js +1 -1
  32. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  33. package/lib/commonjs/dom/nodes/drawings/ImageNode.js +2 -2
  34. package/lib/commonjs/dom/nodes/drawings/ImageNode.js.map +1 -1
  35. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +1 -1
  36. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  37. package/lib/commonjs/dom/nodes/paint/Shaders.js +5 -2
  38. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  39. package/lib/commonjs/dom/types/Common.js.map +1 -1
  40. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  41. package/lib/commonjs/renderer/components/Mask.js +2 -6
  42. package/lib/commonjs/renderer/components/Mask.js.map +1 -1
  43. package/lib/commonjs/renderer/components/image/Image.js +0 -5
  44. package/lib/commonjs/renderer/components/image/Image.js.map +1 -1
  45. package/lib/commonjs/renderer/components/image/ImageShader.js +20 -10
  46. package/lib/commonjs/renderer/components/image/ImageShader.js.map +1 -1
  47. package/lib/commonjs/renderer/components/imageFilters/Blur.js +10 -5
  48. package/lib/commonjs/renderer/components/imageFilters/Blur.js.map +1 -1
  49. package/lib/commonjs/renderer/components/imageFilters/Morphology.js +10 -5
  50. package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
  51. package/lib/commonjs/renderer/components/imageFilters/Offset.js +12 -6
  52. package/lib/commonjs/renderer/components/imageFilters/Offset.js.map +1 -1
  53. package/lib/commonjs/renderer/components/maskFilters/Blur.js +12 -6
  54. package/lib/commonjs/renderer/components/maskFilters/Blur.js.map +1 -1
  55. package/lib/commonjs/renderer/components/pathEffects/Discrete.js +10 -5
  56. package/lib/commonjs/renderer/components/pathEffects/Discrete.js.map +1 -1
  57. package/lib/commonjs/renderer/components/shaders/FractalNoise.js +14 -7
  58. package/lib/commonjs/renderer/components/shaders/FractalNoise.js.map +1 -1
  59. package/lib/commonjs/renderer/components/shaders/Shader.js +10 -5
  60. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  61. package/lib/commonjs/renderer/components/shaders/Turbulence.js +14 -7
  62. package/lib/commonjs/renderer/components/shaders/Turbulence.js.map +1 -1
  63. package/lib/commonjs/renderer/components/shapes/Circle.js +0 -6
  64. package/lib/commonjs/renderer/components/shapes/Circle.js.map +1 -1
  65. package/lib/commonjs/renderer/components/shapes/FitBox.js +1 -4
  66. package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
  67. package/lib/commonjs/renderer/components/shapes/Oval.js +0 -4
  68. package/lib/commonjs/renderer/components/shapes/Oval.js.map +1 -1
  69. package/lib/commonjs/renderer/components/shapes/Path.js +12 -6
  70. package/lib/commonjs/renderer/components/shapes/Path.js.map +1 -1
  71. package/lib/commonjs/renderer/components/shapes/Points.js +10 -5
  72. package/lib/commonjs/renderer/components/shapes/Points.js.map +1 -1
  73. package/lib/commonjs/renderer/components/shapes/RoundedRect.js +0 -3
  74. package/lib/commonjs/renderer/components/shapes/RoundedRect.js.map +1 -1
  75. package/lib/commonjs/renderer/components/shapes/Vertices.js +10 -5
  76. package/lib/commonjs/renderer/components/shapes/Vertices.js.map +1 -1
  77. package/lib/commonjs/renderer/components/text/Glyphs.js +12 -6
  78. package/lib/commonjs/renderer/components/text/Glyphs.js.map +1 -1
  79. package/lib/commonjs/renderer/components/text/Text.js +12 -6
  80. package/lib/commonjs/renderer/components/text/Text.js.map +1 -1
  81. package/lib/commonjs/renderer/components/text/TextBlob.js +12 -6
  82. package/lib/commonjs/renderer/components/text/TextBlob.js.map +1 -1
  83. package/lib/commonjs/renderer/components/text/TextPath.js +10 -5
  84. package/lib/commonjs/renderer/components/text/TextPath.js.map +1 -1
  85. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  86. package/lib/commonjs/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
  87. package/lib/commonjs/skia/types/Shader/Shader.js +25 -25
  88. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  89. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +6 -1
  90. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  91. package/lib/commonjs/skia/web/JsiSkRuntimeEffectFactory.js +1 -1
  92. package/lib/commonjs/skia/web/JsiSkRuntimeEffectFactory.js.map +1 -1
  93. package/lib/module/dom/nodes/datatypes/Circle.js +8 -1
  94. package/lib/module/dom/nodes/datatypes/Circle.js.map +1 -1
  95. package/lib/module/dom/nodes/datatypes/Rect.js +7 -3
  96. package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
  97. package/lib/module/dom/nodes/drawings/Box.js +1 -1
  98. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  99. package/lib/module/dom/nodes/drawings/ImageNode.js +4 -2
  100. package/lib/module/dom/nodes/drawings/ImageNode.js.map +1 -1
  101. package/lib/module/dom/nodes/paint/ImageFilters.js +1 -1
  102. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  103. package/lib/module/dom/nodes/paint/Shaders.js +5 -4
  104. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  105. package/lib/module/dom/types/Common.js.map +1 -1
  106. package/lib/module/dom/types/Drawings.js.map +1 -1
  107. package/lib/module/renderer/components/Mask.js +2 -6
  108. package/lib/module/renderer/components/Mask.js.map +1 -1
  109. package/lib/module/renderer/components/image/Image.js +0 -5
  110. package/lib/module/renderer/components/image/Image.js.map +1 -1
  111. package/lib/module/renderer/components/image/ImageShader.js +20 -10
  112. package/lib/module/renderer/components/image/ImageShader.js.map +1 -1
  113. package/lib/module/renderer/components/imageFilters/Blur.js +10 -5
  114. package/lib/module/renderer/components/imageFilters/Blur.js.map +1 -1
  115. package/lib/module/renderer/components/imageFilters/Morphology.js +10 -5
  116. package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
  117. package/lib/module/renderer/components/imageFilters/Offset.js +12 -6
  118. package/lib/module/renderer/components/imageFilters/Offset.js.map +1 -1
  119. package/lib/module/renderer/components/maskFilters/Blur.js +12 -6
  120. package/lib/module/renderer/components/maskFilters/Blur.js.map +1 -1
  121. package/lib/module/renderer/components/pathEffects/Discrete.js +10 -5
  122. package/lib/module/renderer/components/pathEffects/Discrete.js.map +1 -1
  123. package/lib/module/renderer/components/shaders/FractalNoise.js +14 -7
  124. package/lib/module/renderer/components/shaders/FractalNoise.js.map +1 -1
  125. package/lib/module/renderer/components/shaders/Shader.js +10 -5
  126. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  127. package/lib/module/renderer/components/shaders/Turbulence.js +14 -7
  128. package/lib/module/renderer/components/shaders/Turbulence.js.map +1 -1
  129. package/lib/module/renderer/components/shapes/Circle.js +0 -6
  130. package/lib/module/renderer/components/shapes/Circle.js.map +1 -1
  131. package/lib/module/renderer/components/shapes/FitBox.js +1 -4
  132. package/lib/module/renderer/components/shapes/FitBox.js.map +1 -1
  133. package/lib/module/renderer/components/shapes/Oval.js +0 -4
  134. package/lib/module/renderer/components/shapes/Oval.js.map +1 -1
  135. package/lib/module/renderer/components/shapes/Path.js +12 -6
  136. package/lib/module/renderer/components/shapes/Path.js.map +1 -1
  137. package/lib/module/renderer/components/shapes/Points.js +10 -5
  138. package/lib/module/renderer/components/shapes/Points.js.map +1 -1
  139. package/lib/module/renderer/components/shapes/RoundedRect.js +0 -3
  140. package/lib/module/renderer/components/shapes/RoundedRect.js.map +1 -1
  141. package/lib/module/renderer/components/shapes/Vertices.js +10 -5
  142. package/lib/module/renderer/components/shapes/Vertices.js.map +1 -1
  143. package/lib/module/renderer/components/text/Glyphs.js +12 -6
  144. package/lib/module/renderer/components/text/Glyphs.js.map +1 -1
  145. package/lib/module/renderer/components/text/Text.js +12 -6
  146. package/lib/module/renderer/components/text/Text.js.map +1 -1
  147. package/lib/module/renderer/components/text/TextBlob.js +12 -6
  148. package/lib/module/renderer/components/text/TextBlob.js.map +1 -1
  149. package/lib/module/renderer/components/text/TextPath.js +10 -5
  150. package/lib/module/renderer/components/text/TextPath.js.map +1 -1
  151. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  152. package/lib/module/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
  153. package/lib/module/skia/types/Shader/Shader.js +25 -25
  154. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  155. package/lib/module/skia/web/JsiSkRuntimeEffect.js +6 -1
  156. package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  157. package/lib/module/skia/web/JsiSkRuntimeEffectFactory.js +1 -1
  158. package/lib/module/skia/web/JsiSkRuntimeEffectFactory.js.map +1 -1
  159. package/lib/typescript/src/dom/nodes/datatypes/Circle.d.ts +4 -1
  160. package/lib/typescript/src/dom/types/Common.d.ts +4 -4
  161. package/lib/typescript/src/dom/types/Drawings.d.ts +1 -1
  162. package/lib/typescript/src/renderer/components/Mask.d.ts +3 -9
  163. package/lib/typescript/src/renderer/components/image/Image.d.ts +1 -8
  164. package/lib/typescript/src/renderer/components/image/ImageShader.d.ts +2 -12
  165. package/lib/typescript/src/renderer/components/imageFilters/Blur.d.ts +2 -7
  166. package/lib/typescript/src/renderer/components/imageFilters/Morphology.d.ts +2 -7
  167. package/lib/typescript/src/renderer/components/imageFilters/Offset.d.ts +2 -8
  168. package/lib/typescript/src/renderer/components/maskFilters/Blur.d.ts +2 -8
  169. package/lib/typescript/src/renderer/components/pathEffects/Discrete.d.ts +2 -7
  170. package/lib/typescript/src/renderer/components/shaders/FractalNoise.d.ts +2 -9
  171. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -7
  172. package/lib/typescript/src/renderer/components/shaders/Turbulence.d.ts +2 -9
  173. package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -9
  174. package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +2 -7
  175. package/lib/typescript/src/renderer/components/shapes/Oval.d.ts +1 -7
  176. package/lib/typescript/src/renderer/components/shapes/Path.d.ts +2 -8
  177. package/lib/typescript/src/renderer/components/shapes/Points.d.ts +2 -7
  178. package/lib/typescript/src/renderer/components/shapes/RoundedRect.d.ts +1 -6
  179. package/lib/typescript/src/renderer/components/shapes/Vertices.d.ts +2 -7
  180. package/lib/typescript/src/renderer/components/text/Glyphs.d.ts +2 -8
  181. package/lib/typescript/src/renderer/components/text/Text.d.ts +2 -8
  182. package/lib/typescript/src/renderer/components/text/TextBlob.d.ts +2 -8
  183. package/lib/typescript/src/renderer/components/text/TextPath.d.ts +2 -7
  184. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +5 -0
  185. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +4 -0
  186. package/lib/typescript/src/skia/types/Shader/Shader.d.ts +1 -2
  187. package/lib/typescript/src/skia/web/JsiSkRuntimeEffect.d.ts +3 -1
  188. package/package.json +1 -1
  189. package/src/dom/nodes/datatypes/Circle.ts +1 -1
  190. package/src/dom/nodes/datatypes/Rect.ts +3 -3
  191. package/src/dom/nodes/drawings/Box.ts +1 -1
  192. package/src/dom/nodes/drawings/ImageNode.ts +2 -1
  193. package/src/dom/nodes/paint/ImageFilters.ts +1 -1
  194. package/src/dom/nodes/paint/Shaders.ts +5 -5
  195. package/src/dom/types/Common.ts +4 -4
  196. package/src/dom/types/Drawings.ts +1 -1
  197. package/src/renderer/components/Mask.tsx +8 -8
  198. package/src/renderer/components/image/Image.tsx +0 -6
  199. package/src/renderer/components/image/ImageShader.tsx +24 -12
  200. package/src/renderer/components/imageFilters/Blur.tsx +6 -7
  201. package/src/renderer/components/imageFilters/Morphology.tsx +6 -7
  202. package/src/renderer/components/imageFilters/Offset.tsx +7 -8
  203. package/src/renderer/components/maskFilters/Blur.tsx +7 -8
  204. package/src/renderer/components/pathEffects/Discrete.tsx +6 -9
  205. package/src/renderer/components/shaders/FractalNoise.tsx +18 -9
  206. package/src/renderer/components/shaders/Shader.tsx +6 -7
  207. package/src/renderer/components/shaders/Turbulence.tsx +15 -9
  208. package/src/renderer/components/shapes/Circle.tsx +0 -4
  209. package/src/renderer/components/shapes/FitBox.tsx +2 -6
  210. package/src/renderer/components/shapes/Oval.tsx +0 -5
  211. package/src/renderer/components/shapes/Path.tsx +7 -8
  212. package/src/renderer/components/shapes/Points.tsx +6 -7
  213. package/src/renderer/components/shapes/RoundedRect.tsx +0 -4
  214. package/src/renderer/components/shapes/Vertices.tsx +6 -7
  215. package/src/renderer/components/text/Glyphs.tsx +7 -8
  216. package/src/renderer/components/text/Text.tsx +7 -8
  217. package/src/renderer/components/text/TextBlob.tsx +7 -8
  218. package/src/renderer/components/text/TextPath.tsx +6 -7
  219. package/src/renderer/processors/Animations/Animations.ts +9 -3
  220. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +5 -0
  221. package/src/skia/types/Shader/Shader.ts +30 -36
  222. package/src/skia/web/JsiSkRuntimeEffect.ts +5 -1
  223. package/src/skia/web/JsiSkRuntimeEffectFactory.ts +1 -1
@@ -45,18 +45,18 @@ public:
45
45
  return _pathProp->isSet() || _rectProp->isSet() || _rrectProp->isSet();
46
46
  }
47
47
 
48
- SkPath *getPath() { return _path.get(); }
49
- SkRect *getRect() { return _rect.get(); }
50
- SkRRect *getRRect() { return _rrect.get(); }
48
+ const SkPath *getPath() { return _path.get(); }
49
+ const SkRect *getRect() { return _rect.get(); }
50
+ const SkRRect *getRRect() { return _rrect.get(); }
51
51
 
52
52
  private:
53
53
  PathProp *_pathProp;
54
54
  RectProp *_rectProp;
55
55
  RRectProp *_rrectProp;
56
56
 
57
- std::shared_ptr<SkPath> _path;
58
- std::shared_ptr<SkRect> _rect;
59
- std::shared_ptr<SkRRect> _rrect;
57
+ std::shared_ptr<const SkPath> _path;
58
+ std::shared_ptr<const SkRect> _rect;
59
+ std::shared_ptr<const SkRRect> _rrect;
60
60
  };
61
61
 
62
62
  } // namespace RNSkia
@@ -9,6 +9,11 @@
9
9
 
10
10
  namespace RNSkia {
11
11
 
12
+ static PropId PropName0 = JsiPropId::get("0");
13
+ static PropId PropName1 = JsiPropId::get("1");
14
+ static PropId PropName2 = JsiPropId::get("2");
15
+ static PropId PropName3 = JsiPropId::get("3");
16
+
12
17
  class ColorProp : public DerivedProp<SkColor> {
13
18
  public:
14
19
  explicit ColorProp(PropId name) : DerivedProp<SkColor>() {
@@ -28,10 +33,10 @@ public:
28
33
  static SkColor parseColorValue(const JsiValue &color) {
29
34
  if (color.getType() == PropType::Object) {
30
35
  // Float array
31
- auto r = color.getValue(JsiPropId::get("0"));
32
- auto g = color.getValue(JsiPropId::get("1"));
33
- auto b = color.getValue(JsiPropId::get("2"));
34
- auto a = color.getValue(JsiPropId::get("3"));
36
+ auto r = color.getValue(PropName0);
37
+ auto g = color.getValue(PropName1);
38
+ auto b = color.getValue(PropName2);
39
+ auto a = color.getValue(PropName3);
35
40
  return SkColorSetARGB(a.getAsNumber() * 255.0f, r.getAsNumber() * 255.0f,
36
41
  g.getAsNumber() * 255.0f, b.getAsNumber() * 255.0f);
37
42
 
@@ -30,7 +30,8 @@ public:
30
30
  }
31
31
 
32
32
  void updateDerivedValue() override {
33
- if (_imageProp->value().getType() != PropType::HostObject) {
33
+ if (!_imageProp->isSet() ||
34
+ _imageProp->value().getType() != PropType::HostObject) {
34
35
  throw std::runtime_error("Expected SkImage object for the " +
35
36
  std::string(getName()) + " property.");
36
37
  }
@@ -67,13 +68,15 @@ public:
67
68
 
68
69
  auto rect = _rectProp->getDerivedValue() ? *_rectProp->getDerivedValue()
69
70
  : imageRect;
70
- auto fit = _fitProp->isSet() ? _fitProp->value().getAsString() : "none";
71
+ auto fit = _fitProp->isSet() ? _fitProp->value().getAsString() : "contain";
71
72
 
72
73
  setDerivedValue(fitRects(fit, imageRect, rect));
73
74
  }
74
75
 
75
76
  sk_sp<SkImage> getImage() { return _imageProp->getDerivedValue(); }
76
- std::shared_ptr<SkRect> getRect() { return _rectProp->getDerivedValue(); }
77
+ std::shared_ptr<const SkRect> getRect() {
78
+ return _rectProp->getDerivedValue();
79
+ }
77
80
 
78
81
  SkRect rect2rect(SkRect src, SkRect dst) {
79
82
  auto scaleX = dst.width() / src.width();
@@ -19,8 +19,6 @@
19
19
 
20
20
  namespace RNSkia {
21
21
 
22
- static PropId PropNameCurrent = JsiPropId::get("current");
23
-
24
22
  class PaintProp : public DerivedProp<SkPaint> {
25
23
  public:
26
24
  explicit PaintProp(PropId name) : DerivedProp<SkPaint>() {
@@ -40,20 +38,6 @@ public:
40
38
  throw std::runtime_error("Expected SkPaint object, got unknown "
41
39
  "object when reading paint property.");
42
40
  }
43
- } else if (_paintProp->value().getType() == PropType::Object) {
44
- // We have a JS object - is it a ref?
45
- auto ref = _paintProp->value().getValue(PropNameCurrent);
46
- if (ref.getType() == PropType::HostObject) {
47
- auto ptr = ref.getAs<JsiSkPaint>();
48
- if (ptr != nullptr) {
49
- // Update the local paint for the current context
50
- setDerivedValue(ptr->getObject());
51
- } else {
52
- throw std::runtime_error(
53
- "Expected reference to a SkPaint object, got unknown object "
54
- "when reading paint property.");
55
- }
56
- }
57
41
  } else {
58
42
  setDerivedValue(nullptr);
59
43
  }
@@ -92,22 +76,31 @@ public:
92
76
 
93
77
  // Opacity
94
78
  if (_opacity->isChanged() || context->isChanged()) {
79
+ auto parent = context->getParent();
80
+ auto paint = context->getMutablePaint();
95
81
  if (_opacity->isSet()) {
96
- context->setOpacity(_opacity->value().getAsNumber());
82
+ auto currentOpacity = _opacity->value().getAsNumber();
83
+ auto parent = context->getParent();
84
+ if (parent != nullptr) {
85
+ currentOpacity *= parent->getPaint()->getAlphaf();
86
+ }
87
+ paint->setAlphaf(currentOpacity);
97
88
  } else {
98
- context->clearOpacity();
89
+ if (parent != nullptr) {
90
+ paint->setAlphaf(parent->getPaint()->getAlphaf());
91
+ } else {
92
+ paint->setAlphaf(1.0);
93
+ }
99
94
  }
100
95
  }
101
96
 
102
97
  // COLOR
103
98
  if (_color->isSet() && (_color->isChanged() || context->isChanged())) {
104
99
  auto paint = context->getMutablePaint();
100
+ auto opacity = paint->getAlphaf();
105
101
  paint->setShader(nullptr);
106
102
  paint->setColor(*_color->getDerivedValue());
107
- paint->setAlphaf(context->getOpacity() * paint->getColor4f().fA);
108
- } else if (context->isChanged()) {
109
- auto paint = context->getMutablePaint();
110
- paint->setAlphaf(context->getOpacity());
103
+ paint->setAlphaf(opacity * paint->getColor4f().fA);
111
104
  }
112
105
 
113
106
  // Style
@@ -76,10 +76,17 @@ public:
76
76
  }
77
77
 
78
78
  void updateDerivedValue() override {
79
- if (_x->isSet() && _y->isSet() && _width->isSet() && _height->isSet()) {
80
- setDerivedValue(SkRect::MakeXYWH(
81
- _x->value().getAsNumber(), _y->value().getAsNumber(),
82
- _width->value().getAsNumber(), _height->value().getAsNumber()));
79
+ if (_width->isSet() && _height->isSet()) {
80
+ auto x = 0.0;
81
+ auto y = 0.0;
82
+ if (_x->isSet()) {
83
+ x = _x->value().getAsNumber();
84
+ }
85
+ if (_y->isSet()) {
86
+ y = _y->value().getAsNumber();
87
+ }
88
+ setDerivedValue(SkRect::MakeXYWH(x, y, _width->value().getAsNumber(),
89
+ _height->value().getAsNumber()));
83
90
  }
84
91
  }
85
92
 
@@ -16,6 +16,68 @@
16
16
 
17
17
  namespace RNSkia {
18
18
 
19
+ bool isJSPoint(const JsiValue &value) {
20
+ return value.getType() == PropType::Object && value.hasValue(PropNameX) &&
21
+ value.hasValue(PropNameY);
22
+ }
23
+
24
+ bool isSkPoint(const JsiValue &value) {
25
+ return value.getType() == PropType::HostObject &&
26
+ std::dynamic_pointer_cast<JsiSkPoint>(value.getAsHostObject()) !=
27
+ nullptr;
28
+ }
29
+
30
+ bool isIndexable(const JsiValue &value) {
31
+ return value.getType() == PropType::Object && value.hasValue(PropName0);
32
+ }
33
+
34
+ void processValue(std::vector<SkScalar> &values, const JsiValue &value) {
35
+ if (value.getType() == PropType::Number) {
36
+ auto n = value.getAsNumber();
37
+ values.push_back(n);
38
+ } else if (value.getType() == PropType::Array) {
39
+ auto arrayValue = value.getAsArray();
40
+ for (size_t i = 0; i < arrayValue.size(); ++i) {
41
+ auto a = arrayValue[i];
42
+ processValue(values, a);
43
+ }
44
+ } else if (isJSPoint(value) || isSkPoint(value)) {
45
+ auto pointValue = PointProp::processValue(value);
46
+ values.push_back(pointValue.x());
47
+ values.push_back(pointValue.y());
48
+ } else if (isIndexable(value)) {
49
+ auto length = value.getKeys().size();
50
+ for (size_t i = 0; i < length; ++i) {
51
+ values.push_back(
52
+ value.getValue(JsiPropId::get(std::to_string(i))).getAsNumber());
53
+ }
54
+ }
55
+ }
56
+
57
+ void processUniform(std::vector<SkScalar> &values, SkRuntimeEffect *source,
58
+ const JsiValue &uniforms, SkRuntimeShaderBuilder *rtb) {
59
+ auto uniformsCount = source->uniforms().size();
60
+ for (size_t i = 0; i < uniformsCount; ++i) {
61
+ auto it = source->uniforms().begin() + i;
62
+ auto name = JsiPropId::get(std::string(it->name));
63
+ if (!uniforms.hasValue(name)) {
64
+ throw std::runtime_error("The runtime effect has the uniform value \"" +
65
+ std::string(name) +
66
+ "\" declared, but it is missing from the "
67
+ "uniforms property of the Runtime effect.");
68
+ }
69
+ auto value = uniforms.getValue(name);
70
+ if (rtb == nullptr) {
71
+ processValue(values, value);
72
+ } else {
73
+ std::vector<SkScalar> uniformValue;
74
+ processValue(uniformValue, value);
75
+ rtb->uniform(name).set(uniformValue.data(),
76
+ static_cast<int>(uniformValue.size()));
77
+ }
78
+ }
79
+ }
80
+
19
81
  class UniformsProp : public DerivedSkProp<SkData> {
20
82
  public:
21
83
  UniformsProp(PropId name, NodeProp *sourceProp) : DerivedSkProp<SkData>() {
@@ -32,7 +94,9 @@ public:
32
94
  auto source = _sourceProp->value().getAs<JsiSkRuntimeEffect>()->getObject();
33
95
 
34
96
  // Flatten uniforms from property
35
- auto uniformValues = flattenUniforms(source.get(), _uniformsProp->value());
97
+ std::vector<SkScalar> uniformValues;
98
+ processUniform(uniformValues, source.get(), _uniformsProp->value(),
99
+ nullptr);
36
100
 
37
101
  // Cast uniforms according to the declaration in the shader
38
102
  auto uniformsData = castUniforms(source.get(), uniformValues);
@@ -41,11 +105,30 @@ public:
41
105
  setDerivedValue(uniformsData);
42
106
  }
43
107
 
108
+ void processUniforms(SkRuntimeShaderBuilder &rtb) {
109
+ if (!_uniformsProp->isSet()) {
110
+ return;
111
+ }
112
+
113
+ // Get the effect
114
+ auto source = _sourceProp->value().getAs<JsiSkRuntimeEffect>()->getObject();
115
+ // Flatten uniforms from property
116
+ std::vector<SkScalar> uniformValues;
117
+ processUniform(uniformValues, source.get(), _uniformsProp->value(), &rtb);
118
+ }
119
+
44
120
  private:
45
121
  sk_sp<SkData> castUniforms(SkRuntimeEffect *source,
46
122
  const std::vector<SkScalar> &values) {
47
123
  // Create memory for uniforms
48
- auto uniformsData = SkData::MakeUninitialized(source->uniformSize());
124
+ auto uniformSize = source->uniformSize();
125
+ if (values.size() * sizeof(float) != uniformSize) {
126
+ throw std::runtime_error(
127
+ "Uniforms size differs from effect's uniform size. Received " +
128
+ std::to_string(values.size()) + " expected " +
129
+ std::to_string(uniformSize / sizeof(float)));
130
+ }
131
+ auto uniformsData = SkData::MakeUninitialized(uniformSize);
49
132
 
50
133
  // Loop through all uniforms in the effect and load data from the flattened
51
134
  // array of values
@@ -57,7 +140,7 @@ private:
57
140
  const std::size_t offset = reu.slot + j;
58
141
  float fValue = values.at(offset);
59
142
  int iValue = static_cast<int>(fValue);
60
- auto value = reu.isInteger ? iValue : fValue;
143
+ auto value = reu.isInteger ? SkBits2Float(iValue) : fValue;
61
144
  memcpy(SkTAddOffset<void>(uniformsData->writable_data(),
62
145
  offset * sizeof(value)),
63
146
  &value, sizeof(value));
@@ -67,126 +150,6 @@ private:
67
150
  return uniformsData;
68
151
  }
69
152
 
70
- std::vector<SkScalar> flattenUniforms(SkRuntimeEffect *source,
71
- const JsiValue &propObject) {
72
- auto uniformsCount = source->uniforms().size();
73
- std::vector<SkScalar> uniformValues;
74
-
75
- for (size_t i = 0; i < uniformsCount; ++i) {
76
- auto it = source->uniforms().begin() + i;
77
- auto name = JsiPropId::get(std::string(it->name));
78
-
79
- if (!propObject.hasValue(name)) {
80
- throw std::runtime_error("The runtime effect has the uniform value \"" +
81
- std::string(name) +
82
- "\" declared, but it is missing from the "
83
- "uniforms property of the Runtime effect.");
84
- }
85
-
86
- auto value = propObject.getValue(name);
87
-
88
- // A uniform value can be a single number, a vector or an array of numbers
89
- // Or an array of the above
90
- if (value.getType() == PropType::Number) {
91
- // Set numeric uniform
92
- uniformValues.push_back(value.getAsNumber());
93
- } else if (value.getType() == PropType::Array) {
94
- // Array
95
- auto arrayValue = value.getAsArray();
96
- for (size_t n = 0; n < arrayValue.size(); ++n) {
97
- auto a = arrayValue[n];
98
- if (a.getType() == PropType::Number) {
99
- uniformValues.push_back(a.getAsNumber());
100
- } else {
101
- for (size_t j = 0; j < a.getAsArray().size(); ++j) {
102
- uniformValues.push_back(a.getAsArray()[j].getAsNumber());
103
- }
104
- }
105
- }
106
- } else if (value.getType() == PropType::HostObject ||
107
- value.getType() == PropType::Object) {
108
- // Vector (JsiSkPoint / JsiSkRect)
109
- auto pointValue = PointProp::processValue(value);
110
- uniformValues.push_back(pointValue.x());
111
- uniformValues.push_back(pointValue.y());
112
- }
113
- }
114
- return uniformValues;
115
- }
116
-
117
- NodeProp *_uniformsProp;
118
- NodeProp *_sourceProp;
119
- };
120
-
121
- class SimpleUniformsProp : public BaseDerivedProp {
122
- public:
123
- SimpleUniformsProp(PropId name, NodeProp *sourceProp) : BaseDerivedProp() {
124
- _uniformsProp = addProperty(std::make_shared<NodeProp>(name));
125
- _sourceProp = sourceProp;
126
- }
127
-
128
- void processUniforms(SkRuntimeShaderBuilder &rtb) {
129
- if (!_uniformsProp->isSet()) {
130
- return;
131
- }
132
-
133
- auto propObject = _uniformsProp->value();
134
- auto source = _sourceProp->value().getAs<JsiSkRuntimeEffect>()->getObject();
135
-
136
- auto uniformsCount = source->uniforms().size();
137
-
138
- for (size_t i = 0; i < uniformsCount; ++i) {
139
- auto it = source->uniforms().begin() + i;
140
- auto name = JsiPropId::get(std::string(it->name));
141
-
142
- if (!propObject.hasValue(name)) {
143
- throw std::runtime_error("The runtime effect has the uniform value \"" +
144
- std::string(name) +
145
- "\" declared, but it is missing from the "
146
- "uniforms property of the Runtime effect.");
147
- }
148
-
149
- auto value = propObject.getValue(name);
150
-
151
- // A uniform value can be a single number, a vector or an array of numbers
152
- // Or an array of the above
153
- if (value.getType() == PropType::Number) {
154
- // Set numeric uniform
155
- rtb.uniform(name) = value.getAsNumber();
156
- } else if (value.getType() == PropType::Array) {
157
- // Array
158
- auto arrayValue = value.getAsArray();
159
- std::vector<SkScalar> set;
160
- for (size_t n = 0; n < arrayValue.size(); ++n) {
161
- auto a = arrayValue[n];
162
- if (a.getType() == PropType::Number) {
163
- set.push_back(a.getAsNumber());
164
- } else {
165
- for (size_t j = 0; j < a.getAsArray().size(); ++j) {
166
- set.push_back(a.getAsArray()[j].getAsNumber());
167
- }
168
- }
169
- }
170
- rtb.uniform(name).set(set.data(), static_cast<int>(set.size()));
171
-
172
- } else if (value.getType() == PropType::HostObject ||
173
- value.getType() == PropType::Object) {
174
- // Vector (JsiSkPoint / JsiSkRect)
175
- auto pointValue = PointProp::processValue(value);
176
- std::vector<SkScalar> set = {pointValue.x(), pointValue.y()};
177
-
178
- rtb.uniform(name).set(set.data(), static_cast<int>(set.size()));
179
- } else {
180
- throw std::runtime_error("Unexpected type for uniform prop \"" +
181
- std::string(name) + "\". Got " +
182
- value.getTypeAsString(value.getType()));
183
- }
184
- }
185
- }
186
-
187
- void updateDerivedValue() override {}
188
-
189
- private:
190
153
  NodeProp *_uniformsProp;
191
154
  NodeProp *_sourceProp;
192
155
  };
@@ -40,9 +40,9 @@ public:
40
40
  bool hasColors() { return _colorsProp->isSet(); }
41
41
 
42
42
  void updateDerivedValue() override {
43
- SkVertices::VertexMode *vertextMode =
43
+ const SkVertices::VertexMode *vertextMode =
44
44
  _vertexModeProp->getDerivedValue().get();
45
- std::vector<SkColor> *colors = _colorsProp->getDerivedValue().get();
45
+ const std::vector<SkColor> *colors = _colorsProp->getDerivedValue().get();
46
46
  auto vertices = _verticesProp->getDerivedValue();
47
47
  auto textures = _texturesProp->getDerivedValue();
48
48
  auto indices = _indicesProp->getDerivedValue();
@@ -142,12 +142,8 @@ protected:
142
142
  @param runtime Current JS Runtime
143
143
  */
144
144
  void notifyListeners(jsi::Runtime &runtime) {
145
- std::unordered_map<long, std::function<void(jsi::Runtime &)>> tmp;
146
- {
147
- std::lock_guard<std::mutex> lock(_mutex);
148
- tmp.insert(_listeners.cbegin(), _listeners.cend());
149
- }
150
- for (const auto &listener : tmp) {
145
+ std::lock_guard<std::mutex> lock(_mutex);
146
+ for (const auto &listener : _listeners) {
151
147
  listener.second(runtime);
152
148
  }
153
149
  }
@@ -19,7 +19,12 @@ const processCircle = (Skia, def) => {
19
19
  };
20
20
  }
21
21
 
22
- return def;
22
+ return { ...def,
23
+ c: def.c ?? {
24
+ x: 0,
25
+ y: 0
26
+ }
27
+ };
23
28
  };
24
29
 
25
30
  exports.processCircle = processCircle;
@@ -1 +1 @@
1
- {"version":3,"names":["isCircleScalarDef","def","cx","undefined","processCircle","Skia","c","Point","cy","r"],"sources":["Circle.ts"],"sourcesContent":["import type { Skia } from \"../../../skia/types\";\nimport type { CircleDef, ScalarCircleDef } from \"../../types\";\n\nexport const isCircleScalarDef = (def: CircleDef): def is ScalarCircleDef =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (def as any).cx !== undefined;\n\nexport const processCircle = (Skia: Skia, def: CircleDef) => {\n if (isCircleScalarDef(def)) {\n return { c: Skia.Point(def.cx, def.cy), r: def.r };\n }\n return def;\n};\n"],"mappings":";;;;;;;AAGO,MAAMA,iBAAiB,GAAIC,GAAD,IAC/B;AACA;AACCA,GAAD,CAAaC,EAAb,KAAoBC,SAHf;;;;AAKA,MAAMC,aAAa,GAAG,CAACC,IAAD,EAAaJ,GAAb,KAAgC;EAC3D,IAAID,iBAAiB,CAACC,GAAD,CAArB,EAA4B;IAC1B,OAAO;MAAEK,CAAC,EAAED,IAAI,CAACE,KAAL,CAAWN,GAAG,CAACC,EAAf,EAAmBD,GAAG,CAACO,EAAvB,CAAL;MAAiCC,CAAC,EAAER,GAAG,CAACQ;IAAxC,CAAP;EACD;;EACD,OAAOR,GAAP;AACD,CALM"}
1
+ {"version":3,"names":["isCircleScalarDef","def","cx","undefined","processCircle","Skia","c","Point","cy","r","x","y"],"sources":["Circle.ts"],"sourcesContent":["import type { Skia } from \"../../../skia/types\";\nimport type { CircleDef, ScalarCircleDef } from \"../../types\";\n\nexport const isCircleScalarDef = (def: CircleDef): def is ScalarCircleDef =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (def as any).cx !== undefined;\n\nexport const processCircle = (Skia: Skia, def: CircleDef) => {\n if (isCircleScalarDef(def)) {\n return { c: Skia.Point(def.cx, def.cy), r: def.r };\n }\n return { ...def, c: def.c ?? { x: 0, y: 0 } };\n};\n"],"mappings":";;;;;;;AAGO,MAAMA,iBAAiB,GAAIC,GAAD,IAC/B;AACA;AACCA,GAAD,CAAaC,EAAb,KAAoBC,SAHf;;;;AAKA,MAAMC,aAAa,GAAG,CAACC,IAAD,EAAaJ,GAAb,KAAgC;EAC3D,IAAID,iBAAiB,CAACC,GAAD,CAArB,EAA4B;IAC1B,OAAO;MAAEK,CAAC,EAAED,IAAI,CAACE,KAAL,CAAWN,GAAG,CAACC,EAAf,EAAmBD,GAAG,CAACO,EAAvB,CAAL;MAAiCC,CAAC,EAAER,GAAG,CAACQ;IAAxC,CAAP;EACD;;EACD,OAAO,EAAE,GAAGR,GAAL;IAAUK,CAAC,EAAEL,GAAG,CAACK,CAAJ,IAAS;MAAEI,CAAC,EAAE,CAAL;MAAQC,CAAC,EAAE;IAAX;EAAtB,CAAP;AACD,CALM"}
@@ -20,7 +20,7 @@ const isRectCtor = def => def.rect === undefined;
20
20
 
21
21
  const processRect = (Skia, def) => {
22
22
  if (isRectCtor(def)) {
23
- return Skia.XYWHRect(def.x, def.y, def.width, def.height);
23
+ return Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height);
24
24
  } else {
25
25
  return def.rect;
26
26
  }
@@ -30,8 +30,8 @@ exports.processRect = processRect;
30
30
 
31
31
  const processRRect = (Skia, def) => {
32
32
  if (isRRectCtor(def)) {
33
- const r = (0, _Radius.processRadius)(Skia, def.r);
34
- return Skia.RRectXY(Skia.XYWHRect(def.x, def.y, def.width, def.height), r.x, r.y);
33
+ const r = (0, _Radius.processRadius)(Skia, def.r ?? 0);
34
+ return Skia.RRectXY(Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height), r.x, r.y);
35
35
  } else {
36
36
  return def.rect;
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"names":["isEdge","pos","b","x","y","width","height","isRRectCtor","def","rect","undefined","isRectCtor","processRect","Skia","XYWHRect","processRRect","r","processRadius","RRectXY"],"sources":["Rect.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Skia, SkRect, Vector } from \"../../../skia/types\";\nimport type { RectCtor, RectDef, RRectCtor, RRectDef } from \"../../types\";\n\nimport { processRadius } from \"./Radius\";\n\nexport const isEdge = (pos: Vector, b: SkRect) =>\n pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height;\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n\nexport const processRect = (Skia: Skia, def: RectDef) => {\n if (isRectCtor(def)) {\n return Skia.XYWHRect(def.x, def.y, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (Skia: Skia, def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(Skia, def.r);\n return Skia.RRectXY(\n Skia.XYWHRect(def.x, def.y, def.width, def.height),\n r.x,\n r.y\n );\n } else {\n return def.rect;\n }\n};\n"],"mappings":";;;;;;;AAIA;;AAJA;AAMO,MAAMA,MAAM,GAAG,CAACC,GAAD,EAAcC,CAAd,KACpBD,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACC,CAAZ,IAAiBF,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACE,CAA7B,IAAkCH,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACG,KAA9C,IAAuDJ,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACI,MAD9D,C,CAGP;;;;;AACA,MAAMC,WAAW,GAAIC,GAAD,IACjBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB,C,CAEA;;;AACA,MAAMC,UAAU,GAAIH,GAAD,IAChBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB;;AAGO,MAAME,WAAW,GAAG,CAACC,IAAD,EAAaL,GAAb,KAA8B;EACvD,IAAIG,UAAU,CAACH,GAAD,CAAd,EAAqB;IACnB,OAAOK,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAlB,EAAqBK,GAAG,CAACJ,CAAzB,EAA4BI,GAAG,CAACH,KAAhC,EAAuCG,GAAG,CAACF,MAA3C,CAAP;EACD,CAFD,MAEO;IACL,OAAOE,GAAG,CAACC,IAAX;EACD;AACF,CANM;;;;AAQA,MAAMM,YAAY,GAAG,CAACF,IAAD,EAAaL,GAAb,KAA+B;EACzD,IAAID,WAAW,CAACC,GAAD,CAAf,EAAsB;IACpB,MAAMQ,CAAC,GAAG,IAAAC,qBAAA,EAAcJ,IAAd,EAAoBL,GAAG,CAACQ,CAAxB,CAAV;IACA,OAAOH,IAAI,CAACK,OAAL,CACLL,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAlB,EAAqBK,GAAG,CAACJ,CAAzB,EAA4BI,GAAG,CAACH,KAAhC,EAAuCG,GAAG,CAACF,MAA3C,CADK,EAELU,CAAC,CAACb,CAFG,EAGLa,CAAC,CAACZ,CAHG,CAAP;EAKD,CAPD,MAOO;IACL,OAAOI,GAAG,CAACC,IAAX;EACD;AACF,CAXM"}
1
+ {"version":3,"names":["isEdge","pos","b","x","y","width","height","isRRectCtor","def","rect","undefined","isRectCtor","processRect","Skia","XYWHRect","processRRect","r","processRadius","RRectXY"],"sources":["Rect.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Skia, SkRect, Vector } from \"../../../skia/types\";\nimport type { RectCtor, RectDef, RRectCtor, RRectDef } from \"../../types\";\n\nimport { processRadius } from \"./Radius\";\n\nexport const isEdge = (pos: Vector, b: SkRect) =>\n pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height;\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n\nexport const processRect = (Skia: Skia, def: RectDef) => {\n if (isRectCtor(def)) {\n return Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (Skia: Skia, def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(Skia, def.r ?? 0);\n return Skia.RRectXY(\n Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height),\n r.x,\n r.y\n );\n } else {\n return def.rect;\n }\n};\n"],"mappings":";;;;;;;AAIA;;AAJA;AAMO,MAAMA,MAAM,GAAG,CAACC,GAAD,EAAcC,CAAd,KACpBD,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACC,CAAZ,IAAiBF,GAAG,CAACG,CAAJ,KAAUF,CAAC,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iDeclarationNode {
29
29
  constructor(ctx, props) {
30
- super(ctx, _types2.DeclarationType.Unknown, _types2.NodeType.Box, props);
30
+ super(ctx, _types2.DeclarationType.Unknown, _types2.NodeType.BoxShadow, props);
31
31
  }
32
32
 
33
33
  materialize() {
@@ -1 +1 @@
1
- {"version":3,"names":["inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","JsiDeclarationNode","constructor","ctx","props","DeclarationType","Unknown","NodeType","Box","materialize","BoxNode","JsiRenderNode","renderNode","canvas","paint","defaultBox","opacity","getAlphaf","isRRect","shadows","_children","map","node","filter","n","shadow","inner","color","blur","spread","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","BlurStyle","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","ClipOp","Intersect","outer","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import type { SkRRect, Skia } from \"../../../skia/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport type { BoxShadowProps, BoxProps } from \"../../types/Drawings\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { JsiRenderNode } from \"../RenderNode\";\n\nconst inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) =>\n Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => inflate(Skia, box, -dx, -dy, tx, ty);\n\nexport class BoxShadowNode extends JsiDeclarationNode<\n BoxShadowProps,\n BoxShadowProps\n> {\n constructor(ctx: NodeContext, props: BoxShadowProps) {\n super(ctx, DeclarationType.Unknown, NodeType.Box, props);\n }\n\n materialize() {\n return this.props;\n }\n}\n\nexport class BoxNode extends JsiRenderNode<BoxProps> {\n constructor(ctx: NodeContext, props: BoxProps) {\n super(ctx, NodeType.Box, props);\n }\n\n renderNode({ canvas, paint }: DrawingContext) {\n const { box: defaultBox } = this.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox)\n ? defaultBox\n : this.Skia.RRectXY(defaultBox, 0, 0);\n const shadows = this._children\n .map((node) => {\n if (node instanceof BoxShadowNode) {\n return node.materialize();\n }\n return null;\n })\n .filter((n): n is BoxShadowProps => n !== null);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(\n inflate(this.Skia, box, spread, spread, dx, dy),\n lPaint\n );\n });\n\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = this.Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(this.Skia, box, spread, spread, dx, dy);\n const outer = inflate(this.Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n }\n}\n"],"mappings":";;;;;;;AACA;;AAEA;;AAGA;;AACA;;AAEA,MAA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AZ,EAAiBwD,KAAK,CAAChD,CAAvB,EAA0BgD,KAAK,CAAC/C,CAAhC,CAArB;MACAmB,MAAM,CAACqC,UAAP,CAAkBD,KAAlB,EAAyBvB,KAAzB,EAAgCI,MAAhC;MACAjB,MAAM,CAACsC,OAAP;IACD,CAlBH;EAmBD;;AAxDkD"}
1
+ {"version":3,"names":["inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","JsiDeclarationNode","constructor","ctx","props","DeclarationType","Unknown","NodeType","BoxShadow","materialize","BoxNode","JsiRenderNode","Box","renderNode","canvas","paint","defaultBox","opacity","getAlphaf","isRRect","shadows","_children","map","node","filter","n","shadow","inner","color","blur","spread","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","BlurStyle","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","ClipOp","Intersect","outer","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import type { SkRRect, Skia } from \"../../../skia/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport type { BoxShadowProps, BoxProps } from \"../../types/Drawings\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { JsiRenderNode } from \"../RenderNode\";\n\nconst inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) =>\n Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => inflate(Skia, box, -dx, -dy, tx, ty);\n\nexport class BoxShadowNode extends JsiDeclarationNode<\n BoxShadowProps,\n BoxShadowProps\n> {\n constructor(ctx: NodeContext, props: BoxShadowProps) {\n super(ctx, DeclarationType.Unknown, NodeType.BoxShadow, props);\n }\n\n materialize() {\n return this.props;\n }\n}\n\nexport class BoxNode extends JsiRenderNode<BoxProps> {\n constructor(ctx: NodeContext, props: BoxProps) {\n super(ctx, NodeType.Box, props);\n }\n\n renderNode({ canvas, paint }: DrawingContext) {\n const { box: defaultBox } = this.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox)\n ? defaultBox\n : this.Skia.RRectXY(defaultBox, 0, 0);\n const shadows = this._children\n .map((node) => {\n if (node instanceof BoxShadowNode) {\n return node.materialize();\n }\n return null;\n })\n .filter((n): n is BoxShadowProps => n !== null);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(\n inflate(this.Skia, box, spread, spread, dx, dy),\n lPaint\n );\n });\n\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = this.Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(this.Skia, box, spread, spread, dx, dy);\n const outer = inflate(this.Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n }\n}\n"],"mappings":";;;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AAGnE,OAAO,CAAC,KAAKC,IAAN,EAAYC,GAAZ,EAAiByD,KAAK,CAACjD,CAAvB,EAA0BiD,KAAK,CAAChD,CAAhC,CAArB;MACAoB,MAAM,CAACqC,UAAP,CAAkBD,KAAlB,EAAyBvB,KAAzB,EAAgCI,MAAhC;MACAjB,MAAM,CAACsC,OAAP;IACD,CAlBH;EAmBD;;AAxDkD"}
@@ -18,9 +18,9 @@ class ImageNode extends _DrawingNode.JsiDrawingNode {
18
18
 
19
19
  deriveProps() {
20
20
  const {
21
- image,
22
- fit
21
+ image
23
22
  } = this.props;
23
+ const fit = this.props.fit ?? "contain";
24
24
  const rect = (0, _datatypes.processRect)(this.Skia, this.props);
25
25
  const {
26
26
  src,
@@ -1 +1 @@
1
- {"version":3,"names":["ImageNode","JsiDrawingNode","constructor","ctx","props","NodeType","Image","deriveProps","image","fit","rect","processRect","Skia","src","dst","fitRects","x","y","width","height","draw","canvas","paint","derived","Error","drawImageRect"],"sources":["ImageNode.ts"],"sourcesContent":["import type { SkRect } from \"../../../skia/types\";\nimport type { DrawingContext, ImageProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { fitRects, processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageNode extends JsiDrawingNode<\n ImageProps,\n { src: SkRect; dst: SkRect }\n> {\n constructor(ctx: NodeContext, props: ImageProps) {\n super(ctx, NodeType.Image, props);\n }\n\n deriveProps() {\n const { image, fit } = this.props;\n const rect = processRect(this.Skia, this.props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n return { src, dst };\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { image } = this.props;\n if (!this.derived) {\n throw new Error(\"ImageNode: src and dst are undefined\");\n }\n const { src, dst } = this.derived;\n canvas.drawImageRect(image, src, dst, paint);\n }\n}\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAGO,MAAMA,SAAN,SAAwBC,2BAAxB,CAGL;EACAC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWE,eAAA,CAASC,KAApB,EAA2BF,KAA3B;EACD;;EAEDG,WAAW,GAAG;IACZ,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAiB,KAAKL,KAA5B;IACA,MAAMM,IAAI,GAAG,IAAAC,sBAAA,EAAY,KAAKC,IAAjB,EAAuB,KAAKR,KAA5B,CAAb;IACA,MAAM;MAAES,GAAF;MAAOC;IAAP,IAAe,IAAAC,mBAAA,EACnBN,GADmB,EAEnB;MACEO,CAAC,EAAE,CADL;MAEEC,CAAC,EAAE,CAFL;MAGEC,KAAK,EAAEV,KAAK,CAACU,KAAN,EAHT;MAIEC,MAAM,EAAEX,KAAK,CAACW,MAAN;IAJV,CAFmB,EAQnBT,IARmB,CAArB;IAUA,OAAO;MAAEG,GAAF;MAAOC;IAAP,CAAP;EACD;;EAEDM,IAAI,OAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEd;IAAF,IAAY,KAAKJ,KAAvB;;IACA,IAAI,CAAC,KAAKmB,OAAV,EAAmB;MACjB,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;IACD;;IACD,MAAM;MAAEX,GAAF;MAAOC;IAAP,IAAe,KAAKS,OAA1B;IACAF,MAAM,CAACI,aAAP,CAAqBjB,KAArB,EAA4BK,GAA5B,EAAiCC,GAAjC,EAAsCQ,KAAtC;EACD;;AA5BD"}
1
+ {"version":3,"names":["ImageNode","JsiDrawingNode","constructor","ctx","props","NodeType","Image","deriveProps","image","fit","rect","processRect","Skia","src","dst","fitRects","x","y","width","height","draw","canvas","paint","derived","Error","drawImageRect"],"sources":["ImageNode.ts"],"sourcesContent":["import type { SkRect } from \"../../../skia/types\";\nimport type { DrawingContext, ImageProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { fitRects, processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageNode extends JsiDrawingNode<\n ImageProps,\n { src: SkRect; dst: SkRect }\n> {\n constructor(ctx: NodeContext, props: ImageProps) {\n super(ctx, NodeType.Image, props);\n }\n\n deriveProps() {\n const { image } = this.props;\n const fit = this.props.fit ?? \"contain\";\n const rect = processRect(this.Skia, this.props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n return { src, dst };\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { image } = this.props;\n if (!this.derived) {\n throw new Error(\"ImageNode: src and dst are undefined\");\n }\n const { src, dst } = this.derived;\n canvas.drawImageRect(image, src, dst, paint);\n }\n}\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAGO,MAAMA,SAAN,SAAwBC,2BAAxB,CAGL;EACAC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWE,eAAA,CAASC,KAApB,EAA2BF,KAA3B;EACD;;EAEDG,WAAW,GAAG;IACZ,MAAM;MAAEC;IAAF,IAAY,KAAKJ,KAAvB;IACA,MAAMK,GAAG,GAAG,KAAKL,KAAL,CAAWK,GAAX,IAAkB,SAA9B;IACA,MAAMC,IAAI,GAAG,IAAAC,sBAAA,EAAY,KAAKC,IAAjB,EAAuB,KAAKR,KAA5B,CAAb;IACA,MAAM;MAAES,GAAF;MAAOC;IAAP,IAAe,IAAAC,mBAAA,EACnBN,GADmB,EAEnB;MACEO,CAAC,EAAE,CADL;MAEEC,CAAC,EAAE,CAFL;MAGEC,KAAK,EAAEV,KAAK,CAACU,KAAN,EAHT;MAIEC,MAAM,EAAEX,KAAK,CAACW,MAAN;IAJV,CAFmB,EAQnBT,IARmB,CAArB;IAUA,OAAO;MAAEG,GAAF;MAAOC;IAAP,CAAP;EACD;;EAEDM,IAAI,OAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEd;IAAF,IAAY,KAAKJ,KAAvB;;IACA,IAAI,CAAC,KAAKmB,OAAV,EAAmB;MACjB,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;IACD;;IACD,MAAM;MAAEX,GAAF;MAAOC;IAAP,IAAe,KAAKS,OAA1B;IACAF,MAAM,CAACI,aAAP,CAAqBjB,KAArB,EAA4BK,GAA5B,EAAiCC,GAAjC,EAAsCQ,KAAtC;EACD;;AA7BD"}
@@ -122,7 +122,7 @@ exports.BlurImageFilterNode = BlurImageFilterNode;
122
122
 
123
123
  class DropShadowImageFilterNode extends ImageFilterDeclaration {
124
124
  constructor(ctx, props) {
125
- super(ctx, _types2.NodeType.BlurImageFilter, props);
125
+ super(ctx, _types2.NodeType.DropShadowImageFilter, props);
126
126
  }
127
127
 
128
128
  materialize() {