@shopify/react-native-skia 0.1.172 → 0.1.174

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. package/android/CMakeLists.txt +1 -0
  2. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +5 -0
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +106 -5
  4. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -1
  5. package/cpp/api/JsiSkSurface.h +7 -1
  6. package/cpp/api/JsiSkSurfaceFactory.h +15 -2
  7. package/cpp/rnskia/RNSkDomView.cpp +2 -4
  8. package/cpp/rnskia/RNSkJsView.cpp +3 -0
  9. package/cpp/rnskia/RNSkPictureView.h +3 -0
  10. package/cpp/rnskia/RNSkPlatformContext.h +9 -0
  11. package/cpp/rnskia/dom/JsiDomApi.h +1 -0
  12. package/cpp/rnskia/dom/base/ConcatablePaint.cpp +117 -0
  13. package/cpp/rnskia/dom/base/ConcatablePaint.h +49 -0
  14. package/cpp/rnskia/dom/base/Declaration.h +88 -0
  15. package/cpp/rnskia/dom/base/DeclarationContext.h +79 -0
  16. package/cpp/rnskia/dom/base/DerivedNodeProp.h +25 -9
  17. package/cpp/rnskia/dom/base/DrawingContext.cpp +32 -186
  18. package/cpp/rnskia/dom/base/DrawingContext.h +45 -64
  19. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +35 -106
  20. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +28 -9
  21. package/cpp/rnskia/dom/base/JsiDomNode.h +46 -17
  22. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +81 -67
  23. package/cpp/rnskia/dom/base/NodeProp.h +12 -2
  24. package/cpp/rnskia/dom/base/NodePropsContainer.h +15 -16
  25. package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +22 -11
  26. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +43 -59
  27. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +16 -17
  28. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +6 -5
  29. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +45 -69
  30. package/cpp/rnskia/dom/nodes/JsiGroupNode.h +1 -1
  31. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +121 -161
  32. package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -0
  33. package/cpp/rnskia/dom/nodes/JsiLayerNode.h +28 -18
  34. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +82 -45
  35. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +68 -101
  36. package/cpp/rnskia/dom/nodes/JsiPathNode.h +3 -2
  37. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +150 -207
  38. package/cpp/rnskia/dom/props/BezierProps.h +4 -2
  39. package/cpp/rnskia/dom/props/BlendModeProp.h +4 -2
  40. package/cpp/rnskia/dom/props/BoxShadowProps.h +8 -10
  41. package/cpp/rnskia/dom/props/CircleProp.h +6 -5
  42. package/cpp/rnskia/dom/props/ClipProp.h +6 -4
  43. package/cpp/rnskia/dom/props/ColorProp.h +8 -4
  44. package/cpp/rnskia/dom/props/DrawingProp.h +5 -3
  45. package/cpp/rnskia/dom/props/FontProp.h +4 -2
  46. package/cpp/rnskia/dom/props/GlyphsProp.h +4 -2
  47. package/cpp/rnskia/dom/props/ImageProps.h +9 -6
  48. package/cpp/rnskia/dom/props/LayerProp.h +6 -4
  49. package/cpp/rnskia/dom/props/MatrixProp.h +4 -2
  50. package/cpp/rnskia/dom/props/NumbersProp.h +8 -4
  51. package/cpp/rnskia/dom/props/PaintProps.h +55 -92
  52. package/cpp/rnskia/dom/props/PathProp.h +4 -2
  53. package/cpp/rnskia/dom/props/PictureProp.h +4 -2
  54. package/cpp/rnskia/dom/props/PointProp.h +4 -2
  55. package/cpp/rnskia/dom/props/PointsProp.h +8 -4
  56. package/cpp/rnskia/dom/props/RRectProp.h +23 -16
  57. package/cpp/rnskia/dom/props/RadiusProp.h +4 -2
  58. package/cpp/rnskia/dom/props/RectProp.h +18 -12
  59. package/cpp/rnskia/dom/props/StrokeProps.h +8 -4
  60. package/cpp/rnskia/dom/props/SvgProp.h +4 -2
  61. package/cpp/rnskia/dom/props/TextBlobProp.h +10 -8
  62. package/cpp/rnskia/dom/props/TileModeProp.h +4 -2
  63. package/cpp/rnskia/dom/props/TransformProp.h +4 -2
  64. package/cpp/rnskia/dom/props/TransformsProps.h +5 -7
  65. package/cpp/rnskia/dom/props/UniformsProp.h +4 -2
  66. package/cpp/rnskia/dom/props/VertexModeProp.h +4 -2
  67. package/cpp/rnskia/dom/props/VerticesProps.h +7 -11
  68. package/ios/RNSkia-iOS/DisplayLink.mm +22 -24
  69. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +53 -50
  70. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -0
  71. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +56 -25
  72. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +17 -17
  73. package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +17 -17
  74. package/ios/RNSkia-iOS/SkiaManager.mm +12 -10
  75. package/ios/RNSkia-iOS/SkiaMetalRenderer.h +5 -0
  76. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +53 -0
  77. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +17 -17
  78. package/ios/RNSkia-iOS/SkiaUIView.mm +63 -53
  79. package/ios/RNSkiaModule.mm +5 -7
  80. package/lib/commonjs/dom/nodes/DrawingNode.js +5 -1
  81. package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
  82. package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +33 -34
  83. package/lib/commonjs/dom/nodes/LayerNode.js +13 -6
  84. package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -1
  85. package/lib/commonjs/dom/nodes/Node.d.ts +6 -11
  86. package/lib/commonjs/dom/nodes/Node.js +8 -26
  87. package/lib/commonjs/dom/nodes/Node.js.map +1 -1
  88. package/lib/commonjs/dom/nodes/PaintContext.js.map +1 -1
  89. package/lib/commonjs/dom/nodes/PaintNode.d.ts +3 -3
  90. package/lib/commonjs/dom/nodes/PaintNode.js +32 -15
  91. package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
  92. package/lib/commonjs/dom/nodes/RenderNode.d.ts +2 -3
  93. package/lib/commonjs/dom/nodes/RenderNode.js +19 -187
  94. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  95. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  96. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js +25 -7
  97. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
  98. package/lib/commonjs/dom/nodes/drawings/Box.d.ts +3 -1
  99. package/lib/commonjs/dom/nodes/drawings/Box.js +3 -0
  100. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  101. package/lib/commonjs/dom/nodes/paint/BlendNode.d.ts +3 -7
  102. package/lib/commonjs/dom/nodes/paint/BlendNode.js +16 -47
  103. package/lib/commonjs/dom/nodes/paint/BlendNode.js.map +1 -1
  104. package/lib/commonjs/dom/nodes/paint/ColorFilters.d.ts +10 -11
  105. package/lib/commonjs/dom/nodes/paint/ColorFilters.js +29 -43
  106. package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
  107. package/lib/commonjs/dom/nodes/paint/ImageFilters.d.ts +11 -11
  108. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +45 -42
  109. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  110. package/lib/commonjs/dom/nodes/paint/MaskFilters.d.ts +3 -3
  111. package/lib/commonjs/dom/nodes/paint/MaskFilters.js +3 -2
  112. package/lib/commonjs/dom/nodes/paint/MaskFilters.js.map +1 -1
  113. package/lib/commonjs/dom/nodes/paint/PathEffects.d.ts +15 -18
  114. package/lib/commonjs/dom/nodes/paint/PathEffects.js +30 -72
  115. package/lib/commonjs/dom/nodes/paint/PathEffects.js.map +1 -1
  116. package/lib/commonjs/dom/nodes/paint/Shaders.d.ts +11 -12
  117. package/lib/commonjs/dom/nodes/paint/Shaders.js +28 -18
  118. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  119. package/lib/commonjs/dom/types/DeclarationContext.d.ts +29 -0
  120. package/lib/commonjs/dom/types/DeclarationContext.js +118 -0
  121. package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -0
  122. package/lib/commonjs/dom/types/DrawingContext.d.ts +18 -1
  123. package/lib/commonjs/dom/types/DrawingContext.js +330 -0
  124. package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
  125. package/lib/commonjs/dom/types/Node.d.ts +4 -10
  126. package/lib/commonjs/dom/types/Node.js.map +1 -1
  127. package/lib/commonjs/dom/types/SkDOM.d.ts +22 -23
  128. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  129. package/lib/commonjs/dom/types/index.d.ts +1 -0
  130. package/lib/commonjs/dom/types/index.js +13 -0
  131. package/lib/commonjs/dom/types/index.js.map +1 -1
  132. package/lib/commonjs/index.d.ts +1 -0
  133. package/lib/commonjs/index.js +13 -0
  134. package/lib/commonjs/index.js.map +1 -1
  135. package/lib/commonjs/renderer/Canvas.js +3 -3
  136. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  137. package/lib/commonjs/renderer/DrawingContext.d.ts +4 -3
  138. package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
  139. package/lib/commonjs/renderer/HostComponents.d.ts +35 -35
  140. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  141. package/lib/commonjs/renderer/HostConfig.js +1 -0
  142. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  143. package/lib/commonjs/renderer/Offscreen.d.ts +2 -0
  144. package/lib/commonjs/renderer/Offscreen.js +31 -0
  145. package/lib/commonjs/renderer/Offscreen.js.map +1 -0
  146. package/lib/commonjs/renderer/Reconciler.js +0 -1
  147. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  148. package/lib/commonjs/skia/types/Surface/Surface.d.ts +4 -0
  149. package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
  150. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  151. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  152. package/lib/commonjs/skia/web/JsiSkDataFactory.js +0 -1
  153. package/lib/commonjs/skia/web/JsiSkDataFactory.js.map +1 -1
  154. package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
  155. package/lib/commonjs/skia/web/JsiSkImage.js +34 -3
  156. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  157. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
  158. package/lib/commonjs/skia/web/JsiSkSurface.js +4 -0
  159. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  160. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  161. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +21 -1
  162. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  163. package/lib/commonjs/views/SkiaBaseWebView.js +14 -8
  164. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  165. package/lib/commonjs/views/SkiaDomView.web.js +3 -14
  166. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
  167. package/lib/commonjs/views/SkiaPictureView.web.js +0 -7
  168. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  169. package/lib/commonjs/views/SkiaView.web.js +0 -7
  170. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  171. package/lib/module/dom/nodes/DrawingNode.js +5 -1
  172. package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
  173. package/lib/module/dom/nodes/JsiSkDOM.d.ts +33 -34
  174. package/lib/module/dom/nodes/LayerNode.js +13 -7
  175. package/lib/module/dom/nodes/LayerNode.js.map +1 -1
  176. package/lib/module/dom/nodes/Node.d.ts +6 -11
  177. package/lib/module/dom/nodes/Node.js +8 -25
  178. package/lib/module/dom/nodes/Node.js.map +1 -1
  179. package/lib/module/dom/nodes/PaintContext.js.map +1 -1
  180. package/lib/module/dom/nodes/PaintNode.d.ts +3 -3
  181. package/lib/module/dom/nodes/PaintNode.js +32 -15
  182. package/lib/module/dom/nodes/PaintNode.js.map +1 -1
  183. package/lib/module/dom/nodes/RenderNode.d.ts +2 -3
  184. package/lib/module/dom/nodes/RenderNode.js +20 -187
  185. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  186. package/lib/module/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  187. package/lib/module/dom/nodes/drawings/BackdropFilterNode.js +23 -4
  188. package/lib/module/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
  189. package/lib/module/dom/nodes/drawings/Box.d.ts +3 -1
  190. package/lib/module/dom/nodes/drawings/Box.js +3 -0
  191. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  192. package/lib/module/dom/nodes/paint/BlendNode.d.ts +3 -7
  193. package/lib/module/dom/nodes/paint/BlendNode.js +15 -46
  194. package/lib/module/dom/nodes/paint/BlendNode.js.map +1 -1
  195. package/lib/module/dom/nodes/paint/ColorFilters.d.ts +10 -11
  196. package/lib/module/dom/nodes/paint/ColorFilters.js +29 -43
  197. package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
  198. package/lib/module/dom/nodes/paint/ImageFilters.d.ts +11 -11
  199. package/lib/module/dom/nodes/paint/ImageFilters.js +48 -41
  200. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  201. package/lib/module/dom/nodes/paint/MaskFilters.d.ts +3 -3
  202. package/lib/module/dom/nodes/paint/MaskFilters.js +3 -2
  203. package/lib/module/dom/nodes/paint/MaskFilters.js.map +1 -1
  204. package/lib/module/dom/nodes/paint/PathEffects.d.ts +15 -18
  205. package/lib/module/dom/nodes/paint/PathEffects.js +29 -72
  206. package/lib/module/dom/nodes/paint/PathEffects.js.map +1 -1
  207. package/lib/module/dom/nodes/paint/Shaders.d.ts +11 -12
  208. package/lib/module/dom/nodes/paint/Shaders.js +28 -18
  209. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  210. package/lib/module/dom/types/DeclarationContext.d.ts +29 -0
  211. package/lib/module/dom/types/DeclarationContext.js +107 -0
  212. package/lib/module/dom/types/DeclarationContext.js.map +1 -0
  213. package/lib/module/dom/types/DrawingContext.d.ts +18 -1
  214. package/lib/module/dom/types/DrawingContext.js +322 -1
  215. package/lib/module/dom/types/DrawingContext.js.map +1 -1
  216. package/lib/module/dom/types/Node.d.ts +4 -10
  217. package/lib/module/dom/types/Node.js.map +1 -1
  218. package/lib/module/dom/types/SkDOM.d.ts +22 -23
  219. package/lib/module/dom/types/SkDOM.js.map +1 -1
  220. package/lib/module/dom/types/index.d.ts +1 -0
  221. package/lib/module/dom/types/index.js +1 -0
  222. package/lib/module/dom/types/index.js.map +1 -1
  223. package/lib/module/index.d.ts +1 -0
  224. package/lib/module/index.js +1 -0
  225. package/lib/module/index.js.map +1 -1
  226. package/lib/module/renderer/Canvas.js +3 -3
  227. package/lib/module/renderer/Canvas.js.map +1 -1
  228. package/lib/module/renderer/DrawingContext.d.ts +4 -3
  229. package/lib/module/renderer/DrawingContext.js.map +1 -1
  230. package/lib/module/renderer/HostComponents.d.ts +35 -35
  231. package/lib/module/renderer/HostComponents.js.map +1 -1
  232. package/lib/module/renderer/HostConfig.js +1 -0
  233. package/lib/module/renderer/HostConfig.js.map +1 -1
  234. package/lib/module/renderer/Offscreen.d.ts +2 -0
  235. package/lib/module/renderer/Offscreen.js +19 -0
  236. package/lib/module/renderer/Offscreen.js.map +1 -0
  237. package/lib/module/renderer/Reconciler.js +0 -1
  238. package/lib/module/renderer/Reconciler.js.map +1 -1
  239. package/lib/module/skia/types/Surface/Surface.d.ts +4 -0
  240. package/lib/module/skia/types/Surface/Surface.js.map +1 -1
  241. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  242. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  243. package/lib/module/skia/web/JsiSkDataFactory.js +0 -1
  244. package/lib/module/skia/web/JsiSkDataFactory.js.map +1 -1
  245. package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
  246. package/lib/module/skia/web/JsiSkImage.js +31 -3
  247. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  248. package/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
  249. package/lib/module/skia/web/JsiSkSurface.js +4 -0
  250. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  251. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  252. package/lib/module/skia/web/JsiSkSurfaceFactory.js +21 -1
  253. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  254. package/lib/module/views/SkiaBaseWebView.js +14 -8
  255. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  256. package/lib/module/views/SkiaDomView.web.js +2 -11
  257. package/lib/module/views/SkiaDomView.web.js.map +1 -1
  258. package/lib/module/views/SkiaPictureView.web.js +0 -5
  259. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  260. package/lib/module/views/SkiaView.web.js +0 -5
  261. package/lib/module/views/SkiaView.web.js.map +1 -1
  262. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +33 -34
  263. package/lib/typescript/src/dom/nodes/Node.d.ts +6 -11
  264. package/lib/typescript/src/dom/nodes/PaintNode.d.ts +3 -3
  265. package/lib/typescript/src/dom/nodes/RenderNode.d.ts +2 -3
  266. package/lib/typescript/src/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  267. package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +3 -1
  268. package/lib/typescript/src/dom/nodes/paint/BlendNode.d.ts +3 -7
  269. package/lib/typescript/src/dom/nodes/paint/ColorFilters.d.ts +10 -11
  270. package/lib/typescript/src/dom/nodes/paint/ImageFilters.d.ts +11 -11
  271. package/lib/typescript/src/dom/nodes/paint/MaskFilters.d.ts +3 -3
  272. package/lib/typescript/src/dom/nodes/paint/PathEffects.d.ts +15 -18
  273. package/lib/typescript/src/dom/nodes/paint/Shaders.d.ts +11 -12
  274. package/lib/typescript/src/dom/types/DeclarationContext.d.ts +29 -0
  275. package/lib/typescript/src/dom/types/DrawingContext.d.ts +18 -1
  276. package/lib/typescript/src/dom/types/Node.d.ts +4 -10
  277. package/lib/typescript/src/dom/types/SkDOM.d.ts +22 -23
  278. package/lib/typescript/src/dom/types/index.d.ts +1 -0
  279. package/lib/typescript/src/index.d.ts +1 -0
  280. package/lib/typescript/src/renderer/DrawingContext.d.ts +4 -3
  281. package/lib/typescript/src/renderer/HostComponents.d.ts +35 -35
  282. package/lib/typescript/src/renderer/Offscreen.d.ts +2 -0
  283. package/lib/typescript/src/skia/types/Surface/Surface.d.ts +4 -0
  284. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  285. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
  286. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -0
  287. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  288. package/package.json +1 -1
  289. package/src/dom/nodes/DrawingNode.ts +5 -1
  290. package/src/dom/nodes/LayerNode.ts +13 -11
  291. package/src/dom/nodes/Node.ts +18 -41
  292. package/src/dom/nodes/PaintContext.ts +1 -0
  293. package/src/dom/nodes/PaintNode.ts +28 -18
  294. package/src/dom/nodes/RenderNode.ts +25 -183
  295. package/src/dom/nodes/drawings/BackdropFilterNode.ts +18 -11
  296. package/src/dom/nodes/drawings/Box.ts +6 -4
  297. package/src/dom/nodes/paint/BlendNode.ts +16 -63
  298. package/src/dom/nodes/paint/ColorFilters.ts +32 -55
  299. package/src/dom/nodes/paint/ImageFilters.ts +58 -53
  300. package/src/dom/nodes/paint/MaskFilters.ts +5 -7
  301. package/src/dom/nodes/paint/PathEffects.ts +37 -90
  302. package/src/dom/nodes/paint/Shaders.ts +31 -29
  303. package/src/dom/types/DeclarationContext.ts +105 -0
  304. package/src/dom/types/DrawingContext.ts +304 -1
  305. package/src/dom/types/Node.ts +4 -20
  306. package/src/dom/types/SkDOM.ts +22 -43
  307. package/src/dom/types/index.ts +1 -0
  308. package/src/index.ts +1 -0
  309. package/src/renderer/Canvas.tsx +3 -3
  310. package/src/renderer/DrawingContext.ts +4 -5
  311. package/src/renderer/HostComponents.ts +34 -53
  312. package/src/renderer/HostConfig.ts +1 -0
  313. package/src/renderer/Offscreen.tsx +24 -0
  314. package/src/renderer/Reconciler.tsx +0 -1
  315. package/src/skia/types/Surface/Surface.ts +5 -0
  316. package/src/skia/types/Surface/SurfaceFactory.ts +7 -0
  317. package/src/skia/web/JsiSkDataFactory.ts +0 -1
  318. package/src/skia/web/JsiSkImage.ts +26 -2
  319. package/src/skia/web/JsiSkSurface.ts +4 -0
  320. package/src/skia/web/JsiSkSurfaceFactory.ts +21 -2
  321. package/src/views/SkiaBaseWebView.tsx +9 -2
  322. package/src/views/SkiaDomView.web.tsx +2 -13
  323. package/src/views/SkiaPictureView.web.tsx +0 -7
  324. package/src/views/SkiaView.web.tsx +0 -7
