@shopify/react-native-skia 0.1.172 → 0.1.174

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. package/android/CMakeLists.txt +1 -0
  2. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +5 -0
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +106 -5
  4. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -1
  5. package/cpp/api/JsiSkSurface.h +7 -1
  6. package/cpp/api/JsiSkSurfaceFactory.h +15 -2
  7. package/cpp/rnskia/RNSkDomView.cpp +2 -4
  8. package/cpp/rnskia/RNSkJsView.cpp +3 -0
  9. package/cpp/rnskia/RNSkPictureView.h +3 -0
  10. package/cpp/rnskia/RNSkPlatformContext.h +9 -0
  11. package/cpp/rnskia/dom/JsiDomApi.h +1 -0
  12. package/cpp/rnskia/dom/base/ConcatablePaint.cpp +117 -0
  13. package/cpp/rnskia/dom/base/ConcatablePaint.h +49 -0
  14. package/cpp/rnskia/dom/base/Declaration.h +88 -0
  15. package/cpp/rnskia/dom/base/DeclarationContext.h +79 -0
  16. package/cpp/rnskia/dom/base/DerivedNodeProp.h +25 -9
  17. package/cpp/rnskia/dom/base/DrawingContext.cpp +32 -186
  18. package/cpp/rnskia/dom/base/DrawingContext.h +45 -64
  19. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +35 -106
  20. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +28 -9
  21. package/cpp/rnskia/dom/base/JsiDomNode.h +46 -17
  22. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +81 -67
  23. package/cpp/rnskia/dom/base/NodeProp.h +12 -2
  24. package/cpp/rnskia/dom/base/NodePropsContainer.h +15 -16
  25. package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +22 -11
  26. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +43 -59
  27. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +16 -17
  28. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +6 -5
  29. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +45 -69
  30. package/cpp/rnskia/dom/nodes/JsiGroupNode.h +1 -1
  31. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +121 -161
  32. package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -0
  33. package/cpp/rnskia/dom/nodes/JsiLayerNode.h +28 -18
  34. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +82 -45
  35. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +68 -101
  36. package/cpp/rnskia/dom/nodes/JsiPathNode.h +3 -2
  37. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +150 -207
  38. package/cpp/rnskia/dom/props/BezierProps.h +4 -2
  39. package/cpp/rnskia/dom/props/BlendModeProp.h +4 -2
  40. package/cpp/rnskia/dom/props/BoxShadowProps.h +8 -10
  41. package/cpp/rnskia/dom/props/CircleProp.h +6 -5
  42. package/cpp/rnskia/dom/props/ClipProp.h +6 -4
  43. package/cpp/rnskia/dom/props/ColorProp.h +8 -4
  44. package/cpp/rnskia/dom/props/DrawingProp.h +5 -3
  45. package/cpp/rnskia/dom/props/FontProp.h +4 -2
  46. package/cpp/rnskia/dom/props/GlyphsProp.h +4 -2
  47. package/cpp/rnskia/dom/props/ImageProps.h +9 -6
  48. package/cpp/rnskia/dom/props/LayerProp.h +6 -4
  49. package/cpp/rnskia/dom/props/MatrixProp.h +4 -2
  50. package/cpp/rnskia/dom/props/NumbersProp.h +8 -4
  51. package/cpp/rnskia/dom/props/PaintProps.h +55 -92
  52. package/cpp/rnskia/dom/props/PathProp.h +4 -2
  53. package/cpp/rnskia/dom/props/PictureProp.h +4 -2
  54. package/cpp/rnskia/dom/props/PointProp.h +4 -2
  55. package/cpp/rnskia/dom/props/PointsProp.h +8 -4
  56. package/cpp/rnskia/dom/props/RRectProp.h +23 -16
  57. package/cpp/rnskia/dom/props/RadiusProp.h +4 -2
  58. package/cpp/rnskia/dom/props/RectProp.h +18 -12
  59. package/cpp/rnskia/dom/props/StrokeProps.h +8 -4
  60. package/cpp/rnskia/dom/props/SvgProp.h +4 -2
  61. package/cpp/rnskia/dom/props/TextBlobProp.h +10 -8
  62. package/cpp/rnskia/dom/props/TileModeProp.h +4 -2
  63. package/cpp/rnskia/dom/props/TransformProp.h +4 -2
  64. package/cpp/rnskia/dom/props/TransformsProps.h +5 -7
  65. package/cpp/rnskia/dom/props/UniformsProp.h +4 -2
  66. package/cpp/rnskia/dom/props/VertexModeProp.h +4 -2
  67. package/cpp/rnskia/dom/props/VerticesProps.h +7 -11
  68. package/ios/RNSkia-iOS/DisplayLink.mm +22 -24
  69. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +53 -50
  70. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -0
  71. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +56 -25
  72. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +17 -17
  73. package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +17 -17
  74. package/ios/RNSkia-iOS/SkiaManager.mm +12 -10
  75. package/ios/RNSkia-iOS/SkiaMetalRenderer.h +5 -0
  76. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +53 -0
  77. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +17 -17
  78. package/ios/RNSkia-iOS/SkiaUIView.mm +63 -53
  79. package/ios/RNSkiaModule.mm +5 -7
  80. package/lib/commonjs/dom/nodes/DrawingNode.js +5 -1
  81. package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
  82. package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +33 -34
  83. package/lib/commonjs/dom/nodes/LayerNode.js +13 -6
  84. package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -1
  85. package/lib/commonjs/dom/nodes/Node.d.ts +6 -11
  86. package/lib/commonjs/dom/nodes/Node.js +8 -26
  87. package/lib/commonjs/dom/nodes/Node.js.map +1 -1
  88. package/lib/commonjs/dom/nodes/PaintContext.js.map +1 -1
  89. package/lib/commonjs/dom/nodes/PaintNode.d.ts +3 -3
  90. package/lib/commonjs/dom/nodes/PaintNode.js +32 -15
  91. package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
  92. package/lib/commonjs/dom/nodes/RenderNode.d.ts +2 -3
  93. package/lib/commonjs/dom/nodes/RenderNode.js +19 -187
  94. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  95. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  96. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js +25 -7
  97. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
  98. package/lib/commonjs/dom/nodes/drawings/Box.d.ts +3 -1
  99. package/lib/commonjs/dom/nodes/drawings/Box.js +3 -0
  100. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  101. package/lib/commonjs/dom/nodes/paint/BlendNode.d.ts +3 -7
  102. package/lib/commonjs/dom/nodes/paint/BlendNode.js +16 -47
  103. package/lib/commonjs/dom/nodes/paint/BlendNode.js.map +1 -1
  104. package/lib/commonjs/dom/nodes/paint/ColorFilters.d.ts +10 -11
  105. package/lib/commonjs/dom/nodes/paint/ColorFilters.js +29 -43
  106. package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
  107. package/lib/commonjs/dom/nodes/paint/ImageFilters.d.ts +11 -11
  108. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +45 -42
  109. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  110. package/lib/commonjs/dom/nodes/paint/MaskFilters.d.ts +3 -3
  111. package/lib/commonjs/dom/nodes/paint/MaskFilters.js +3 -2
  112. package/lib/commonjs/dom/nodes/paint/MaskFilters.js.map +1 -1
  113. package/lib/commonjs/dom/nodes/paint/PathEffects.d.ts +15 -18
  114. package/lib/commonjs/dom/nodes/paint/PathEffects.js +30 -72
  115. package/lib/commonjs/dom/nodes/paint/PathEffects.js.map +1 -1
  116. package/lib/commonjs/dom/nodes/paint/Shaders.d.ts +11 -12
  117. package/lib/commonjs/dom/nodes/paint/Shaders.js +28 -18
  118. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  119. package/lib/commonjs/dom/types/DeclarationContext.d.ts +29 -0
  120. package/lib/commonjs/dom/types/DeclarationContext.js +118 -0
  121. package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -0
  122. package/lib/commonjs/dom/types/DrawingContext.d.ts +18 -1
  123. package/lib/commonjs/dom/types/DrawingContext.js +330 -0
  124. package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
  125. package/lib/commonjs/dom/types/Node.d.ts +4 -10
  126. package/lib/commonjs/dom/types/Node.js.map +1 -1
  127. package/lib/commonjs/dom/types/SkDOM.d.ts +22 -23
  128. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  129. package/lib/commonjs/dom/types/index.d.ts +1 -0
  130. package/lib/commonjs/dom/types/index.js +13 -0
  131. package/lib/commonjs/dom/types/index.js.map +1 -1
  132. package/lib/commonjs/index.d.ts +1 -0
  133. package/lib/commonjs/index.js +13 -0
  134. package/lib/commonjs/index.js.map +1 -1
  135. package/lib/commonjs/renderer/Canvas.js +3 -3
  136. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  137. package/lib/commonjs/renderer/DrawingContext.d.ts +4 -3
  138. package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
  139. package/lib/commonjs/renderer/HostComponents.d.ts +35 -35
  140. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  141. package/lib/commonjs/renderer/HostConfig.js +1 -0
  142. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  143. package/lib/commonjs/renderer/Offscreen.d.ts +2 -0
  144. package/lib/commonjs/renderer/Offscreen.js +31 -0
  145. package/lib/commonjs/renderer/Offscreen.js.map +1 -0
  146. package/lib/commonjs/renderer/Reconciler.js +0 -1
  147. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  148. package/lib/commonjs/skia/types/Surface/Surface.d.ts +4 -0
  149. package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
  150. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  151. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  152. package/lib/commonjs/skia/web/JsiSkDataFactory.js +0 -1
  153. package/lib/commonjs/skia/web/JsiSkDataFactory.js.map +1 -1
  154. package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
  155. package/lib/commonjs/skia/web/JsiSkImage.js +34 -3
  156. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  157. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
  158. package/lib/commonjs/skia/web/JsiSkSurface.js +4 -0
  159. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  160. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  161. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +21 -1
  162. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  163. package/lib/commonjs/views/SkiaBaseWebView.js +14 -8
  164. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  165. package/lib/commonjs/views/SkiaDomView.web.js +3 -14
  166. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
  167. package/lib/commonjs/views/SkiaPictureView.web.js +0 -7
  168. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  169. package/lib/commonjs/views/SkiaView.web.js +0 -7
  170. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  171. package/lib/module/dom/nodes/DrawingNode.js +5 -1
  172. package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
  173. package/lib/module/dom/nodes/JsiSkDOM.d.ts +33 -34
  174. package/lib/module/dom/nodes/LayerNode.js +13 -7
  175. package/lib/module/dom/nodes/LayerNode.js.map +1 -1
  176. package/lib/module/dom/nodes/Node.d.ts +6 -11
  177. package/lib/module/dom/nodes/Node.js +8 -25
  178. package/lib/module/dom/nodes/Node.js.map +1 -1
  179. package/lib/module/dom/nodes/PaintContext.js.map +1 -1
  180. package/lib/module/dom/nodes/PaintNode.d.ts +3 -3
  181. package/lib/module/dom/nodes/PaintNode.js +32 -15
  182. package/lib/module/dom/nodes/PaintNode.js.map +1 -1
  183. package/lib/module/dom/nodes/RenderNode.d.ts +2 -3
  184. package/lib/module/dom/nodes/RenderNode.js +20 -187
  185. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  186. package/lib/module/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  187. package/lib/module/dom/nodes/drawings/BackdropFilterNode.js +23 -4
  188. package/lib/module/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
  189. package/lib/module/dom/nodes/drawings/Box.d.ts +3 -1
  190. package/lib/module/dom/nodes/drawings/Box.js +3 -0
  191. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  192. package/lib/module/dom/nodes/paint/BlendNode.d.ts +3 -7
  193. package/lib/module/dom/nodes/paint/BlendNode.js +15 -46
  194. package/lib/module/dom/nodes/paint/BlendNode.js.map +1 -1
  195. package/lib/module/dom/nodes/paint/ColorFilters.d.ts +10 -11
  196. package/lib/module/dom/nodes/paint/ColorFilters.js +29 -43
  197. package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
  198. package/lib/module/dom/nodes/paint/ImageFilters.d.ts +11 -11
  199. package/lib/module/dom/nodes/paint/ImageFilters.js +48 -41
  200. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  201. package/lib/module/dom/nodes/paint/MaskFilters.d.ts +3 -3
  202. package/lib/module/dom/nodes/paint/MaskFilters.js +3 -2
  203. package/lib/module/dom/nodes/paint/MaskFilters.js.map +1 -1
  204. package/lib/module/dom/nodes/paint/PathEffects.d.ts +15 -18
  205. package/lib/module/dom/nodes/paint/PathEffects.js +29 -72
  206. package/lib/module/dom/nodes/paint/PathEffects.js.map +1 -1
  207. package/lib/module/dom/nodes/paint/Shaders.d.ts +11 -12
  208. package/lib/module/dom/nodes/paint/Shaders.js +28 -18
  209. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  210. package/lib/module/dom/types/DeclarationContext.d.ts +29 -0
  211. package/lib/module/dom/types/DeclarationContext.js +107 -0
  212. package/lib/module/dom/types/DeclarationContext.js.map +1 -0
  213. package/lib/module/dom/types/DrawingContext.d.ts +18 -1
  214. package/lib/module/dom/types/DrawingContext.js +322 -1
  215. package/lib/module/dom/types/DrawingContext.js.map +1 -1
  216. package/lib/module/dom/types/Node.d.ts +4 -10
  217. package/lib/module/dom/types/Node.js.map +1 -1
  218. package/lib/module/dom/types/SkDOM.d.ts +22 -23
  219. package/lib/module/dom/types/SkDOM.js.map +1 -1
  220. package/lib/module/dom/types/index.d.ts +1 -0
  221. package/lib/module/dom/types/index.js +1 -0
  222. package/lib/module/dom/types/index.js.map +1 -1
  223. package/lib/module/index.d.ts +1 -0
  224. package/lib/module/index.js +1 -0
  225. package/lib/module/index.js.map +1 -1
  226. package/lib/module/renderer/Canvas.js +3 -3
  227. package/lib/module/renderer/Canvas.js.map +1 -1
  228. package/lib/module/renderer/DrawingContext.d.ts +4 -3
  229. package/lib/module/renderer/DrawingContext.js.map +1 -1
  230. package/lib/module/renderer/HostComponents.d.ts +35 -35
  231. package/lib/module/renderer/HostComponents.js.map +1 -1
  232. package/lib/module/renderer/HostConfig.js +1 -0
  233. package/lib/module/renderer/HostConfig.js.map +1 -1
  234. package/lib/module/renderer/Offscreen.d.ts +2 -0
  235. package/lib/module/renderer/Offscreen.js +19 -0
  236. package/lib/module/renderer/Offscreen.js.map +1 -0
  237. package/lib/module/renderer/Reconciler.js +0 -1
  238. package/lib/module/renderer/Reconciler.js.map +1 -1
  239. package/lib/module/skia/types/Surface/Surface.d.ts +4 -0
  240. package/lib/module/skia/types/Surface/Surface.js.map +1 -1
  241. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  242. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  243. package/lib/module/skia/web/JsiSkDataFactory.js +0 -1
  244. package/lib/module/skia/web/JsiSkDataFactory.js.map +1 -1
  245. package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
  246. package/lib/module/skia/web/JsiSkImage.js +31 -3
  247. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  248. package/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
  249. package/lib/module/skia/web/JsiSkSurface.js +4 -0
  250. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  251. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  252. package/lib/module/skia/web/JsiSkSurfaceFactory.js +21 -1
  253. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  254. package/lib/module/views/SkiaBaseWebView.js +14 -8
  255. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  256. package/lib/module/views/SkiaDomView.web.js +2 -11
  257. package/lib/module/views/SkiaDomView.web.js.map +1 -1
  258. package/lib/module/views/SkiaPictureView.web.js +0 -5
  259. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  260. package/lib/module/views/SkiaView.web.js +0 -5
  261. package/lib/module/views/SkiaView.web.js.map +1 -1
  262. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +33 -34
  263. package/lib/typescript/src/dom/nodes/Node.d.ts +6 -11
  264. package/lib/typescript/src/dom/nodes/PaintNode.d.ts +3 -3
  265. package/lib/typescript/src/dom/nodes/RenderNode.d.ts +2 -3
  266. package/lib/typescript/src/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  267. package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +3 -1
  268. package/lib/typescript/src/dom/nodes/paint/BlendNode.d.ts +3 -7
  269. package/lib/typescript/src/dom/nodes/paint/ColorFilters.d.ts +10 -11
  270. package/lib/typescript/src/dom/nodes/paint/ImageFilters.d.ts +11 -11
  271. package/lib/typescript/src/dom/nodes/paint/MaskFilters.d.ts +3 -3
  272. package/lib/typescript/src/dom/nodes/paint/PathEffects.d.ts +15 -18
  273. package/lib/typescript/src/dom/nodes/paint/Shaders.d.ts +11 -12
  274. package/lib/typescript/src/dom/types/DeclarationContext.d.ts +29 -0
  275. package/lib/typescript/src/dom/types/DrawingContext.d.ts +18 -1
  276. package/lib/typescript/src/dom/types/Node.d.ts +4 -10
  277. package/lib/typescript/src/dom/types/SkDOM.d.ts +22 -23
  278. package/lib/typescript/src/dom/types/index.d.ts +1 -0
  279. package/lib/typescript/src/index.d.ts +1 -0
  280. package/lib/typescript/src/renderer/DrawingContext.d.ts +4 -3
  281. package/lib/typescript/src/renderer/HostComponents.d.ts +35 -35
  282. package/lib/typescript/src/renderer/Offscreen.d.ts +2 -0
  283. package/lib/typescript/src/skia/types/Surface/Surface.d.ts +4 -0
  284. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  285. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
  286. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -0
  287. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  288. package/package.json +1 -1
  289. package/src/dom/nodes/DrawingNode.ts +5 -1
  290. package/src/dom/nodes/LayerNode.ts +13 -11
  291. package/src/dom/nodes/Node.ts +18 -41
  292. package/src/dom/nodes/PaintContext.ts +1 -0
  293. package/src/dom/nodes/PaintNode.ts +28 -18
  294. package/src/dom/nodes/RenderNode.ts +25 -183
  295. package/src/dom/nodes/drawings/BackdropFilterNode.ts +18 -11
  296. package/src/dom/nodes/drawings/Box.ts +6 -4
  297. package/src/dom/nodes/paint/BlendNode.ts +16 -63
  298. package/src/dom/nodes/paint/ColorFilters.ts +32 -55
  299. package/src/dom/nodes/paint/ImageFilters.ts +58 -53
  300. package/src/dom/nodes/paint/MaskFilters.ts +5 -7
  301. package/src/dom/nodes/paint/PathEffects.ts +37 -90
  302. package/src/dom/nodes/paint/Shaders.ts +31 -29
  303. package/src/dom/types/DeclarationContext.ts +105 -0
  304. package/src/dom/types/DrawingContext.ts +304 -1
  305. package/src/dom/types/Node.ts +4 -20
  306. package/src/dom/types/SkDOM.ts +22 -43
  307. package/src/dom/types/index.ts +1 -0
  308. package/src/index.ts +1 -0
  309. package/src/renderer/Canvas.tsx +3 -3
  310. package/src/renderer/DrawingContext.ts +4 -5
  311. package/src/renderer/HostComponents.ts +34 -53
  312. package/src/renderer/HostConfig.ts +1 -0
  313. package/src/renderer/Offscreen.tsx +24 -0
  314. package/src/renderer/Reconciler.tsx +0 -1
  315. package/src/skia/types/Surface/Surface.ts +5 -0
  316. package/src/skia/types/Surface/SurfaceFactory.ts +7 -0
  317. package/src/skia/web/JsiSkDataFactory.ts +0 -1
  318. package/src/skia/web/JsiSkImage.ts +26 -2
  319. package/src/skia/web/JsiSkSurface.ts +4 -0
  320. package/src/skia/web/JsiSkSurfaceFactory.ts +21 -2
  321. package/src/views/SkiaBaseWebView.tsx +9 -2
  322. package/src/views/SkiaDomView.web.tsx +2 -13
  323. package/src/views/SkiaPictureView.web.tsx +0 -7
  324. package/src/views/SkiaView.web.tsx +0 -7
