@shopify/react-native-skia 1.11.8 → 1.11.9-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/android/CMakeLists.txt +30 -153
  2. package/android/build.gradle +1 -1
  3. package/cpp/skia/include/codec/SkCodec.h +7 -2
  4. package/cpp/skia/include/config/SkUserConfig.h +11 -0
  5. package/cpp/skia/include/core/SkCanvas.h +11 -7
  6. package/cpp/skia/include/core/SkColor.h +10 -0
  7. package/cpp/skia/include/core/SkColorSpace.h +184 -2
  8. package/cpp/skia/include/core/SkColorType.h +114 -32
  9. package/cpp/skia/include/core/SkFontScanner.h +5 -8
  10. package/cpp/skia/include/core/SkFontStyle.h +1 -1
  11. package/cpp/skia/include/core/SkMaskFilter.h +0 -8
  12. package/cpp/skia/include/core/SkMilestone.h +1 -1
  13. package/cpp/skia/include/core/SkPath.h +1 -1
  14. package/cpp/skia/include/core/SkRRect.h +3 -1
  15. package/cpp/skia/include/core/SkShader.h +3 -3
  16. package/cpp/skia/include/core/SkString.h +8 -8
  17. package/cpp/skia/include/core/SkSurface.h +14 -0
  18. package/cpp/skia/include/core/SkTypeface.h +24 -7
  19. package/cpp/skia/include/effects/SkGradientShader.h +6 -1
  20. package/cpp/skia/include/effects/SkRuntimeEffect.h +1 -0
  21. package/cpp/skia/include/encode/SkPngEncoder.h +14 -0
  22. package/cpp/skia/include/gpu/GpuTypes.h +9 -0
  23. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +135 -133
  24. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +5 -0
  25. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +3 -3
  26. package/cpp/skia/include/gpu/ganesh/GrTypes.h +14 -9
  27. package/cpp/skia/include/gpu/graphite/Context.h +25 -2
  28. package/cpp/skia/include/gpu/graphite/ContextOptions.h +23 -5
  29. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +20 -1
  30. package/cpp/skia/include/gpu/graphite/Image.h +1 -0
  31. package/cpp/skia/include/gpu/graphite/LogPriority.h +36 -0
  32. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +52 -0
  33. package/cpp/skia/include/gpu/graphite/Recorder.h +6 -0
  34. package/cpp/skia/include/gpu/graphite/Recording.h +3 -1
  35. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +4 -36
  36. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +48 -0
  37. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +3 -2
  38. package/cpp/skia/include/pathops/SkPathOps.h +9 -1
  39. package/cpp/skia/include/ports/SkFontMgr_FontConfigInterface.h +3 -0
  40. package/cpp/skia/include/private/SkPathRef.h +15 -21
  41. package/cpp/skia/include/private/base/SkAttributes.h +16 -10
  42. package/cpp/skia/include/private/base/SkMutex.h +8 -0
  43. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  44. package/cpp/skia/include/private/base/SkTDArray.h +1 -1
  45. package/cpp/skia/include/private/base/SkTemplates.h +24 -11
  46. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  47. package/cpp/skia/include/sksl/SkSLDebugTrace.h +0 -3
  48. package/cpp/skia/modules/skcms/src/Transform_inl.h +20 -20
  49. package/cpp/skia/modules/skcms/src/skcms_Transform.h +4 -3
  50. package/cpp/skia/modules/skcms/src/skcms_public.h +19 -15
  51. package/cpp/skia/modules/skresources/include/SkResources.h +3 -1
  52. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  53. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  54. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  55. package/cpp/skia/modules/svg/include/SkSVGImage.h +2 -2
  56. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  57. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  58. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  59. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +2 -0
  60. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -0
  61. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  62. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +4 -0
  63. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  64. package/cpp/skia/src/core/SkLRUCache.h +19 -13
  65. package/cpp/skia/src/core/SkTHash.h +50 -4
  66. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +1 -0
  67. package/lib/commonjs/external/reanimated/textures.js +4 -3
  68. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  69. package/lib/commonjs/headless/index.d.ts +1 -1
  70. package/lib/commonjs/headless/index.js +2 -2
  71. package/lib/commonjs/headless/index.js.map +1 -1
  72. package/lib/commonjs/renderer/Canvas.d.ts +2 -2
  73. package/lib/commonjs/renderer/Canvas.js +10 -27
  74. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  75. package/lib/commonjs/renderer/Offscreen.d.ts +2 -2
  76. package/lib/commonjs/renderer/Offscreen.js +4 -4
  77. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  78. package/lib/commonjs/renderer/__tests__/setup.d.ts +5 -5
  79. package/lib/commonjs/sksg/Container.d.ts +3 -1
  80. package/lib/commonjs/sksg/Container.js +7 -1
  81. package/lib/commonjs/sksg/Container.js.map +1 -1
  82. package/lib/commonjs/sksg/HostConfig.d.ts +1 -1
  83. package/lib/commonjs/sksg/HostConfig.js +36 -6
  84. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  85. package/lib/commonjs/sksg/Reconciler.d.ts +3 -2
  86. package/lib/commonjs/sksg/Reconciler.js +16 -6
  87. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  88. package/lib/module/Platform/Platform.web.js +1 -1
  89. package/lib/module/Platform/Platform.web.js.map +1 -1
  90. package/lib/module/dom/nodes/datatypes/Circle.js +1 -2
  91. package/lib/module/dom/nodes/datatypes/Circle.js.map +1 -1
  92. package/lib/module/dom/nodes/datatypes/Gradient.js +3 -3
  93. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  94. package/lib/module/dom/nodes/datatypes/Rect.js +3 -5
  95. package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
  96. package/lib/module/external/reanimated/buffers.js +1 -2
  97. package/lib/module/external/reanimated/buffers.js.map +1 -1
  98. package/lib/module/external/reanimated/textures.js +5 -4
  99. package/lib/module/external/reanimated/textures.js.map +1 -1
  100. package/lib/module/external/reanimated/useAnimatedImageValue.js +1 -1
  101. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
  102. package/lib/module/external/reanimated/useVideo.js +10 -23
  103. package/lib/module/external/reanimated/useVideo.js.map +1 -1
  104. package/lib/module/headless/index.d.ts +1 -1
  105. package/lib/module/headless/index.js +2 -2
  106. package/lib/module/headless/index.js.map +1 -1
  107. package/lib/module/renderer/Canvas.d.ts +2 -2
  108. package/lib/module/renderer/Canvas.js +9 -27
  109. package/lib/module/renderer/Canvas.js.map +1 -1
  110. package/lib/module/renderer/Offscreen.d.ts +2 -2
  111. package/lib/module/renderer/Offscreen.js +4 -4
  112. package/lib/module/renderer/Offscreen.js.map +1 -1
  113. package/lib/module/renderer/__tests__/setup.d.ts +5 -5
  114. package/lib/module/skia/core/Vector.js +1 -1
  115. package/lib/module/skia/core/Vector.js.map +1 -1
  116. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js +1 -4
  117. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js.map +1 -1
  118. package/lib/module/skia/web/Host.js +1 -7
  119. package/lib/module/skia/web/Host.js.map +1 -1
  120. package/lib/module/skia/web/JsiSkAnimatedImage.js +3 -6
  121. package/lib/module/skia/web/JsiSkAnimatedImage.js.map +1 -1
  122. package/lib/module/skia/web/JsiSkCanvas.js +3 -6
  123. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  124. package/lib/module/skia/web/JsiSkColorFilter.js +3 -6
  125. package/lib/module/skia/web/JsiSkColorFilter.js.map +1 -1
  126. package/lib/module/skia/web/JsiSkContourMeasure.js +3 -6
  127. package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
  128. package/lib/module/skia/web/JsiSkContourMeasureIter.js +3 -6
  129. package/lib/module/skia/web/JsiSkContourMeasureIter.js.map +1 -1
  130. package/lib/module/skia/web/JsiSkData.js +3 -6
  131. package/lib/module/skia/web/JsiSkData.js.map +1 -1
  132. package/lib/module/skia/web/JsiSkFont.js +3 -6
  133. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  134. package/lib/module/skia/web/JsiSkImage.js +8 -12
  135. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  136. package/lib/module/skia/web/JsiSkImageFilter.js +3 -6
  137. package/lib/module/skia/web/JsiSkImageFilter.js.map +1 -1
  138. package/lib/module/skia/web/JsiSkMaskFilter.js +3 -6
  139. package/lib/module/skia/web/JsiSkMaskFilter.js.map +1 -1
  140. package/lib/module/skia/web/JsiSkMatrix.js +5 -8
  141. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  142. package/lib/module/skia/web/JsiSkPaint.js +3 -6
  143. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  144. package/lib/module/skia/web/JsiSkParagraphBuilder.js +2 -3
  145. package/lib/module/skia/web/JsiSkParagraphBuilder.js.map +1 -1
  146. package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js +1 -1
  147. package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js.map +1 -1
  148. package/lib/module/skia/web/JsiSkParagraphStyle.js +15 -15
  149. package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
  150. package/lib/module/skia/web/JsiSkPath.js +3 -6
  151. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  152. package/lib/module/skia/web/JsiSkPathEffect.js +3 -6
  153. package/lib/module/skia/web/JsiSkPathEffect.js.map +1 -1
  154. package/lib/module/skia/web/JsiSkPicture.js +3 -6
  155. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  156. package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -6
  157. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  158. package/lib/module/skia/web/JsiSkPoint.js +3 -6
  159. package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
  160. package/lib/module/skia/web/JsiSkRRect.js +3 -6
  161. package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
  162. package/lib/module/skia/web/JsiSkRSXform.js +3 -6
  163. package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
  164. package/lib/module/skia/web/JsiSkRect.js +3 -6
  165. package/lib/module/skia/web/JsiSkRect.js.map +1 -1
  166. package/lib/module/skia/web/JsiSkRuntimeEffect.js +3 -6
  167. package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  168. package/lib/module/skia/web/JsiSkSVG.js +5 -8
  169. package/lib/module/skia/web/JsiSkSVG.js.map +1 -1
  170. package/lib/module/skia/web/JsiSkShader.js +3 -6
  171. package/lib/module/skia/web/JsiSkShader.js.map +1 -1
  172. package/lib/module/skia/web/JsiSkSurface.js +3 -6
  173. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  174. package/lib/module/skia/web/JsiSkTextBlob.js +3 -6
  175. package/lib/module/skia/web/JsiSkTextBlob.js.map +1 -1
  176. package/lib/module/skia/web/JsiSkTypeface.js +3 -6
  177. package/lib/module/skia/web/JsiSkTypeface.js.map +1 -1
  178. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +1 -4
  179. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
  180. package/lib/module/skia/web/JsiSkVertices.js +3 -6
  181. package/lib/module/skia/web/JsiSkVertices.js.map +1 -1
  182. package/lib/module/skia/web/JsiVideo.js +2 -5
  183. package/lib/module/skia/web/JsiVideo.js.map +1 -1
  184. package/lib/module/sksg/Container.d.ts +3 -1
  185. package/lib/module/sksg/Container.js +11 -8
  186. package/lib/module/sksg/Container.js.map +1 -1
  187. package/lib/module/sksg/HostConfig.d.ts +1 -1
  188. package/lib/module/sksg/HostConfig.js +36 -7
  189. package/lib/module/sksg/HostConfig.js.map +1 -1
  190. package/lib/module/sksg/Reconciler.d.ts +3 -2
  191. package/lib/module/sksg/Reconciler.js +16 -11
  192. package/lib/module/sksg/Reconciler.js.map +1 -1
  193. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +1 -5
  194. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  195. package/lib/module/sksg/Recorder/Recorder.js +3 -6
  196. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  197. package/lib/module/sksg/Recorder/Visitor.js +1 -1
  198. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  199. package/lib/module/sksg/Recorder/commands/Drawing.js +2 -4
  200. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  201. package/lib/module/sksg/Recorder/commands/Shaders.js +2 -3
  202. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  203. package/lib/module/views/SkiaBaseWebView.js +9 -12
  204. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  205. package/lib/module/views/SkiaPictureView.js +1 -5
  206. package/lib/module/views/SkiaPictureView.js.map +1 -1
  207. package/lib/module/views/SkiaPictureView.web.js +1 -4
  208. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  209. package/lib/module/web/LoadSkiaWeb.js +1 -2
  210. package/lib/module/web/LoadSkiaWeb.js.map +1 -1
  211. package/lib/module/web/WithSkiaWeb.js +1 -1
  212. package/lib/module/web/WithSkiaWeb.js.map +1 -1
  213. package/lib/typescript/lib/commonjs/headless/index.d.ts +1 -1
  214. package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +9 -1
  215. package/lib/typescript/lib/commonjs/renderer/Offscreen.d.ts +2 -2
  216. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +3 -0
  217. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +21 -4
  218. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +9 -2
  219. package/lib/typescript/lib/module/headless/index.d.ts +1 -1
  220. package/lib/typescript/lib/module/renderer/Canvas.d.ts +9 -1
  221. package/lib/typescript/lib/module/renderer/Offscreen.d.ts +2 -2
  222. package/lib/typescript/lib/module/skia/web/CanvasKitWebGLBufferImpl.d.ts +2 -2
  223. package/lib/typescript/lib/module/skia/web/JsiSkAnimatedImage.d.ts +1 -0
  224. package/lib/typescript/lib/module/skia/web/JsiSkCanvas.d.ts +1 -0
  225. package/lib/typescript/lib/module/skia/web/JsiSkColorFilter.d.ts +1 -0
  226. package/lib/typescript/lib/module/skia/web/JsiSkContourMeasure.d.ts +1 -0
  227. package/lib/typescript/lib/module/skia/web/JsiSkContourMeasureIter.d.ts +1 -0
  228. package/lib/typescript/lib/module/skia/web/JsiSkData.d.ts +1 -0
  229. package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -0
  230. package/lib/typescript/lib/module/skia/web/JsiSkImage.d.ts +1 -0
  231. package/lib/typescript/lib/module/skia/web/JsiSkImageFilter.d.ts +1 -0
  232. package/lib/typescript/lib/module/skia/web/JsiSkMaskFilter.d.ts +1 -0
  233. package/lib/typescript/lib/module/skia/web/JsiSkMatrix.d.ts +1 -0
  234. package/lib/typescript/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
  235. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +1 -0
  236. package/lib/typescript/lib/module/skia/web/JsiSkPathEffect.d.ts +1 -0
  237. package/lib/typescript/lib/module/skia/web/JsiSkPicture.d.ts +1 -0
  238. package/lib/typescript/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -0
  239. package/lib/typescript/lib/module/skia/web/JsiSkPoint.d.ts +1 -0
  240. package/lib/typescript/lib/module/skia/web/JsiSkRRect.d.ts +1 -0
  241. package/lib/typescript/lib/module/skia/web/JsiSkRSXform.d.ts +1 -0
  242. package/lib/typescript/lib/module/skia/web/JsiSkRect.d.ts +1 -0
  243. package/lib/typescript/lib/module/skia/web/JsiSkRuntimeEffect.d.ts +1 -0
  244. package/lib/typescript/lib/module/skia/web/JsiSkSVG.d.ts +1 -0
  245. package/lib/typescript/lib/module/skia/web/JsiSkShader.d.ts +1 -0
  246. package/lib/typescript/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
  247. package/lib/typescript/lib/module/skia/web/JsiSkTextBlob.d.ts +1 -0
  248. package/lib/typescript/lib/module/skia/web/JsiSkTypeface.d.ts +1 -0
  249. package/lib/typescript/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -0
  250. package/lib/typescript/lib/module/skia/web/JsiSkVertices.d.ts +1 -0
  251. package/lib/typescript/lib/module/skia/web/JsiVideo.d.ts +2 -2
  252. package/lib/typescript/lib/module/sksg/Container.d.ts +7 -12
  253. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +20 -4
  254. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +18 -17
  255. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  256. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +5 -2
  257. package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +12 -11
  258. package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +2 -2
  259. package/lib/typescript/lib/module/views/SkiaPictureView.web.d.ts +1 -1
  260. package/lib/typescript/src/headless/index.d.ts +1 -1
  261. package/lib/typescript/src/renderer/Canvas.d.ts +2 -2
  262. package/lib/typescript/src/renderer/Offscreen.d.ts +2 -2
  263. package/lib/typescript/src/renderer/__tests__/setup.d.ts +5 -5
  264. package/lib/typescript/src/sksg/Container.d.ts +3 -1
  265. package/lib/typescript/src/sksg/HostConfig.d.ts +1 -1
  266. package/lib/typescript/src/sksg/Reconciler.d.ts +3 -2
  267. package/libs/apple/libskia.xcframework/Info.plist +15 -15
  268. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  269. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  270. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  271. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  272. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  273. package/libs/apple/libskottie.xcframework/Info.plist +8 -8
  274. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  275. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  276. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  277. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  278. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  279. package/libs/apple/libskparagraph.xcframework/Info.plist +7 -7
  280. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  281. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  282. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  283. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  284. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  285. package/libs/apple/libsksg.xcframework/Info.plist +12 -12
  286. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  287. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  288. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  289. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  290. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  291. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  292. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  293. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  294. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  295. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  296. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  297. package/libs/apple/libskunicode_core.xcframework/Info.plist +14 -14
  298. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  299. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  300. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  301. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
  302. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  303. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
  304. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  305. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  306. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  307. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  308. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  309. package/libs/apple/libsvg.xcframework/Info.plist +11 -11
  310. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  311. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  312. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  313. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  314. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  315. package/package.json +10 -9
  316. package/src/external/reanimated/textures.tsx +5 -4
  317. package/src/headless/index.ts +2 -2
  318. package/src/renderer/Canvas.tsx +57 -80
  319. package/src/renderer/Offscreen.tsx +4 -4
  320. package/src/renderer/__tests__/Data.spec.tsx +9 -10
  321. package/src/renderer/__tests__/Drawings.spec.tsx +11 -11
  322. package/src/renderer/__tests__/FitBox.spec.tsx +10 -10
  323. package/src/renderer/__tests__/Glyphs.spec.tsx +2 -2
  324. package/src/renderer/__tests__/Image.spec.tsx +2 -2
  325. package/src/renderer/__tests__/Paths.spec.tsx +8 -8
  326. package/src/renderer/__tests__/Picture.spec.tsx +10 -12
  327. package/src/renderer/__tests__/Simple.spec.tsx +6 -6
  328. package/src/renderer/__tests__/Surfaces.spec.tsx +2 -2
  329. package/src/renderer/__tests__/Text.spec.tsx +12 -12
  330. package/src/renderer/__tests__/Transform.spec.tsx +8 -8
  331. package/src/renderer/__tests__/documentation/Group.spec.tsx +12 -12
  332. package/src/renderer/__tests__/documentation/getting-started/HelloWorld.spec.tsx +2 -2
  333. package/src/renderer/__tests__/documentation/paint/Overview.spec.tsx +8 -8
  334. package/src/renderer/__tests__/documentation/shapes/Box.spec.tsx +4 -4
  335. package/src/renderer/__tests__/e2e/Atlas.spec.tsx +3 -3
  336. package/src/renderer/__tests__/e2e/Offscreen.spec.tsx +1 -1
  337. package/src/renderer/__tests__/examples/BlendModes.spec.tsx +4 -4
  338. package/src/renderer/__tests__/setup.tsx +13 -13
  339. package/src/sksg/Container.ts +9 -1
  340. package/src/sksg/HostConfig.ts +37 -7
  341. package/src/sksg/Reconciler.ts +17 -6
  342. package/src/sksg/__tests__/Simple.spec.tsx +8 -8
  343. package/lib/commonjs/sksg/HostConfig2.d.ts +0 -19
  344. package/lib/commonjs/sksg/HostConfig2.js +0 -159
  345. package/lib/commonjs/sksg/HostConfig2.js.map +0 -1
  346. package/lib/module/sksg/HostConfig2.d.ts +0 -19
  347. package/lib/module/sksg/HostConfig2.js +0 -152
  348. package/lib/module/sksg/HostConfig2.js.map +0 -1
  349. package/lib/typescript/lib/commonjs/sksg/HostConfig2.d.ts +0 -44
  350. package/lib/typescript/lib/module/sksg/HostConfig2.d.ts +0 -43
  351. package/lib/typescript/src/sksg/HostConfig2.d.ts +0 -19
  352. package/src/sksg/HostConfig2.ts +0 -247