@@ -8,6 +8,7 @@ import {
8
8
  import type {
9
9
  BlendImageFilterProps,
10
10
  BlurImageFilterProps,
11
+ DeclarationContext,
11
12
  DisplacementMapImageFilterProps,
12
13
  DropShadowImageFilterProps,
13
14
  MorphologyImageFilterProps,
@@ -55,37 +56,31 @@ const MakeInnerShadow = (
55
56
  );
56
57
  };
57
58
 
58
- export abstract class ImageFilterDeclaration<
59
- P,
60
- Nullable extends null | never = never
61
- > extends JsiDeclarationNode<P, SkImageFilter, Nullable> {
59
+ export abstract class ImageFilterDeclaration<P> extends JsiDeclarationNode<P> {
62
60
  constructor(ctx: NodeContext, type: NodeType, props: P) {
63
61
  super(ctx, DeclarationType.ImageFilter, type, props);
64
62
  }
65
63
 
66
- getOptionalChildInstance(index: number) {
67
- const child = this._children[index];
68
- if (!child) {
69
- return null;
70
- }
71
- return this.getMandatoryChildInstance(index);
72
- }
73
-
74
- getMandatoryChildInstance(index: number) {
75
- const child = this._children[index];
76
- if (child instanceof JsiDeclarationNode) {
77
- if (child.isImageFilter()) {
78
- return child.materialize();
79
- } else if (child.isShader()) {
80
- return this.Skia.ImageFilter.MakeShader(child.materialize(), null);
81
- } else if (child.declarationType === DeclarationType.ColorFilter) {
82
- return this.Skia.ImageFilter.MakeColorFilter(child.materialize(), null);
83
- } else {
84
- throw new Error(`Found invalid child ${child.type} in ${this.type}`);
85
- }
86
- } else {
87
- throw new Error(`Found invalid child ${child.type} in ${this.type}`);
64
+ protected input(ctx: DeclarationContext) {
65
+ return ctx.imageFilters.pop() ?? null;
66
+ }
67
+
68
+ protected composeAndPush(ctx: DeclarationContext, imgf1: SkImageFilter) {
69
+ ctx.save();
70
+ this.decorateChildren(ctx);
71
+ let imgf2 = ctx.imageFilters.popAllAsOne();
72
+ const cf = ctx.colorFilters.popAllAsOne();
73
+ ctx.restore();
74
+ if (cf) {
75
+ imgf2 = this.Skia.ImageFilter.MakeCompose(
76
+ imgf2 ?? null,
77
+ this.Skia.ImageFilter.MakeColorFilter(cf, null)
78
+ );
88
79
  }
80
+ const imgf = imgf2
81
+ ? this.Skia.ImageFilter.MakeCompose(imgf1, imgf2)
82
+ : imgf1;
83
+ ctx.imageFilters.push(imgf);
89
84
  }
90
85
  }
91
86
 
@@ -94,13 +89,11 @@ export class OffsetImageFilterNode extends ImageFilterDeclaration<OffsetImageFil
94
89
  super(ctx, NodeType.OffsetImageFilter, props);
95
90
  }
96
91
 
97
- materialize() {
92
+ decorate(ctx: DeclarationContext) {
93
+ this.decorateChildren(ctx);
98
94
  const { x, y } = this.props;
99
- return this.Skia.ImageFilter.MakeOffset(
100
- x,
101
- y,
102
- this.getOptionalChildInstance(0)
103
- );
95
+ const imgf = this.Skia.ImageFilter.MakeOffset(x, y, null);
96
+ this.composeAndPush(ctx, imgf);
104
97
  }
105
98
  }
106
99
 
@@ -109,15 +102,16 @@ export class DisplacementMapImageFilterNode extends ImageFilterDeclaration<Displ
109
102
  super(ctx, NodeType.DisplacementMapImageFilter, props);
110
103
  }
111
104
 
112
- materialize() {
105
+ decorate(ctx: DeclarationContext) {
113
106
  const { channelX, channelY, scale } = this.props;
114
- return this.Skia.ImageFilter.MakeDisplacementMap(
107
+ const imgf = this.Skia.ImageFilter.MakeDisplacementMap(
115
108
  ColorChannel[enumKey(channelX)],
116
109
  ColorChannel[enumKey(channelY)],
117
110
  scale,
118
- this.getMandatoryChildInstance(0),
119
- this.getOptionalChildInstance(1)
111
+ ctx.imageFilters.pop()!,
112
+ this.input(ctx)
120
113
  );
114
+ this.composeAndPush(ctx, imgf);
121
115
  }
122
116
  }
123
117
 
@@ -126,15 +120,16 @@ export class BlurImageFilterNode extends ImageFilterDeclaration<BlurImageFilterP
126
120
  super(ctx, NodeType.BlurImageFilter, props);
127
121
  }
128
122
 
129
- materialize() {
123
+ decorate(ctx: DeclarationContext) {
130
124
  const { mode, blur } = this.props;
131
125
  const sigma = processRadius(this.Skia, blur);
132
- return this.Skia.ImageFilter.MakeBlur(
126
+ const imgf = this.Skia.ImageFilter.MakeBlur(
133
127
  sigma.x,
134
128
  sigma.y,
135
129
  TileMode[enumKey(mode)],
136
- this.getOptionalChildInstance(0)
130
+ this.input(ctx)
137
131
  );
132
+ this.composeAndPush(ctx, imgf);
138
133
  }
139
134
  }
140
135
 
@@ -143,10 +138,9 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration<DropShadow
143
138
  super(ctx, NodeType.DropShadowImageFilter, props);
144
139
  }
145
140
 
146
- materialize() {
141
+ decorate(ctx: DeclarationContext) {
147
142
  const { dx, dy, blur, shadowOnly, color: cl, inner } = this.props;
148
143
  const color = this.Skia.Color(cl);
149
- const input = this.getOptionalChildInstance(0);
150
144
  let factory;
151
145
  if (inner) {
152
146
  factory = MakeInnerShadow.bind(null, this.Skia, shadowOnly);
@@ -155,7 +149,8 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration<DropShadow
155
149
  ? this.Skia.ImageFilter.MakeDropShadowOnly.bind(this.Skia.ImageFilter)
156
150
  : this.Skia.ImageFilter.MakeDropShadow.bind(this.Skia.ImageFilter);
157
151
  }
158
- return factory(dx, dy, blur, blur, color, input);
152
+ const imgf = factory(dx, dy, blur, blur, color, this.input(ctx));
153
+ this.composeAndPush(ctx, imgf);
159
154
  }
160
155
  }
161
156
 
@@ -169,14 +164,16 @@ export class MorphologyImageFilterNode extends ImageFilterDeclaration<Morphology
169
164
  super(ctx, NodeType.MorphologyImageFilter, props);
170
165
  }
171
166
 
172
- materialize() {
167
+ decorate(ctx: DeclarationContext) {
173
168
  const { operator } = this.props;
174
169
  const r = processRadius(this.Skia, this.props.radius);
175
- const input = this.getOptionalChildInstance(0);
170
+ let imgf;
176
171
  if (MorphologyOperator[enumKey(operator)] === MorphologyOperator.Erode) {
177
- return this.Skia.ImageFilter.MakeErode(r.x, r.y, input);
172
+ imgf = this.Skia.ImageFilter.MakeErode(r.x, r.y, this.input(ctx));
173
+ } else {
174
+ imgf = this.Skia.ImageFilter.MakeDilate(r.x, r.y, this.input(ctx));
178
175
  }
179
- return this.Skia.ImageFilter.MakeDilate(r.x, r.y, input);
176
+ this.composeAndPush(ctx, imgf);
180
177
  }
181
178
  }
182
179
 
@@ -185,11 +182,15 @@ export class BlendImageFilterNode extends ImageFilterDeclaration<BlendImageFilte
185
182
  super(ctx, NodeType.BlendImageFilter, props);
186
183
  }
