@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,74 +2,55 @@
2
2
 
3
3
  #include "JsiDomDeclarationNode.h"
4
4
 
5
+ #include <algorithm>
5
6
  #include <memory>
6
7
  #include <string>
7
8
 
8
9
  namespace RNSkia {
9
10
 
10
- class JsiBlendNode : public JsiBaseDomDeclarationNode,
11
+ class JsiBlendNode : public JsiDomDeclarationNode,
11
12
  public JsiDomNodeCtor<JsiBlendNode> {
12
13
  public:
13
14
  explicit JsiBlendNode(std::shared_ptr<RNSkPlatformContext> context)
14
- : JsiBaseDomDeclarationNode(context, "skBlend") {}
15
+ : JsiDomDeclarationNode(context, "skBlend",
16
+ DeclarationType::ImageFilter) {}
15
17
 
16
- protected:
17
- void decorate(DrawingContext *context) override {
18
- if (context->isChanged() || getPropsContainer()->isChanged()) {
19
- auto children = getChildren();
20
- auto childSize = children.size();
21
-
22
- // No need to do anything if there are no children here
23
- if (childSize == 0) {
24
- return;
25
- }
26
-
27
- // Blend mode
28
- auto blendMode = *_blendProp->getDerivedValue();
29
-
30
- // Find the latest child and check if it is a shader or image filter
31
- bool asShader = std::dynamic_pointer_cast<JsiBaseShaderNode>(
32
- children.at(childSize - 1)) != nullptr;
33
-
34
- // Traverse children in reverse
35
- sk_sp<SkShader> innerShader;
36
- sk_sp<SkImageFilter> innerImageFilter;
37
-
38
- for (size_t i = childSize - 1; i != (std::size_t)-1; i--) {
39
- auto child = children.at(i);
40
- auto maybeShader = std::dynamic_pointer_cast<JsiBaseShaderNode>(child);
41
- auto maybeImageFilter =
42
- std::dynamic_pointer_cast<JsiBaseImageFilterNode>(child);
43
-
44
- if (maybeShader) {
45
- sk_sp<SkShader> outer = maybeShader->getCurrent();
46
- if (innerShader != nullptr) {
47
- innerShader = SkShaders::Blend(blendMode, outer, innerShader);
48
- } else {
49
- innerShader = outer;
50
- }
51
- } else if (maybeImageFilter) {
52
- sk_sp<SkImageFilter> outer = maybeImageFilter->getCurrent();
53
- if (outer != nullptr) {
54
- innerImageFilter = SkImageFilters::Blend(blendMode, outer,
55
- innerImageFilter, nullptr);
56
- } else {
57
- innerImageFilter = outer;
58
- }
59
- }
60
- }
61
-
62
- // Materialize
63
- if (asShader) {
64
- context->getMutablePaint()->setShader(innerShader);
65
- } else {
66
- context->getMutablePaint()->setImageFilter(innerImageFilter);
67
- }
18
+ void decorate(DeclarationContext *context) override {
19
+
20
+ // No need to do anything if there are no children here
21
+ if (getChildren().size() == 0) {
22
+ return;
23
+ }
24
+
25
+ decorateChildren(context);
26
+
27
+ // Blend mode
28
+ auto blendMode = *_blendProp->getDerivedValue();
29
+
30
+ // Shader
31
+ auto shader = context->getShaders()->popAsOne(
32
+ [blendMode](sk_sp<SkShader> inner, sk_sp<SkShader> outer) {
33
+ return SkShaders::Blend(blendMode, outer, inner);
34
+ });
35
+
36
+ if (shader != nullptr) {
37
+ context->getShaders()->push(shader);
38
+ }
39
+
40
+ auto imageFilter =
41
+ context->getImageFilters()->Declaration<sk_sp<SkImageFilter>>::popAsOne(
42
+ [blendMode](sk_sp<SkImageFilter> inner,
43
+ sk_sp<SkImageFilter> outer) {
44
+ return SkImageFilters::Blend(blendMode, outer, inner);
45
+ });
46
+ if (imageFilter != nullptr) {
47
+ context->getImageFilters()->push(imageFilter);
68
48
  }
69
49
  }
70
50
 
51
+ protected:
71
52
  void defineProperties(NodePropsContainer *container) override {
72
- JsiBaseDomDeclarationNode::defineProperties(container);
53
+ JsiDomDeclarationNode::defineProperties(container);
73
54
  _blendProp = container->defineProperty<BlendModeProp>("mode");
74
55
  _blendProp->require();
75
56
  }
@@ -78,7 +59,7 @@ protected:
78
59
  Validates that only declaration nodes can be children
79
60
  */
80
61
  void addChild(std::shared_ptr<JsiDomNode> child) override {
81
- JsiBaseDomDeclarationNode::addChild(child);
62
+ JsiDomDeclarationNode::addChild(child);
82
63
  // Verify declaration of either shader or image filter
83
64
  verifyChild(child);
84
65
  }
@@ -88,15 +69,18 @@ protected:
88
69
  */
89
70
  void insertChildBefore(std::shared_ptr<JsiDomNode> child,
90
71
  std::shared_ptr<JsiDomNode> before) override {
91
- JsiBaseDomDeclarationNode::insertChildBefore(child, before);
72
+ JsiDomDeclarationNode::insertChildBefore(child, before);
92
73
  // Verify declaration of either shader or image filter
93
74
  verifyChild(child);
94
75
  }
95
76
 
96
77
  private:
97
78
  void verifyChild(std::shared_ptr<JsiDomNode> child) {
98
- if (std::dynamic_pointer_cast<JsiBaseShaderNode>(child) == nullptr &&
99
- std::dynamic_pointer_cast<JsiBaseImageFilterNode>(child) == nullptr) {
79
+ if (child->getNodeClass() != NodeClass::DeclarationNode ||
80
+ (std::static_pointer_cast<JsiDomDeclarationNode>(child)
81
+ ->getDeclarationType() != DeclarationType::Shader &&
82
+ std::static_pointer_cast<JsiDomDeclarationNode>(child)
83
+ ->getDeclarationType() != DeclarationType::ImageFilter)) {
100
84
  // We'll raise an error when other children are added.
101
85
  std::runtime_error("Blend nodes only supports either shaders or image "
102
86
  "filters as children, got " +
@@ -16,33 +16,32 @@
16
16
 
17
17
  namespace RNSkia {
18
18
 
19
- class JsiBlurMaskNode : public JsiBaseDomDeclarationNode,
19
+ class JsiBlurMaskNode : public JsiDomDeclarationNode,
20
20
  public JsiDomNodeCtor<JsiBlurMaskNode> {
21
21
  public:
22
22
  explicit JsiBlurMaskNode(std::shared_ptr<RNSkPlatformContext> context)
23
- : JsiBaseDomDeclarationNode(context, "skBlurMaskFilter") {}
23
+ : JsiDomDeclarationNode(context, "skBlurMaskFilter",
24
+ DeclarationType::MaskFilter) {}
24
25
 
25
- protected:
26
- void decorate(DrawingContext *context) override {
27
- if (context->isChanged() || getPropsContainer()->isChanged()) {
26
+ void decorate(DeclarationContext *context) override {
28
27
 
29
- bool respectCTM =
30
- _respectCTM->isSet() ? _respectCTM->value().getAsBool() : true;
31
- SkBlurStyle style = SkBlurStyle::kNormal_SkBlurStyle;
32
- if (_style->isSet()) {
33
- style = getBlurStyleFromString(_style->value().getAsString());
34
- }
28
+ bool respectCTM =
29
+ _respectCTM->isSet() ? _respectCTM->value().getAsBool() : true;
30
+ SkBlurStyle style = SkBlurStyle::kNormal_SkBlurStyle;
31
+ if (_style->isSet()) {
32
+ style = getBlurStyleFromString(_style->value().getAsString());
33
+ }
35
34
 
36
- auto filter = SkMaskFilter::MakeBlur(style, _blur->value().getAsNumber(),
37
- respectCTM);
35
+ auto filter =
36
+ SkMaskFilter::MakeBlur(style, _blur->value().getAsNumber(), respectCTM);
38
37
 
39
- // Set the mask filter
40
- context->getMutablePaint()->setMaskFilter(filter);
41
- }
38
+ // Set the mask filter
39
+ context->getMaskFilters()->push(filter);
42
40
  }
43
41
 
42
+ protected:
44
43
  void defineProperties(NodePropsContainer *container) override {
45
- JsiBaseDomDeclarationNode::defineProperties(container);
44
+ JsiDomDeclarationNode::defineProperties(container);
46
45
 
47
46
  _style = container->defineProperty<NodeProp>("style");
48
47
  _respectCTM = container->defineProperty<NodeProp>("respectCTM");
@@ -7,21 +7,22 @@
7
7
 
8
8
  namespace RNSkia {
9
9
 
10
- class JsiBoxShadowNode : public JsiBaseDomDeclarationNode,
10
+ class JsiBoxShadowNode : public JsiDomDeclarationNode,
11
11
  public JsiDomNodeCtor<JsiBoxShadowNode> {
12
12
  public:
13
13
  explicit JsiBoxShadowNode(std::shared_ptr<RNSkPlatformContext> context)
14
- : JsiBaseDomDeclarationNode(context, "skBoxShadow") {}
14
+ : JsiDomDeclarationNode(context, "skBoxShadow",
15
+ DeclarationType::Unknown) {}
15
16
 
16
17
  BoxShadowProps *getBoxShadowProps() { return _boxShadowProps; }
17
18
 
18
- protected:
19
- void decorate(DrawingContext *context) override {
19
+ void decorate(DeclarationContext *context) override {
20
20
  // Do nothing, we are just a container for properties
21
21
  }
22
22
 
23
+ protected:
23
24
  void defineProperties(NodePropsContainer *container) override {
24
- JsiBaseDomDeclarationNode::defineProperties(container);
25
+ JsiDomDeclarationNode::defineProperties(container);
25
26
  _boxShadowProps = container->defineProperty<BoxShadowProps>();
26
27
  }
27
28
 
@@ -17,39 +17,20 @@
17
17
 
18
18
  namespace RNSkia {
19
19
 
20
- class JsiBaseColorFilterNode
21
- : public JsiDomDeclarationNode<JsiBaseColorFilterNode,
22
- sk_sp<SkColorFilter>> {
20
+ class JsiBaseColorFilterNode : public JsiDomDeclarationNode {
23
21
  public:
24
22
  JsiBaseColorFilterNode(std::shared_ptr<RNSkPlatformContext> context,
25
23
  const char *type)
26
- : JsiDomDeclarationNode<JsiBaseColorFilterNode, sk_sp<SkColorFilter>>(
27
- context, type) {}
24
+ : JsiDomDeclarationNode(context, type, DeclarationType::ColorFilter) {}
28
25
 
29
26
  protected:
30
- sk_sp<SkColorFilter> resolve(std::shared_ptr<JsiDomNode> child) override {
31
- auto ptr = std::dynamic_pointer_cast<JsiBaseColorFilterNode>(child);
32
- if (ptr) {
33
- return ptr->getCurrent();
34
- }
35
- return nullptr;
36
- }
37
-
38
- void setColorFilter(DrawingContext *context, sk_sp<SkColorFilter> f) {
39
- set(context, f);
40
- }
41
-
42
- void set(DrawingContext *context, sk_sp<SkColorFilter> ColorFilter) override {
43
- auto paint = context->getMutablePaint();
44
- if (paint->getColorFilter() != nullptr &&
45
- paint->getColorFilter() != getCurrent().get()) {
46
- paint->setColorFilter(
47
- SkColorFilters::Compose(ColorFilter, paint->refColorFilter()));
48
- } else {
49
- paint->setColorFilter(ColorFilter);
50
- }
51
-
52
- setCurrent(ColorFilter);
27
+ void composeAndPush(DeclarationContext *context, sk_sp<SkColorFilter> cf1) {
28
+ context->save();
29
+ decorateChildren(context);
30
+ auto cf2 = context->getColorFilters()->popAsOne();
31
+ context->restore();
32
+ auto cf = cf2 ? SkColorFilters::Compose(cf1, cf2) : cf1;
33
+ context->getColorFilters()->push(cf);
53
34
  }
54
35
  };
55
36
 
@@ -61,22 +42,20 @@ public:
61
42
  std::shared_ptr<RNSkPlatformContext> context)
62
43
  : JsiBaseColorFilterNode(context, "skMatrixColorFilter") {}
63
44
 
64
- protected:
65
- void decorate(DrawingContext *context) override {
66
- if (isChanged(context)) {
67
- auto array = _matrixProp->value().getAsArray();
68
- float matrix[20];
69
- for (int i = 0; i < 20; i++) {
70
- if (array.size() > i) {
71
- matrix[i] = array[i].getAsNumber();
72
- }
45
+ void decorate(DeclarationContext *context) override {
46
+ auto array = _matrixProp->value().getAsArray();
47
+ float matrix[20];
48
+ for (int i = 0; i < 20; i++) {
49
+ if (array.size() > i) {
50
+ matrix[i] = array[i].getAsNumber();
73
51
  }
74
- setColorFilter(context, SkColorFilters::Matrix(matrix));
75
52
  }
53
+ composeAndPush(context, SkColorFilters::Matrix(matrix));
76
54
  }
77
55
 
56
+ protected:
78
57
  void defineProperties(NodePropsContainer *container) override {
79
- JsiBaseDomDeclarationNode::defineProperties(container);
58
+ JsiDomDeclarationNode::defineProperties(container);
80
59
  _matrixProp = container->defineProperty<NodeProp>("matrix");
81
60
  _matrixProp->require();
82
61
  }
@@ -91,17 +70,15 @@ public:
91
70
  explicit JsiBlendColorFilterNode(std::shared_ptr<RNSkPlatformContext> context)
92
71
  : JsiBaseColorFilterNode(context, "skBlendColorFilter") {}
93
72
 
94
- protected:
95
- void decorate(DrawingContext *context) override {
96
- if (isChanged(context)) {
97
- setColorFilter(context,
98
- SkColorFilters::Blend(*_colorProp->getDerivedValue(),
99
- *_blendModeProp->getDerivedValue()));
100
- }
73
+ void decorate(DeclarationContext *context) override {
74
+ auto color = _colorProp->getDerivedValue();
75
+ auto mode = _blendModeProp->getDerivedValue();
76
+ composeAndPush(context, SkColorFilters::Blend(*color, *mode));
101
77
  }
102
78
 
79
+ protected:
103
80
  void defineProperties(NodePropsContainer *container) override {
104
- JsiBaseDomDeclarationNode::defineProperties(container);
81
+ JsiDomDeclarationNode::defineProperties(container);
105
82
  _blendModeProp = container->defineProperty<BlendModeProp>("mode");
106
83
  _colorProp = container->defineProperty<ColorProp>("color");
107
84
 
@@ -122,11 +99,8 @@ public:
122
99
  std::shared_ptr<RNSkPlatformContext> context)
123
100
  : JsiBaseColorFilterNode(context, "skLinearToSRGBGammaColorFilter") {}
124
101
 
125
- protected:
126
- void decorate(DrawingContext *context) override {
127
- if (isChanged(context)) {
128
- setColorFilter(context, SkColorFilters::LinearToSRGBGamma());
129
- }
102
+ void decorate(DeclarationContext *context) override {
103
+ composeAndPush(context, SkColorFilters::LinearToSRGBGamma());
130
104
  }
131
105
  };
132
106
 
@@ -138,11 +112,8 @@ public:
138
112
  std::shared_ptr<RNSkPlatformContext> context)
139
113
  : JsiBaseColorFilterNode(context, "skSRGBToLinearGammaColorFilter") {}
140
114
 
141
- protected:
142
- void decorate(DrawingContext *context) override {
143
- if (isChanged(context)) {
144
- setColorFilter(context, SkColorFilters::SRGBToLinearGamma());
145
- }
115
+ void decorate(DeclarationContext *context) override {
116
+ composeAndPush(context, SkColorFilters::SRGBToLinearGamma());
146
117
  }
147
118
  };
148
119
 
@@ -152,11 +123,8 @@ public:
152
123
  explicit JsiLumaColorFilterNode(std::shared_ptr<RNSkPlatformContext> context)
153
124
  : JsiBaseColorFilterNode(context, "skLumaColorFilter") {}
154
125
 
155
- protected:
156
- void decorate(DrawingContext *context) override {
157
- if (isChanged(context)) {
158
- setColorFilter(context, SkLumaColorFilter::Make());
159
- }
126
+ void decorate(DeclarationContext *context) override {
127
+ composeAndPush(context, SkLumaColorFilter::Make());
160
128
  }
161
129
  };
162
130
 
@@ -166,17 +134,25 @@ public:
166
134
  explicit JsiLerpColorFilterNode(std::shared_ptr<RNSkPlatformContext> context)
167
135
  : JsiBaseColorFilterNode(context, "skLerpColorFilter") {}
168
136
 
169
- protected:
170
- void decorate(DrawingContext *context) override {
171
- if (isChanged(context)) {
172
- setColorFilter(context,
173
- SkColorFilters::Lerp(_tProp->value().getAsNumber(),
174
- requireChild(0), requireChild(1)));
137
+ void decorate(DeclarationContext *context) override {
138
+ context->save();
139
+ decorateChildren(context);
140
+ auto second = context->getColorFilters()->pop();
141
+ auto first = context->getColorFilters()->pop();
142
+ context->restore();
143
+
144
+ if (first == nullptr || second == nullptr) {
145
+ throw std::runtime_error(
146
+ "LerpColorFilterNode: missing two color filters as children");
175
147
  }
148
+
149
+ auto t = _tProp->value().getAsNumber();
150
+ context->getColorFilters()->push(SkColorFilters::Lerp(t, first, second));
176
151
  }
177
152
 
153
+ protected:
178
154
  void defineProperties(NodePropsContainer *container) override {
179
- JsiBaseDomDeclarationNode::defineProperties(container);
155
+ JsiDomDeclarationNode::defineProperties(container);
180
156
  _tProp = container->defineProperty<NodeProp>("t");
181
157
  _tProp->require();
182
158
  }
@@ -15,7 +15,7 @@ public:
15
15
 
16
16
  void renderNode(DrawingContext *context) override {
17
17
  for (auto &child : getChildren()) {
18
- if (child->getNodeClass() == JsiDomNodeClass::RenderNode) {
18
+ if (child->getNodeClass() == NodeClass::RenderNode) {
19
19
  std::static_pointer_cast<JsiDomRenderNode>(child)->render(context);
20
20
  }
21
21
  }