@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
@@ -16,7 +16,7 @@ public:
16
16
  protected:
17
17
  void defineProperties(NodePropsContainer *container) override {
18
18
  JsiDomRenderNode::defineProperties(container);
19
- container->defineProperty<PaintProp>();
19
+ _paintProp = container->defineProperty<PaintDrawingContextProp>();
20
20
  }
21
21
 
22
22
  /**
@@ -28,23 +28,42 @@ protected:
28
28
  #if SKIA_DOM_DEBUG
29
29
  printDebugInfo("Begin Draw", 1);
30
30
  #endif
31
-
32
- #if SKIA_DOM_DEBUG
33
- printDebugInfo(context->getDebugDescription(), 2);
34
- #endif
35
- draw(context);
31
+ // Save paint if the paint property is set
32
+ if (_paintProp->isSet()) {
33
+ draw(_paintProp->getUnsafeDerivedValue().get());
34
+ } else {
35
+ // Call abstract draw method
36
+ draw(context);
37
+ }
36
38
 
37
39
  // Draw once more for each child paint node
40
+ auto declarationCtx = context->getDeclarationContext();
38
41
  for (auto &child : getChildren()) {
39
- auto ptr = std::dynamic_pointer_cast<JsiPaintNode>(child);
40
- if (ptr != nullptr) {
41
- draw(ptr->getDrawingContext());
42
+ if (child->getNodeClass() == NodeClass::DeclarationNode &&
43
+ std::static_pointer_cast<JsiDomDeclarationNode>(child)
44
+ ->getDeclarationType() == DeclarationType::Paint) {
45
+ auto paintNode = std::static_pointer_cast<JsiPaintNode>(child);
46
+ // Draw once again with the paint
47
+ declarationCtx->save();
48
+ paintNode->decorate(declarationCtx);
49
+ auto paint = declarationCtx->getPaints()->pop();
50
+ declarationCtx->restore();
51
+
52
+ // FIXME: Can we avoid creating a new drawing context here each time?
53
+ auto localContext =
54
+ std::make_shared<DrawingContext>(std::shared_ptr<SkPaint>(paint));
55
+ localContext->setCanvas(context->getCanvas());
56
+ draw(localContext.get());
42
57
  }
43
58
  }
59
+
44
60
  #if SKIA_DOM_DEBUG
45
61
  printDebugInfo("End Draw", 1);
46
62
  #endif
47
63
  }
64
+
65
+ private:
66
+ PaintDrawingContextProp *_paintProp;
48
67
  };
49
68
 
50
69
  } // namespace RNSkia
@@ -33,7 +33,7 @@ static std::atomic<size_t> NodeIdent = 1000;
33
33
  typedef enum {
34
34
  RenderNode = 1,
35
35
  DeclarationNode = 2,
36
- } JsiDomNodeClass;
36
+ } NodeClass;
37
37
 
38
38
  /**
39
39
  Implements an abstract base class for nodes in the Skia Reconciler. This node
@@ -46,8 +46,10 @@ public:
46
46
  Contructor. Takes as parameters the values comming from the JS world that
47
47
  initialized the class.
48
48
  */
49
- JsiDomNode(std::shared_ptr<RNSkPlatformContext> context, const char *type)
50
- : _type(type), _context(context), _nodeId(NodeIdent++), JsiHostObject() {}
49
+ JsiDomNode(std::shared_ptr<RNSkPlatformContext> context, const char *type,
50
+ NodeClass nodeClass)
51
+ : _type(type), _context(context), _nodeClass(nodeClass),
52
+ _nodeId(NodeIdent++), JsiHostObject() {}
51
53
 
52
54
  /**
53
55
  Called when creating the node, resolves properties from the node constructor.
@@ -183,7 +185,7 @@ public:
183
185
  Returns the class of node so that we can do loops faster without
184
186
  having to check using runtime type information
185
187
  */
186
- virtual JsiDomNodeClass getNodeClass() = 0;
188
+ NodeClass getNodeClass() { return _nodeClass; }
187
189
 