187
184
 
188
- materialize() {
185
+ decorate(ctx: DeclarationContext) {
189
186
  const { mode } = this.props;
190
- const a = this.getMandatoryChildInstance(0);
191
- const b = this.getMandatoryChildInstance(1);
192
- return this.Skia.ImageFilter.MakeBlend(mode, a, b);
187
+ const a = ctx.imageFilters.pop();
188
+ const b = ctx.imageFilters.pop();
189
+ if (!a || !b) {
190
+ throw new Error("BlendImageFilter requires two image filters");
191
+ }
192
+ const imgf = this.Skia.ImageFilter.MakeBlend(mode, a, b);
193
+ this.composeAndPush(ctx, imgf);
193
194
  }
194
195
  }
195
196
 
@@ -198,13 +199,17 @@ export class RuntimeShaderImageFilterNode extends ImageFilterDeclaration<Runtime
198
199
  super(ctx, NodeType.RuntimeShaderImageFilter, props);
199
200
  }
200
201
 
201
- materialize() {
202
+ decorate(ctx: DeclarationContext) {
202
203
  const { source, uniforms } = this.props;
203
204
  const rtb = this.Skia.RuntimeShaderBuilder(source);
204
205
  if (uniforms) {
205
206
  processUniforms(source, uniforms, rtb);
206
207
  }
207
- const input = this.getOptionalChildInstance(0);
208
- return this.Skia.ImageFilter.MakeRuntimeShader(rtb, null, input);
208
+ const imgf = this.Skia.ImageFilter.MakeRuntimeShader(
209
+ rtb,
210
+ null,
211
+ this.input(ctx)
212
+ );
213
+ this.composeAndPush(ctx, imgf);
209
214
  }
210
215
  }
