@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
@@ -1,21 +1,21 @@
1
- import type { SkPaint } from "../../skia/types";
2
1
  import { StrokeCap, StrokeJoin, PaintStyle, BlendMode } from "../../skia/types";
3
2
  import type { DeclarationNode, PaintProps } from "../types";
4
3
  import { DeclarationType, NodeType } from "../types";
4
+ import type { DeclarationContext } from "../types/DeclarationContext";
5
5
 
6
6
  import { enumKey } from "./datatypes";
7
7
  import type { NodeContext } from "./Node";
8
8
  import { JsiDeclarationNode } from "./Node";
9
9
 
10
10
  export class PaintNode
11
- extends JsiDeclarationNode<PaintProps, SkPaint>
12
- implements DeclarationNode<PaintProps, SkPaint>
11
+ extends JsiDeclarationNode<PaintProps>
12
+ implements DeclarationNode<PaintProps>
13
13
  {
14
14
  constructor(ctx: NodeContext, props: PaintProps = {}) {
15
15
  super(ctx, DeclarationType.Paint, NodeType.Paint, props);
16
16
  }
17
17
 
18
- materialize() {
18
+ decorate(ctx: DeclarationContext) {
19
19
  const {
20
20
  color,
21
21
  strokeWidth,
@@ -55,23 +55,33 @@ export class PaintNode
55
55
  if (antiAlias !== undefined) {
56
56
  paint.setAntiAlias(antiAlias);
57
57
  }
58
+ ctx.save();
58
59
  this._children.forEach((child) => {
59
60
  if (child instanceof JsiDeclarationNode) {
60
- if (child.isShader()) {
61
- paint.setShader(child.materialize());
62
- } else if (child.isColorFilter()) {
63
- paint.setColorFilter(child.materialize());
64
- } else if (child.isImageFilter()) {
65
- paint.setImageFilter(child.materialize());
66
- } else if (child.isMaskFilter()) {
67
- paint.setMaskFilter(child.materialize());
68
- } else if (child.isPathEffect()) {
69
- paint.setPathEffect(child.materialize());
70
- } else {
71
- throw new Error(`Unknown paint child ${child.type}`);
72
- }
61
+ child.decorate(ctx);
73
62
  }
74
63
  });
75
- return paint;
64
+ const colorFilter = ctx.colorFilters.popAllAsOne();
65
+ const imageFilter = ctx.imageFilters.popAllAsOne();
66
+ const shader = ctx.shaders.pop();
67
+ const maskFilter = ctx.maskFilters.pop();
68
+ const pathEffect = ctx.pathEffects.popAllAsOne();
69
+ ctx.restore();
70
+ if (imageFilter) {
71
+ paint.setImageFilter(imageFilter);
72
+ }
73
+ if (shader) {
74
+ paint.setShader(shader);
75
+ }
76
+ if (pathEffect) {
77
+ paint.setPathEffect(pathEffect);
78
+ }
79
+ if (colorFilter) {
80
+ paint.setColorFilter(colorFilter);
81
+ }
82
+ if (maskFilter) {
83
+ paint.setMaskFilter(maskFilter);
84
+ }
85
+ ctx.paints.push(paint);
76
86
  }
77
87
  }
@@ -5,27 +5,18 @@ import type {
5
5
  SkPath,
6
6
  SkPaint,
7
7
  } from "../../skia/types";
8
- import {
9
- StrokeCap,
10
- StrokeJoin,
11
- PaintStyle,
12
- BlendMode,
13
- ClipOp,
14
- isRRect,
15
- } from "../../skia/types";
8
+ import { ClipOp, isRRect } from "../../skia/types";
16
9
  import type {
17
10
  RenderNode,
18
11
  GroupProps,
19
- DrawingContext,
20
12
  NodeType,
21
13
  Node,
14
+ DrawingContext,
22
15
  } from "../types";
23
16
 
24
17
  import { isPathDef, processPath, processTransformProps } from "./datatypes";
25
18
  import type { NodeContext } from "./Node";
26
19
  import { JsiNode, JsiDeclarationNode } from "./Node";
27
- import type { PaintContext } from "./PaintContext";
28
- import { enumKey } from "./datatypes/Enum";
29
20
 
30
21
  const paintProps = [
31
22
  "color",
@@ -49,6 +40,7 @@ export abstract class JsiRenderNode<P extends GroupProps>
49
40
  implements RenderNode<P>
50
41
  {
51
42
  paintCache: PaintCache | null = null;
43
+
52
44
  matrix: SkMatrix;
53
45
  clipRect?: SkRect;
54
46
  clipRRect?: SkRRect;
@@ -63,7 +55,6 @@ export abstract class JsiRenderNode<P extends GroupProps>
63
55
  setProps(props: P) {
64
56
  super.setProps(props);
65
57
  this.onPropChange();
66
- this.paintCache = null;
67
58
  }
68
59
 
69
60
  setProp<K extends keyof P>(key: K, value: P[K]) {
@@ -88,14 +79,18 @@ export abstract class JsiRenderNode<P extends GroupProps>
88
79
 
89
80
  addChild(child: Node<unknown>) {
90
81
  if (child instanceof JsiDeclarationNode) {
91
- child.setInvalidate(() => (this.paintCache = null));
82
+ child.setInvalidate(() => {
83
+ this.paintCache = null;
84
+ });
92
85
  }
93
86
  super.addChild(child);
94
87
  }
95
88
 
96
89
  insertChildBefore(child: Node<unknown>, before: Node<unknown>) {
97
90
  if (child instanceof JsiDeclarationNode) {
98
- child.setInvalidate(() => (this.paintCache = null));
91
+ child.setInvalidate(() => {
92
+ this.paintCache = null;
93
+ });
99
94
  }
100
95
  super.insertChildBefore(child, before);
101
96
  }
@@ -117,110 +112,17 @@ export abstract class JsiRenderNode<P extends GroupProps>
117
112
  processTransformProps(this.matrix, this.props);
118
113
  }
119
114
 
120
- private getPaintCtx() {
121
- let ctx: PaintContext | undefined;
122
- const {
123
- color,
124
- strokeWidth,
125
- blendMode,
126
- style,
127
- strokeJoin,
128
- strokeCap,
129
- strokeMiter,
130
- opacity,
131
- antiAlias,
132
- } = this.props;
133
- if (
134
- color !== undefined ||
135
- strokeWidth !== undefined ||
136
- blendMode !== undefined ||
137
- style !== undefined ||
138
- strokeJoin !== undefined ||
139
- strokeCap !== undefined ||
140
- strokeMiter !== undefined ||
141
- opacity !== undefined ||
142
- antiAlias !== undefined
143
- ) {
144
- ctx = { opacity: 1 };
145
- if (color !== undefined) {
146
- ctx.color = this.Skia.Color(color);
147
- }
148
- if (strokeWidth !== undefined) {
149
- ctx.strokeWidth = strokeWidth;
150
- }
151
- if (blendMode !== undefined) {
152
- ctx.blendMode = BlendMode[enumKey(blendMode)];
153
- }
154
- if (style !== undefined) {
155
- ctx.style = PaintStyle[enumKey(style)];
156
- }
157
- if (strokeJoin !== undefined) {
158
- ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];
159
- }
160
- if (strokeCap !== undefined) {
161
- ctx.strokeCap = StrokeCap[enumKey(strokeCap)];
162
- }
163
- if (strokeMiter !== undefined) {
164
- ctx.strokeMiter = strokeMiter;
165
- }
166
- if (opacity !== undefined) {
167
- ctx.opacity = opacity;
168
- }
169
- if (antiAlias !== undefined) {
170
- ctx.antiAlias = antiAlias;
171
- }
172
- }
173
- this._children.forEach((child) => {
174
- if (child instanceof JsiDeclarationNode) {
175
- if (child.isColorFilter()) {
176
- ctx = ctx || {};
177
- const cf = child.materialize();
178
- ctx.colorFilter = ctx.colorFilter
179
- ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)
180
- : cf;
181
- } else if (child.isShader()) {
182
- ctx = ctx || {};
183
- const shader = child.materialize();
184
- ctx.shader = shader;
185
- } else if (child.isPathEffect()) {
186
- ctx = ctx || {};
187
- const pe = child.materialize();
188
- ctx.pathEffect = ctx.pathEffect
189
- ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)
190
- : pe;
191
- } else if (child.isImageFilter()) {
192
- ctx = ctx || {};
193
- const filter = child.materialize();
194
- ctx.imageFilter = ctx.imageFilter
195
- ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)
196
- : filter;
197
- } else if (child.isMaskFilter()) {
198
- ctx = ctx || {};
199
- const filter = child.materialize();
200
- ctx.maskFilter = filter;
201
- }
202
- }
203
- });
204
- return ctx;
205
- }
206
-
207
- render(parentCtx: DrawingContext) {
115
+ render(ctx: DrawingContext) {
208
116
  const { invertClip, layer, matrix, transform } = this.props;
209
- const { canvas } = parentCtx;
117
+ const { canvas } = ctx;
118
+ const parentPaint = ctx.paint;
119
+
120
+ const cache =
121
+ this.paintCache !== null && this.paintCache.parent === ctx.paint
122
+ ? this.paintCache.child
123
+ : undefined;
124
+ const shouldRestore = ctx.saveAndConcat(this, cache);
210
125
 
211
- if (
212
- this.paintCache === null ||
213
- this.paintCache.parent !== parentCtx.paint
214
- ) {
215
- const paintCtx = this.getPaintCtx();
216
- const child = paintCtx
217
- ? concatPaint(parentCtx.paint.copy(), paintCtx)
218
- : parentCtx.paint;
219
- this.paintCache = { parent: parentCtx.paint, child };
220
- }
221
- const paint = this.paintCache.child;
222
- // TODO: can we only recreate a new context here if needed?
223
- const ctx = { ...parentCtx, paint };
224
126
  const hasTransform = matrix !== undefined || transform !== undefined;
225
127
  const hasClip =
226
128
  this.clipRect !== undefined ||
@@ -256,74 +158,14 @@ export abstract class JsiRenderNode<P extends GroupProps>
256
158
  if (shouldSave) {
257
159
  canvas.restore();
258
160
  }
161
+ if (shouldRestore) {
162
+ this.paintCache = {
163
+ parent: parentPaint,
164
+ child: ctx.paint,
165
+ };
166
+ ctx.restore();
167
+ }
259
168
  }
260
169
 
261
170
  abstract renderNode(ctx: DrawingContext): void;
262
171
  }