@@ -105,6 +105,9 @@ SKCMS_API bool skcms_TransferFunction_isHLGish (const skcms_TransferFunction*);
105
105
  // Unified representation of 'curv' or 'para' tag data, or a 1D table from 'mft1' or 'mft2'
106
106
  typedef union skcms_Curve {
107
107
  struct {
108
+ // this needs to line up with alias_of_table_entries so we can tell if there are or
109
+ // are not table entries. If this is 0, this struct is a parametric function,
110
+ // otherwise it's a table entry.
108
111
  uint32_t alias_of_table_entries;
109
112
  skcms_TransferFunction parametric;
110
113
  };
@@ -123,44 +126,44 @@ typedef struct skcms_A2B {
123
126
  // Optional: N 1D "A" curves, followed by an N-dimensional CLUT.
124
127
  // If input_channels == 0, these curves and CLUT are skipped,
125
128
  // Otherwise, input_channels must be in [1, 4].
126
- uint32_t input_channels;
127
129
  skcms_Curve input_curves[4];
128
- uint8_t grid_points[4];
129
130
  const uint8_t* grid_8;
130
131
  const uint8_t* grid_16;
132
+ uint32_t input_channels;
133
+ uint8_t grid_points[4];
131
134
 
132
135
  // Optional: 3 1D "M" curves, followed by a color matrix.
133
136
  // If matrix_channels == 0, these curves and matrix are skipped,
134
137
  // Otherwise, matrix_channels must be 3.
135
- uint32_t matrix_channels;
136
138
  skcms_Curve matrix_curves[3];
137
139
  skcms_Matrix3x4 matrix;
140
+ uint32_t matrix_channels;
138
141
 
139
142
  // Required: 3 1D "B" curves. Always present, and output_channels must be 3.
140
- uint32_t output_channels;
143
+ uint32_t output_channels; // list first to pack with matrix_channels
141
144
  skcms_Curve output_curves[3];
142
145
  } skcms_A2B;
143
146
 
144
147
  typedef struct skcms_B2A {
145
148
  // Required: 3 1D "B" curves. Always present, and input_channels must be 3.
146
- uint32_t input_channels;
147
149
  skcms_Curve input_curves[3];
150
+ uint32_t input_channels;
148
151
 
149
152
  // Optional: a color matrix, followed by 3 1D "M" curves.
150
153
  // If matrix_channels == 0, this matrix and these curves are skipped,
151
154
  // Otherwise, matrix_channels must be 3.
152
- uint32_t matrix_channels;
153
- skcms_Matrix3x4 matrix;
155
+ uint32_t matrix_channels; // list first to pack with input_channels
154
156
  skcms_Curve matrix_curves[3];
157
+ skcms_Matrix3x4 matrix;
155
158
 
156
159
  // Optional: an N-dimensional CLUT, followed by N 1D "A" curves.
157
160
  // If output_channels == 0, this CLUT and these curves are skipped,
158
161
  // Otherwise, output_channels must be in [1, 4].
159
- uint32_t output_channels;
160
- uint8_t grid_points[4];
162
+ skcms_Curve output_curves[4];
161
163
  const uint8_t* grid_8;
162
164
  const uint8_t* grid_16;
163
- skcms_Curve output_curves[4];
165
+ uint8_t grid_points[4];
166
+ uint32_t output_channels;
164
167
  } skcms_B2A;
165
168
 
166
169
  typedef struct skcms_CICP {
@@ -182,30 +185,31 @@ typedef struct skcms_ICCProfile {
182
185
 
183
186
  // If we can parse red, green and blue transfer curves from the profile,
184
187
  // trc will be set to those three curves, and has_trc will be true.
185
- bool has_trc;
186
188
  skcms_Curve trc[3];
187
189
 
188
190
  // If this profile's gamut can be represented by a 3x3 transform to XYZD50,
189
191
  // skcms_Parse() sets toXYZD50 to that transform and has_toXYZD50 to true.
190
- bool has_toXYZD50;
191
192
  skcms_Matrix3x3 toXYZD50;
192
193
 
193
194
  // If the profile has a valid A2B0 or A2B1 tag, skcms_Parse() sets A2B to
194
195
  // that data, and has_A2B to true. skcms_ParseWithA2BPriority() does the
195
196
  // same following any user-provided prioritization of A2B0, A2B1, or A2B2.
196
- bool has_A2B;
197
197
  skcms_A2B A2B;
198
198
 
199
199
  // If the profile has a valid B2A0 or B2A1 tag, skcms_Parse() sets B2A to
200
200
  // that data, and has_B2A to true. skcms_ParseWithA2BPriority() does the
201
201
  // same following any user-provided prioritization of B2A0, B2A1, or B2A2.
202
- bool has_B2A;
203
202
  skcms_B2A B2A;
204
203
 
205
204
  // If the profile has a valid CICP tag, skcms_Parse() sets CICP to that data,
206
205
  // and has_CICP to true.
207
- bool has_CICP;
208
206
  skcms_CICP CICP;
207
+
208
+ bool has_trc;
209
+ bool has_toXYZD50;
210
+ bool has_A2B;
211
+ bool has_B2A;
212
+ bool has_CICP;
209
213
  } skcms_ICCProfile;
210
214
 
211
215
  // The sRGB color profile is so commonly used that we offer a canonical skcms_ICCProfile for it.
@@ -108,9 +108,11 @@ public:
108
108
  static sk_sp<MultiFrameImageAsset> Make(std::unique_ptr<SkCodec>,
109
109
  ImageDecodeStrategy = ImageDecodeStrategy::kLazyDecode);
110
110
 
111
-
112
111
  bool isMultiFrame() override;
113
112
 
113
+ // Animation duration, in ms.
114
+ float duration() const;
115
+
114
116
  sk_sp<SkImage> getFrame(float t) override;
115
117
 
116
118
  private:
@@ -42,7 +42,7 @@ protected:
42
42
 
43
43
  SkPath onAsPath(const SkSVGRenderContext&) const override;
44
44
 
45
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
45
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
46
46
 
47
47
  private:
48
48
  SkSVGCircle();
@@ -29,7 +29,7 @@ protected:
29
29
 
30
30
  SkPath onAsPath(const SkSVGRenderContext&) const override;
31
31
 
32
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
32
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const final;
33
33
 
34
34
  bool hasChildren() const final;
35
35
 
@@ -20,7 +20,7 @@
20
20
  class SK_API SkSVGFeLightSource : public SkSVGHiddenContainer {
21
21
  public:
22
22
  void appendChild(sk_sp<SkSVGNode>) final {
23
- SkDebugf("cannot append child nodes to an SVG light source.\n");
23
+ SkDEBUGF("cannot append child nodes to an SVG light source.\n");
24
24
  }
25
25
 
26
26
  protected:
@@ -31,13 +31,13 @@ public:
31
31
  }
32
32
 
33
33
  void appendChild(sk_sp<SkSVGNode>) override {
34
- SkDebugf("cannot append child nodes to this element.\n");
34
+ SkDEBUGF("cannot append child nodes to this element.\n");
35
35
  }
36
36
 
37
37
  bool onPrepareToRender(SkSVGRenderContext*) const override;
38
38
  void onRender(const SkSVGRenderContext&) const override;
39
39
  SkPath onAsPath(const SkSVGRenderContext&) const override;
40
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
40
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
41
41
 
42
42
  struct ImageInfo {
43
43
  sk_sp<SkImage> fImage;
@@ -35,7 +35,7 @@ protected:
35
35
 
36
36
  SkPath onAsPath(const SkSVGRenderContext&) const override;
37
37
 
38
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
38
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
39
39
 
40
40
  private:
41
41
  SkSVGPath();
@@ -43,7 +43,7 @@ protected:
43
43
 
44
44
  SkPath onAsPath(const SkSVGRenderContext&) const override;
45
45
 
46
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
46
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
47
47
 
48
48
  private:
49
49
  SkSVGPoly(SkSVGTag);
@@ -44,7 +44,7 @@ protected:
44
44
 
45
45
  SkPath onAsPath(const SkSVGRenderContext&) const override;
46
46
 
47
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
47
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
48
48
 
49
49
  private:
50
50
  SkSVGRect();
@@ -171,6 +171,8 @@ public:
171
171
  const SkSVGLength& w, const SkSVGLength& h,
172
172
  SkSVGObjectBoundingBoxUnits) const;
173
173
 
174
+ const OBBScope& currentOBBScope() const { return fOBBScope; }
175
+
174
176
  std::unique_ptr<SkShaper> makeShaper() const {
175
177
  SkASSERT(fTextShapingFactory);
176
178
  return fTextShapingFactory->makeShaper(this->fontMgr());
@@ -8,6 +8,7 @@
8
8
  #ifndef SkSVGShape_DEFINED
9
9
  #define SkSVGShape_DEFINED
10
10
 
11
+ #include "include/core/SkRect.h"
11
12
  #include "include/core/SkRefCnt.h"
12
13
  #include "include/private/base/SkAPI.h"
13
14
  #include "modules/svg/include/SkSVGTransformableNode.h"
@@ -75,7 +75,7 @@ private:
75
75
 
76
76
  void onRender(const SkSVGRenderContext&) const override;
77
77
 
78
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
78
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
79
79
  SkPath onAsPath(const SkSVGRenderContext&) const override;
80
80
 
81
81
  using INHERITED = SkSVGTextContainer;
@@ -34,6 +34,10 @@ protected:
34
34
 
35
35
  void mapToParent(SkRect*) const;
36
36
 
37
+ SkRect onObjectBoundingBox(const SkSVGRenderContext& ) const final;
38
+
39
+ virtual SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const;
40
+
37
41
  private:
38
42
  // FIXME: should be sparse
39
43
  SkSVGTransformType fTransform;
@@ -36,7 +36,7 @@ protected:
36
36
  bool onPrepareToRender(SkSVGRenderContext*) const override;
37
37
  void onRender(const SkSVGRenderContext&) const override;
38
38
  SkPath onAsPath(const SkSVGRenderContext&) const override;
39
- SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
39
+ SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
40
40
 
41
41
  private:
42
42
  SkSVGUse();
@@ -12,16 +12,21 @@
12
12
  #include "src/core/SkChecksum.h"
13
13
  #include "src/core/SkTHash.h"
14
14
 
15
+ struct SkNoOpPurge {
16
+ template <typename K, typename V>
17
+ void operator()(const K& /* k */, const V* /* v */) const {}
18
+ };
19
+
15
20
  /**
16
21
  * A generic LRU cache.
17
22
  */
18
- template <typename K, typename V, typename HashK = SkGoodHash>
23
+ template <typename K, typename V, typename HashK = SkGoodHash, typename PurgeCB = SkNoOpPurge>
19
24
  class SkLRUCache {
20
25
  private:
21
26
  struct Entry {
22
27
  Entry(const K& key, V&& value)
23
- : fKey(key)
24
- , fValue(std::move(value)) {}
28
+ : fKey(key)
29
+ , fValue(std::move(value)) {}
25
30
 
26
31
  K fKey;
27
32
  V fValue;
@@ -101,6 +106,17 @@ public:
101
106
  }
102
107
  }
103
108
 
109
+ void remove(const K& key) {
110
+ Entry** value = fMap.find(key);
111
+ SkASSERT(value);
112
+ Entry* entry = *value;
113
+ SkASSERT(key == entry->fKey);
114
+ PurgeCB()(key, &entry->fValue);
115
+ fMap.remove(key);
116
+ fLRU.remove(entry);
117
+ delete entry;
118
+ }
119
+
104
120
  private:
105
121
  struct Traits {
106
122
  static const K& GetKey(Entry* e) {
@@ -112,16 +128,6 @@ private:
112
128
  }
113
129
  };
114
130
 
115
- void remove(const K& key) {
116
- Entry** value = fMap.find(key);
117
- SkASSERT(value);
118
- Entry* entry = *value;
119
- SkASSERT(key == entry->fKey);
120
- fMap.remove(key);
121
- fLRU.remove(entry);
122
- delete entry;
123
- }
124
-
125
131
  int fMaxCount;
126
132
  skia_private::THashTable<Entry*, K, Traits> fMap;
127
133
  SkTInternalLList<Entry> fLRU;
@@ -27,6 +27,10 @@ namespace skia_private {
27
27
  // Traits must have:
28
28
  // - static K GetKey(T)
29
29
  // - static uint32_t Hash(K)
30
+ // Traits may also define (both required if either is defined):
31
+ // - static bool ShouldGrow(int count, int capacity)
32
+ // - static bool ShouldShrink(int count, int capacity)
33
+ // , which specify the max/min load factor of the table.
30
34
  // If the key is large and stored inside T, you may want to make K a const&.
31
35
  // Similarly, if T is large you might want it to be a pointer.
32
36
  template <typename T, typename K, typename Traits = T>
@@ -98,7 +102,13 @@ public:
98
102
  // Copy val into the hash table, returning a pointer to the copy now in the table.
99
103
  // If there already is an entry in the table with the same key, we overwrite it.
100
104
  T* set(T val) {
101
- if (4 * fCount >= 3 * fCapacity) {
105
+ bool shouldGrow = false;
106
+ if constexpr (HasShouldGrow<Traits>::value) {
107
+ shouldGrow = Traits::ShouldGrow(fCount, fCapacity);
108
+ } else {
109
+ shouldGrow = (4 * fCount >= 3 * fCapacity);
110
+ }
111
+ if (shouldGrow) {
102
112
  this->resize(fCapacity > 0 ? fCapacity * 2 : 4);
103
113
  }
104
114
  return this->uncheckedSet(std::move(val));
@@ -143,8 +153,16 @@ public:
143
153
  }
144
154
  if (hash == s.fHash && key == Traits::GetKey(*s)) {
145
155
  this->removeSlot(index);
146
- if (4 * fCount <= fCapacity && fCapacity > 4) {
147
- this->resize(fCapacity / 2);
156
+ if (fCapacity > 4) {
157
+ bool shouldShrink = false;
158
+ if constexpr (HasShouldShrink<Traits>::value) {
159
+ shouldShrink = Traits::ShouldShrink(fCount, fCapacity);
160
+ } else {
161
+ shouldShrink = (4 * fCount <= fCapacity);
162
+ }
163
+ if (shouldShrink) {
164
+ this->resize(fCapacity / 2);
165
+ }
148
166
  }
149
167
  return true;
150
168
  }
@@ -192,7 +210,14 @@ public:
192
210
  // - Hash tables grow when they exceed 3/4 capacity, not when they are full.
193
211
  void reserve(int n) {
194
212
  int newCapacity = SkNextPow2(n);
195
- if (n * 4 > newCapacity * 3) {
213
+
214
+ bool shouldGrow = false;
215
+ if constexpr (HasShouldGrow<Traits>::value) {
216
+ shouldGrow = Traits::ShouldGrow(n, newCapacity);
217
+ } else {
218
+ shouldGrow = (n * 4 > newCapacity * 3);
219
+ }
220
+ if (shouldGrow) {
196
221
  newCapacity *= 2;
197
222
  }
198
223
 
@@ -274,6 +299,27 @@ public:
274
299
  };
275
300
 
276
301
  private:
302
+ template <typename U, typename = void> struct HasShouldGrow : std::false_type {};
303
+ template <typename U, typename = void> struct HasShouldShrink : std::false_type {};
304
+
305
+ template <typename U>
306
+ struct HasShouldGrow<
307
+ U,
308
+ std::void_t<decltype(U::ShouldGrow(std::declval<int>(), std::declval<int>()))>>
309
+ : std::true_type {
310
+ static_assert(HasShouldShrink<U>::value,
311
+ "The traits class must also provide ShouldShrink() method.");
312
+ };
313
+
314
+ template <typename U>
315
+ struct HasShouldShrink<
316
+ U,
317
+ std::void_t<decltype(U::ShouldShrink(std::declval<int>(), std::declval<int>()))>>
318
+ : std::true_type {
319
+ static_assert(HasShouldGrow<U>::value,
320
+ "The traits class must also provide ShouldGrow() method.");
321
+ };
322
+
277
323
  // Finds the first non-empty slot for an iterator.
278
324
  int firstPopulatedSlot() const {
279
325
  for (int i = 0; i < fCapacity; i++) {
@@ -891,6 +891,7 @@
891
891
  #define GR_GL_ANY_SAMPLES_PASSED 0x8C2F
892
892
  #define GR_GL_TIME_ELAPSED 0x88BF
893
893
  #define GR_GL_TIMESTAMP 0x8E28
894
+ #define GR_GL_GPU_DISJOINT 0x8FBB
894
895
  #define GR_GL_PRIMITIVES_GENERATED 0x8C87
895
896
  #define GR_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
896
897
 
@@ -19,13 +19,14 @@ const useTexture = (element, size) => {
19
19
  width,
20
20
  height
21
21
  } = size;
22
- const picture = (0, _react.useMemo)(() => {
23
- return (0, _Offscreen.drawAsPicture)(element, {
22
+ const [picture, setPicture] = (0, _react.useState)(null);
23
+ (0, _react.useEffect)(() => {
24
+ (0, _Offscreen.drawAsPicture)(element, {
24
25
  x: 0,
25
26
  y: 0,
26
27
  width,
27
28
  height
28
- });
29
+ }).then(pic => setPicture(pic));
29
30
  }, [element, width, height]);
30
31
  return usePictureAsTexture(picture, size);
31
32
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Offscreen","_skia","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","createTexture","texture","picture","size","value","drawAsImageFromPicture","useTexture","element","width","height","useMemo","drawAsPicture","x","y","usePictureAsTexture","exports","useTextureAsValue","console","warn","useTextureValueFromPicture","Rea","useSharedValue","useEffect","runOnUI","useImageAsTexture","source","image","useImage","recorder","Skia","PictureRecorder","canvas","beginRecording","drawImage","finishRecordingAsPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n DataSourceParam,\n SkImage,\n SkPicture,\n SkSize,\n} from \"../../skia/types\";\nimport {\n drawAsImageFromPicture,\n drawAsPicture,\n} from \"../../renderer/Offscreen\";\nimport { Skia, useImage } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n texture.value = drawAsImageFromPicture(picture, size);\n};\n\nexport const useTexture = (element: ReactElement, size: SkSize) => {\n const { width, height } = size;\n const picture = useMemo(() => {\n return drawAsPicture(element, {\n x: 0,\n y: 0,\n width,\n height,\n });\n }, [element, width, height]);\n return usePictureAsTexture(picture, size);\n};\n\nexport const useTextureAsValue = (element: ReactElement, size: SkSize) => {\n console.warn(\"useTextureAsValue has been renamed to use useTexture\");\n return useTexture(element, size);\n};\n\nexport const useTextureValueFromPicture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n console.warn(\n \"useTextureValueFromPicture has been renamed to use usePictureAsTexture\"\n );\n return usePictureAsTexture(picture, size);\n};\n\nexport const usePictureAsTexture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n const texture = Rea.useSharedValue<SkImage | null>(null);\n useEffect(() => {\n if (picture !== null) {\n Rea.runOnUI(createTexture)(texture, picture, size);\n }\n }, [texture, picture, size]);\n return texture;\n};\n\nexport const useImageAsTexture = (source: DataSourceParam) => {\n const image = useImage(source);\n const size = useMemo(() => {\n if (image) {\n return { width: image.width(), height: image.height() };\n }\n return { width: 0, height: 0 };\n }, [image]);\n const picture = useMemo(() => {\n if (image) {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording({\n x: 0,\n y: 0,\n width: size.width,\n height: size.height,\n });\n canvas.drawImage(image, 0, 0);\n return recorder.finishRecordingAsPicture();\n } else {\n return null;\n }\n }, [size, image]);\n return usePictureAsTexture(picture, size);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAUA,IAAAC,UAAA,GAAAD,OAAA;AAIA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAoC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpC,MAAMG,aAAa,GAAGA,CACpBC,OAAoC,EACpCC,OAAkB,EAClBC,IAAY,KACT;EACH,SAAS;;EACTF,OAAO,CAACG,KAAK,GAAG,IAAAC,iCAAsB,EAACH,OAAO,EAAEC,IAAI,CAAC;AACvD,CAAC;AAEM,MAAMG,UAAU,GAAGA,CAACC,OAAqB,EAAEJ,IAAY,KAAK;EACjE,MAAM;IAAEK,KAAK;IAAEC;EAAO,CAAC,GAAGN,IAAI;EAC9B,MAAMD,OAAO,GAAG,IAAAQ,cAAO,EAAC,MAAM;IAC5B,OAAO,IAAAC,wBAAa,EAACJ,OAAO,EAAE;MAC5BK,CAAC,EAAE,CAAC;MACJC,CAAC,EAAE,CAAC;MACJL,KAAK;MACLC;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACF,OAAO,EAAEC,KAAK,EAAEC,MAAM,CAAC,CAAC;EAC5B,OAAOK,mBAAmB,CAACZ,OAAO,EAAEC,IAAI,CAAC;AAC3C,CAAC;AAACY,OAAA,CAAAT,UAAA,GAAAA,UAAA;AAEK,MAAMU,iBAAiB,GAAGA,CAACT,OAAqB,EAAEJ,IAAY,KAAK;EACxEc,OAAO,CAACC,IAAI,CAAC,sDA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;IAC5B,IAAIgB,KAAK,EAAE;MACT,MAAME,QAAQ,GAAGC,UAAI,CAACC,eAAe,CAAC,CAAC;MACvC,MAAMC,MAAM,GAAGH,QAAQ,CAACI,cAAc,CAAC;QACrCpB,CAAC,EAAE,CAAC;QACJC,CAAC,EAAE,CAAC;QACJL,KAAK,EAAEL,IAAI,CAACK,KAAK;QACjBC,MAAM,EAAEN,IAAI,CAACM;MACf,CAAC,CAAC;MACFsB,MAAM,CAACE,SAAS,CAACP,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;MAC7B,OAAOE,QAAQ,CAACM,wBAAwB,CAAC,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO,IAAI;IACb;EACF,CAAC,EAAE,CAAC/B,IAAI,EAAEuB,KAAK,CAAC,CAAC;EACjB,OAAOZ,mBAAmB,CAACZ,OAAO,EAAEC,IAAI,CAAC;AAC3C,CAAC;AAACY,OAAA,CAAAS,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_Offscreen","_skia","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","createTexture","texture","picture","size","value","drawAsImageFromPicture","useTexture","element","width","height","setPicture","useState","useEffect","drawAsPicture","x","y","then","pic","usePictureAsTexture","exports","useTextureAsValue","console","warn","useTextureValueFromPicture","Rea","useSharedValue","runOnUI","useImageAsTexture","source","image","useImage","useMemo","recorder","Skia","PictureRecorder","canvas","beginRecording","drawImage","finishRecordingAsPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport type { ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n DataSourceParam,\n SkImage,\n SkPicture,\n SkSize,\n} from \"../../skia/types\";\nimport {\n drawAsImageFromPicture,\n drawAsPicture,\n} from \"../../renderer/Offscreen\";\nimport { Skia, useImage } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n texture.value = drawAsImageFromPicture(picture, size);\n};\n\nexport const useTexture = (element: ReactElement, size: SkSize) => {\n const { width, height } = size;\n const [picture, setPicture] = useState<SkPicture | null>(null);\n useEffect(() => {\n drawAsPicture(element, {\n x: 0,\n y: 0,\n width,\n height,\n }).then((pic) => setPicture(pic));\n }, [element, width, height]);\n return usePictureAsTexture(picture, size);\n};\n\nexport const useTextureAsValue = (element: ReactElement, size: SkSize) => {\n console.warn(\"useTextureAsValue has been renamed to use useTexture\");\n return useTexture(element, size);\n};\n\nexport const useTextureValueFromPicture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n console.warn(\n \"useTextureValueFromPicture has been renamed to use usePictureAsTexture\"\n );\n return usePictureAsTexture(picture, size);\n};\n\nexport const usePictureAsTexture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n const texture = Rea.useSharedValue<SkImage | null>(null);\n useEffect(() => {\n if (picture !== null) {\n Rea.runOnUI(createTexture)(texture, picture, size);\n }\n }, [texture, picture, size]);\n return texture;\n};\n\nexport const useImageAsTexture = (source: DataSourceParam) => {\n const image = useImage(source);\n const size = useMemo(() => {\n if (image) {\n return { width: image.width(), height: image.height() };\n }\n return { width: 0, height: 0 };\n }, [image]);\n const picture = useMemo(() => {\n if (image) {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording({\n x: 0,\n y: 0,\n width: size.width,\n height: size.height,\n });\n canvas.drawImage(image, 0, 0);\n return recorder.finishRecordingAsPicture();\n } else {\n return null;\n }\n }, [size, image]);\n return usePictureAsTexture(picture, size);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAUA,IAAAC,UAAA,GAAAD,OAAA;AAIA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAoC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,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CAAC,EAAE,CAAC,CAAC;MAC7B,OAAOG,QAAQ,CAACM,wBAAwB,CAAC,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO,IAAI;IACb;EACF,CAAC,EAAE,CAACnC,IAAI,EAAE0B,KAAK,CAAC,CAAC;EACjB,OAAOX,mBAAmB,CAAChB,OAAO,EAAEC,IAAI,CAAC;AAC3C,CAAC;AAACgB,OAAA,CAAAQ,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -5,4 +5,4 @@ export declare const makeOffscreenSurface: (width: number, height: number) => Sk
5
5
  export declare const getSkiaExports: () => {
6
6
  Skia: import("../skia/types").Skia;
7
7
  };
8
- export declare const drawOffscreen: (surface: SkSurface, element: ReactNode) => import("../skia").SkImage;
8
+ export declare const drawOffscreen: (surface: SkSurface, element: ReactNode) => Promise<import("../skia").SkImage>;
@@ -47,9 +47,9 @@ const getSkiaExports = () => {
47
47
  };
48
48
  };
49
49
  exports.getSkiaExports = getSkiaExports;
50
- const drawOffscreen = (surface, element) => {
50
+ const drawOffscreen = async (surface, element) => {
51
51
  const root = new _Reconciler.SkiaSGRoot(Skia);
52
- root.render(element);
52
+ await root.render(element);
53
53
  const canvas = surface.getCanvas();
54
54
  root.drawOnCanvas(canvas);
55
55
  root.unmount();
@@ -1 +1 @@
1
- {"version":3,"names":["_web","require","_Reconciler","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","Skia","makeOffscreenSurface","width","height","JsiSkApi","CanvasKit","surface","Surface","MakeOffscreen","Error","getSkiaExports","drawOffscreen","element","root","SkiaSGRoot","render","canvas","getCanvas","drawOnCanvas","unmount","flush","makeImageSnapshot"],"sources":["index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type { ReactNode } from \"react\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport type { SkSurface } from \"../skia\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\nexport * from \"../renderer/components\";\n\nlet Skia: ReturnType<typeof JsiSkApi>;\n\nexport const makeOffscreenSurface = (width: number, height: number) => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n const surface = Skia.Surface.MakeOffscreen(width, height);\n if (surface === null) {\n throw new Error(\"Couldn't create surface!\");\n }\n return surface;\n};\n\nexport const getSkiaExports = () => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n return { Skia };\n};\n\nexport const drawOffscreen = (surface: SkSurface, element: ReactNode) => {\n const root = new SkiaSGRoot(Skia);\n root.render(element);\n const canvas = surface.getCanvas();\n root.drawOnCanvas(canvas);\n root.unmount();\n surface.flush();\n return surface.makeImageSnapshot();\n};\n"],"mappings":";;;;;;;;;;;AAKA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AATA;AACA;;AAUA,IAAIS,IAAiC;AAE9B,MAAMC,oBAAoB,GAAGA,CAACC,KAAa,EAAEC,MAAc,KAAK;EACrE,IAAI,CAACH,IAAI,EAAE;IACTA,IAAI,GAAG,IAAAI,aAAQ,EAACC,SAAS,CAAC;EAC5B;EACA,MAAMC,OAAO,GAAGN,IAAI,CAACO,OAAO,CAACC,aAAa,CAACN,KAAK,EAAEC,MAAM,CAAC;EACzD,IAAIG,OAAO,KAAK,IAAI,EAAE;IACpB,MAAM,IAAIG,KAAK,CAAC,0BAA0B,CAAC;EAC7C;EACA,OAAOH,OAAO;AAChB,CAAC;AAACV,OAAA,CAAAK,oBAAA,GAAAA,oBAAA;AAEK,MAAMS,cAAc,GAAGA,CAAA,KAAM;EAClC,IAAI,CAACV,IAAI,EAAE;IACTA,IAAI,GAAG,IAAAI,aAAQ,EAACC,SAAS,CAAC;EAC5B;EACA,OAAO;IAAEL;EAAK,CAAC;AACjB,CAAC;AAACJ,OAAA,CAAAc,cAAA,GAAAA,cAAA;AAEK,MAAMC,aAAa,GAAGA,CAACL,OAAkB,EAAEM,OAAkB,KAAK;EACvE,MAAMC,IAAI,GAAG,IAAIC,sBAAU,CAACd,IAAI,CAAC;EACjCa,IAAI,CAACE,MAAM,CAACH,OAAO,CAAC;EACpB,MAAMI,MAAM,GAAGV,OAAO,CAACW,SAAS,CAAC,CAAC;EAClCJ,IAAI,CAACK,YAAY,CAACF,MAAM,CAAC;EACzBH,IAAI,CAACM,OAAO,CAAC,CAAC;EACdb,OAAO,CAACc,KAAK,CAAC,CAAC;EACf,OAAOd,OAAO,CAACe,iBAAiB,CAAC,CAAC;AACpC,CAAC;AAACzB,OAAA,CAAAe,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_web","require","_Reconciler","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","Skia","makeOffscreenSurface","width","height","JsiSkApi","CanvasKit","surface","Surface","MakeOffscreen","Error","getSkiaExports","drawOffscreen","element","root","SkiaSGRoot","render","canvas","getCanvas","drawOnCanvas","unmount","flush","makeImageSnapshot"],"sources":["index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type { ReactNode } from \"react\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport type { SkSurface } from \"../skia\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\nexport * from \"../renderer/components\";\n\nlet Skia: ReturnType<typeof JsiSkApi>;\n\nexport const makeOffscreenSurface = (width: number, height: number) => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n const surface = Skia.Surface.MakeOffscreen(width, height);\n if (surface === null) {\n throw new Error(\"Couldn't create surface!\");\n }\n return surface;\n};\n\nexport const getSkiaExports = () => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n return { Skia };\n};\n\nexport const drawOffscreen = async (surface: SkSurface, element: ReactNode) => {\n const root = new SkiaSGRoot(Skia);\n await root.render(element);\n const canvas = surface.getCanvas();\n root.drawOnCanvas(canvas);\n root.unmount();\n surface.flush();\n return surface.makeImageSnapshot();\n};\n"],"mappings":";;;;;;;;;;;AAKA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AATA;AACA;;AAUA,IAAIS,IAAiC;AAE9B,MAAMC,oBAAoB,GAAGA,CAACC,KAAa,EAAEC,MAAc,KAAK;EACrE,IAAI,CAACH,IAAI,EAAE;IACTA,IAAI,GAAG,IAAAI,aAAQ,EAACC,SAAS,CAAC;EAC5B;EACA,MAAMC,OAAO,GAAGN,IAAI,CAACO,OAAO,CAACC,aAAa,CAACN,KAAK,EAAEC,MAAM,CAAC;EACzD,IAAIG,OAAO,KAAK,IAAI,EAAE;IACpB,MAAM,IAAIG,KAAK,CAAC,0BAA0B,CAAC;EAC7C;EACA,OAAOH,OAAO;AAChB,CAAC;AAACV,OAAA,CAAAK,oBAAA,GAAAA,oBAAA;AAEK,MAAMS,cAAc,GAAGA,CAAA,KAAM;EAClC,IAAI,CAACV,IAAI,EAAE;IACTA,IAAI,GAAG,IAAAI,aAAQ,EAACC,SAAS,CAAC;EAC5B;EACA,OAAO;IAAEL;EAAK,CAAC;AACjB,CAAC;AAACJ,OAAA,CAAAc,cAAA,GAAAA,cAAA;AAEK,MAAMC,aAAa,GAAG,MAAAA,CAAOL,OAAkB,EAAEM,OAAkB,KAAK;EAC7E,MAAMC,IAAI,GAAG,IAAIC,sBAAU,CAACd,IAAI,CAAC;EACjC,MAAMa,IAAI,CAACE,MAAM,CAACH,OAAO,CAAC;EAC1B,MAAMI,MAAM,GAAGV,OAAO,CAACW,SAAS,CAAC,CAAC;EAClCJ,IAAI,CAACK,YAAY,CAACF,MAAM,CAAC;EACzBH,IAAI,CAACM,OAAO,CAAC,CAAC;EACdb,OAAO,CAACc,KAAK,CAAC,CAAC;EACf,OAAOd,OAAO,CAACe,iBAAiB,CAAC,CAAC;AACpC,CAAC;AAACzB,OAAA,CAAAe,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -14,7 +14,7 @@ export interface CanvasProps extends ViewProps {
14
14
  debug?: boolean;
15
15
  opaque?: boolean;
16
16
  onSize?: SharedValue<SkSize>;
17
- mode?: "continuous" | "default";
17
+ ref?: React.Ref<CanvasRef>;
18
18
  }
19
- export declare const Canvas: React.ForwardRefExoticComponent<CanvasProps & React.RefAttributes<unknown>>;
19
+ export declare const Canvas: ({ debug, opaque, children, onSize, onLayout: _onLayout, ref, ...viewProps }: CanvasProps) => React.JSX.Element;
20
20
  export {};
@@ -14,10 +14,11 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
16
16
  const useCanvasRef = () => (0, _react.useRef)(null);
17
- exports.useCanvasRef = useCanvasRef;
18
- const NativeSkiaPictureView = _SkiaPictureViewNativeComponent.default;
17
+
18
+ //const NativeSkiaPictureView = SkiaPictureViewNativeComponent;
19
19
 
20
20
  // TODO: no need to go through the JS thread for this
21
+ exports.useCanvasRef = useCanvasRef;
21
22
  const useOnSizeEvent = (resultValue, onLayout) => {
22
23
  return (0, _react.useCallback)(event => {
23
24
  if (onLayout) {
@@ -35,16 +36,15 @@ const useOnSizeEvent = (resultValue, onLayout) => {
35
36
  }
36
37
  }, [onLayout, resultValue]);
37
38
  };
38
- const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
39
- mode,
39
+ const Canvas = ({
40
40
  debug,
41
41
  opaque,
42
42
  children,
43
43
  onSize,
44
44
  onLayout: _onLayout,
45
+ ref,
45
46
  ...viewProps
46
- }, ref) => {
47
- const rafId = (0, _react.useRef)(null);
47
+ }) => {
48
48
  const onLayout = useOnSizeEvent(onSize, _onLayout);
49
49
  // Native ID
50
50
  const nativeId = (0, _react.useMemo)(() => {
@@ -63,25 +63,7 @@ const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
63
63
  root.unmount();
64
64
  };
65
65
  }, [root]);
66
- const requestRedraw = (0, _react.useCallback)(() => {
67
- rafId.current = requestAnimationFrame(() => {
68
- root.render(children);
69
- if (mode === "continuous") {
70
- requestRedraw();
71
- }
72
- });
73
- }, [children, mode, root]);
74
- (0, _react.useEffect)(() => {
75
- if (mode === "continuous") {
76
- console.warn("The `mode` property in `Canvas` is deprecated.");
77
- requestRedraw();
78
- }
79
- return () => {
80
- if (rafId.current !== null) {
81
- cancelAnimationFrame(rafId.current);
82
- }
83
- };
84
- }, [mode, requestRedraw]);
66
+
85
67
  // Component methods
86
68
  (0, _react.useImperativeHandle)(ref, () => ({
87
69
  makeImageSnapshot: rect => {
@@ -97,12 +79,13 @@ const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
97
79
  return nativeId;
98
80
  }
99
81
  }));
100
- return /*#__PURE__*/_react.default.createElement(NativeSkiaPictureView, _extends({
82
+ return /*#__PURE__*/_react.default.createElement(_SkiaPictureViewNativeComponent.default, _extends({
101
83
  collapsable: false,
102
84
  nativeID: `${nativeId}`,
103
85
  debug: debug,
104
86
  opaque: opaque,
105
87
  onLayout: onLayout
106
88
  }, viewProps));
107
- });
89
+ };
90
+ exports.Canvas = Canvas;
108
91
  //# sourceMappingURL=Canvas.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","NativeSkiaPictureView","SkiaPictureViewNativeComponent","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useEffect","render","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,I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AAiB,EAAGC,IAAa,IAAK;MACpC,OAAOC,WAAW,CAACF,iBAAiB,CAAChB,QAAQ,EAAEiB,IAAI,CAAC;IACtD,CAAC;IACDE,sBAAsB,EAAGF,IAAa,IAAK;MACzC,OAAOC,WAAW,CAACC,sBAAsB,CAACnB,QAAQ,EAAEiB,IAAI,CAAC;IAC3D,CAAC;IACDG,MAAM,EAAEA,CAAA,KAAM;MACZF,WAAW,CAACR,aAAa,CAACV,QAAQ,CAAC;IACrC,CAAC;IACDqB,WAAW,EAAEA,CAAA,KAAM;MACjB,OAAOrB,QAAQ;IACjB;EACF,CAAC,CAAC,CAAC;EACH,oBACE5D,MAAA,CAAAU,OAAA,CAAAwE,aAAA,CAAC7C,qBAAqB,EAAAT,QAAA;IACpBuD,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGxB,QAAQ,EAAG;IACxBR,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfZ,QAAQ,EAAEA;EAAS,GACfgB,SAAS,CACd,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","debug","opaque","children","onSize","_onLayout","ref","viewProps","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useEffect","render","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\n//const NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n ref?: React.Ref<CanvasRef>;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ref,\n ...viewProps\n}: CanvasProps) => {\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n } as CanvasRef)\n );\n return (\n <SkiaPictureViewNativeComponent\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAUA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,I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,IAAI,CAAC;IAC3D,CAAC;IACDG,MAAM,EAAEA,CAAA,KAAM;MACZF,WAAW,CAACG,aAAa,CAAChB,QAAQ,CAAC;IACrC,CAAC;IACDiB,WAAW,EAAEA,CAAA,KAAM;MACjB,OAAOjB,QAAQ;IACjB;EACF,CAAC,CACL,CAAC;EACD,oBACEvD,MAAA,CAAAU,OAAA,CAAA+D,aAAA,CAACrE,+BAAA,CAAAM,OAA8B,EAAAkB,QAAA;IAC7B8C,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGpB,QAAQ,EAAG;IACxBP,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfV,QAAQ,EAAEA;EAAS,GACfe,SAAS,CACd,CAAC;AAEN,CAAC;AAAClB,OAAA,CAAAW,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { ReactElement } from "react";
2
2
  import type { SkPicture, SkRect, SkSize } from "../skia/types";
3
3
  export declare const isOnMainThread: () => boolean;
4
- export declare const drawAsPicture: (element: ReactElement, bounds?: SkRect) => SkPicture;
5
- export declare const drawAsImage: (element: ReactElement, size: SkSize) => import("../skia").SkImage;
4
+ export declare const drawAsPicture: (element: ReactElement, bounds?: SkRect) => Promise<SkPicture>;
5
+ export declare const drawAsImage: (element: ReactElement, size: SkSize) => Promise<import("../skia").SkImage>;
6
6
  export declare const drawAsImageFromPicture: (picture: SkPicture, size: SkSize) => import("../skia").SkImage;