@@ -1,25 +1,23 @@
1
- import type { SkMaskFilter } from "../../../skia/types";
2
1
  import { BlurStyle } from "../../../skia/types";
3
2
  import type { NodeContext } from "../Node";
4
3
  import { JsiDeclarationNode } from "../Node";
5
4
  import type { BlurMaskFilterProps } from "../../types";
6
5
  import { DeclarationType, NodeType } from "../../types";
7
6
  import { enumKey } from "../datatypes";
7
+ import type { DeclarationContext } from "../../types/DeclarationContext";
8
8
 
9
- export class BlurMaskFilterNode extends JsiDeclarationNode<
10
- BlurMaskFilterProps,
11
- SkMaskFilter
12
- > {
9
+ export class BlurMaskFilterNode extends JsiDeclarationNode<BlurMaskFilterProps> {
13
10
  constructor(ctx: NodeContext, props: BlurMaskFilterProps) {
14
11
  super(ctx, DeclarationType.MaskFilter, NodeType.BlurMaskFilter, props);
15
12
  }
16
13
 
17
- materialize() {
14
+ decorate(ctx: DeclarationContext) {
18
15
  const { style, blur, respectCTM } = this.props;
19
- return this.Skia.MaskFilter.MakeBlur(
16
+ const mf = this.Skia.MaskFilter.MakeBlur(
20
17
  BlurStyle[enumKey(style)],
21
18
  blur,
22
19
  respectCTM
23
20
  );
21
+ ctx.maskFilters.push(mf);
24
22
  }
25
23
  }
@@ -7,71 +7,27 @@ import type {
7
7
  DashPathEffectProps,
8
8
  DiscretePathEffectProps,
9
9
  Line2DPathEffectProps,
10
- Node,
11
10
  Path1DPathEffectProps,
12
11
  Path2DPathEffectProps,
13
12
  } from "../../types";
14
13
  import { DeclarationType, NodeType } from "../../types";
15
14
  import { enumKey } from "../datatypes/Enum";
16
15
  import { processPath } from "../datatypes";
16
+ import type { DeclarationContext } from "../../types/DeclarationContext";
17
+ import { composeDeclarations } from "../../types/DeclarationContext";
17
18
 
18
- abstract class PathEffectDeclaration<
19
- P,
20
- Nullable extends null | never = never
21
- > extends JsiDeclarationNode<P, SkPathEffect, Nullable> {
19
+ abstract class PathEffectDeclaration<P> extends JsiDeclarationNode<P> {
22
20
  constructor(ctx: NodeContext, type: NodeType, props: P) {
23
21
  super(ctx, DeclarationType.PathEffect, type, props);
24
22
  }
25
23
 
26
- addChild(child: Node<unknown>) {
27
- if (!(child instanceof PathEffectDeclaration)) {
28
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
29
- }
30
- super.addChild(child);
31
- }
32
-
33
- insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {
34
- if (!(child instanceof PathEffectDeclaration)) {
35
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
36
- }
37
- super.insertChildBefore(child, before);
38
- }
39
-
40
- compose(pe: SkPathEffect) {
41
- const children = this._children as PathEffectDeclaration<unknown>[];
42
- if (this._children.length === 0) {
43
- return pe;
44
- } else {
45
- return this.Skia.PathEffect.MakeCompose(
46
- pe,
47
- children.reduce<SkPathEffect | null>((acc, child) => {
48
- if (acc === null) {
49
- return child.materialize();
50
- }
51
- return this.Skia.PathEffect.MakeCompose(acc, child.materialize());
52
- }, null) as SkPathEffect
53
- );
54
- }
55
- }
56
- getOptionalChildInstance(index: number) {
57
- const child = this._children[index];
58
- if (!child) {
59
- return null;
60
- }
61
- return this.getMandatoryChildInstance(index);
62
- }
63
-
64
- getMandatoryChildInstance(index: number) {
65
- const child = this._children[index];
66
- if (child instanceof JsiDeclarationNode) {
67
- if (child.isPathEffect()) {
68
- return child.materialize();
69
- } else {
70
- throw new Error(`Found invalid child ${child.type} in ${this.type}`);
71
- }
72
- } else {
73
- throw new Error(`Found invalid child ${child.type} in ${this.type}`);
74
- }
24
+ protected composeAndPush(ctx: DeclarationContext, pe1: SkPathEffect) {
25
+ ctx.save();
26
+ this.decorateChildren(ctx);
27
+ const pe2 = ctx.pathEffects.popAllAsOne();
28
+ ctx.restore();
29
+ const pe = pe2 ? this.Skia.PathEffect.MakeCompose(pe1, pe2) : pe1;
30
+ ctx.pathEffects.push(pe);
75
31
  }
76
32
  }
77
33
 
@@ -80,29 +36,26 @@ export class DiscretePathEffectNode extends PathEffectDeclaration<DiscretePathEf
80
36
  super(ctx, NodeType.DiscretePathEffect, props);
81
37
  }
82
38
 
83
- materialize() {
39
+ decorate(ctx: DeclarationContext) {
84
40
  const { length, deviation, seed } = this.props;
85
41
  const pe = this.Skia.PathEffect.MakeDiscrete(length, deviation, seed);
86
- return this.compose(pe);
42
+ this.composeAndPush(ctx, pe);
87
43
  }
88
44
  }
89
45
 
90
- export class Path2DPathEffectNode extends PathEffectDeclaration<
91
- Path2DPathEffectProps,
92
- null
93
- > {
46
+ export class Path2DPathEffectNode extends PathEffectDeclaration<Path2DPathEffectProps> {
94
47
  constructor(ctx: NodeContext, props: Path2DPathEffectProps) {
95
48
  super(ctx, NodeType.Path2DPathEffect, props);
96
49
  }
97
50
 
98
- materialize() {
51
+ decorate(ctx: DeclarationContext) {
99
52
  const { matrix } = this.props;
100
53
  const path = processPath(this.Skia, this.props.path);
101
54
  const pe = this.Skia.PathEffect.MakePath2D(matrix, path);
102
55
  if (pe === null) {
103
- return null;
56
+ throw new Error("Path2DPathEffectNode: invalid path");
104
57
  }
105
- return this.compose(pe);
58
+ this.composeAndPush(ctx, pe);
106
59
  }
107
60
  }
108
61
 
@@ -111,28 +64,25 @@ export class DashPathEffectNode extends PathEffectDeclaration<DashPathEffectProp
111
64
  super(ctx, NodeType.DashPathEffect, props);
112
65
  }
113
66
 
114
- materialize() {
67
+ decorate(ctx: DeclarationContext) {
115
68
  const { intervals, phase } = this.props;
116
69
  const pe = this.Skia.PathEffect.MakeDash(intervals, phase);
117
- return this.compose(pe);
70
+ this.composeAndPush(ctx, pe);
118
71
  }
119
72
  }
120
73
 
121
- export class CornerPathEffectNode extends PathEffectDeclaration<
122
- CornerPathEffectProps,
123
- null
124
- > {
74
+ export class CornerPathEffectNode extends PathEffectDeclaration<CornerPathEffectProps> {
125
75
  constructor(ctx: NodeContext, props: CornerPathEffectProps) {
126
76
  super(ctx, NodeType.CornerPathEffect, props);
127
77
  }
128
78
 
129
- materialize() {
79
+ decorate(ctx: DeclarationContext) {
130
80
  const { r } = this.props;
131
81
  const pe = this.Skia.PathEffect.MakeCorner(r);
132
82
  if (pe === null) {
133
- return null;
83
+ throw new Error("CornerPathEffectNode: couldn't create path effect");
134
84
  }
135
- return this.compose(pe);
85
+ this.composeAndPush(ctx, pe);
136
86
  }
137
87
  }
138
88
 
@@ -141,41 +91,38 @@ export class SumPathEffectNode extends PathEffectDeclaration<null> {
141
91
  super(ctx, NodeType.SumPathEffect, null);
142
92
  }
143
93
 
144
- materialize() {
145
- return this.Skia.PathEffect.MakeSum(
146
- this.getMandatoryChildInstance(0),
147
- this.getMandatoryChildInstance(1)
94
+ decorate(ctx: DeclarationContext) {
95
+ this.decorateChildren(ctx);
96
+ const pes = ctx.pathEffects.popAll();
97
+ const pe = composeDeclarations(
98
+ pes,
99
+ this.Skia.PathEffect.MakeSum.bind(this.Skia.PathEffect)
148
100
  );
101
+ ctx.pathEffects.push(pe);
149
102
  }
150
103
  }
151
104
 
152
- export class Line2DPathEffectNode extends PathEffectDeclaration<
153
- Line2DPathEffectProps,
154
- null
155
- > {
105
+ export class Line2DPathEffectNode extends PathEffectDeclaration<Line2DPathEffectProps> {
156
106
  constructor(ctx: NodeContext, props: Line2DPathEffectProps) {
157
107
  super(ctx, NodeType.Line2DPathEffect, props);
158
108
  }
159
109
 
160
- materialize() {
110
+ decorate(ctx: DeclarationContext) {
161
111
  const { width, matrix } = this.props;
162
112
  const pe = this.Skia.PathEffect.MakeLine2D(width, matrix);
163
113
  if (pe === null) {
164
- return null;
114
+ throw new Error("Line2DPathEffectNode: could not create path effect");
165
115
  }
166
- return this.compose(pe);
116
+ this.composeAndPush(ctx, pe);
167
117
  }
168
118
  }
169
119
 
170
- export class Path1DPathEffectNode extends PathEffectDeclaration<
171
- Path1DPathEffectProps,
172
- null
173
- > {
120
+ export class Path1DPathEffectNode extends PathEffectDeclaration<Path1DPathEffectProps> {
174
121
  constructor(ctx: NodeContext, props: Path1DPathEffectProps) {
175
122
  super(ctx, NodeType.Path1DPathEffect, props);
176
123
  }
177
124
 
178
- materialize() {
125
+ decorate(ctx: DeclarationContext) {
179
126
  const { advance, phase, style } = this.props;
180
127
  const path = processPath(this.Skia, this.props.path);
181
128
  const pe = this.Skia.PathEffect.MakePath1D(
@@ -185,8 +132,8 @@ export class Path1DPathEffectNode extends PathEffectDeclaration<
185
132
  Path1DEffectStyle[enumKey(style)]
186
133
  );
187
134
  if (pe === null) {
188
- return null;
135
+ throw new Error("Path1DPathEffectNode: could not create path effect");
189
136
  }
190
- return this.compose(pe);
137
+ this.composeAndPush(ctx, pe);
191
138
  }
192
139
  }
@@ -4,11 +4,11 @@ import {
4
4
  MipmapMode,
5
5
  TileMode,
6
6
  } from "../../../skia/types";
7
- import type { SkShader } from "../../../skia/types";
8
7
  import type { NodeContext } from "../Node";
9
8
  import { JsiDeclarationNode } from "../Node";
10
9
  import type {
11
10
  ColorProps,
11
+ DeclarationContext,
12
12
  FractalNoiseProps,
13
13
  ImageShaderProps,
14
14
  LinearGradientProps,
@@ -28,10 +28,7 @@ import {
28
28
  rect2rect,
29
29
  } from "../datatypes";
30
30
 
31
- export abstract class ShaderDeclaration<P> extends JsiDeclarationNode<
32
- P,
33
- SkShader
34
- > {
31
+ export abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {
35
32
  constructor(ctx: NodeContext, type: NodeType, props: P) {
36
33
  super(ctx, DeclarationType.Shader, type, props);
37
34
  }
@@ -42,20 +39,17 @@ export class ShaderNode extends ShaderDeclaration<ShaderProps> {
42
39
  super(ctx, NodeType.Shader, props);
43
40
  }
44
41
 
45
- materialize() {
42
+ decorate(ctx: DeclarationContext) {
43
+ this.decorateChildren(ctx);
46
44
  const { source, uniforms, ...transform } = this.props;
47
45
  const m3 = this.Skia.Matrix();
48
46
  processTransformProps(m3, transform);
49
- return source.makeShaderWithChildren(
47
+ const shader = source.makeShaderWithChildren(
50
48
  processUniforms(source, uniforms),
51
- this.children()
52
- .filter(
53
- (child): child is JsiDeclarationNode<unknown, SkShader> =>
54
- child instanceof JsiDeclarationNode && child.isShader()
55
- )
56
- .map((child) => child.materialize()),
49
+ ctx.shaders.popAll(),
57
50
  m3
58
51
  );
52
+ ctx.shaders.push(shader);
59
53
  }
60
54
  }
61
55
 
@@ -64,7 +58,7 @@ export class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {
64
58
  super(ctx, NodeType.ImageShader, props);
65
59
  }
66
60
 
67
- materialize() {
61
+ decorate(ctx: DeclarationContext) {
68
62
  const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;
69
63
  const rct = getRect(this.Skia, imageShaderProps);
70
64
  const m3 = this.Skia.Matrix();
@@ -81,13 +75,14 @@ export class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {
81
75
  const lm = this.Skia.Matrix();
82
76
  lm.concat(m3);
83
77
  processTransformProps(lm, imageShaderProps);
84
- return image.makeShaderOptions(
78
+ const shader = image.makeShaderOptions(
85
79
  TileMode[enumKey(tx)],
86
80
  TileMode[enumKey(ty)],
87
81
  FilterMode[enumKey(fm)],
88
82
  MipmapMode[enumKey(mm)],
89
83
  lm
90
84
  );
85
+ ctx.shaders.push(shader);
91
86
  }
92
87
  }
93
88
 
@@ -96,9 +91,10 @@ export class ColorNode extends ShaderDeclaration<ColorProps> {
96
91
  super(ctx, NodeType.ColorShader, props);
97
92
  }
98
93
 
99
- materialize() {
94
+ decorate(ctx: DeclarationContext) {
100
95
  const { color } = this.props;
101
- return this.Skia.Shader.MakeColor(this.Skia.Color(color));
96
+ const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));
97
+ ctx.shaders.push(shader);
102
98
  }
103
99
  }
104
100
 
@@ -107,9 +103,9 @@ export class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {
107
103
  super(ctx, NodeType.Turbulence, props);
108
104
  }
109
105
 
110
- materialize() {
106
+ decorate(ctx: DeclarationContext) {
111
107
  const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;
112
- return this.Skia.Shader.MakeTurbulence(
108
+ const shader = this.Skia.Shader.MakeTurbulence(
113
109
  freqX,
114
110
  freqY,
115
111
  octaves,
@@ -117,6 +113,7 @@ export class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {
117
113
  tileWidth,
118
114
  tileHeight
119
115
  );
116
+ ctx.shaders.push(shader);
120
117
  }
121
118
  }
122
119
 
@@ -125,9 +122,9 @@ export class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {
125
122
  super(ctx, NodeType.FractalNoise, props);
126
123
  }
127
124
 
128
- materialize() {
125
+ decorate(ctx: DeclarationContext) {
129
126
  const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;
130
- return this.Skia.Shader.MakeFractalNoise(
127
+ const shader = this.Skia.Shader.MakeFractalNoise(
131
128
  freqX,
132
129
  freqY,
133
130
  octaves,
@@ -135,6 +132,7 @@ export class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {
135
132
  tileWidth,
136
133
  tileHeight
137
134
  );
135
+ ctx.shaders.push(shader);
138
136
  }
139
137
  }
140
138
 
@@ -143,11 +141,11 @@ export class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {
143
141
  super(ctx, NodeType.LinearGradient, props);
144
142
  }
145
143
 
146
- materialize() {
144
+ decorate(ctx: DeclarationContext) {
147
145
  const { start, end } = this.props;
148
146
  const { colors, positions, mode, localMatrix, flags } =
149
147
  processGradientProps(this.Skia, this.props);
150
- return this.Skia.Shader.MakeLinearGradient(
148
+ const shader = this.Skia.Shader.MakeLinearGradient(
151
149
  start,
152
150
  end,
153
151
  colors,
@@ -156,6 +154,7 @@ export class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {
156
154
  localMatrix,
157
155
  flags
158
156
  );
157
+ ctx.shaders.push(shader);
159
158
  }
160
159
  }
161
160
 
@@ -164,11 +163,11 @@ export class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {
164
163
  super(ctx, NodeType.RadialGradient, props);
165
164
  }
166
165
 
167
- materialize() {
166
+ decorate(ctx: DeclarationContext) {
168
167
  const { c, r } = this.props;
169
168
  const { colors, positions, mode, localMatrix, flags } =
170
169
  processGradientProps(this.Skia, this.props);
171
- return this.Skia.Shader.MakeRadialGradient(
170
+ const shader = this.Skia.Shader.MakeRadialGradient(
172
171
  c,
173
172
  r,
174
173
  colors,
@@ -177,6 +176,7 @@ export class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {
177
176
  localMatrix,
178
177
  flags
179
178
  );
179
+ ctx.shaders.push(shader);
180
180
  }
181
181
  }
182
182
 
@@ -185,11 +185,11 @@ export class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {
185
185
  super(ctx, NodeType.SweepGradient, props);
186
186
  }
187
187
 
188
- materialize() {
188
+ decorate(ctx: DeclarationContext) {
189
189
  const { c, start, end } = this.props;
190
190
  const { colors, positions, mode, localMatrix, flags } =
191
191
  processGradientProps(this.Skia, this.props);
192
- return this.Skia.Shader.MakeSweepGradient(
192
+ const shader = this.Skia.Shader.MakeSweepGradient(
193
193
  c.x,
194
194
  c.y,
195
195
  colors,
@@ -200,6 +200,7 @@ export class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {
200
200
  start,
201
201
  end
202
202
  );
203
+ ctx.shaders.push(shader);
203
204
  }
204
205
  }
205
206
 
@@ -208,11 +209,11 @@ export class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConic
208
209
  super(ctx, NodeType.TwoPointConicalGradient, props);
209
210
  }
210
211
 
211
- materialize() {
212
+ decorate(ctx: DeclarationContext) {
212
213
  const { startR, endR, start, end } = this.props;
213
214
  const { colors, positions, mode, localMatrix, flags } =
214
215
  processGradientProps(this.Skia, this.props);
215
- return this.Skia.Shader.MakeTwoPointConicalGradient(
216
+ const shader = this.Skia.Shader.MakeTwoPointConicalGradient(
216
217
  start,
217
218
  startR,
218
219
  end,
@@ -223,5 +224,6 @@ export class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConic
223
224
  localMatrix,
224
225
  flags
225
226
  );
227
+ ctx.shaders.push(shader);
226
228
  }
227
229
  }