@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
@@ -13,7 +13,8 @@ export class ShaderNode extends ShaderDeclaration {
13
13
  super(ctx, NodeType.Shader, props);
14
14
  }
15
15
 
16
- materialize() {
16
+ decorate(ctx) {
17
+ this.decorateChildren(ctx);
17
18
  const {
18
19
  source,
19
20
  uniforms,
@@ -21,7 +22,8 @@ export class ShaderNode extends ShaderDeclaration {
21
22
  } = this.props;
22
23
  const m3 = this.Skia.Matrix();
23
24
  processTransformProps(m3, transform);
24
- return source.makeShaderWithChildren(processUniforms(source, uniforms), this.children().filter(child => child instanceof JsiDeclarationNode && child.isShader()).map(child => child.materialize()), m3);
25
+ const shader = source.makeShaderWithChildren(processUniforms(source, uniforms), ctx.shaders.popAll(), m3);
26
+ ctx.shaders.push(shader);
25
27
  }
26
28
 
27
29
  }
@@ -30,7 +32,7 @@ export class ImageShaderNode extends ShaderDeclaration {
30
32
  super(ctx, NodeType.ImageShader, props);
31
33
  }
32
34
 
33
- materialize() {
35
+ decorate(ctx) {
34
36
  const {
35
37
  fit,
36
38
  image,
@@ -58,7 +60,8 @@ export class ImageShaderNode extends ShaderDeclaration {
58
60
  const lm = this.Skia.Matrix();
59
61
  lm.concat(m3);
60
62
  processTransformProps(lm, imageShaderProps);
61
- return image.makeShaderOptions(TileMode[enumKey(tx)], TileMode[enumKey(ty)], FilterMode[enumKey(fm)], MipmapMode[enumKey(mm)], lm);
63
+ const shader = image.makeShaderOptions(TileMode[enumKey(tx)], TileMode[enumKey(ty)], FilterMode[enumKey(fm)], MipmapMode[enumKey(mm)], lm);
64
+ ctx.shaders.push(shader);
62
65
  }
63
66
 
64
67
  }
@@ -67,11 +70,12 @@ export class ColorNode extends ShaderDeclaration {
67
70
  super(ctx, NodeType.ColorShader, props);
68
71
  }
69
72
 
70
- materialize() {
73
+ decorate(ctx) {
71
74
  const {
72
75
  color
73
76
  } = this.props;
74
- return this.Skia.Shader.MakeColor(this.Skia.Color(color));
77
+ const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));
78
+ ctx.shaders.push(shader);
75
79
  }
76
80
 
77
81
  }
@@ -80,7 +84,7 @@ export class TurbulenceNode extends ShaderDeclaration {
80
84
  super(ctx, NodeType.Turbulence, props);
81
85
  }
82
86
 
83
- materialize() {
87
+ decorate(ctx) {
84
88
  const {
85
89
  freqX,
86
90
  freqY,
@@ -89,7 +93,8 @@ export class TurbulenceNode extends ShaderDeclaration {
89
93
  tileWidth,
90
94
  tileHeight
91
95
  } = this.props;
92
- return this.Skia.Shader.MakeTurbulence(freqX, freqY, octaves, seed, tileWidth, tileHeight);
96
+ const shader = this.Skia.Shader.MakeTurbulence(freqX, freqY, octaves, seed, tileWidth, tileHeight);
97
+ ctx.shaders.push(shader);
93
98
  }
94
99
 
95
100
  }
@@ -98,7 +103,7 @@ export class FractalNoiseNode extends ShaderDeclaration {
98
103
  super(ctx, NodeType.FractalNoise, props);
99
104
  }
100
105
 
101
- materialize() {
106
+ decorate(ctx) {
102
107
  const {
103
108
  freqX,
104
109
  freqY,
@@ -107,7 +112,8 @@ export class FractalNoiseNode extends ShaderDeclaration {
107
112
  tileWidth,
108
113
  tileHeight
109
114
  } = this.props;
110
- return this.Skia.Shader.MakeFractalNoise(freqX, freqY, octaves, seed, tileWidth, tileHeight);
115
+ const shader = this.Skia.Shader.MakeFractalNoise(freqX, freqY, octaves, seed, tileWidth, tileHeight);
116
+ ctx.shaders.push(shader);
111
117
  }
112
118
 
113
119
  }
@@ -116,7 +122,7 @@ export class LinearGradientNode extends ShaderDeclaration {
116
122
  super(ctx, NodeType.LinearGradient, props);
117
123
  }
118
124
 
119
- materialize() {
125
+ decorate(ctx) {
120
126
  const {
121
127
  start,
122
128
  end
@@ -128,7 +134,8 @@ export class LinearGradientNode extends ShaderDeclaration {
128
134
  localMatrix,
129
135
  flags
130
136
  } = processGradientProps(this.Skia, this.props);
131
- return this.Skia.Shader.MakeLinearGradient(start, end, colors, positions !== null && positions !== void 0 ? positions : null, mode, localMatrix, flags);
137
+ const shader = this.Skia.Shader.MakeLinearGradient(start, end, colors, positions !== null && positions !== void 0 ? positions : null, mode, localMatrix, flags);
138
+ ctx.shaders.push(shader);
132
139
  }
133
140
 
134
141
  }
@@ -137,7 +144,7 @@ export class RadialGradientNode extends ShaderDeclaration {
137
144
  super(ctx, NodeType.RadialGradient, props);
138
145
  }
139
146
 
140
- materialize() {
147
+ decorate(ctx) {
141
148
  const {
142
149
  c,
143
150
  r
@@ -149,7 +156,8 @@ export class RadialGradientNode extends ShaderDeclaration {
149
156
  localMatrix,
150
157
  flags
151
158
  } = processGradientProps(this.Skia, this.props);
152
- return this.Skia.Shader.MakeRadialGradient(c, r, colors, positions, mode, localMatrix, flags);
159
+ const shader = this.Skia.Shader.MakeRadialGradient(c, r, colors, positions, mode, localMatrix, flags);
160
+ ctx.shaders.push(shader);
153
161
  }
154
162
 
155
163
  }
@@ -158,7 +166,7 @@ export class SweepGradientNode extends ShaderDeclaration {
158
166
  super(ctx, NodeType.SweepGradient, props);
159
167
  }
160
168
 
161
- materialize() {
169
+ decorate(ctx) {
162
170
  const {
163
171
  c,
164
172
  start,
@@ -171,7 +179,8 @@ export class SweepGradientNode extends ShaderDeclaration {
171
179
  localMatrix,
172
180
  flags
173
181
  } = processGradientProps(this.Skia, this.props);
174
- return this.Skia.Shader.MakeSweepGradient(c.x, c.y, colors, positions, mode, localMatrix, flags, start, end);
182
+ const shader = this.Skia.Shader.MakeSweepGradient(c.x, c.y, colors, positions, mode, localMatrix, flags, start, end);
183
+ ctx.shaders.push(shader);
175
184
  }
176
185
 
177
186
  }
@@ -180,7 +189,7 @@ export class TwoPointConicalGradientNode extends ShaderDeclaration {
180
189
  super(ctx, NodeType.TwoPointConicalGradient, props);
181
190
  }
182
191
 
183
- materialize() {
192
+ decorate(ctx) {
184
193
  const {
185
194
  startR,
186
195
  endR,
@@ -194,7 +203,8 @@ export class TwoPointConicalGradientNode extends ShaderDeclaration {
194
203
  localMatrix,
195
204
  flags
196
205
  } = processGradientProps(this.Skia, this.props);
197
- return this.Skia.Shader.MakeTwoPointConicalGradient(start, startR, end, endR, colors, positions, mode, localMatrix, flags);
206
+ const shader = this.Skia.Shader.MakeTwoPointConicalGradient(start, startR, end, endR, colors, positions, mode, localMatrix, flags);
207
+ ctx.shaders.push(shader);
198
208
  }
199
209
 
200
210
  }
@@ -1 +1 @@
1
- {"version":3,"names":["processUniforms","FilterMode","MipmapMode","TileMode","JsiDeclarationNode","DeclarationType","NodeType","enumKey","fitRects","getRect","processGradientProps","processTransformProps","rect2rect","ShaderDeclaration","constructor","ctx","type","props","Shader","ShaderNode","materialize","source","uniforms","transform","m3","Skia","Matrix","makeShaderWithChildren","children","filter","child","isShader","map","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","rects","x","y","width","height","sx","sy","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { SkShader } from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<\n P,\n SkShader\n> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n materialize() {\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n return source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n this.children()\n .filter(\n (child): child is JsiDeclarationNode<unknown, SkShader> =>\n child instanceof JsiDeclarationNode && child.isShader()\n )\n .map((child) => child.materialize()),\n m3\n );\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n materialize() {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n return image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n materialize() {\n const { color } = this.props;\n return this.Skia.Shader.MakeColor(this.Skia.Color(color));\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n materialize() {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n return this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n materialize() {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n return this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n materialize() {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n materialize() {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n materialize() {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n materialize() {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n }\n}\n"],"mappings":"AAAA,SACEA,eADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,QAJF,QAKO,qBALP;AAQA,SAASC,kBAAT,QAAmC,SAAnC;AAYA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,aAA1C;AACA,SACEC,OADF,EAEEC,QAFF,EAG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Type","enumKey","fitRects","getRect","processGradientProps","processTransformProps","rect2rect","ShaderDeclaration","constructor","ctx","type","props","Shader","ShaderNode","decorate","decorateChildren","source","uniforms","transform","m3","Skia","Matrix","shader","makeShaderWithChildren","shaders","popAll","push","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","rects","x","y","width","height","sx","sy","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n DeclarationContext,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.popAll(),\n m3\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { color } = this.props;\n const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));\n ctx.shaders.push(shader);\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n"],"mappings":"AAAA,SACEA,eADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,QAJF,QAKO,qBALP;AAOA,SAASC,kBAAT,QAAmC,SAAnC;AAaA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,aAA1C;AACA,SACEC,OADF,EAEEC,QAFF,EAGEC,OAHF,EAIEC,oBAJF,EAKEC,qBALF,EAMEC,SANF,QAOO,cAPP;AASA,OAAO,MAAeC,iBAAf,SAA4CT,kBAA5C,CAAkE;EACvEU,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWV,eAAe,CAACa,MAA3B,EAAmCF,IAAnC,EAAyCC,KAAzC;EACD;;AAHsE;AAMzE,OAAO,MAAME,UAAN,SAAyBN,iBAAzB,CAAwD;EAC7DC,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAuC;IAChD,MAAMF,GAAN,EAAWT,QAAQ,CAACY,MAApB,EAA4BD,KAA5B;EACD;;EAEDG,QAAQ,CAACL,GAAD,EAA0B;IAChC,KAAKM,gBAAL,CAAsBN,GAAtB;IACA,MAAM;MAAEO,MAAF;MAAUC,QAAV;MAAoB,GAAGC;IAAvB,IAAqC,KAAKP,KAAhD;IACA,MAAMQ,EAAE,GAAG,KAAKC,IAAL,CAAUC,MAAV,EAAX;IACAhB,qBAAqB,CAACc,EAAD,EAAKD,SAAL,CAArB;IACA,MAAMI,MAAM,GAAGN,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ia, 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 {};
@@ -0,0 +1,107 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ export const composeDeclarations = (filters, composer) => {
4
+ if (filters.length <= 1) {
5
+ return filters[0];
6
+ }
7
+
8
+ return filters.reverse().reduce((inner, outer) => {
9
+ if (!inner) {
10
+ return outer;
11
+ }
12
+
13
+ return composer(outer, inner);
14
+ });
15
+ };
16
+
17
+ class Declaration {
18
+ constructor(composer) {
19
+ this.composer = composer;
20
+
21
+ _defineProperty(this, "decls", []);
22
+
23
+ _defineProperty(this, "indexes", [0]);
24
+ }
25
+
26
+ get index() {
27
+ return this.indexes[this.indexes.length - 1];
28
+ }
29
+
30
+ save() {
31
+ this.indexes.push(this.decls.length);
32
+ }
33
+
34
+ restore() {
35
+ this.indexes.pop();
36
+ }
37
+
38
+ pop() {
39
+ return this.decls.pop();
40
+ }
41
+
42
+ push(decl) {
43
+ this.decls.push(decl);
44
+ }
45
+
46
+ popAll() {
47
+ return this.decls.splice(this.index, this.decls.length - this.index);
48
+ }
49
+
50
+ popAllAsOne() {
51
+ if (!this.composer) {
52
+ throw new Error("No composer for this type of declaration");
53
+ }
54
+
55
+ const decls = this.popAll();
56
+ return composeDeclarations(decls, this.composer);
57
+ }
58
+
59
+ }
60
+
61
+ export class DeclarationContext {
62
+ constructor(Skia) {
63
+ this.Skia = Skia;
64
+
65
+ _defineProperty(this, "paints", void 0);
66
+
67
+ _defineProperty(this, "maskFilters", void 0);
68
+
69
+ _defineProperty(this, "shaders", void 0);
70
+
71
+ _defineProperty(this, "pathEffects", void 0);
72
+
73
+ _defineProperty(this, "imageFilters", void 0);
74
+
75
+ _defineProperty(this, "colorFilters", void 0);
76
+
77
+ const peComp = this.Skia.PathEffect.MakeCompose.bind(this.Skia.PathEffect);
78
+ const ifComp = this.Skia.ImageFilter.MakeCompose.bind(this.Skia.ImageFilter);
79
+ const cfComp = this.Skia.ColorFilter.MakeCompose.bind(this.Skia.ColorFilter);
80
+ this.paints = new Declaration();
81
+ this.maskFilters = new Declaration();
82
+ this.shaders = new Declaration();
83
+ this.pathEffects = new Declaration(peComp);
84
+ this.imageFilters = new Declaration(ifComp);
85
+ this.colorFilters = new Declaration(cfComp);
86
+ }
87
+
88
+ save() {
89
+ this.paints.save();
90
+ this.maskFilters.save();
91
+ this.shaders.save();
92
+ this.pathEffects.save();
93
+ this.imageFilters.save();
94
+ this.colorFilters.save();
95
+ }
96
+
97
+ restore() {
98
+ this.paints.restore();
99
+ this.maskFilters.restore();
100
+ this.shaders.restore();
101
+ this.pathEffects.restore();
102
+ this.imageFilters.restore();
103
+ this.colorFilters.restore();
104
+ }
105
+
106
+ }
107
+ //# sourceMappingURL=DeclarationContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["composeDeclarations","filters","composer","length","reverse","reduce","inner","outer","Declaration","constructor","index","indexes","save","push","decls","restore","pop","decl","popAll","splice","popAllAsOne","Error","DeclarationContext","Skia","peComp","PathEffect","MakeCompose","bind","ifComp","ImageFilter","cfComp","ColorFilter","paints","maskFilters","shaders","pathEffects","imageFilters","colorFilters"],"sources":["DeclarationContext.ts"],"sourcesContent":["import type {\n SkShader,\n SkPaint,\n SkImageFilter,\n SkMaskFilter,\n SkPathEffect,\n Skia,\n SkColorFilter,\n} from \"../../skia/types\";\n\ntype Composer<T> = (outer: T, inner: T) => T;\n\nexport const composeDeclarations = <T>(filters: T[], composer: Composer<T>) => {\n if (filters.length <= 1) {\n return filters[0];\n }\n return filters.reverse().reduce((inner, outer) => {\n if (!inner) {\n return outer;\n }\n return composer(outer, inner);\n });\n};\n\nclass Declaration<T> {\n private decls: T[] = [];\n private indexes = [0];\n\n constructor(private composer?: Composer<T>) {}\n\n private get index() {\n return this.indexes[this.indexes.length - 1];\n }\n\n save() {\n this.indexes.push(this.decls.length);\n }\n\n restore() {\n this.indexes.pop();\n }\n\n pop() {\n return this.decls.pop();\n }\n\n push(decl: T) {\n this.decls.push(decl);\n }\n\n popAll() {\n return this.decls.splice(this.index, this.decls.length - this.index);\n }\n\n popAllAsOne() {\n if (!this.composer) {\n throw new Error(\"No composer for this type of declaration\");\n }\n const decls = this.popAll();\n return composeDeclarations(decls, this.composer!);\n }\n}\n\nexport class DeclarationContext {\n readonly paints: Declaration<SkPaint>;\n readonly maskFilters: Declaration<SkMaskFilter>;\n readonly shaders: Declaration<SkShader>;\n readonly pathEffects: Declaration<SkPathEffect>;\n readonly imageFilters: Declaration<SkImageFilter>;\n readonly colorFilters: Declaration<SkColorFilter>;\n\n constructor(private Skia: Skia) {\n const peComp = this.Skia.PathEffect.MakeCompose.bind(this.Skia.PathEffect);\n const ifComp = this.Skia.ImageFilter.MakeCompose.bind(\n this.Skia.ImageFilter\n );\n const cfComp = this.Skia.ColorFilter.MakeCompose.bind(\n this.Skia.ColorFilter\n );\n this.paints = new Declaration<SkPaint>();\n this.maskFilters = new Declaration<SkMaskFilter>();\n this.shaders = new Declaration<SkShader>();\n this.pathEffects = new Declaration<SkPathEffect>(peComp);\n this.imageFilters = new Declaration<SkImageFilter>(ifComp);\n this.colorFilters = new Declaration<SkColorFilter>(cfComp);\n }\n\n save() {\n this.paints.save();\n this.maskFilters.save();\n this.shaders.save();\n this.pathEffects.save();\n this.imageFilters.save();\n this.colorFilters.save();\n }\n\n restore() {\n this.paints.restore();\n this.maskFilters.restore();\n this.shaders.restore();\n this.pathEffects.restore();\n this.imageFilters.restore();\n this.colorFilters.restore();\n }\n}\n"],"mappings":";;AAYA,OAAO,MAAMA,mBAAmB,GAAG,CAAIC,OAAJ,EAAkBC,QAAlB,KAA4C;EAC7E,IAAID,OAAO,CAACE,MAAR,IAAkB,CAAtB,EAAyB;IACvB,OAAOF,OAAO,CAAC,CAAD,CAAd;EACD;;EACD,OAAOA,OAAO,CAACG,OAAR,GAAkBC,MAAlB,CAAyB,CAACC,KAAD,EAAQC,KAAR,KAAkB;IAChD,IAAI,CAACD,KAAL,EAAY;MACV,OAAOC,KAAP;IACD;;IACD,OAAOL,QAAQ,CAACK,KAAD,EAAQD,KAAR,CAAf;EACD,CALM,CAAP;AAMD,CAVM;;AAYP,MAAME,WAAN,CAAqB;EAInBC,WAAW,CAASP,QAAT,EAAiC;IAAA,KAAxBA,QAAwB,GAAxBA,QAAwB;;IAAA,+BAHvB,EAGuB;;IAAA,iCAF1B,CAAC,CAAD,CAE0B;EAAE;;EAE7B,IAALQ,KAAK,GAAG;IAClB,OAAO,KAAKC,OAAL,CAAa,KAAKA,OAAL,CAAaR,MAAb,GAAsB,CAAnC,CAAP;EACD;;EAEDS,IAAI,GAAG;IACL,KAAKD,OAAL,CAAaE,IAAb,CAAkB,KAAKC,KAAL,CAAWX,MAA7B;EACD;;EAEDY,OAAO,GAAG;IACR,KAAKJ,OAAL,CAAaK,GAAb;EACD;;EAEDA,GAAG,GAAG;IACJ,OAAO,KAAKF,KAAL,CAAWE,GAAX,EAAP;EACD;;EAEDH,IAAI,CAACI,IAAD,EAAU;IACZ,KAAKH,KAAL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AI7B,WAAJ,CAA+BsB,MAA/B,CAApB;EACD;;EAEDlB,IAAI,GAAG;IACL,KAAKoB,MAAL,CAAYpB,IAAZ;IACA,KAAKqB,WAAL,CAAiBrB,IAAjB;IACA,KAAKsB,OAAL,CAAatB,IAAb;IACA,KAAKuB,WAAL,CAAiBvB,IAAjB;IACA,KAAKwB,YAAL,CAAkBxB,IAAlB;IACA,KAAKyB,YAAL,CAAkBzB,IAAlB;EACD;;EAEDG,OAAO,GAAG;IACR,KAAKiB,MAAL,CAAYjB,OAAZ;IACA,KAAKkB,WAAL,CAAiBlB,OAAjB;IACA,KAAKmB,OAAL,CAAanB,OAAb;IACA,KAAKoB,WAAL,CAAiBpB,OAAjB;IACA,KAAKqB,YAAL,CAAkBrB,OAAlB;IACA,KAAKsB,YAAL,CAAkBtB,OAAlB;EACD;;AAxC6B"}
@@ -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
  }