263
-
264
- const concatPaint = (
265
- paint: SkPaint,
266
- {
267
- color,
268
- strokeWidth,
269
- shader,
270
- antiAlias,
271
- blendMode,
272
- colorFilter,
273
- imageFilter,
274
- maskFilter,
275
- pathEffect,
276
- opacity,
277
- strokeCap,
278
- strokeJoin,
279
- strokeMiter,
280
- style,
281
- }: PaintContext
282
- ) => {
283
- if (opacity !== undefined) {
284
- paint.setAlphaf(paint.getAlphaf() * opacity);
285
- }
286
- if (color !== undefined) {
287
- const currentOpacity = paint.getAlphaf();
288
- paint.setShader(null);
289
- paint.setColor(color);
290
- paint.setAlphaf(currentOpacity * paint.getAlphaf());
291
- }
292
- if (strokeWidth !== undefined) {
293
- paint.setStrokeWidth(strokeWidth);
294
- }
295
- if (shader !== undefined) {
296
- paint.setShader(shader);
297
- }
298
- if (antiAlias !== undefined) {
299
- paint.setAntiAlias(antiAlias);
300
- }
301
- if (blendMode !== undefined) {
302
- paint.setBlendMode(blendMode);
303
- }
304
- if (colorFilter !== undefined) {
305
- paint.setColorFilter(colorFilter);
306
- }
307
- if (imageFilter !== undefined) {
308
- paint.setImageFilter(imageFilter);
309
- }
310
- if (maskFilter !== undefined) {
311
- paint.setMaskFilter(maskFilter);
312
- }
313
- if (pathEffect !== undefined) {
314
- paint.setPathEffect(pathEffect);
315
- }
316
- if (strokeCap !== undefined) {
317
- paint.setStrokeCap(strokeCap);
318
- }
319
- if (strokeJoin !== undefined) {
320
- paint.setStrokeJoin(strokeJoin);
321
- }
322
- if (strokeMiter !== undefined) {
323
- paint.setStrokeMiter(strokeMiter);
324
- }
325
- if (style !== undefined) {
326
- paint.setStyle(style);
327
- }
328
- return paint;
329
- };
@@ -1,9 +1,9 @@
1
- import { isColorFilter } from "../../../skia/types";
2
1
  import type { ChildrenProps, DrawingContext } from "../../types";
