@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
@@ -2,63 +2,32 @@ import { BlendMode } from "../../../skia/types";
2
2
  import { DeclarationType, NodeType } from "../../types/NodeType";
3
3
  import { JsiDeclarationNode } from "../Node";
4
4
  import { enumKey } from "../datatypes";
5
- import { ImageFilterDeclaration } from "./ImageFilters";
6
- import { ShaderDeclaration } from "./Shaders";
5
+ import { composeDeclarations } from "../../types/DeclarationContext";
7
6
  export class BlendNode extends JsiDeclarationNode {
8
7
  constructor(ctx, props) {
9
8
  super(ctx, DeclarationType.ImageFilter, NodeType.Blend, props);
10
9
  }
11
10
 
12
- checkChild(child) {
13
- if (this._children.length > 0) {
14
- if (child.declarationType === DeclarationType.ImageFilter) {
15
- this.declarationType = DeclarationType.ImageFilter;
16
- } else {
17
- this.declarationType = DeclarationType.Shader;
18
- }
19
- }
20
- }
21
-
22
- addChild(child) {
23
- if (!(child instanceof JsiDeclarationNode) || child.declarationType !== DeclarationType.Shader && child.declarationType !== DeclarationType.ImageFilter) {
24
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
25
- }
26
-
27
- this.checkChild(child);
28
- super.addChild(child);
29
- }
30
-
31
- insertChildBefore(child, before) {
32
- if (!(child instanceof ImageFilterDeclaration) || !(child instanceof ShaderDeclaration)) {
33
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
34
- }
35
-
36
- this.checkChild(child);
37
- super.insertChildBefore(child, before);
38
- }
39
-
40
- materialize() {
11
+ decorate(ctx) {
12
+ this.decorateChildren(ctx);
41
13
  const {
42
14
  Skia
43
15
  } = this;
44
- const blend = BlendMode[enumKey(this.props.mode)];
16
+ const blend = BlendMode[enumKey(this.props.mode)]; // Blend ImageFilters
17
+
18
+ const imageFilters = ctx.imageFilters.popAll();
19
+
20
+ if (imageFilters.length > 0) {
21
+ const composer = Skia.ImageFilter.MakeBlend.bind(Skia.ImageFilter, blend);
22
+ ctx.imageFilters.push(composeDeclarations(imageFilters, composer));
23
+ } // Blend Shaders
45
24
 
46
- if (this.declarationType === DeclarationType.ImageFilter) {
47
- return this._children.reverse().reduce((inner, outer) => {
48
- if (inner === null) {
49
- return outer.materialize();
50
- }
51
25
 
52
- return Skia.ImageFilter.MakeBlend(blend, outer.materialize(), inner);
53
- }, null);
54
- } else {
55
- return this._children.reverse().reduce((inner, outer) => {
56
- if (inner === null) {
57
- return outer.materialize();
58
- }
26
+ const shaders = ctx.shaders.popAll();
59
27
 
60
- return Skia.Shader.MakeBlend(blend, outer.materialize(), inner);
61
- }, null);
28
+ if (shaders.length > 0) {
29
+ const composer = Skia.Shader.MakeBlend.bind(Skia.Shader, blend);
30
+ ctx.shaders.push(composeDeclarations(shaders, composer));
62
31
  }
63
32
  }
64
33
 
@@ -1 +1 @@
1
- {"version":3,"names":["BlendMode","DeclarationType","NodeType","JsiDeclarationNode","enumKey","ImageFilterDeclaration","ShaderDeclaration","BlendNode","constructor","ctx","props","ImageFilter","Blend","checkChild","child","_children","length","declarationType","Shader","addChild","Error","type","insertChildBefore","before","materialize","Skia","blend","mode","reverse","reduce","inner","outer","MakeBlend"],"sources":["BlendNode.ts"],"sourcesContent":["import type { BlendProps } from \"../../types/ImageFilters\";\nimport type { SkShader, SkImageFilter } from \"../../../skia/types\";\nimport { BlendMode } from \"../../../skia/types\";\nimport { DeclarationType, NodeType } from \"../../types/NodeType\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type { Node } from \"../../types\";\nimport { enumKey } from \"../datatypes\";\n\nimport { ImageFilterDeclaration } from \"./ImageFilters\";\nimport { ShaderDeclaration } from \"./Shaders\";\n\nexport class BlendNode extends JsiDeclarationNode<\n BlendProps,\n SkShader | SkImageFilter\n> {\n constructor(ctx: NodeContext, props: BlendProps) {\n super(ctx, DeclarationType.ImageFilter, NodeType.Blend, props);\n }\n\n private checkChild(\n child: ImageFilterDeclaration<unknown> | ShaderDeclaration<unknown>\n ) {\n if (this._children.length > 0) {\n if (child.declarationType === DeclarationType.ImageFilter) {\n this.declarationType = DeclarationType.ImageFilter;\n } else {\n this.declarationType = DeclarationType.Shader;\n }\n }\n }\n\n addChild(child: Node<unknown>) {\n if (\n !(child instanceof JsiDeclarationNode) ||\n (child.declarationType !== DeclarationType.Shader &&\n child.declarationType !== DeclarationType.ImageFilter)\n ) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n this.checkChild(child);\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {\n if (\n !(child instanceof ImageFilterDeclaration) ||\n !(child instanceof ShaderDeclaration)\n ) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n this.checkChild(child);\n super.insertChildBefore(child, before);\n }\n\n materialize() {\n const { Skia } = this;\n const blend = BlendMode[enumKey(this.props.mode)];\n if (this.declarationType === DeclarationType.ImageFilter) {\n return (this._children as ImageFilterDeclaration<unknown>[])\n .reverse()\n .reduce<SkImageFilter | null>((inner, outer) => {\n if (inner === null) {\n return outer.materialize();\n }\n return Skia.ImageFilter.MakeBlend(blend, outer.materialize(), inner);\n }, null) as SkImageFilter;\n } else {\n return (this._children as ShaderDeclaration<unknown>[])\n .reverse()\n .reduce<SkShader | null>((inner, outer) => {\n if (inner === null) {\n return outer.materialize();\n }\n return Skia.Shader.MakeBlend(blend, outer.materialize(), inner);\n }, null) as SkShader;\n }\n }\n}\n"],"mappings":"AAEA,SAASA,SAAT,QAA0B,qBAA1B;AACA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,sBAA1C;AAEA,SAASC,kBAAT,QAAmC,SAAnC;AAEA,SAASC,OAAT,QAAwB,cAAxB;AAEA,SAASC,sBAAT,QAAuC,gBAAvC;AACA,SAASC,iBAAT,QAAkC,WAAlC;AAEA,OAAO,MAAMC,SAAN,SAAwBJ,kBAAxB,CAGL;EACAK,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWR,eAAe,CAACU,WAA3B,EAAwCT,QAAQ,CAACU,KAAjD,EAAwDF,KAAxD;EACD;;EAEOG,UAAU,CAChBC,KADgB,EAEhB;IACA,IAAI,KAAKC,SAAL,CAAeC,MAAf,GAAwB,CAA5B,EAA+B;MAC7B,IAAIF,KAAK,CAACG,eAAN,KAA0BhB,eAAe,CAACU,WAA9C,EAA2D;QACzD,KAAKM,eAAL,GAAuBhB,eAAe,CAACU,WAAvC;MACD,CAFD,MAEO;QACL,KAAKM,eAAL,GAAuBhB,eAAe,CAACiB,MAAvC;MACD;IACF;EACF;;EAEDC,QAAQ,CAACL,KAAD,EAAuB;IAC7B,IACE,EAAEA,KAAK,YAAYX,kBAAnB,KACCW,KAAK,CAACG,eAAN,KAA0BhB,eAAe,CAACiB,MAA1C,IACCJ,KAAK,CAACG,eAAN,KAA0BhB,eAAe,CAACU,WAH9C,EAIE;MACA,MAAM,IAAIS,KAAJ,CAAW,4BAA2BN,KAAK,CAACO,I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P,WAAN,EAA7B,EAAkDM,KAAlD,CAAP;MACD,CAPI,EAOF,IAPE,CAAP;IAQD;EACF;;AA9DD"}
1
+ {"version":3,"names":["BlendMode","DeclarationType","NodeType","JsiDeclarationNode","enumKey","composeDeclarations","BlendNode","constructor","ctx","props","ImageFilter","Blend","decorate","decorateChildren","Skia","blend","mode","imageFilters","popAll","length","composer","MakeBlend","bind","push","shaders","Shader"],"sources":["BlendNode.ts"],"sourcesContent":["import type { BlendProps } from \"../../types/ImageFilters\";\nimport { BlendMode } from \"../../../skia/types\";\nimport { DeclarationType, NodeType } from \"../../types/NodeType\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { enumKey } from \"../datatypes\";\nimport type { DeclarationContext } from \"../../types/DeclarationContext\";\nimport { composeDeclarations } from \"../../types/DeclarationContext\";\n\nexport class BlendNode extends JsiDeclarationNode<BlendProps> {\n constructor(ctx: NodeContext, props: BlendProps) {\n super(ctx, DeclarationType.ImageFilter, NodeType.Blend, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { Skia } = this;\n const blend = BlendMode[enumKey(this.props.mode)];\n // Blend ImageFilters\n const imageFilters = ctx.imageFilters.popAll();\n if (imageFilters.length > 0) {\n const composer = Skia.ImageFilter.MakeBlend.bind(Skia.ImageFilter, blend);\n ctx.imageFilters.push(composeDeclarations(imageFilters, composer));\n }\n // Blend Shaders\n const shaders = ctx.shaders.popAll();\n if (shaders.length > 0) {\n const composer = Skia.Shader.MakeBlend.bind(Skia.Shader, blend);\n ctx.shaders.push(composeDeclarations(shaders, composer));\n }\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,qBAA1B;AACA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,sBAA1C;AAEA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,OAAT,QAAwB,cAAxB;AAEA,SAASC,mBAAT,QAAoC,gCAApC;AAEA,OAAO,MAAMC,SAAN,SAAwBH,kBAAxB,CAAuD;EAC5DI,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWP,eAAe,CAACS,WAA3B,EAAwCR,QAAQ,CAACS,KAAjD,EAAwDF,KAAxD;EACD;;EAEDG,QAAQ,CAACJ,GAAD,EAA0B;IAChC,KAAKK,gBAAL,CAAsBL,GAAtB;IACA,MAAM;MAAEM;IAAF,IAAW,IAAjB;IACA,MAAMC,KAAK,GAAGf,SAAS,CAACI,OAAO,CAAC,KAAKK,KAAL,CAAWO,IAAZ,CAAR,CAAvB,CAHgC,CAIhC;;IACA,MAAMC,YAAY,GAAGT,GAAG,CAACS,YAAJ,CAAiBC,MAAjB,EAArB;;IACA,IAAID,YAAY,CAACE,MAAb,GAAsB,CAA1B,EAA6B;MAC3B,MAAMC,QAAQ,GAAGN,IAAI,CAACJ,WAAL,CAAiBW,SAAjB,CAA2BC,IAA3B,CAAgCR,IAAI,CAACJ,WAArC,EAAkDK,KAAlD,CAAjB;MACAP,GAAG,CAACS,YAAJ,CAAiBM,IAAjB,CAAsBlB,mBAAmB,CAACY,YAAD,EAAeG,QAAf,CAAzC;IACD,CAT+B,CAUhC;;;IACA,MAAMI,OAAO,GAAGhB,GAAG,CAACgB,OAAJ,CAAYN,MAAZ,EAAhB;;IACA,IAAIM,OAAO,CAACL,MAAR,GAAiB,CAArB,EAAwB;MACtB,MAAMC,QAAQ,GAAGN,IAAI,CAACW,MAAL,CAAYJ,SAAZ,CAAsBC,IAAtB,CAA2BR,IAAI,CAACW,MAAhC,EAAwCV,KAAxC,CAAjB;MACAP,GAAG,CAACgB,OAAJ,CAAYD,IAAZ,CAAiBlB,mBAAmB,CAACmB,OAAD,EAAUJ,QAAV,CAApC;IACD;EACF;;AArB2D"}
@@ -1,36 +1,35 @@
1
1
  import type { SkColorFilter } from "../../../skia/types";
2
2
  import type { NodeContext } from "../Node";
3
3
  import { JsiDeclarationNode } from "../Node";
4
- import type { BlendColorFilterProps, MatrixColorFilterProps, Node } from "../../types";
4
+ import type { BlendColorFilterProps, MatrixColorFilterProps } from "../../types";
5
5
  import { NodeType } from "../../types";
6
6
  import type { LerpColorFilterProps } from "../../types/ColorFilters";
7
- export declare abstract class ColorFilterDeclaration<P, Nullable extends null | never = never> extends JsiDeclarationNode<P, SkColorFilter, Nullable> {
7
+ import type { DeclarationContext } from "../../types/DeclarationContext";
8
+ export declare abstract class ColorFilterDeclaration<P> extends JsiDeclarationNode<P> {
8
9
  constructor(ctx: NodeContext, type: NodeType, props: P);
9
- addChild(child: Node<unknown>): void;
10
- insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;
11
- compose(filter: SkColorFilter): SkColorFilter;
10
+ protected composeAndPush(ctx: DeclarationContext, cf1: SkColorFilter): void;
12
11
  }
13
12
  export declare class MatrixColorFilterNode extends ColorFilterDeclaration<MatrixColorFilterProps> {
14
13
  constructor(ctx: NodeContext, props: MatrixColorFilterProps);
15
- materialize(): SkColorFilter;
14
+ decorate(ctx: DeclarationContext): void;
16
15
  }
17
16
  export declare class BlendColorFilterNode extends ColorFilterDeclaration<BlendColorFilterProps> {
18
17
  constructor(ctx: NodeContext, props: BlendColorFilterProps);
19
- materialize(): SkColorFilter;
18
+ decorate(ctx: DeclarationContext): void;
20
19
  }
21
20
  export declare class LinearToSRGBGammaColorFilterNode extends ColorFilterDeclaration<null> {
22
21
  constructor(ctx: NodeContext);
23
- materialize(): SkColorFilter;
22
+ decorate(ctx: DeclarationContext): void;
24
23
  }
25
24
  export declare class SRGBToLinearGammaColorFilterNode extends ColorFilterDeclaration<null> {
26
25
  constructor(ctx: NodeContext);
27
- materialize(): SkColorFilter;
26
+ decorate(ctx: DeclarationContext): void;
28
27
  }
29
28
  export declare class LumaColorFilterNode extends ColorFilterDeclaration<null> {
30
29
  constructor(ctx: NodeContext);
31
- materialize(): SkColorFilter;
30
+ decorate(ctx: DeclarationContext): void;
32
31
  }
33
32
  export declare class LerpColorFilterNode extends ColorFilterDeclaration<LerpColorFilterProps> {
34
33
  constructor(ctx: NodeContext, props: LerpColorFilterProps);
35
- materialize(): SkColorFilter;
34
+ decorate(ctx: DeclarationContext): void;
36
35
  }
@@ -7,36 +7,13 @@ export class ColorFilterDeclaration extends JsiDeclarationNode {
7
7
  super(ctx, DeclarationType.ColorFilter, type, props);
8
8
  }
9
9
 
10
- addChild(child) {
11
- if (!(child instanceof ColorFilterDeclaration)) {
12
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
13
- }
14
-
15
- super.addChild(child);
16
- }
17
-
18
- insertChildBefore(child, before) {
19
- if (!(child instanceof ColorFilterDeclaration)) {
20
- throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
21
- }
22
-
23
- super.insertChildBefore(child, before);
24
- }
25
-
26
- compose(filter) {
27
- const children = this._children;
28
-
29
- if (this._children.length === 0) {
30
- return filter;
31
- } else {
32
- return this.Skia.ColorFilter.MakeCompose(filter, children.reduce((acc, child) => {
33
- if (acc === null) {
34
- return child.materialize();
35
- }
36
-
37
- return this.Skia.ColorFilter.MakeCompose(acc, child.materialize());
38
- }, null));
39
- }
10
+ composeAndPush(ctx, cf1) {
11
+ ctx.save();
12
+ this.decorateChildren(ctx);
13
+ const cf2 = ctx.colorFilters.popAllAsOne();
14
+ ctx.restore();
15
+ const cf = cf2 ? this.Skia.ColorFilter.MakeCompose(cf1, cf2) : cf1;
16
+ ctx.colorFilters.push(cf);
40
17
  }
41
18
 
42
19
  }
@@ -45,12 +22,12 @@ export class MatrixColorFilterNode extends ColorFilterDeclaration {
45
22
  super(ctx, NodeType.MatrixColorFilter, props);
46
23
  }
47
24
 
48
- materialize() {
25
+ decorate(ctx) {
49
26
  const {
50
27
  matrix
51
28
  } = this.props;
52
29
  const cf = this.Skia.ColorFilter.MakeMatrix(matrix);
53
- return this.compose(cf);
30
+ this.composeAndPush(ctx, cf);
54
31
  }
55
32
 
56
33
  }
@@ -59,13 +36,13 @@ export class BlendColorFilterNode extends ColorFilterDeclaration {
59
36
  super(ctx, NodeType.BlendColorFilter, props);
60
37
  }
61
38
 
62
- materialize() {
39
+ decorate(ctx) {
63
40
  const {
64
41
  mode
65
42
  } = this.props;
66
43
  const color = this.Skia.Color(this.props.color);
67
44
  const cf = this.Skia.ColorFilter.MakeBlend(color, BlendMode[enumKey(mode)]);
68
- return this.compose(cf);
45
+ this.composeAndPush(ctx, cf);
69
46
  }
70
47
 
71
48
  }
@@ -74,9 +51,9 @@ export class LinearToSRGBGammaColorFilterNode extends ColorFilterDeclaration {
74
51
  super(ctx, NodeType.LinearToSRGBGammaColorFilter, null);
75
52
  }
76
53
 
77
- materialize() {
54
+ decorate(ctx) {
78
55
  const cf = this.Skia.ColorFilter.MakeLinearToSRGBGamma();
79
- return this.compose(cf);
56
+ this.composeAndPush(ctx, cf);
80
57
  }
81
58
 
82
59
  }
@@ -85,9 +62,9 @@ export class SRGBToLinearGammaColorFilterNode extends ColorFilterDeclaration {
85
62
  super(ctx, NodeType.SRGBToLinearGammaColorFilter, null);
86
63
  }
87
64
 
88
- materialize() {
65
+ decorate(ctx) {
89
66
  const cf = this.Skia.ColorFilter.MakeSRGBToLinearGamma();
90
- return this.compose(cf);
67
+ this.composeAndPush(ctx, cf);
91
68
  }
92
69
 
93
70
  }
@@ -96,9 +73,9 @@ export class LumaColorFilterNode extends ColorFilterDeclaration {
96
73
  super(ctx, NodeType.LumaColorFilter, null);
97
74
  }
98
75
 
99
- materialize() {
76
+ decorate(ctx) {
100
77
  const cf = this.Skia.ColorFilter.MakeLumaColorFilter();
101
- return this.compose(cf);
78
+ this.composeAndPush(ctx, cf);
102
79
  }
103
80
 
104
81
  }
@@ -107,12 +84,21 @@ export class LerpColorFilterNode extends ColorFilterDeclaration {
107
84
  super(ctx, NodeType.LerpColorFilter, props);
108
85
  }
109
86
 
110
- materialize() {
87
+ decorate(ctx) {
88
+ ctx.save();
89
+ this.decorateChildren(ctx);
111
90
  const {
112
91
  t
113
92
  } = this.props;
114
- const [first, second] = this.children();
115
- return this.Skia.ColorFilter.MakeLerp(t, first.materialize(), second.materialize());
93
+ const second = ctx.colorFilters.pop();
94
+ const first = ctx.colorFilters.pop();
95
+ ctx.restore();
96
+
97
+ if (!first || !second) {
98
+ throw new Error("LerpColorFilterNode: missing two color filters as children");
99
+ }
100
+
101
+ ctx.colorFilters.push(this.Skia.ColorFilter.MakeLerp(t, first, second));
116
102
  }
117
103
 
118
104
  }
@@ -1 +1 @@
1
- {"version":3,"names":["BlendMode","JsiDeclarationNode","DeclarationType","NodeType","enumKey","ColorFilterDeclaration","constructor","ctx","type","props","ColorFilter","addChild","child","Error","insertChildBefore","before","compose","filter","children","_children","length","Skia","MakeCompose","reduce","acc","materialize","MatrixColorFilterNode","MatrixColorFilter","matrix","cf","MakeMatrix","BlendColorFilterNode","BlendColorFilter","mode","color","Color","MakeBlend","LinearToSRGBGammaColorFilterNode","LinearToSRGBGammaColorFilter","MakeLinearToSRGBGamma","SRGBToLinearGammaColorFilterNode","SRGBToLinearGammaColorFilter","MakeSRGBToLinearGamma","LumaColorFilterNode","LumaColorFilter","MakeLumaColorFilter","LerpColorFilterNode","LerpColorFilter","t","first","second","MakeLerp"],"sources":["ColorFilters.ts"],"sourcesContent":["import { BlendMode } from \"../../../skia/types\";\nimport type { SkColorFilter } from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n BlendColorFilterProps,\n MatrixColorFilterProps,\n Node,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport { enumKey } from \"../datatypes/Enum\";\nimport type { LerpColorFilterProps } from \"../../types/ColorFilters\";\n\nexport abstract class ColorFilterDeclaration<\n P,\n Nullable extends null | never = never\n> extends JsiDeclarationNode<P, SkColorFilter, Nullable> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.ColorFilter, type, props);\n }\n\n addChild(child: Node<unknown>) {\n if (!(child instanceof ColorFilterDeclaration)) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {\n if (!(child instanceof ColorFilterDeclaration)) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n super.insertChildBefore(child, before);\n }\n\n compose(filter: SkColorFilter) {\n const children = this._children as ColorFilterDeclaration<unknown>[];\n if (this._children.length === 0) {\n return filter;\n } else {\n return this.Skia.ColorFilter.MakeCompose(\n filter,\n children.reduce<SkColorFilter | null>((acc, child) => {\n if (acc === null) {\n return child.materialize();\n }\n return this.Skia.ColorFilter.MakeCompose(acc, child.materialize());\n }, null) as SkColorFilter\n );\n }\n }\n}\n\nexport class MatrixColorFilterNode extends ColorFilterDeclaration<MatrixColorFilterProps> {\n constructor(ctx: NodeContext, props: MatrixColorFilterProps) {\n super(ctx, NodeType.MatrixColorFilter, props);\n }\n\n materialize() {\n const { matrix } = this.props;\n const cf = this.Skia.ColorFilter.MakeMatrix(matrix);\n return this.compose(cf);\n }\n}\n\nexport class BlendColorFilterNode extends ColorFilterDeclaration<BlendColorFilterProps> {\n constructor(ctx: NodeContext, props: BlendColorFilterProps) {\n super(ctx, NodeType.BlendColorFilter, props);\n }\n\n materialize() {\n const { mode } = this.props;\n const color = this.Skia.Color(this.props.color);\n const cf = this.Skia.ColorFilter.MakeBlend(color, BlendMode[enumKey(mode)]);\n return this.compose(cf);\n }\n}\n\nexport class LinearToSRGBGammaColorFilterNode extends ColorFilterDeclaration<null> {\n constructor(ctx: NodeContext) {\n super(ctx, NodeType.LinearToSRGBGammaColorFilter, null);\n }\n\n materialize() {\n const cf = this.Skia.ColorFilter.MakeLinearToSRGBGamma();\n return this.compose(cf);\n }\n}\n\nexport class SRGBToLinearGammaColorFilterNode extends ColorFilterDeclaration<null> {\n constructor(ctx: NodeContext) {\n super(ctx, NodeType.SRGBToLinearGammaColorFilter, null);\n }\n\n materialize() {\n const cf = this.Skia.ColorFilter.MakeSRGBToLinearGamma();\n return this.compose(cf);\n }\n}\n\nexport class LumaColorFilterNode extends ColorFilterDeclaration<null> {\n constructor(ctx: NodeContext) {\n super(ctx, NodeType.LumaColorFilter, null);\n }\n\n materialize() {\n const cf = this.Skia.ColorFilter.MakeLumaColorFilter();\n return this.compose(cf);\n }\n}\n\nexport class LerpColorFilterNode extends ColorFilterDeclaration<LerpColorFilterProps> {\n constructor(ctx: NodeContext, props: LerpColorFilterProps) {\n super(ctx, NodeType.LerpColorFilter, props);\n }\n\n materialize() {\n const { t } = this.props;\n const [first, second] = this.children() as JsiDeclarationNode<\n unknown,\n SkColorFilter\n >[];\n return this.Skia.ColorFilter.MakeLerp(\n t,\n first.materialize(),\n second.materialize()\n );\n }\n}\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,qBAA1B;AAGA,SAASC,kBAAT,QAAmC,SAAnC;AAMA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,aAA1C;AACA,SAASC,OAAT,QAAwB,mBAAxB;AAGA,OAAO,MAAeC,sBAAf,SAGGJ,kBAHH,CAGkD;EACvDK,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWL,eAAe,CAACQ,WAA3B,EAAwCF,IAAxC,EAA8CC,KAA9C;EACD;;EAEDE,QAAQ,CAACC,KAAD,EAAuB;IAC7B,IAAI,EAAEA,KAAK,YAAYP,sBAAnB,CAAJ,EAAgD;MAC9C,MAAM,IAAIQ,KAAJ,CAAW,4BAA2BD,KAAK,CAACJ,IAAK,OAAM,KAAKA,IAAK,EAAjE,CAAN;IACD;;IACD,MAAMG,QAAN,CAAeC,KAAf;EACD;;EAEDE,iBAAiB,CAACF,KAAD,EAAuBG,MAAvB,EAAoD;IACnE,IAAI,EAAEH,KAAK,YAAYP,sBAAnB,CAAJ,EAAgD;MAC9C,MAAM,IAAIQ,KAAJ,CAAW,4BAA2BD,KAAK,CAACJ,IAAK,OAAM,KAAKA,IAAK,EAAjE,CAAN;IAC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E,OAAO,MAAMiB,mBAAN,SAAkCzC,sBAAlC,CAA+E;EACpFC,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAgD;IACzD,MAAMF,GAAN,EAAWJ,QAAQ,CAAC4C,eAApB,EAAqCtC,KAArC;EACD;;EAEDgB,WAAW,GAAG;IACZ,MAAM;MAAEuB;IAAF,IAAQ,KAAKvC,KAAnB;IACA,MAAM,CAACwC,KAAD,EAAQC,MAAR,IAAkB,KAAKhC,QAAL,EAAxB;IAIA,OAAO,KAAKG,IAAL,CAAUX,WAAV,CAAsByC,QAAtB,CACLH,CADK,EAELC,KAAK,CAACxB,WAAN,EAFK,EAGLyB,MAAM,CAACzB,WAAP,EAHK,CAAP;EAKD;;AAhBmF"}
1
+ {"version":3,"names":["BlendMode","JsiDeclarationNode","DeclarationType","NodeType","enumKey","ColorFilterDeclaration","constructor","ctx","type","props","ColorFilter","composeAndPush","cf1","save","decorateChildren","cf2","colorFilters","popAllAsOne","restore","cf","Skia","MakeCompose","push","MatrixColorFilterNode","MatrixColorFilter","decorate","matrix","MakeMatrix","BlendColorFilterNode","BlendColorFilter","mode","color","Color","MakeBlend","LinearToSRGBGammaColorFilterNode","LinearToSRGBGammaColorFilter","MakeLinearToSRGBGamma","SRGBToLinearGammaColorFilterNode","SRGBToLinearGammaColorFilter","MakeSRGBToLinearGamma","LumaColorFilterNode","LumaColorFilter","MakeLumaColorFilter","LerpColorFilterNode","LerpColorFilter","t","second","pop","first","Error","MakeLerp"],"sources":["ColorFilters.ts"],"sourcesContent":["import type { SkColorFilter } from \"../../../skia/types\";\nimport { BlendMode } from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n BlendColorFilterProps,\n MatrixColorFilterProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport { enumKey } from \"../datatypes/Enum\";\nimport type { LerpColorFilterProps } from \"../../types/ColorFilters\";\nimport type { DeclarationContext } from \"../../types/DeclarationContext\";\n\nexport abstract class ColorFilterDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.ColorFilter, type, props);\n }\n\n protected composeAndPush(ctx: DeclarationContext, cf1: SkColorFilter) {\n ctx.save();\n this.decorateChildren(ctx);\n const cf2 = ctx.colorFilters.popAllAsOne();\n ctx.restore();\n const cf = cf2 ? this.Skia.ColorFilter.MakeCompose(cf1, cf2) : cf1;\n ctx.colorFilters.push(cf);\n }\n}\n\nexport class MatrixColorFilterNode extends ColorFilterDeclaration<MatrixColorFilterProps> {\n constructor(ctx: NodeContext, props: MatrixColorFilterProps) {\n super(ctx, NodeType.MatrixColorFilter, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { matrix } = this.props;\n const cf = this.Skia.ColorFilter.MakeMatrix(matrix);\n this.composeAndPush(ctx, cf);\n }\n}\n\nexport class BlendColorFilterNode extends ColorFilterDeclaration<BlendColorFilterProps> {\n constructor(ctx: NodeContext, props: BlendColorFilterProps) {\n super(ctx, NodeType.BlendColorFilter, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { mode } = this.props;\n const color = this.Skia.Color(this.props.color);\n const cf = this.Skia.ColorFilter.MakeBlend(color, BlendMode[enumKey(mode)]);\n this.composeAndPush(ctx, cf);\n }\n}\n\nexport class LinearToSRGBGammaColorFilterNode extends ColorFilterDeclaration<null> {\n constructor(ctx: NodeContext) {\n super(ctx, NodeType.LinearToSRGBGammaColorFilter, null);\n }\n\n decorate(ctx: DeclarationContext) {\n const cf = this.Skia.ColorFilter.MakeLinearToSRGBGamma();\n this.composeAndPush(ctx, cf);\n }\n}\n\nexport class SRGBToLinearGammaColorFilterNode extends ColorFilterDeclaration<null> {\n constructor(ctx: NodeContext) {\n super(ctx, NodeType.SRGBToLinearGammaColorFilter, null);\n }\n\n decorate(ctx: DeclarationContext) {\n const cf = this.Skia.ColorFilter.MakeSRGBToLinearGamma();\n this.composeAndPush(ctx, cf);\n }\n}\n\nexport class LumaColorFilterNode extends ColorFilterDeclaration<null> {\n constructor(ctx: NodeContext) {\n super(ctx, NodeType.LumaColorFilter, null);\n }\n\n decorate(ctx: DeclarationContext) {\n const cf = this.Skia.ColorFilter.MakeLumaColorFilter();\n this.composeAndPush(ctx, cf);\n }\n}\n\nexport class LerpColorFilterNode extends ColorFilterDeclaration<LerpColorFilterProps> {\n constructor(ctx: NodeContext, props: LerpColorFilterProps) {\n super(ctx, NodeType.LerpColorFilter, props);\n }\n\n decorate(ctx: DeclarationContext) {\n ctx.save();\n this.decorateChildren(ctx);\n const { t } = this.props;\n const second = ctx.colorFilters.pop();\n const first = ctx.colorFilters.pop();\n ctx.restore();\n if (!first || !second) {\n throw new Error(\n \"LerpColorFilterNode: missing two color filters as children\"\n );\n }\n ctx.colorFilters.push(this.Skia.ColorFilter.MakeLerp(t, first, second));\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,qBAA1B;AAEA,SAASC,kBAAT,QAAmC,SAAnC;AAKA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,aAA1C;AACA,SAASC,OAAT,QAAwB,mBAAxB;AAIA,OAAO,MAAeC,sBAAf,SAAiDJ,kBAAjD,CAAuE;EAC5EK,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWL,eAAe,CAACQ,WAA3B,EAAwCF,IAAxC,EAA8CC,KAA9C;EACD;;EAESE,cAAc,CAACJ,GAAD,EAA0BK,GAA1B,EAA8C;IACpEL,GAAG,CAACM,IAAJ;IACA,KAAKC,gBAAL,CAAsBP,GAAtB;IACA,MAAMQ,GAAG,GAAGR,GAAG,CAACS,YAAJ,CAAiBC,WAAjB,EAAZ;IACAV,GAAG,CAACW,OAAJ;IACA,MAAMC,EAAE,GAAGJ,GAAG,GAAG,KAAKK,IAAL,CAAUV,WAAV,CAAsBW,WAAtB,CAAkCT,GAAlC,EAAuCG,GAAvC,CAAH,G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,CAACS,YAAJ,CAAiB+B,GAAjB,EAAd;IACAxC,GAAG,CAACW,OAAJ;;IACA,IAAI,CAAC8B,KAAD,IAAU,CAACF,MAAf,EAAuB;MACrB,MAAM,IAAIG,KAAJ,CACJ,4DADI,CAAN;IAGD;;IACD1C,GAAG,CAACS,YAAJ,CAAiBM,IAAjB,CAAsB,KAAKF,IAAL,CAAUV,WAAV,CAAsBwC,QAAtB,CAA+BL,CAA/B,EAAkCG,KAAlC,EAAyCF,MAAzC,CAAtB;EACD;;AAlBmF"}
@@ -1,28 +1,28 @@
1
1
  import type { SkImageFilter } from "../../../skia/types";
2
- import type { BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, MorphologyImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps } from "../../types";
2
+ import type { BlendImageFilterProps, BlurImageFilterProps, DeclarationContext, DisplacementMapImageFilterProps, DropShadowImageFilterProps, MorphologyImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps } from "../../types";
3
3
  import { NodeType } from "../../types";
4
4
  import type { NodeContext } from "../Node";
5
5
  import { JsiDeclarationNode } from "../Node";
6
- export declare abstract class ImageFilterDeclaration<P, Nullable extends null | never = never> extends JsiDeclarationNode<P, SkImageFilter, Nullable> {
6
+ export declare abstract class ImageFilterDeclaration<P> extends JsiDeclarationNode<P> {
7
7
  constructor(ctx: NodeContext, type: NodeType, props: P);
8
- getOptionalChildInstance(index: number): any;
9
- getMandatoryChildInstance(index: number): any;
8
+ protected input(ctx: DeclarationContext): SkImageFilter | null;
9
+ protected composeAndPush(ctx: DeclarationContext, imgf1: SkImageFilter): void;
10
10
  }
11
11
  export declare class OffsetImageFilterNode extends ImageFilterDeclaration<OffsetImageFilterProps> {
12
12
  constructor(ctx: NodeContext, props: OffsetImageFilterProps);
13
- materialize(): SkImageFilter;
13
+ decorate(ctx: DeclarationContext): void;
14
14
  }
15
15
  export declare class DisplacementMapImageFilterNode extends ImageFilterDeclaration<DisplacementMapImageFilterProps> {
16
16
  constructor(ctx: NodeContext, props: DisplacementMapImageFilterProps);
17
- materialize(): SkImageFilter;
17
+ decorate(ctx: DeclarationContext): void;
18
18
  }
19
19
  export declare class BlurImageFilterNode extends ImageFilterDeclaration<BlurImageFilterProps> {
20
20
  constructor(ctx: NodeContext, props: BlurImageFilterProps);
21
- materialize(): SkImageFilter;
21
+ decorate(ctx: DeclarationContext): void;
22
22
  }
23
23
  export declare class DropShadowImageFilterNode extends ImageFilterDeclaration<DropShadowImageFilterProps> {
24
24
  constructor(ctx: NodeContext, props: DropShadowImageFilterProps);
25
- materialize(): SkImageFilter;
25
+ decorate(ctx: DeclarationContext): void;
26
26
  }
27
27
  export declare enum MorphologyOperator {
28
28
  Erode = 0,
@@ -30,13 +30,13 @@ export declare enum MorphologyOperator {
30
30
  }
31
31
  export declare class MorphologyImageFilterNode extends ImageFilterDeclaration<MorphologyImageFilterProps> {
32
32
  constructor(ctx: NodeContext, props: MorphologyImageFilterProps);
33
- materialize(): SkImageFilter;
33
+ decorate(ctx: DeclarationContext): void;
34
34
  }
35
35
  export declare class BlendImageFilterNode extends ImageFilterDeclaration<BlendImageFilterProps> {
36
36
  constructor(ctx: NodeContext, props: BlendImageFilterProps);
37
- materialize(): SkImageFilter;
37
+ decorate(ctx: DeclarationContext): void;
38
38
  }
39
39
  export declare class RuntimeShaderImageFilterNode extends ImageFilterDeclaration<RuntimeShaderImageFilterProps> {
40
40
  constructor(ctx: NodeContext, props: RuntimeShaderImageFilterProps);
41
- materialize(): SkImageFilter;
41
+ decorate(ctx: DeclarationContext): void;
42
42
  }
@@ -24,32 +24,27 @@ export class ImageFilterDeclaration extends JsiDeclarationNode {
24
24
  super(ctx, DeclarationType.ImageFilter, type, props);
25
25
  }
26
26
 
27
- getOptionalChildInstance(index) {
28
- const child = this._children[index];
27
+ input(ctx) {
28
+ var _ctx$imageFilters$pop;
29
29
 
30
- if (!child) {
31
- return null;
32
- }
33
-
34
- return this.getMandatoryChildInstance(index);
30
+ return (_ctx$imageFilters$pop = ctx.imageFilters.pop()) !== null && _ctx$imageFilters$pop !== void 0 ? _ctx$imageFilters$pop : null;
35
31
  }
36
32
 
37
- getMandatoryChildInstance(index) {
38
- const child = this._children[index];
33
+ composeAndPush(ctx, imgf1) {
34
+ ctx.save();
35
+ this.decorateChildren(ctx);
36
+ let imgf2 = ctx.imageFilters.popAllAsOne();
37
+ const cf = ctx.colorFilters.popAllAsOne();
38
+ ctx.restore();
39
39
 
40
- if (child instanceof JsiDeclarationNode) {
41
- if (child.isImageFilter()) {
42
- return child.materialize();
43
- } else if (child.isShader()) {
44
- return this.Skia.ImageFilter.MakeShader(child.materialize(), null);
45
- } else if (child.declarationType === DeclarationType.ColorFilter) {
46
- return this.Skia.ImageFilter.MakeColorFilter(child.materialize(), null);
47
- } else {
48
- throw new Error(`Found invalid child ${child.type} in ${this.type}`);
49
- }
50
- } else {
51
- throw new Error(`Found invalid child ${child.type} in ${this.type}`);
40
+ if (cf) {
41
+ var _imgf;
42
+
43
+ imgf2 = this.Skia.ImageFilter.MakeCompose((_imgf = imgf2) !== null && _imgf !== void 0 ? _imgf : null, this.Skia.ImageFilter.MakeColorFilter(cf, null));
52
44
  }
45
+
46
+ const imgf = imgf2 ? this.Skia.ImageFilter.MakeCompose(imgf1, imgf2) : imgf1;
47
+ ctx.imageFilters.push(imgf);
53
48
  }
54
49
 
55
50
  }
@@ -58,12 +53,14 @@ export class OffsetImageFilterNode extends ImageFilterDeclaration {
58
53
  super(ctx, NodeType.OffsetImageFilter, props);
59
54
  }
60
55
 
61
- materialize() {
56
+ decorate(ctx) {
57
+ this.decorateChildren(ctx);
62
58
  const {
63
59
  x,
64
60
  y
65
61
  } = this.props;
66
- return this.Skia.ImageFilter.MakeOffset(x, y, this.getOptionalChildInstance(0));
62
+ const imgf = this.Skia.ImageFilter.MakeOffset(x, y, null);
63
+ this.composeAndPush(ctx, imgf);
67
64
  }
68
65
 
69
66
  }
@@ -72,13 +69,14 @@ export class DisplacementMapImageFilterNode extends ImageFilterDeclaration {
72
69
  super(ctx, NodeType.DisplacementMapImageFilter, props);
73
70
  }
74
71
 
75
- materialize() {
72
+ decorate(ctx) {
76
73
  const {
77
74
  channelX,
78
75
  channelY,
79
76
  scale
80
77
  } = this.props;
81
- return this.Skia.ImageFilter.MakeDisplacementMap(ColorChannel[enumKey(channelX)], ColorChannel[enumKey(channelY)], scale, this.getMandatoryChildInstance(0), this.getOptionalChildInstance(1));
78
+ const imgf = this.Skia.ImageFilter.MakeDisplacementMap(ColorChannel[enumKey(channelX)], ColorChannel[enumKey(channelY)], scale, ctx.imageFilters.pop(), this.input(ctx));
79
+ this.composeAndPush(ctx, imgf);
82
80
  }
83
81
 
84
82
  }
@@ -87,13 +85,14 @@ export class BlurImageFilterNode extends ImageFilterDeclaration {
87
85
  super(ctx, NodeType.BlurImageFilter, props);
88
86
  }
89
87
 
90
- materialize() {
88
+ decorate(ctx) {
91
89
  const {
92
90
  mode,
93
91
  blur
94
92
  } = this.props;
95
93
  const sigma = processRadius(this.Skia, blur);
96
- return this.Skia.ImageFilter.MakeBlur(sigma.x, sigma.y, TileMode[enumKey(mode)], this.getOptionalChildInstance(0));
94
+ const imgf = this.Skia.ImageFilter.MakeBlur(sigma.x, sigma.y, TileMode[enumKey(mode)], this.input(ctx));
95
+ this.composeAndPush(ctx, imgf);
97
96
  }
98
97
 
99
98
  }
@@ -102,7 +101,7 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration {
102
101
  super(ctx, NodeType.DropShadowImageFilter, props);
103
102
  }
104
103
 
105
- materialize() {
104
+ decorate(ctx) {
106
105
  const {
107
106
  dx,
108
107
  dy,
@@ -112,7 +111,6 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration {
112
111
  inner
113
112
  } = this.props;
114
113
  const color = this.Skia.Color(cl);
115
- const input = this.getOptionalChildInstance(0);
116
114
  let factory;
117
115
 
118
116
  if (inner) {
@@ -121,7 +119,8 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration {
121
119
  factory = shadowOnly ? this.Skia.ImageFilter.MakeDropShadowOnly.bind(this.Skia.ImageFilter) : this.Skia.ImageFilter.MakeDropShadow.bind(this.Skia.ImageFilter);
122
120
  }
123
121
 
124
- return factory(dx, dy, blur, blur, color, input);
122
+ const imgf = factory(dx, dy, blur, blur, color, this.input(ctx));
123
+ this.composeAndPush(ctx, imgf);
125
124
  }
126
125
 
127
126
  }
@@ -137,18 +136,20 @@ export class MorphologyImageFilterNode extends ImageFilterDeclaration {
137
136
  super(ctx, NodeType.MorphologyImageFilter, props);
138
137
  }
139
138
 
140
- materialize() {
139
+ decorate(ctx) {
141
140
  const {
142
141
  operator
143
142
  } = this.props;
144
143
  const r = processRadius(this.Skia, this.props.radius);
145
- const input = this.getOptionalChildInstance(0);
144
+ let imgf;
146
145
 
147
146
  if (MorphologyOperator[enumKey(operator)] === MorphologyOperator.Erode) {
148
- return this.Skia.ImageFilter.MakeErode(r.x, r.y, input);
147
+ imgf = this.Skia.ImageFilter.MakeErode(r.x, r.y, this.input(ctx));
148
+ } else {
149
+ imgf = this.Skia.ImageFilter.MakeDilate(r.x, r.y, this.input(ctx));
149
150
  }
150
151
 
151
- return this.Skia.ImageFilter.MakeDilate(r.x, r.y, input);
152
+ this.composeAndPush(ctx, imgf);
152
153
  }
153
154
 
154
155
  }
@@ -157,13 +158,19 @@ export class BlendImageFilterNode extends ImageFilterDeclaration {
157
158
  super(ctx, NodeType.BlendImageFilter, props);
158
159
  }
159
160
 
160
- materialize() {
161
+ decorate(ctx) {
161
162
  const {
162
163
  mode
163
164
  } = this.props;
164
- const a = this.getMandatoryChildInstance(0);
165
- const b = this.getMandatoryChildInstance(1);
166
- return this.Skia.ImageFilter.MakeBlend(mode, a, b);
165
+ const a = ctx.imageFilters.pop();
166
+ const b = ctx.imageFilters.pop();
167
+
168
+ if (!a || !b) {
169
+ throw new Error("BlendImageFilter requires two image filters");
170
+ }
171
+
172
+ const imgf = this.Skia.ImageFilter.MakeBlend(mode, a, b);
173
+ this.composeAndPush(ctx, imgf);
167
174
  }
168
175
 
169
176
  }
@@ -172,7 +179,7 @@ export class RuntimeShaderImageFilterNode extends ImageFilterDeclaration {
172
179
  super(ctx, NodeType.RuntimeShaderImageFilter, props);
173
180
  }
174
181
 
175
- materialize() {
182
+ decorate(ctx) {
176
183
  const {
177
184
  source,
178
185
  uniforms
@@ -183,8 +190,8 @@ export class RuntimeShaderImageFilterNode extends ImageFilterDeclaration {
183
190
  processUniforms(source, uniforms, rtb);
184
191
  }
185
192
 
186
- const input = this.getOptionalChildInstance(0);
187
- return this.Skia.ImageFilter.MakeRuntimeShader(rtb, null, input);
193
+ const imgf = this.Skia.ImageFilter.MakeRuntimeShader(rtb, null, this.input(ctx));
194
+ this.composeAndPush(ctx, imgf);
188
195
  }
189
196
 
190
197
  }