188
190
  /**
189
191
  Updates any pending property changes in all nodes and child nodes. This
@@ -205,11 +207,6 @@ public:
205
207
  op();
206
208
  }
207
209
 
208
- // If there are any ops here we should invalidate the cached context
209
- if (_queuedNodeOps.size() > 0) {
210
- invalidateContext();
211
- }
212
-
213
210
  _queuedNodeOps.clear();
214
211
  }
215
212
 
@@ -268,7 +265,21 @@ public:
268
265
  }
269
266
  }
270
267
 
268
+ /**
269
+ Empty implementation of the decorate context method
270
+ */
271
+ virtual void decorateContext(DeclarationContext *context) {
272
+ // Empty implementation
273
+ }
274
+
271
275
  protected:
276
+ /**
277
+ Adds an operation that will be executed when the render cycle is finished.
278
+ */
279
+ void enqueAsynOperation(std::function<void()> &&fp) {
280
+ std::lock_guard<std::mutex> lock(_childrenLock);
281
+ _queuedNodeOps.push_back(std::move(fp));
282
+ }
272
283
  /**
273
284
  Override to define properties in node implementations
274
285
  */
@@ -298,7 +309,8 @@ protected:
298
309
  if (_propsContainer == nullptr) {
299
310
 
300
311
  // Initialize properties container
301
- _propsContainer = std::make_shared<NodePropsContainer>(getType());
312
+ _propsContainer = std::make_shared<NodePropsContainer>(
313
+ getType(), [=](BaseNodeProp *p) { onPropertyChanged(p); });
302
314
 
303
315
  // Ask sub classes to define their properties
304
316
  defineProperties(_propsContainer.get());
@@ -320,7 +332,8 @@ protected:
320
332
  if (_propsContainer == nullptr) {
321
333
 
322
334
  // Initialize properties container
323
- _propsContainer = std::make_shared<NodePropsContainer>(getType());
335
+ _propsContainer = std::make_shared<NodePropsContainer>(
336
+ getType(), [=](BaseNodeProp *p) { onPropertyChanged(p); });
324
337
 
325
338
  // Ask sub classes to define their properties
326
339
  defineProperties(_propsContainer.get());
@@ -335,6 +348,11 @@ protected:
335
348
  return _children;
336
349
  }
337
350
 
351
+ /**
352
+ Override to be notified when a node property has changed
353
+ */
354
+ virtual void onPropertyChanged(BaseNodeProp *prop) {}
355
+
338
356
  /**
339
357
  Adds a child node to the array of children for this node
340
358
  */
@@ -343,8 +361,7 @@ protected:
343
361
  printDebugInfo("JS:addChild(childId: " + std::to_string(child->_nodeId) +
344
362
  ")");
345
363
  #endif
346
- std::lock_guard<std::mutex> lock(_childrenLock);
347
- _queuedNodeOps.push_back([child, this]() {
364
+ enqueAsynOperation([child, this]() {
348
365
  _children.push_back(child);
349
366
  child->setParent(this);
350
367
  });
@@ -361,8 +378,7 @@ protected:
361
378
  "JS:insertChildBefore(childId: " + std::to_string(child->_nodeId) +
362
379
  ", beforeId: " + std::to_string(before->_nodeId) + ")");
363
380
  #endif
364
- std::lock_guard<std::mutex> lock(_childrenLock);
365
- _queuedNodeOps.push_back([child, before, this]() {
381
+ enqueAsynOperation([child, before, this]() {
366
382
  auto position = std::find(_children.begin(), _children.end(), before);
367
383
  _children.insert(position, child);
368
384
  child->setParent(this);
@@ -378,8 +394,7 @@ protected:
378
394
  printDebugInfo("JS:removeChild(childId: " + std::to_string(child->_nodeId) +
379
395
  ")");
380
396
  #endif
381
- std::lock_guard<std::mutex> lock(_childrenLock);
382
- _queuedNodeOps.push_back([child, this]() {
397
+ enqueAsynOperation([child, this]() {
383
398
  // Delete child itself
384
399
  _children.erase(
385
400
  std::remove_if(_children.begin(), _children.end(),
@@ -429,6 +444,18 @@ protected:
429
444
  */
430
445
  JsiDomNode *getParent() { return _parent; }
431
446
 
447
+ /**
448
+ Loops through all declaration nodes and gives each one of them the
449
+ opportunity to decorate the context.
450
+ */
451
+ void decorateChildren(DeclarationContext *context) {
452
+ for (auto &child : getChildren()) {
453
+ // All JsiDomNodes has the decorateContext method - but only the
454
+ // JsiDomDeclarationNode is actually doing stuff inside this method.
455
+ child->decorateContext(context);
456
+ }
457
+ }
458
+
432
459
  private:
433
460
  const char *_type;
434
461
  std::shared_ptr<RNSkPlatformContext> _context;
@@ -448,6 +475,8 @@ private:
448
475
  std::vector<std::function<void()>> _queuedNodeOps;
449
476
 
450
477
  JsiDomNode *_parent = nullptr;
478
+
479
+ NodeClass _nodeClass;
451
480
  };
452
481
 
453
482
  } // namespace RNSkia
@@ -15,6 +15,7 @@
15
15
 
16
16
  #include <memory>
17
17
  #include <string>
18
+ #include <vector>
18
19
 
19
20
  namespace RNSkia {
20
21
 
@@ -22,17 +23,19 @@ class JsiDomRenderNode : public JsiDomNode {
22
23
  public:
23
24
  JsiDomRenderNode(std::shared_ptr<RNSkPlatformContext> context,
24
25
  const char *type)
25
- : JsiDomNode(context, type) {}
26
+ : JsiDomNode(context, type, NodeClass::RenderNode) {}
26
27
 
27
28
  void render(DrawingContext *context) {
28
29
  #if SKIA_DOM_DEBUG
29
30
  printDebugInfo("Begin Render");
30
31
  #endif
31
32
 
32
- // Ensure we have a local drawing context inheriting from the parent context
33
- if (_localContext == nullptr) {
34
- _localContext = context->inheritContext(getType());
35
- }
33
+ auto parentPaint = context->getPaint();
34
+ auto cache =
35
+ _paintCache.parent == parentPaint ? _paintCache.child : nullptr;
36
+
37
+ auto shouldRestore =
38
+ context->saveAndConcat(_paintProps, getChildren(), cache);
36
39
 
37
40
  auto shouldTransform = _matrixProp->isSet() || _transformProp->isSet();
38
41
  auto shouldSave =
@@ -43,37 +46,36 @@ public:
43
46
  // Save canvas state
44
47
  if (_layerProp->isSet()) {
45
48
  if (_layerProp->isBool()) {
46
- #if SKIA_DOM_DEBUG
49
+ #if SKIA_DOM_DEBUG_VERBOSE
47
50
  printDebugInfo("canvas->saveLayer()");
48
51
  #endif
49
- _localContext->getCanvas()->saveLayer(
52
+ context->getCanvas()->saveLayer(
50
53
  SkCanvas::SaveLayerRec(nullptr, nullptr, nullptr, 0));
51
54
  } else {
52
- #if SKIA_DOM_DEBUG
55
+ #if SKIA_DOM_DEBUG_VERBOSE
53
56
  printDebugInfo("canvas->saveLayer(paint)");
54
57
  #endif
55
- _localContext->getCanvas()->saveLayer(SkCanvas::SaveLayerRec(
58
+ context->getCanvas()->saveLayer(SkCanvas::SaveLayerRec(
56
59
  nullptr, _layerProp->getDerivedValue().get(), nullptr, 0));
57
60
  }
58
61
  } else {
59
- #if SKIA_DOM_DEBUG
62
+ #if SKIA_DOM_DEBUG_VERBOSE
60
63
  printDebugInfo("canvas->save()");
61
64
  #endif
62
- _localContext->getCanvas()->save();
65
+ context->getCanvas()->save();
63
66
  }
64
67
 
65
68
  if (_originProp->isSet()) {
66
- #if SKIA_DOM_DEBUG
69
+ #if SKIA_DOM_DEBUG_VERBOSE
67
70
  printDebugInfo("canvas->translate(origin)");
68
71
  #endif
69
72
  // Handle origin
70
- _localContext->getCanvas()->translate(
71
- _originProp->getDerivedValue()->x(),
72
- _originProp->getDerivedValue()->y());
73
+ context->getCanvas()->translate(_originProp->getDerivedValue()->x(),
74
+ _originProp->getDerivedValue()->y());
73
75
  }
74
76
 
75
77
  if (shouldTransform) {
76
- #if SKIA_DOM_DEBUG
78
+ #if SKIA_DOM_DEBUG_VERBOSE
77
79
  printDebugInfo(
78
80
  "canvas->concat(" +
79
81
  std::string(_matrixProp->isSet() ? "matrix" : "transform") +
@@ -83,43 +85,40 @@ public:
83
85
  : _transformProp->getDerivedValue();
84
86
 
85
87
  // Concat canvas' matrix with our matrix
86
- _localContext->getCanvas()->concat(*matrix);
88
+ context->getCanvas()->concat(*matrix);
87
89
  }
88
90
 
89
91
  // Clipping
90
92
  if (_clipProp->isSet()) {
91
93
  auto invert = _invertClip->isSet() && _invertClip->value().getAsBool();
92
- clip(context, _localContext->getCanvas(), invert);
94
+ clip(context, context->getCanvas(), invert);
93
95
  }
94
96
 
95
97
  if (_originProp->isSet()) {
96
- #if SKIA_DOM_DEBUG
98
+ #if SKIA_DOM_DEBUG_VERBOSE
97
99
  printDebugInfo("canvas->translate(-origin)");
98
100
  #endif
99
101
  // Handle origin
100
- _localContext->getCanvas()->translate(
101
- -_originProp->getDerivedValue()->x(),
102
- -_originProp->getDerivedValue()->y());
102
+ context->getCanvas()->translate(-_originProp->getDerivedValue()->x(),
103
+ -_originProp->getDerivedValue()->y());
103
104
  }
104
105
  }
105
106
 
106
- // Let any local paint props decorate the context
107
- _paintProps->decorate(_localContext.get());
108
-
109
- // Now let's make sure the local context is resolved correctly - ie. that
110
- // all children of type declaration (except paint) is given the opportunity
111
- // to decorate the context.
112
- materializeDeclarations();
113
-
114
107
  // Render the node
115
- renderNode(_localContext.get());
108
+ renderNode(context);
116
109
 
117
110
  // Restore if needed
118
111
  if (shouldSave) {
119
- #if SKIA_DOM_DEBUG
112
+ #if SKIA_DOM_DEBUG_VERBOSE
120
113
  printDebugInfo("canvas->restore()");
121
114
  #endif
122
- _localContext->getCanvas()->restore();
115
+ context->getCanvas()->restore();
116
+ }
117
+
118
+ if (shouldRestore) {
119
+ _paintCache.parent = parentPaint;
120
+ _paintCache.child = context->getPaint();
121
+ context->restore();
123
122
  }
124
123
 
125
124
  #if SKIA_DOM_DEBUG
@@ -131,36 +130,22 @@ public:
131
130
  Override reset (last thing that happens in the render cycle) to also reset
132
131
  the changed flag on the local drawing context if necessary.
133
132
  */
134
- void resetPendingChanges() override {
135
- JsiDomNode::resetPendingChanges();
136
- _localContext->resetChangedFlag();
137
- }
133
+ void resetPendingChanges() override { JsiDomNode::resetPendingChanges(); }
138
134
 
139
135
  /**
140
136
  Signal from the JS side that the node is removed from the dom.
141
137
  */
142
- void dispose() override {
143
- JsiDomNode::dispose();
144
-
145
- // Clear local drawing context
146
- if (_localContext != nullptr) {
147
- _localContext->dispose();
148
- _localContext = nullptr;
149
- }
150
- }
151
-
152
- JsiDomNodeClass getNodeClass() override {
153
- return JsiDomNodeClass::RenderNode;
154
- }
138
+ void dispose() override { JsiDomNode::dispose(); }
155
139
 
156
140
  protected:
157
141
  /**
158
142
  Invalidates and marks then context as changed.
159
143
  */
160
144
  void invalidateContext() override {
161
- if (_localContext != nullptr) {
162
- _localContext->markAsChanged();
163
- }
145
+ enqueAsynOperation([=]() {
146
+ _paintCache.parent = nullptr;
147
+ _paintCache.child = nullptr;
148
+ });
164
149
  }
165
150
 
166
151
  /**
@@ -185,6 +170,43 @@ protected:
185
170
  _layerProp = container->defineProperty<LayerProp>("layer");
186
171
  }
187
172
 
173
+ /**
174
+ Validates that only declaration nodes can be children
175
+ */
176
+ void addChild(std::shared_ptr<JsiDomNode> child) override {
177
+ JsiDomNode::addChild(child);
178
+ _paintCache.parent = nullptr;
179
+ _paintCache.child = nullptr;
180
+ }
181
+
182
+ /**
183
+ Validates that only declaration nodes can be children
184
+ */
185
+ void insertChildBefore(std::shared_ptr<JsiDomNode> child,
186
+ std::shared_ptr<JsiDomNode> before) override {
187
+ JsiDomNode::insertChildBefore(child, before);
188
+ _paintCache.parent = nullptr;
189
+ _paintCache.child = nullptr;
190
+ }
191
+
192
+ /**
193
+ A property changed
194
+ */
195
+ void onPropertyChanged(BaseNodeProp *prop) override {
196
+ static std::vector<const char *> paintProps = {
197
+ JsiPropId::get("color"), JsiPropId::get("strokeWidth"),
198
+ JsiPropId::get("blendMode"), JsiPropId::get("strokeCap"),
199
+ JsiPropId::get("strokeJoin"), JsiPropId::get("strokeMiter"),
200
+ JsiPropId::get("style"), JsiPropId::get("antiAlias"),
201
+ JsiPropId::get("opacity")};
202
+
203
+ // We'll invalidate paint if a prop change happened in a paint property
204
+ if (std::find(paintProps.begin(), paintProps.end(), prop->getName()) !=
205
+ paintProps.end()) {
206
+ invalidateContext();
207
+ }
208
+ }
209
+
188
210
  private:
189
211
  /**
190
212
  Clips the canvas depending on the clip property
@@ -209,18 +231,12 @@ private:
209
231
  }
210
232
  }
211
233
 
212
- /**
213
- Loops through all declaration nodes and gives each one of them the
214
- opportunity to decorate the context
215
- */
216
- void materializeDeclarations() {
217
- for (auto &child : getChildren()) {
218
- if (child->getNodeClass() == JsiDomNodeClass::DeclarationNode) {
219
- std::static_pointer_cast<JsiBaseDomDeclarationNode>(child)
220
- ->decorateContext(_localContext.get());
221
- }
222
- }
223
- }
234
+ struct PaintCache {
235
+ std::shared_ptr<SkPaint> parent;
236
+ std::shared_ptr<SkPaint> child;
237
+ };
238
+
239
+ PaintCache _paintCache;
224
240
 
225
241
  PointProp *_originProp;
226
242
  MatrixProp *_matrixProp;
@@ -229,8 +245,6 @@ private:
229
245
  ClipProp *_clipProp;
230
246
  LayerProp *_layerProp;
231
247
  PaintProps *_paintProps;
232
-
233
- std::shared_ptr<DrawingContext> _localContext;
234
248
  };
235
249
 
236
250
  } // namespace RNSkia
@@ -5,6 +5,7 @@
5
5
 
6
6
  #include <chrono>
7
7
  #include <memory>
8
+ #include <mutex>
8
9
  #include <string>
9
10
 
10
11
  namespace RNSkia {
@@ -19,8 +20,9 @@ public:
19
20
  /**
20
21
  Constructs a new optional dom node properrty
21
22
  */
22
- explicit NodeProp(const std::string &name)
23
- : _name(JsiPropId::get(name)), BaseNodeProp() {}
23
+ explicit NodeProp(const std::string &name,
24
+ const std::function<void(BaseNodeProp *)> &onChange)
25
+ : _name(JsiPropId::get(name)), _onChange(onChange), BaseNodeProp() {}
24
26
 
25
27
  /**
26
28
  Reads JS value and swaps out with a new value
@@ -44,6 +46,9 @@ public:
44
46
  _buffer->setCurrent(runtime, read(runtime, _name, this));
45
47
  }
46
48
  _hasNewValue = *_buffer.get() != *_value.get();
49
+ if (_hasNewValue && _onChange != nullptr) {
50
+ _onChange(this);
51
+ }
47
52
  }
48
53
  }
49
54
 
@@ -62,6 +67,9 @@ public:
62
67
  // This is almost always a change - meaning a swap is
63
68
  // cheaper than comparing for equality.
64
69
  _hasNewValue = true;
70
+ if (_onChange != nullptr) {
71
+ _onChange(this);
72
+ }
65
73
  }
66
74
 
67
75
  /**
@@ -119,6 +127,8 @@ public:
119
127
  private:
120
128
  PropId _name;
121
129
 
130
+ std::function<void(BaseNodeProp *)> _onChange;
131
+
122
132
  std::shared_ptr<JsiValue> _value;
123
133
  std::shared_ptr<JsiValue> _buffer;
124
134
  std::atomic<bool> _isChanged = {false};
@@ -20,11 +20,12 @@ namespace RNSkia {
20
20
  class NodePropsContainer {
21
21
  public:
22
22
  /**
23
- Constructor. Pass the runtime and the JS object representing the properties,
24
- and a function that will be called when any property was changed from within
25
- this class as a result of a Skia value change.
23
+ Constructor for the node prop container
26
24
  */
27
- explicit NodePropsContainer(PropId componentType) : _type(componentType) {}
25
+ explicit NodePropsContainer(
26
+ PropId componentType,
27
+ const std::function<void(BaseNodeProp *)> &onPropChanged)
28
+ : _onPropChanged(onPropChanged), _type(componentType) {}
28
29
 
29
30
  /**
30
31
  Returns true if there are any changes in the props container in the current
@@ -102,25 +103,23 @@ public:
102
103
  }
103
104
 
104
105
  /**
105
- Defines a property that will be updated with the container changes.
106
- */
107
- template <typename T = BaseNodeProp>
108
- T *defineProperty(std::shared_ptr<T> prop) {
109
- _properties.push_back(prop);
110
- return prop.get();
111
- }
112
-
113
- /**
114
- Defines a property that will be updated with the container changes.
106
+ Defines a property that will be added to the container
115
107
  */
116
108
  template <class _Tp, class... _Args,
117
109
  class = std::_EnableIf<!std::is_array<_Tp>::value>>
118
110
  _Tp *defineProperty(_Args &&...__args) {
119
- return defineProperty(
120
- std::make_shared<_Tp>(std::forward<_Args>(__args)...));
111
+ // Create property and set onChange callback
112
+ auto prop =
113
+ std::make_shared<_Tp>(std::forward<_Args>(__args)..., _onPropChanged);
114
+
115
+ // Add to props list
116
+ _properties.push_back(prop);
117
+
118
+ return prop.get();
121
119
  }
122
120
 
123
121
  private:
122
+ std::function<void(BaseNodeProp *)> _onPropChanged;
124
123
  std::vector<std::shared_ptr<BaseNodeProp>> _properties;
125
124
  std::map<PropId, std::vector<NodeProp *>> _mappedProperties;
126
125
  PropId _type;
@@ -15,22 +15,33 @@ public:
15
15
 
16
16
  protected:
17
17
  void draw(DrawingContext *context) override {
18
- if (getChildren().size() == 0) {
19
- throw std::runtime_error(
20
- "Expected at least one child in the BackdropFilter node.");
18
+ auto children = getChildren();
19
+
20
+ if (children.size() == 0) {
21
+ return;
21
22
  }
22
- auto child = getChildren()[0];
23
- auto colorFilter = std::dynamic_pointer_cast<JsiBaseColorFilterNode>(child);
24
- auto imageFilter = std::dynamic_pointer_cast<JsiBaseImageFilterNode>(child);
25
23
 
26
24
  auto canvas = context->getCanvas();
27
- auto filter =
28
- colorFilter != nullptr
29
- ? SkImageFilters::ColorFilter(colorFilter->getCurrent(), nullptr)
30
- : imageFilter->getCurrent();
25
+ auto firstChild = children[0];
26
+ sk_sp<SkImageFilter> imageFilter;
27
+
28
+ if (firstChild->getNodeClass() == NodeClass::DeclarationNode) {
29
+ context->getDeclarationContext()->save();
30
+ firstChild->decorateContext(context->getDeclarationContext());
31
+ auto imgF = context->getDeclarationContext()->getImageFilters()->pop();
32
+ if (imgF) {
33
+ imageFilter = imgF;
34
+ } else {
35
+ auto cf = context->getDeclarationContext()->getColorFilters()->pop();
36
+ if (cf) {
37
+ imageFilter = SkImageFilters::ColorFilter(cf, nullptr);
38
+ }
39
+ }
40
+ context->getDeclarationContext()->restore();
41
+ }
31
42
 
32
43
  canvas->saveLayer(
33
- SkCanvas::SaveLayerRec(nullptr, nullptr, filter.get(), 0));
44
+ SkCanvas::SaveLayerRec(nullptr, nullptr, imageFilter.get(), 0));
34
45
  canvas->restore();
35
46
  }
36
47
  };