3
2
  import { NodeType } from "../../types";
4
3
  import { JsiDrawingNode } from "../DrawingNode";
5
4
  import type { NodeContext } from "../Node";
6
5
  import { JsiDeclarationNode } from "../Node";
6
+ import type { SkImageFilter } from "../../../skia/types/ImageFilter/ImageFilter";
7
7
 
8
8
  export class BackdropFilterNode extends JsiDrawingNode<ChildrenProps, null> {
9
9
  constructor(ctx: NodeContext, props: ChildrenProps) {
@@ -14,17 +14,24 @@ export class BackdropFilterNode extends JsiDrawingNode<ChildrenProps, null> {
14
14
  return null;
15
15
  }
16
16
 
17
- draw({ canvas }: DrawingContext) {
17
+ draw({ canvas, declarationCtx }: DrawingContext) {
18
18
  const child = this._children[0];
19
- const filter =
20
- child instanceof JsiDeclarationNode ? child.materialize() : null;
21
- canvas.saveLayer(
22
- undefined,
23
- null,
24
- isColorFilter(filter)
25
- ? this.Skia.ImageFilter.MakeColorFilter(filter, null)
26
- : filter
27
- );
19
+ let imageFilter: SkImageFilter | null = null;
20
+ if (child instanceof JsiDeclarationNode) {
21
+ declarationCtx.save();
22
+ child.decorate(declarationCtx);
23
+ const imgf = declarationCtx.imageFilters.pop();
24
+ if (imgf) {
25
+ imageFilter = imgf;
26
+ } else {
27
+ const cf = declarationCtx.colorFilters.pop();
28
+ if (cf) {
29
+ imageFilter = this.Skia.ImageFilter.MakeColorFilter(cf, null);
30
+ }
31
+ }
32
+ declarationCtx.restore();
33
+ }
34
+ canvas.saveLayer(undefined, null, imageFilter);
28
35
  canvas.restore();
29
36
  }
30
37
  }
@@ -6,6 +6,7 @@ import type { BoxShadowProps, BoxProps } from "../../types/Drawings";
6
6
  import type { NodeContext } from "../Node";
7
7
  import { JsiDeclarationNode } from "../Node";
8
8
  import { JsiRenderNode } from "../RenderNode";
9
+ import type { DeclarationContext } from "../../types/DeclarationContext";
9
10
 
10
11
  const inflate = (
11
12
  Skia: Skia,
@@ -35,14 +36,15 @@ const deflate = (
35
36
  ty = 0
36
37
  ) => inflate(Skia, box, -dx, -dy, tx, ty);
37
38
 
38
- export class BoxShadowNode extends JsiDeclarationNode<
39
- BoxShadowProps,
40
- BoxShadowProps
41
- > {
39
+ export class BoxShadowNode extends JsiDeclarationNode<BoxShadowProps> {
42
40
  constructor(ctx: NodeContext, props: BoxShadowProps) {
43
41
  super(ctx, DeclarationType.Unknown, NodeType.BoxShadow, props);
44
42
  }
45
43
 
44
+ decorate(_ctx: DeclarationContext) {
45
+ // do nothing
46
+ }
47
+
46
48
  materialize() {
47
49
  return this.props;
48
50
  }
@@ -1,79 +1,32 @@
1
1
  import type { BlendProps } from "../../types/ImageFilters";
2
- import type { SkShader, SkImageFilter } from "../../../skia/types";
3
2
  import { BlendMode } from "../../../skia/types";
4
3
  import { DeclarationType, NodeType } from "../../types/NodeType";
5
4
  import type { NodeContext } from "../Node";
6
5
  import { JsiDeclarationNode } from "../Node";
7
- import type { Node } from "../../types";
8
6
  import { enumKey } from "../datatypes";
7
+ import type { DeclarationContext } from "../../types/DeclarationContext";
8
+ import { composeDeclarations } from "../../types/DeclarationContext";
9
9
 
10
- import { ImageFilterDeclaration } from "./ImageFilters";
11
- import { ShaderDeclaration } from "./Shaders";
12
-
13
- export class BlendNode extends JsiDeclarationNode<
14
- BlendProps,
15
- SkShader | SkImageFilter
16
- > {
10
+ export class BlendNode extends JsiDeclarationNode<BlendProps> {
17
11
  constructor(ctx: NodeContext, props: BlendProps) {
18
12
  super(ctx, DeclarationType.ImageFilter, NodeType.Blend, props);
19
13
  }
20
14
 
21
- private checkChild(
22
- child: ImageFilterDeclaration<unknown> | ShaderDeclaration<unknown>
23
- ) {
24
- if (this._children.length > 0) {
25
- if (child.declarationType === DeclarationType.ImageFilter) {
26
- this.declarationType = DeclarationType.ImageFilter;
27
- } else {
28
- this.declarationType = DeclarationType.Shader;
29
- }
30
- }
31
- }
32
-
33
- addChild(child: Node<unknown>) {
34
- if (
35
- !(child instanceof JsiDeclarationNode) ||
36
- (child.declarationType !== DeclarationType.Shader &&
37
- child.declarationType !== DeclarationType.ImageFilter)
38
- ) {
39
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
40
- }
41
- this.checkChild(child);
42
- super.addChild(child);
43
- }
44
-
45
- insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {
46
- if (
47
- !(child instanceof ImageFilterDeclaration) ||
48
- !(child instanceof ShaderDeclaration)
49
- ) {
50
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
51
- }
52
- this.checkChild(child);
53
- super.insertChildBefore(child, before);
54
- }
55
-
56
- materialize() {
15
+ decorate(ctx: DeclarationContext) {
16
+ this.decorateChildren(ctx);
57
17
  const { Skia } = this;
58
18
  const blend = BlendMode[enumKey(this.props.mode)];
59
- if (this.declarationType === DeclarationType.ImageFilter) {
60
- return (this._children as ImageFilterDeclaration<unknown>[])
61
- .reverse()
62
- .reduce<SkImageFilter | null>((inner, outer) => {
63
- if (inner === null) {
64
- return outer.materialize();
65
- }
66
- return Skia.ImageFilter.MakeBlend(blend, outer.materialize(), inner);
67
- }, null) as SkImageFilter;
68
- } else {
69
- return (this._children as ShaderDeclaration<unknown>[])
70
- .reverse()
71
- .reduce<SkShader | null>((inner, outer) => {
72
- if (inner === null) {
73
- return outer.materialize();
74
- }
75
- return Skia.Shader.MakeBlend(blend, outer.materialize(), inner);
76
- }, null) as SkShader;
19
+ // Blend ImageFilters
20
+ const imageFilters = ctx.imageFilters.popAll();
21
+ if (imageFilters.length > 0) {
22
+ const composer = Skia.ImageFilter.MakeBlend.bind(Skia.ImageFilter, blend);
23
+ ctx.imageFilters.push(composeDeclarations(imageFilters, composer));
24
+ }
25
+ // Blend Shaders
26
+ const shaders = ctx.shaders.popAll();
27
+ if (shaders.length > 0) {
28
+ const composer = Skia.Shader.MakeBlend.bind(Skia.Shader, blend);
29
+ ctx.shaders.push(composeDeclarations(shaders, composer));
77
30
  }
78
31
  }
79
32
  }
@@ -1,53 +1,28 @@
1
- import { BlendMode } from "../../../skia/types";
2
1
  import type { SkColorFilter } from "../../../skia/types";
2
+ import { BlendMode } from "../../../skia/types";
3
3
  import type { NodeContext } from "../Node";
4
4
  import { JsiDeclarationNode } from "../Node";
5
5
  import type {
6
6
  BlendColorFilterProps,
7
7
  MatrixColorFilterProps,
8
- Node,
9
8
  } from "../../types";
10
9
  import { DeclarationType, NodeType } from "../../types";
11
10
  import { enumKey } from "../datatypes/Enum";
12
11
  import type { LerpColorFilterProps } from "../../types/ColorFilters";
12
+ import type { DeclarationContext } from "../../types/DeclarationContext";
13
13
 
14
- export abstract class ColorFilterDeclaration<
15
- P,
16
- Nullable extends null | never = never
17
- > extends JsiDeclarationNode<P, SkColorFilter, Nullable> {
14
+ export abstract class ColorFilterDeclaration<P> extends JsiDeclarationNode<P> {
18
15
  constructor(ctx: NodeContext, type: NodeType, props: P) {
19
16
  super(ctx, DeclarationType.ColorFilter, type, props);
20
17
  }
21
18
 
22
- addChild(child: Node<unknown>) {
23
- if (!(child instanceof ColorFilterDeclaration)) {
24
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
25
- }
26
- super.addChild(child);
27
- }
28
-
29
- insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {
30
- if (!(child instanceof ColorFilterDeclaration)) {
31
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
32
- }
33
- super.insertChildBefore(child, before);
34
- }
35
-
36
- compose(filter: SkColorFilter) {
37
- const children = this._children as ColorFilterDeclaration<unknown>[];
38
- if (this._children.length === 0) {
39
- return filter;
40
- } else {
41
- return this.Skia.ColorFilter.MakeCompose(
42
- filter,
43
- children.reduce<SkColorFilter | null>((acc, child) => {
44
- if (acc === null) {
45
- return child.materialize();
46
- }
47
- return this.Skia.ColorFilter.MakeCompose(acc, child.materialize());
48
- }, null) as SkColorFilter
49
- );
50
- }
19
+ protected composeAndPush(ctx: DeclarationContext, cf1: SkColorFilter) {
20
+ ctx.save();
21
+ this.decorateChildren(ctx);
22
+ const cf2 = ctx.colorFilters.popAllAsOne();
23
+ ctx.restore();
24
+ const cf = cf2 ? this.Skia.ColorFilter.MakeCompose(cf1, cf2) : cf1;
25
+ ctx.colorFilters.push(cf);
51
26
  }
52
27
  }
53
28
 
@@ -56,10 +31,10 @@ export class MatrixColorFilterNode extends ColorFilterDeclaration<MatrixColorFil
56
31
  super(ctx, NodeType.MatrixColorFilter, props);
57
32
  }
58
33
 
59
- materialize() {
34
+ decorate(ctx: DeclarationContext) {
60
35
  const { matrix } = this.props;
61
36
  const cf = this.Skia.ColorFilter.MakeMatrix(matrix);
62
- return this.compose(cf);
37
+ this.composeAndPush(ctx, cf);
63
38
  }
64
39
  }
65
40
 
@@ -68,11 +43,11 @@ export class BlendColorFilterNode extends ColorFilterDeclaration<BlendColorFilte
68
43
  super(ctx, NodeType.BlendColorFilter, props);
69
44
  }
70
45
 
71
- materialize() {
46
+ decorate(ctx: DeclarationContext) {
72
47
  const { mode } = this.props;
73
48
  const color = this.Skia.Color(this.props.color);
74
49
  const cf = this.Skia.ColorFilter.MakeBlend(color, BlendMode[enumKey(mode)]);
75
- return this.compose(cf);
50
+ this.composeAndPush(ctx, cf);
76
51
  }
77
52
  }
78
53
 
@@ -81,9 +56,9 @@ export class LinearToSRGBGammaColorFilterNode extends ColorFilterDeclaration<nul
81
56
  super(ctx, NodeType.LinearToSRGBGammaColorFilter, null);
82
57
  }
83
58
 
84
- materialize() {
59
+ decorate(ctx: DeclarationContext) {
85
60
  const cf = this.Skia.ColorFilter.MakeLinearToSRGBGamma();
86
- return this.compose(cf);
61
+ this.composeAndPush(ctx, cf);
87
62
  }
88
63
  }
89
64
 
@@ -92,9 +67,9 @@ export class SRGBToLinearGammaColorFilterNode extends ColorFilterDeclaration<nul
92
67
  super(ctx, NodeType.SRGBToLinearGammaColorFilter, null);
93
68
  }
94
69
 
95
- materialize() {
70
+ decorate(ctx: DeclarationContext) {
96
71
  const cf = this.Skia.ColorFilter.MakeSRGBToLinearGamma();
97
- return this.compose(cf);
72
+ this.composeAndPush(ctx, cf);
98
73
  }
99
74
  }
100
75
 
@@ -103,9 +78,9 @@ export class LumaColorFilterNode extends ColorFilterDeclaration<null> {
103
78
  super(ctx, NodeType.LumaColorFilter, null);
104
79
  }
105
80
 
106
- materialize() {
81
+ decorate(ctx: DeclarationContext) {
107
82
  const cf = this.Skia.ColorFilter.MakeLumaColorFilter();
108
- return this.compose(cf);
83
+ this.composeAndPush(ctx, cf);
109
84
  }
110
85
  }
111
86
 
@@ -114,16 +89,18 @@ export class LerpColorFilterNode extends ColorFilterDeclaration<LerpColorFilterP
114
89
  super(ctx, NodeType.LerpColorFilter, props);
115
90
  }
116
91
 
117
- materialize() {
92
+ decorate(ctx: DeclarationContext) {
93
+ ctx.save();
94
+ this.decorateChildren(ctx);
118
95
  const { t } = this.props;
119
- const [first, second] = this.children() as JsiDeclarationNode<
120
- unknown,
121
- SkColorFilter
122
- >[];
123
- return this.Skia.ColorFilter.MakeLerp(
124
- t,
125
- first.materialize(),
126
- second.materialize()
127
- );
96
+ const second = ctx.colorFilters.pop();
97
+ const first = ctx.colorFilters.pop();
98
+ ctx.restore();
99
+ if (!first || !second) {
100
+ throw new Error(
101
+ "LerpColorFilterNode: missing two color filters as children"
102
+ );
103
+ }
104
+ ctx.colorFilters.push(this.Skia.ColorFilter.MakeLerp(t, first, second));
128
105
  }
129
106
  }