@@ -1,44 +1,43 @@
1
- import type { SkShader } from "../../../skia/types";
2
1
  import type { NodeContext } from "../Node";
3
2
  import { JsiDeclarationNode } from "../Node";
4
- import type { ColorProps, FractalNoiseProps, ImageShaderProps, LinearGradientProps, RadialGradientProps, ShaderProps, SweepGradientProps, TurbulenceProps, TwoPointConicalGradientProps } from "../../types";
3
+ import type { ColorProps, DeclarationContext, FractalNoiseProps, ImageShaderProps, LinearGradientProps, RadialGradientProps, ShaderProps, SweepGradientProps, TurbulenceProps, TwoPointConicalGradientProps } from "../../types";
5
4
  import { NodeType } from "../../types";
6
- export declare abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P, SkShader> {
5
+ export declare abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {
7
6
  constructor(ctx: NodeContext, type: NodeType, props: P);
8
7
  }
9
8
  export declare class ShaderNode extends ShaderDeclaration<ShaderProps> {
10
9
  constructor(ctx: NodeContext, props: ShaderProps);
11
- materialize(): SkShader;
10
+ decorate(ctx: DeclarationContext): void;
12
11
  }
13
12
  export declare class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {
14
13
  constructor(ctx: NodeContext, props: ImageShaderProps);
15
- materialize(): SkShader;
14
+ decorate(ctx: DeclarationContext): void;
16
15
  }
17
16
  export declare class ColorNode extends ShaderDeclaration<ColorProps> {
18
17
  constructor(ctx: NodeContext, props: ColorProps);
19
- materialize(): SkShader;
18
+ decorate(ctx: DeclarationContext): void;
20
19
  }
21
20
  export declare class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {
22
21
  constructor(ctx: NodeContext, props: TurbulenceProps);
23
- materialize(): SkShader;
22
+ decorate(ctx: DeclarationContext): void;
24
23
  }
25
24
  export declare class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {
26
25
  constructor(ctx: NodeContext, props: FractalNoiseProps);
27
- materialize(): SkShader;
26
+ decorate(ctx: DeclarationContext): void;
28
27
  }
29
28
  export declare class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {
30
29
  constructor(ctx: NodeContext, props: LinearGradientProps);
31
- materialize(): SkShader;
30
+ decorate(ctx: DeclarationContext): void;
32
31
  }
33
32
  export declare class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {
34
33
  constructor(ctx: NodeContext, props: RadialGradientProps);
35
- materialize(): SkShader;
34
+ decorate(ctx: DeclarationContext): void;
36
35
  }
37
36
  export declare class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {
38
37
  constructor(ctx: NodeContext, props: SweepGradientProps);
39
- materialize(): SkShader;
38
+ decorate(ctx: DeclarationContext): void;
40
39
  }
41
40
  export declare class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {
42
41
  constructor(ctx: NodeContext, props: TwoPointConicalGradientProps);
43
- materialize(): SkShader;
42
+ decorate(ctx: DeclarationContext): void;
44
43
  }
@@ -0,0 +1,29 @@
1
+ import type { SkShader, SkPaint, SkImageFilter, SkMaskFilter, SkPathEffect, Skia, SkColorFilter } from "../../skia/types";
2
+ declare type Composer<T> = (outer: T, inner: T) => T;
3
+ export declare const composeDeclarations: <T>(filters: T[], composer: Composer<T>) => T;
4
+ declare class Declaration<T> {
5
+ private composer?;
6
+ private decls;
7
+ private indexes;
8
+ constructor(composer?: Composer<T> | undefined);
9
+ private get index();
10
+ save(): void;
11
+ restore(): void;
12
+ pop(): T | undefined;
13
+ push(decl: T): void;
14
+ popAll(): T[];
15
+ popAllAsOne(): T;
16
+ }
17
+ export declare class DeclarationContext {
18
+ private Skia;
19
+ readonly paints: Declaration<SkPaint>;
20
+ readonly maskFilters: Declaration<SkMaskFilter>;
21
+ readonly shaders: Declaration<SkShader>;
22
+ readonly pathEffects: Declaration<SkPathEffect>;
23
+ readonly imageFilters: Declaration<SkImageFilter>;
24
+ readonly colorFilters: Declaration<SkColorFilter>;
25
+ constructor(Skia: Skia);
26
+ save(): void;
27
+ restore(): void;
28
+ }
29
+ export {};
@@ -1,5 +1,22 @@
1
- import type { SkCanvas, SkPaint } from "../../skia/types";
1
+ import type { SkCanvas, SkPaint, Skia } from "../../skia/types";
2
+ import type { PaintProps } from "./Common";
3
+ import { DeclarationContext } from "./DeclarationContext";
4
+ import type { Node } from "./Node";
2
5
  export interface DrawingContext {
3
6
  canvas: SkCanvas;
4
7
  paint: SkPaint;
8
+ saveAndConcat(node: Node<PaintProps>, cache?: SkPaint): boolean;
9
+ restore(): void;
10
+ declarationCtx: DeclarationContext;
11
+ }
12
+ export declare class JsiDrawingContext implements DrawingContext {
13
+ private readonly Skia;
14
+ readonly canvas: SkCanvas;
15
+ paints: SkPaint[];
16
+ declarationCtx: DeclarationContext;
17
+ constructor(Skia: Skia, canvas: SkCanvas);
18
+ get paint(): SkPaint;
19
+ private save;
20
+ restore(): void;
21
+ saveAndConcat(node: Node<PaintProps>, cache?: SkPaint): boolean;
5
22
  }
@@ -1,7 +1,7 @@
1
- import type { SkColorFilter, SkImageFilter, SkMaskFilter, SkPaint, SkPathEffect, SkShader } from "../../skia/types";
2
1
  import type { GroupProps } from "./Common";
3
- import type { DrawingContext } from "./DrawingContext";
4
2
  import type { DeclarationType, NodeType } from "./NodeType";
3
+ import type { DeclarationContext } from "./DeclarationContext";
4
+ import type { DrawingContext } from "./DrawingContext";
5
5
  export interface Node<P> {
6
6
  type: NodeType;
7
7
  setProps(props: P): void;
@@ -13,16 +13,10 @@ export interface Node<P> {
13
13
  insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;
14
14
  }
15
15
  export declare type Invalidate = () => void;
16
- export interface DeclarationNode<P, T, Nullable extends null | never = never> extends Node<P> {
16
+ export interface DeclarationNode<P> extends Node<P> {
17
17
  declarationType: DeclarationType;
18
- materialize(): T | Nullable;
18
+ decorate(ctx: DeclarationContext): void;
19
19
  setInvalidate(invalidate: Invalidate): void;
20
- isPaint(): this is DeclarationNode<unknown, SkPaint>;
21
- isImageFilter(): this is DeclarationNode<unknown, SkImageFilter>;
22
- isColorFilter(): this is DeclarationNode<unknown, SkColorFilter>;
23
- isShader(): this is DeclarationNode<unknown, SkShader>;
24
- isMaskFilter(): this is DeclarationNode<unknown, SkMaskFilter>;
25
- isPathEffect(): this is DeclarationNode<unknown, SkPathEffect>;
26
20
  }
27
21
  export interface RenderNode<P extends GroupProps> extends Node<P> {
28
22
  render(ctx: DrawingContext): void;
@@ -1,4 +1,3 @@
1
- import type { SkImageFilter, SkMaskFilter, SkShader, SkColorFilter, SkPathEffect, SkPaint } from "../../skia/types";
2
1
  import type { ChildrenProps, GroupProps, PaintProps } from "./Common";
3
2
  import type { BlendImageFilterProps, BlurImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, DisplacementMapImageFilterProps, MorphologyImageFilterProps, BlendProps } from "./ImageFilters";
4
3
  import type { DeclarationNode, RenderNode } from "./Node";
@@ -7,14 +6,14 @@ import type { ImageProps, CircleProps, PathProps, CustomDrawingNodeProps, LinePr
7
6
  import type { BlurMaskFilterProps } from "./MaskFilters";
8
7
  import type { FractalNoiseProps, SweepGradientProps, ImageShaderProps, LinearGradientProps, ShaderProps, TurbulenceProps, TwoPointConicalGradientProps, RadialGradientProps, ColorProps } from "./Shaders";
9
8
  import type { CornerPathEffectProps, DashPathEffectProps, DiscretePathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps } from "./PathEffects";
10
- declare type ImageFilterNode<P> = DeclarationNode<P, SkImageFilter>;
11
- declare type PathEffectNode<P> = DeclarationNode<P, SkPathEffect>;
12
- declare type NullablePathEffectNode<P> = DeclarationNode<P, SkPathEffect, null>;
9
+ declare type ImageFilterNode<P> = DeclarationNode<P>;
10
+ declare type PathEffectNode<P> = DeclarationNode<P>;
11
+ declare type NullablePathEffectNode<P> = DeclarationNode<P>;
13
12
  declare type DrawingNode<P extends GroupProps> = RenderNode<P>;
14
13
  export interface SkDOM {
15
14
  Layer(props?: ChildrenProps): RenderNode<ChildrenProps>;
16
15
  Group(props?: GroupProps): RenderNode<GroupProps>;
17
- Paint(props: PaintProps): DeclarationNode<PaintProps, SkPaint>;
16
+ Paint(props: PaintProps): DeclarationNode<PaintProps>;
18
17
  Fill(props?: DrawingNodeProps): DrawingNode<DrawingNodeProps>;
19
18
  Image(props: ImageProps): DrawingNode<ImageProps>;
20
19
  Circle(props: CircleProps): DrawingNode<CircleProps>;
@@ -34,7 +33,7 @@ export interface SkDOM {
34
33
  DiffRect(props: DiffRectProps): DrawingNode<DiffRectProps>;
35
34
  Picture(props: PictureProps): DrawingNode<PictureProps>;
36
35
  ImageSVG(props: ImageSVGProps): DrawingNode<ImageSVGProps>;
37
- BlurMaskFilter(props: BlurMaskFilterProps): DeclarationNode<BlurMaskFilterProps, SkMaskFilter>;
36
+ BlurMaskFilter(props: BlurMaskFilterProps): DeclarationNode<BlurMaskFilterProps>;
38
37
  BlendImageFilter(props: BlendImageFilterProps): ImageFilterNode<BlendImageFilterProps>;
39
38
  BlurImageFilter(props: BlurImageFilterProps): ImageFilterNode<BlurImageFilterProps>;
40
39
  OffsetImageFilter(props: OffsetImageFilterProps): ImageFilterNode<OffsetImageFilterProps>;
@@ -42,21 +41,21 @@ export interface SkDOM {
42
41
  MorphologyImageFilter(props: MorphologyImageFilterProps): ImageFilterNode<MorphologyImageFilterProps>;
43
42
  DisplacementMapImageFilter(props: DisplacementMapImageFilterProps): ImageFilterNode<DisplacementMapImageFilterProps>;
44
43
  RuntimeShaderImageFilter(props: RuntimeShaderImageFilterProps): ImageFilterNode<RuntimeShaderImageFilterProps>;
45
- MatrixColorFilter(props: MatrixColorFilterProps): DeclarationNode<MatrixColorFilterProps, SkColorFilter>;
46
- BlendColorFilter(props: BlendColorFilterProps): DeclarationNode<BlendColorFilterProps, SkColorFilter>;
47
- LumaColorFilter(): DeclarationNode<null, SkColorFilter>;
48
- LinearToSRGBGammaColorFilter(): DeclarationNode<null, SkColorFilter>;
49
- SRGBToLinearGammaColorFilter(): DeclarationNode<null, SkColorFilter>;
50
- LerpColorFilter(props: LerpColorFilterProps): DeclarationNode<LerpColorFilterProps, SkColorFilter>;
51
- Shader(props: ShaderProps): DeclarationNode<ShaderProps, SkShader>;
52
- ImageShader(props: ImageShaderProps): DeclarationNode<ImageShaderProps, SkShader>;
53
- ColorShader(props: ColorProps): DeclarationNode<ColorProps, SkShader>;
54
- Turbulence(props: TurbulenceProps): DeclarationNode<TurbulenceProps, SkShader>;
55
- FractalNoise(props: FractalNoiseProps): DeclarationNode<FractalNoiseProps, SkShader>;
56
- LinearGradient(props: LinearGradientProps): DeclarationNode<LinearGradientProps, SkShader>;
57
- RadialGradient(props: RadialGradientProps): DeclarationNode<RadialGradientProps, SkShader>;
58
- SweepGradient(props: SweepGradientProps): DeclarationNode<SweepGradientProps, SkShader>;
59
- TwoPointConicalGradient(props: TwoPointConicalGradientProps): DeclarationNode<TwoPointConicalGradientProps, SkShader>;
44
+ MatrixColorFilter(props: MatrixColorFilterProps): DeclarationNode<MatrixColorFilterProps>;
45
+ BlendColorFilter(props: BlendColorFilterProps): DeclarationNode<BlendColorFilterProps>;
46
+ LumaColorFilter(): DeclarationNode<null>;
47
+ LinearToSRGBGammaColorFilter(): DeclarationNode<null>;
48
+ SRGBToLinearGammaColorFilter(): DeclarationNode<null>;
49
+ LerpColorFilter(props: LerpColorFilterProps): DeclarationNode<LerpColorFilterProps>;
50
+ Shader(props: ShaderProps): DeclarationNode<ShaderProps>;
51
+ ImageShader(props: ImageShaderProps): DeclarationNode<ImageShaderProps>;
52
+ ColorShader(props: ColorProps): DeclarationNode<ColorProps>;
53
+ Turbulence(props: TurbulenceProps): DeclarationNode<TurbulenceProps>;
54
+ FractalNoise(props: FractalNoiseProps): DeclarationNode<FractalNoiseProps>;
55
+ LinearGradient(props: LinearGradientProps): DeclarationNode<LinearGradientProps>;
56
+ RadialGradient(props: RadialGradientProps): DeclarationNode<RadialGradientProps>;
57
+ SweepGradient(props: SweepGradientProps): DeclarationNode<SweepGradientProps>;
58
+ TwoPointConicalGradient(props: TwoPointConicalGradientProps): DeclarationNode<TwoPointConicalGradientProps>;
60
59
  CornerPathEffect(props: CornerPathEffectProps): NullablePathEffectNode<CornerPathEffectProps>;
61
60
  DiscretePathEffect(props: DiscretePathEffectProps): PathEffectNode<DiscretePathEffectProps>;
62
61
  DashPathEffect(props: DashPathEffectProps): PathEffectNode<DashPathEffectProps>;
@@ -64,9 +63,9 @@ export interface SkDOM {
64
63
  Path2DPathEffect(props: Path2DPathEffectProps): NullablePathEffectNode<Path2DPathEffectProps>;
65
64
  SumPathEffect(): NullablePathEffectNode<null>;
66
65
  Line2DPathEffect(props: Line2DPathEffectProps): NullablePathEffectNode<Line2DPathEffectProps>;
67
- Blend(props: BlendProps): DeclarationNode<BlendProps, SkShader | SkImageFilter>;
66
+ Blend(props: BlendProps): DeclarationNode<BlendProps>;
68
67
  BackdropFilter(props: ChildrenProps): RenderNode<ChildrenProps>;
69
68
  Box(props: BoxProps): RenderNode<BoxProps>;
70
- BoxShadow(props: BoxShadowProps): DeclarationNode<BoxShadowProps, BoxShadowProps>;
69
+ BoxShadow(props: BoxShadowProps): DeclarationNode<BoxShadowProps>;
71
70
  }
72
71
  export {};
@@ -1,4 +1,5 @@
1
1
  export * from "./DrawingContext";
2
+ export * from "./DeclarationContext";
2
3
  export * from "./Node";
3
4
  export * from "./NodeType";
4
5
  export * from "./SkDOM";
@@ -1,6 +1,7 @@
1
1
  import "./skia/NativeSetup";
2
2
  export * from "./renderer";
3
3
  export * from "./renderer/Canvas";
4
+ export * from "./renderer/Offscreen";
4
5
  export * from "./views";
5
6
  export * from "./skia";
6
7
  export * from "./external";
@@ -1,6 +1,7 @@
1
1
  import type { DrawingInfo } from "../views";
2
- import type { Skia } from "../skia/types";
3
- import type { DrawingContext as DOMDrawingContext } from "../dom/types";
4
- export interface DrawingContext extends Omit<DrawingInfo, "touches">, DOMDrawingContext {
2
+ import type { Skia, SkCanvas, SkPaint } from "../skia/types";
3
+ export interface DrawingContext extends Omit<DrawingInfo, "touches"> {
5
4
  Skia: Skia;
5
+ canvas: SkCanvas;
6
+ paint: SkPaint;
6
7
  }
@@ -2,7 +2,7 @@ import { NodeType } from "../dom/types";
2
2
  import type { DeclarationNode, FractalNoiseProps, RenderNode, CircleProps, DrawingNodeProps, ImageProps, PaintProps, PathProps, CustomDrawingNodeProps, LineProps, OvalProps, DiffRectProps, PointsProps, RectProps, RoundedRectProps, TextProps, VerticesProps, BlurMaskFilterProps, BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, MatrixColorFilterProps, ShaderProps, ImageShaderProps, LinearGradientProps, GroupProps, PatchProps, BlendColorFilterProps, DashPathEffectProps, DiscretePathEffectProps, CornerPathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, BoxProps, BoxShadowProps } from "../dom/types";
3
3
  import type { ChildrenProps } from "../dom/types/Common";
4
4
  import type { BlendProps, MorphologyImageFilterProps } from "../dom/types/ImageFilters";
5
- import type { SkColorFilter, SkImageFilter, SkMaskFilter, SkPaint, SkPathEffect, SkRect, SkRRect, SkShader } from "../skia";
5
+ import type { SkRect, SkRRect } from "../skia/types";
6
6
  import type { JsiDrawingNode } from "../dom/nodes/DrawingNode";
7
7
  import type { SkiaValue } from "../values";
8
8
  import type { Container } from "./Container";
@@ -14,7 +14,7 @@ declare global {
14
14
  RectNode: (props: RectProps) => JsiDrawingNode<RectProps, SkRect>;
15
15
  RRectNode: (props: RoundedRectProps) => JsiDrawingNode<RoundedRectProps, SkRRect>;
16
16
  GroupNode: (props: GroupProps) => RenderNode<GroupProps>;
17
- PaintNode: (props: PaintProps) => DeclarationNode<PaintProps, SkPaint>;
17
+ PaintNode: (props: PaintProps) => DeclarationNode<PaintProps>;
18
18
  FillNode: (props: PaintProps) => RenderNode<PaintProps>;
19
19
  CircleNode: (props: CircleProps) => RenderNode<CircleProps>;
20
20
  PathNode: (props: PathProps) => RenderNode<PathProps>;
@@ -25,36 +25,36 @@ declare global {
25
25
  PatchNode: (props: PatchProps) => RenderNode<PatchProps>;
26
26
  PointsNode: (props: PointsProps) => RenderNode<PointsProps>;
27
27
  DiffRectNode: (props: DiffRectProps) => RenderNode<DiffRectProps>;
28
- BlurMaskFilterNode: (props: BlurMaskFilterProps) => DeclarationNode<BlurMaskFilterProps, SkMaskFilter>;
29
- DashPathEffectNode: (props: DashPathEffectProps) => DeclarationNode<DashPathEffectProps, SkPathEffect>;
30
- DiscretePathEffectNode: (props: DiscretePathEffectProps) => DeclarationNode<DiscretePathEffectProps, SkPathEffect>;
31
- CornerPathEffectNode: (props: CornerPathEffectProps) => DeclarationNode<CornerPathEffectProps, SkPathEffect>;
32
- Path1DPathEffectNode: (props: Path1DPathEffectProps) => DeclarationNode<Path1DPathEffectProps, SkPathEffect>;
33
- Path2DPathEffectNode: (props: Path2DPathEffectProps) => DeclarationNode<Path2DPathEffectProps, SkPathEffect>;
34
- Line2DPathEffectNode: (props: Line2DPathEffectProps) => DeclarationNode<Line2DPathEffectProps, SkPathEffect>;
35
- SumPathEffectNode: () => DeclarationNode<null, SkPathEffect>;
36
- BlendImageFilterNode: (props: BlendImageFilterProps) => DeclarationNode<BlendImageFilterProps, SkImageFilter>;
37
- DropShadowImageFilterNode: (props: DropShadowImageFilterProps) => DeclarationNode<DropShadowImageFilterProps, SkImageFilter>;
38
- DisplacementMapImageFilterNode: (props: DisplacementMapImageFilterProps) => DeclarationNode<DisplacementMapImageFilterProps, SkImageFilter>;
39
- BlurImageFilterNode: (props: BlurImageFilterProps) => DeclarationNode<BlurImageFilterProps, SkImageFilter>;
40
- OffsetImageFilterNode: (props: OffsetImageFilterProps) => DeclarationNode<OffsetImageFilterProps, SkImageFilter>;
41
- MorphologyImageFilterNode: (props: MorphologyImageFilterProps) => DeclarationNode<MorphologyImageFilterProps, SkImageFilter>;
42
- RuntimeShaderImageFilterNode: (props: RuntimeShaderImageFilterProps) => DeclarationNode<RuntimeShaderImageFilterProps, SkImageFilter>;
43
- MatrixColorFilterNode: (props: MatrixColorFilterProps) => DeclarationNode<MatrixColorFilterProps, SkColorFilter>;
44
- BlendColorFilterNode: (props: BlendColorFilterProps) => DeclarationNode<BlendColorFilterProps, SkColorFilter>;
45
- LinearToSRGBGammaColorFilterNode: () => DeclarationNode<null, SkColorFilter>;
46
- SRGBToLinearGammaColorFilterNode: () => DeclarationNode<null, SkColorFilter>;
47
- LumaColorFilterNode: () => DeclarationNode<null, SkColorFilter>;
48
- LerpColorFilterNode: (props: LerpColorFilterProps) => DeclarationNode<LerpColorFilterProps, SkColorFilter>;
49
- ShaderNode: (props: ShaderProps) => DeclarationNode<ShaderProps, SkShader>;
50
- ImageShaderNode: (props: ImageShaderProps) => DeclarationNode<ImageShaderProps, SkShader>;
51
- ColorShaderNode: (props: ColorProps) => DeclarationNode<ColorProps, SkShader>;
52
- TurbulenceNode: (props: TurbulenceProps) => DeclarationNode<TurbulenceProps, SkShader>;
53
- FractalNoiseNode: (props: FractalNoiseProps) => DeclarationNode<FractalNoiseProps, SkShader>;
54
- LinearGradientNode: (props: LinearGradientProps) => DeclarationNode<LinearGradientProps, SkShader>;
55
- RadialGradientNode: (props: RadialGradientProps) => DeclarationNode<RadialGradientProps, SkShader>;
56
- SweepGradientNode: (props: SweepGradientProps) => DeclarationNode<SweepGradientProps, SkShader>;
57
- TwoPointConicalGradientNode: (props: TwoPointConicalGradientProps) => DeclarationNode<TwoPointConicalGradientProps, SkShader>;
28
+ BlurMaskFilterNode: (props: BlurMaskFilterProps) => DeclarationNode<BlurMaskFilterProps>;
29
+ DashPathEffectNode: (props: DashPathEffectProps) => DeclarationNode<DashPathEffectProps>;
30
+ DiscretePathEffectNode: (props: DiscretePathEffectProps) => DeclarationNode<DiscretePathEffectProps>;
31
+ CornerPathEffectNode: (props: CornerPathEffectProps) => DeclarationNode<CornerPathEffectProps>;
32
+ Path1DPathEffectNode: (props: Path1DPathEffectProps) => DeclarationNode<Path1DPathEffectProps>;
33
+ Path2DPathEffectNode: (props: Path2DPathEffectProps) => DeclarationNode<Path2DPathEffectProps>;
34
+ Line2DPathEffectNode: (props: Line2DPathEffectProps) => DeclarationNode<Line2DPathEffectProps>;
35
+ SumPathEffectNode: () => DeclarationNode<null>;
36
+ BlendImageFilterNode: (props: BlendImageFilterProps) => DeclarationNode<BlendImageFilterProps>;
37
+ DropShadowImageFilterNode: (props: DropShadowImageFilterProps) => DeclarationNode<DropShadowImageFilterProps>;
38
+ DisplacementMapImageFilterNode: (props: DisplacementMapImageFilterProps) => DeclarationNode<DisplacementMapImageFilterProps>;
39
+ BlurImageFilterNode: (props: BlurImageFilterProps) => DeclarationNode<BlurImageFilterProps>;
40
+ OffsetImageFilterNode: (props: OffsetImageFilterProps) => DeclarationNode<OffsetImageFilterProps>;
41
+ MorphologyImageFilterNode: (props: MorphologyImageFilterProps) => DeclarationNode<MorphologyImageFilterProps>;
42
+ RuntimeShaderImageFilterNode: (props: RuntimeShaderImageFilterProps) => DeclarationNode<RuntimeShaderImageFilterProps>;
43
+ MatrixColorFilterNode: (props: MatrixColorFilterProps) => DeclarationNode<MatrixColorFilterProps>;
44
+ BlendColorFilterNode: (props: BlendColorFilterProps) => DeclarationNode<BlendColorFilterProps>;
45
+ LinearToSRGBGammaColorFilterNode: () => DeclarationNode<null>;
46
+ SRGBToLinearGammaColorFilterNode: () => DeclarationNode<null>;
47
+ LumaColorFilterNode: () => DeclarationNode<null>;
48
+ LerpColorFilterNode: (props: LerpColorFilterProps) => DeclarationNode<LerpColorFilterProps>;
49
+ ShaderNode: (props: ShaderProps) => DeclarationNode<ShaderProps>;
50
+ ImageShaderNode: (props: ImageShaderProps) => DeclarationNode<ImageShaderProps>;
51
+ ColorShaderNode: (props: ColorProps) => DeclarationNode<ColorProps>;
52
+ TurbulenceNode: (props: TurbulenceProps) => DeclarationNode<TurbulenceProps>;
53
+ FractalNoiseNode: (props: FractalNoiseProps) => DeclarationNode<FractalNoiseProps>;
54
+ LinearGradientNode: (props: LinearGradientProps) => DeclarationNode<LinearGradientProps>;
55
+ RadialGradientNode: (props: RadialGradientProps) => DeclarationNode<RadialGradientProps>;
56
+ SweepGradientNode: (props: SweepGradientProps) => DeclarationNode<SweepGradientProps>;
57
+ TwoPointConicalGradientNode: (props: TwoPointConicalGradientProps) => DeclarationNode<TwoPointConicalGradientProps>;
58
58
  PictureNode: (props: PictureProps) => RenderNode<PictureProps>;
59
59
  ImageSVGNode: (props: ImageSVGProps) => RenderNode<ImageSVGProps>;
60
60
  VerticesNode: (props: VerticesProps) => RenderNode<VerticesProps>;
@@ -62,10 +62,10 @@ declare global {
62
62
  TextPathNode: (prop: TextPathProps) => RenderNode<TextPathProps>;
63
63
  TextBlobNode: (prop: TextBlobProps) => RenderNode<TextBlobProps>;
64
64
  GlyphsNode: (prop: GlyphsProps) => RenderNode<GlyphsProps>;
65
- BlendNode: (prop: BlendProps) => DeclarationNode<BlendProps, SkImageFilter>;
65
+ BlendNode: (prop: BlendProps) => DeclarationNode<BlendProps>;
66
66
  BackdropFilterNode: (prop: ChildrenProps) => RenderNode<ChildrenProps>;
67
67
  BoxNode: (prop: BoxProps) => RenderNode<BoxProps>;
68
- BoxShadowNode: (prop: BoxShadowProps) => DeclarationNode<BoxShadowProps, BoxShadowProps>;
68
+ BoxShadowNode: (prop: BoxShadowProps) => DeclarationNode<BoxShadowProps>;
69
69
  LayerNode: (prop: ChildrenProps) => RenderNode<ChildrenProps>;
70
70
  };
71
71
  namespace JSX {
@@ -129,4 +129,4 @@ declare global {
129
129
  }
130
130
  }
131
131
  }
132
- export declare const createNode: (container: Container, type: NodeType, props: any) => RenderNode<ChildrenProps> | DeclarationNode<PaintProps, SkPaint, never> | DeclarationNode<BlurMaskFilterProps, SkMaskFilter, never> | DeclarationNode<BlendImageFilterProps, SkImageFilter, never> | DeclarationNode<BlurImageFilterProps, SkImageFilter, never> | DeclarationNode<OffsetImageFilterProps, SkImageFilter, never> | DeclarationNode<DropShadowImageFilterProps, SkImageFilter, never> | DeclarationNode<MorphologyImageFilterProps, SkImageFilter, never> | DeclarationNode<DisplacementMapImageFilterProps, SkImageFilter, never> | DeclarationNode<RuntimeShaderImageFilterProps, SkImageFilter, never> | DeclarationNode<MatrixColorFilterProps, SkColorFilter, never> | DeclarationNode<BlendColorFilterProps, SkColorFilter, never> | DeclarationNode<null, SkColorFilter, never> | DeclarationNode<LerpColorFilterProps, SkColorFilter, never> | DeclarationNode<ShaderProps, SkShader, never> | DeclarationNode<ImageShaderProps, SkShader, never> | DeclarationNode<ColorProps, SkShader, never> | DeclarationNode<TurbulenceProps, SkShader, never> | DeclarationNode<LinearGradientProps, SkShader, never> | DeclarationNode<RadialGradientProps, SkShader, never> | DeclarationNode<SweepGradientProps, SkShader, never> | DeclarationNode<CornerPathEffectProps, SkPathEffect, null> | DeclarationNode<DiscretePathEffectProps, SkPathEffect, never> | DeclarationNode<DashPathEffectProps, SkPathEffect, never> | DeclarationNode<Path1DPathEffectProps, SkPathEffect, null> | DeclarationNode<Path2DPathEffectProps, SkPathEffect, null> | DeclarationNode<null, SkPathEffect, null> | DeclarationNode<Line2DPathEffectProps, SkPathEffect, null> | DeclarationNode<BlendProps, SkImageFilter | SkShader, never> | DeclarationNode<BoxShadowProps, BoxShadowProps, never>;
132
+ export declare const createNode: (container: Container, type: NodeType, props: any) => RenderNode<ChildrenProps> | DeclarationNode<PaintProps> | DeclarationNode<BlurMaskFilterProps> | DeclarationNode<BlendImageFilterProps> | DeclarationNode<BlurImageFilterProps> | DeclarationNode<OffsetImageFilterProps> | DeclarationNode<MorphologyImageFilterProps> | DeclarationNode<DisplacementMapImageFilterProps> | DeclarationNode<RuntimeShaderImageFilterProps> | DeclarationNode<MatrixColorFilterProps> | DeclarationNode<null> | DeclarationNode<LerpColorFilterProps> | DeclarationNode<ImageShaderProps> | DeclarationNode<ColorProps> | DeclarationNode<TurbulenceProps> | DeclarationNode<LinearGradientProps> | DeclarationNode<RadialGradientProps> | DeclarationNode<SweepGradientProps> | DeclarationNode<CornerPathEffectProps> | DeclarationNode<DiscretePathEffectProps> | DeclarationNode<DashPathEffectProps> | DeclarationNode<Path1DPathEffectProps> | DeclarationNode<Path2DPathEffectProps> | DeclarationNode<Line2DPathEffectProps> | DeclarationNode<BlendProps> | DeclarationNode<BoxShadowProps>;
@@ -0,0 +1,2 @@
1
+ import type { ReactElement } from "react";
2
+ export declare const drawAsImage: (element: ReactElement, width: number, height: number) => import("../skia").SkImage;
@@ -22,4 +22,8 @@ export interface SkSurface extends SkJSIInstance<"Surface"> {
22
22
  example: https://fiddle.skia.org/c/@Surface_makeImageSnapshot
23
23
  */
24
24
  makeImageSnapshot(bounds?: SkRect): SkImage;
25
+ /**
26
+ * Make sure any queued draws are sent to the screen or the GPU.
27
+ */
28
+ flush(): void;
25
29
  }
@@ -8,4 +8,10 @@ export interface SurfaceFactory {
8
8
  * @param height - number of pixels of the height of the drawable area.
9
9
  */
10
10
  Make: (width: number, height: number) => SkSurface | null;
11
+ /**
12
+ * Creates a GPU backed surface.
13
+ * @param width - number of pixels of the width of the drawable area.
14
+ * @param height - number of pixels of the height of the drawable area.
15
+ */
16
+ MakeOffscreen: (width: number, height: number) => SkSurface | null;
11
17
  }
@@ -1,6 +1,7 @@
1
1
  import type { CanvasKit, Image } from "canvaskit-wasm";
2
2
  import type { ImageFormat, FilterMode, MipmapMode, SkImage, SkMatrix, SkShader, TileMode } from "../types";
3
3
  import { HostObject } from "./Host";
4
+ export declare const toBase64String: (bytes: Uint8Array) => string;
4
5
  export declare class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
5
6
  constructor(CanvasKit: CanvasKit, ref: Image);
6
7
  height(): number;
@@ -3,6 +3,7 @@ import type { SkCanvas, SkImage, SkRect, SkSurface } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  export declare class JsiSkSurface extends HostObject<Surface, "Surface"> implements SkSurface {
5
5
  constructor(CanvasKit: CanvasKit, ref: Surface);
6
+ flush(): void;
6
7
  getCanvas(): SkCanvas;
7
8
  makeImageSnapshot(bounds?: SkRect): SkImage;
8
9
  }
@@ -4,5 +4,6 @@ import { Host } from "./Host";
4
4
  import { JsiSkSurface } from "./JsiSkSurface";
5
5
  export declare class JsiSkSurfaceFactory extends Host implements SurfaceFactory {
6
6
  constructor(CanvasKit: CanvasKit);
7
- Make(width: number, height: number): JsiSkSurface;
7
+ Make(width: number, height: number): JsiSkSurface | null;
8
+ MakeOffscreen(width: number, height: number): JsiSkSurface | null;
8
9
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.172",
10
+ "version": "0.1.174",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -59,7 +59,11 @@ export abstract class JsiDrawingNode<P extends DrawingNodeProps, C>
59
59
  }
60
60
  this.children().map((child) => {
61
61
  if (child instanceof PaintNode) {
62
- const paint = child.materialize();
62
+ const declCtx = ctx.declarationCtx;
63
+ declCtx.save();
64
+ child.decorate(declCtx);
65
+ const paint = declCtx.paints.pop()!;
66
+ declCtx.restore();
63
67
  this.draw({ ...ctx, paint });
64
68
  }
65
69
  });
@@ -1,34 +1,36 @@
1
- import type { DeclarationNode, DrawingContext, Node } from "../types";
1
+ import type { DrawingContext } from "../types";
2
2
  import { NodeType } from "../types";
3
3
  import type { ChildrenProps } from "../types/Common";
4
- import type { SkPaint } from "../../skia";
5
4
 
6
5
  import { JsiRenderNode } from "./RenderNode";
7
6
  import type { NodeContext } from "./Node";
8
7
  import { JsiDeclarationNode } from "./Node";
9
8
 
10
- const isLayer = (
11
- node: Node<unknown>
12
- ): node is DeclarationNode<unknown, SkPaint> =>
13
- node instanceof JsiDeclarationNode && node.isPaint();
14
-
15
9
  export class LayerNode extends JsiRenderNode<ChildrenProps> {
16
10
  constructor(ctx: NodeContext, props: ChildrenProps) {
17
11
  super(ctx, NodeType.Layer, props);
18
12
  }
19
13
 
20
14
  renderNode(ctx: DrawingContext): void {
15
+ let hasLayer = false;
21
16
  const [layer, ...children] = this.children();
22
- if (isLayer(layer)) {
23
- const paint = layer.materialize() as SkPaint;
24
- ctx.canvas.saveLayer(paint);
17
+ if (layer instanceof JsiDeclarationNode) {
18
+ const declCtx = ctx.declarationCtx;
19
+ declCtx.save();
20
+ layer.decorate(declCtx);
21
+ const paint = declCtx.paints.pop();
22
+ declCtx.restore();
23
+ if (paint) {
24
+ hasLayer = true;
25
+ ctx.canvas.saveLayer(paint);
26
+ }
25
27
  }
26
28
  children.map((child) => {
27
29
  if (child instanceof JsiRenderNode) {
28
30
  child.render(ctx);
29
31
  }
30
32
  });
31
- if (isLayer(layer)) {
33
+ if (hasLayer) {
32
34
  ctx.canvas.restore();
33
35
  }
34
36
  }
@@ -1,15 +1,12 @@
1
+ import type { Skia } from "../../skia/types";
1
2
  import type {
2
- SkColorFilter,
3
- Skia,
4
- SkImageFilter,
5
- SkMaskFilter,
6
- SkShader,
7
- SkPathEffect,
8
- SkPaint,
9
- } from "../../skia/types";
10
- import type { Node, DeclarationNode, NodeType } from "../types";
11
- import { DeclarationType } from "../types";
3
+ Node,
4
+ DeclarationNode,
5
+ NodeType,
6
+ DeclarationType,
7
+ } from "../types";
12
8
  import type { DependencyManager } from "../../renderer/DependencyManager";
9
+ import type { DeclarationContext } from "../types/DeclarationContext";
13
10
 
14
11
  export interface NodeContext {
15
12
  Skia: Skia;
@@ -73,13 +70,9 @@ export abstract class JsiNode<P> implements Node<P> {
73
70
 
74
71
  export type Invalidate = () => void;
75
72
 
76
- export abstract class JsiDeclarationNode<
77
- P,
78
- T,
79
- Nullable extends null | never = never
80
- >
73
+ export abstract class JsiDeclarationNode<P>
81
74
  extends JsiNode<P>
82
- implements DeclarationNode<P, T, Nullable>
75
+ implements DeclarationNode<P>
83
76
  {
84
77
  private invalidate: Invalidate = () => {};
85
78
 
@@ -92,7 +85,15 @@ export abstract class JsiDeclarationNode<
92
85
  super(ctx, type, props);
93
86
  }
94
87
 
95
- abstract materialize(): T | Nullable;
88
+ abstract decorate(ctx: DeclarationContext): void;
89
+
90
+ protected decorateChildren(ctx: DeclarationContext) {
91
+ this.children().forEach((child) => {
92
+ if (child instanceof JsiDeclarationNode) {
93
+ child.decorate(ctx);
94
+ }
95
+ });
96
+ }
96
97
 
97
98
  addChild(child: Node<unknown>): void {
98
99
  if (!(child instanceof JsiDeclarationNode)) {
@@ -131,28 +132,4 @@ export abstract class JsiDeclarationNode<
131
132
  }
132
133
  return hasChanged;
133
134
  }
134
-
135
- isPaint(): this is DeclarationNode<unknown, SkPaint> {
136
- return this.declarationType === DeclarationType.Paint;
137
- }
138
-
139
- isImageFilter(): this is DeclarationNode<unknown, SkImageFilter> {
140
- return this.declarationType === DeclarationType.ImageFilter;
141
- }
142
-
143
- isColorFilter(): this is DeclarationNode<unknown, SkColorFilter> {
144
- return this.declarationType === DeclarationType.ColorFilter;
145
- }
146
-
147
- isShader(): this is DeclarationNode<unknown, SkShader> {
148
- return this.declarationType === DeclarationType.Shader;
149
- }
150
-
151
- isMaskFilter(): this is DeclarationNode<unknown, SkMaskFilter> {
152
- return this.declarationType === DeclarationType.MaskFilter;
153
- }
154
-
155
- isPathEffect(): this is DeclarationNode<unknown, SkPathEffect> {
156
- return this.declarationType === DeclarationType.PathEffect;
157
- }
158
135
  }
@@ -11,6 +11,7 @@ import type {
11
11
  } from "../../skia/types";
12
12
  import type { SkColor } from "../../skia/types/Color";
13
13
 
14
+ // TODO: to remove
14
15
  export interface PaintContext {
15
16
  color?: SkColor;
16
17
  strokeWidth?: number;