@shopify/react-native-skia 0.1.233 → 0.1.236

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniSkiaManager.cpp +0 -1
  3. package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -1
  4. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +1 -1
  5. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +1 -2
  6. package/cpp/api/JsiSkTypefaceFactory.h +2 -1
  7. package/cpp/skia/include/android/AHardwareBufferUtils.h +23 -0
  8. package/cpp/skia/include/android/GrAHardwareBufferUtils.h +2 -0
  9. package/cpp/skia/include/android/graphite/SurfaceAndroid.h +59 -0
  10. package/cpp/skia/include/codec/SkAvifDecoder.h +1 -1
  11. package/cpp/skia/include/codec/SkBmpDecoder.h +1 -1
  12. package/cpp/skia/include/codec/SkCodec.h +21 -3
  13. package/cpp/skia/include/codec/SkGifDecoder.h +1 -1
  14. package/cpp/skia/include/codec/SkIcoDecoder.h +1 -1
  15. package/cpp/skia/include/codec/SkJpegDecoder.h +1 -1
  16. package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -1
  17. package/cpp/skia/include/codec/SkPngDecoder.h +1 -1
  18. package/cpp/skia/include/codec/SkRawDecoder.h +1 -1
  19. package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -1
  20. package/cpp/skia/include/codec/SkWebpDecoder.h +1 -1
  21. package/cpp/skia/include/config/SkUserConfig.h +3 -1
  22. package/cpp/skia/include/core/SkCanvas.h +66 -37
  23. package/cpp/skia/include/core/SkColorFilter.h +5 -2
  24. package/cpp/skia/include/core/SkContourMeasure.h +1 -0
  25. package/cpp/skia/include/core/SkDocument.h +1 -0
  26. package/cpp/skia/include/core/SkFont.h +14 -24
  27. package/cpp/skia/include/core/SkFontArguments.h +1 -1
  28. package/cpp/skia/include/core/SkFontMetrics.h +1 -1
  29. package/cpp/skia/include/core/SkFontMgr.h +0 -7
  30. package/cpp/skia/include/core/SkGraphics.h +13 -0
  31. package/cpp/skia/include/core/SkMesh.h +9 -13
  32. package/cpp/skia/include/core/SkMilestone.h +1 -1
  33. package/cpp/skia/include/core/SkPathMeasure.h +2 -0
  34. package/cpp/skia/include/core/SkSerialProcs.h +29 -11
  35. package/cpp/skia/include/core/SkSize.h +3 -3
  36. package/cpp/skia/include/core/SkStream.h +3 -13
  37. package/cpp/skia/include/core/SkSurface.h +6 -3
  38. package/cpp/skia/include/core/SkSurfaceProps.h +2 -4
  39. package/cpp/skia/include/core/SkTraceMemoryDump.h +15 -0
  40. package/cpp/skia/include/core/SkTypeface.h +8 -56
  41. package/cpp/skia/include/core/SkTypes.h +8 -0
  42. package/cpp/skia/include/core/SkVertices.h +1 -1
  43. package/cpp/skia/include/docs/SkMultiPictureDocument.h +53 -0
  44. package/cpp/skia/include/docs/SkPDFDocument.h +11 -0
  45. package/cpp/skia/include/effects/SkGradientShader.h +9 -0
  46. package/cpp/skia/include/effects/SkRuntimeEffect.h +3 -7
  47. package/cpp/skia/include/gpu/GrBackendSemaphore.h +33 -47
  48. package/cpp/skia/include/gpu/GrBackendSurface.h +2 -3
  49. package/cpp/skia/include/gpu/GrContextOptions.h +0 -6
  50. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +44 -28
  51. package/cpp/skia/include/gpu/GrDirectContext.h +12 -31
  52. package/cpp/skia/include/gpu/GrTypes.h +1 -16
  53. package/cpp/skia/include/gpu/MutableTextureState.h +35 -80
  54. package/cpp/skia/include/gpu/ShaderErrorHandler.h +11 -1
  55. package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +2 -2
  56. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +1 -1
  57. package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +3 -2
  58. package/cpp/skia/include/gpu/ganesh/vk/GrVkBackendSemaphore.h +20 -0
  59. package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +30 -0
  60. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +1 -1
  61. package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -0
  62. package/cpp/skia/include/gpu/gl/glx/GrGLMakeGLXInterface.h +6 -0
  63. package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +3 -3
  64. package/cpp/skia/include/gpu/graphite/BackendTexture.h +39 -27
  65. package/cpp/skia/include/gpu/graphite/Context.h +39 -13
  66. package/cpp/skia/include/gpu/graphite/ContextOptions.h +2 -0
  67. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +2 -1
  68. package/cpp/skia/include/gpu/graphite/Image.h +106 -87
  69. package/cpp/skia/include/gpu/graphite/Recorder.h +24 -3
  70. package/cpp/skia/include/gpu/graphite/Surface.h +7 -2
  71. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +41 -2
  72. package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +11 -6
  73. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -2
  74. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +6 -6
  75. package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -0
  76. package/cpp/skia/include/gpu/vk/GrVkBackendContext.h +1 -1
  77. package/cpp/skia/include/gpu/vk/GrVkTypes.h +1 -44
  78. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
  79. package/cpp/skia/include/gpu/vk/VulkanMutableTextureState.h +25 -0
  80. package/cpp/skia/include/gpu/vk/VulkanTypes.h +44 -0
  81. package/cpp/skia/include/ports/SkFontConfigInterface.h +3 -6
  82. package/cpp/skia/include/private/SkEncodedInfo.h +5 -0
  83. package/cpp/skia/include/private/SkExif.h +102 -0
  84. package/cpp/skia/include/private/SkGainmapInfo.h +11 -1
  85. package/cpp/skia/include/private/base/SkAssert.h +16 -0
  86. package/cpp/skia/include/private/base/SkDeque.h +2 -7
  87. package/cpp/skia/include/private/base/SkLoadUserConfig.h +1 -1
  88. package/cpp/skia/include/private/base/SkTArray.h +69 -28
  89. package/cpp/skia/include/private/base/SkThreadAnnotations.h +18 -5
  90. package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +26 -30
  91. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +4 -3
  92. package/cpp/skia/include/private/chromium/SkImageChromium.h +1 -1
  93. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +8 -6
  94. package/cpp/skia/include/private/gpu/graphite/ContextOptionsPriv.h +29 -0
  95. package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +12 -9
  96. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +16 -11
  97. package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -2
  98. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +312 -0
  99. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +77 -0
  100. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +446 -0
  101. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +67 -0
  102. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +36 -0
  103. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +9 -2
  104. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +31 -3
  105. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +10624 -5716
  106. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +2 -1
  107. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +2 -1
  108. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +28 -1
  109. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +2 -1
  110. package/cpp/skia/include/utils/mac/SkCGUtils.h +23 -11
  111. package/cpp/skia/modules/skcms/skcms.h +2 -410
  112. package/cpp/skia/modules/skcms/src/Transform_inl.h +831 -704
  113. package/cpp/skia/modules/skcms/src/skcms_Transform.h +161 -0
  114. package/cpp/skia/modules/skcms/src/skcms_internals.h +136 -0
  115. package/cpp/skia/modules/skcms/src/skcms_public.h +404 -0
  116. package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
  117. package/cpp/skia/modules/skparagraph/include/FontCollection.h +2 -0
  118. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
  119. package/cpp/skia/modules/skparagraph/include/TextStyle.h +4 -3
  120. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -3
  121. package/cpp/skia/modules/skresources/include/SkResources.h +28 -17
  122. package/cpp/skia/modules/skunicode/include/SkUnicode.h +12 -0
  123. package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -1
  124. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +4 -1
  125. package/cpp/skia/src/base/SkUTF.h +7 -0
  126. package/cpp/skia/src/core/SkTHash.h +20 -8
  127. package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +3 -2
  128. package/lib/commonjs/dom/nodes/JsiSkDOM.js +56 -57
  129. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  130. package/lib/commonjs/external/reanimated/index.d.ts +1 -0
  131. package/lib/commonjs/external/reanimated/index.js +13 -0
  132. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  133. package/lib/commonjs/external/reanimated/interpolators.js +16 -2
  134. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  135. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +1 -0
  136. package/lib/commonjs/external/reanimated/moduleWrapper.js +5 -3
  137. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  138. package/lib/commonjs/external/reanimated/textures.d.ts +5 -0
  139. package/lib/commonjs/external/reanimated/textures.js +52 -0
  140. package/lib/commonjs/external/reanimated/textures.js.map +1 -0
  141. package/lib/commonjs/headless/index.js +1 -1
  142. package/lib/commonjs/headless/index.js.map +1 -1
  143. package/lib/commonjs/mock/index.js +3 -0
  144. package/lib/commonjs/mock/index.js.map +1 -1
  145. package/lib/commonjs/renderer/Canvas.js +6 -5
  146. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  147. package/lib/commonjs/renderer/Container.d.ts +1 -1
  148. package/lib/commonjs/renderer/Container.js +2 -1
  149. package/lib/commonjs/renderer/Container.js.map +1 -1
  150. package/lib/commonjs/renderer/Offscreen.d.ts +1 -0
  151. package/lib/commonjs/renderer/Offscreen.js +18 -5
  152. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  153. package/lib/commonjs/renderer/Reconciler.d.ts +1 -1
  154. package/lib/commonjs/renderer/Reconciler.js +7 -4
  155. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  156. package/lib/commonjs/skia/types/Matrix4.d.ts +2 -2
  157. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  158. package/lib/commonjs/skia/types/Shader/Shader.d.ts +1 -1
  159. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  160. package/lib/commonjs/skia/web/JsiSkPath.d.ts +2 -2
  161. package/lib/commonjs/skia/web/JsiSkPath.js +10 -2
  162. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  163. package/lib/commonjs/views/SkiaJSDomView.d.ts +31 -0
  164. package/lib/commonjs/views/SkiaJSDomView.js +161 -0
  165. package/lib/commonjs/views/SkiaJSDomView.js.map +1 -0
  166. package/lib/commonjs/views/SkiaJSDomView.web.d.ts +1 -0
  167. package/lib/commonjs/views/SkiaJSDomView.web.js +14 -0
  168. package/lib/commonjs/views/SkiaJSDomView.web.js.map +1 -0
  169. package/lib/module/dom/nodes/JsiSkDOM.d.ts +3 -2
  170. package/lib/module/dom/nodes/JsiSkDOM.js +56 -56
  171. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  172. package/lib/module/external/reanimated/index.d.ts +1 -0
  173. package/lib/module/external/reanimated/index.js +1 -0
  174. package/lib/module/external/reanimated/index.js.map +1 -1
  175. package/lib/module/external/reanimated/interpolators.js +15 -2
  176. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  177. package/lib/module/external/reanimated/moduleWrapper.d.ts +1 -0
  178. package/lib/module/external/reanimated/moduleWrapper.js +3 -2
  179. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  180. package/lib/module/external/reanimated/textures.d.ts +5 -0
  181. package/lib/module/external/reanimated/textures.js +35 -0
  182. package/lib/module/external/reanimated/textures.js.map +1 -0
  183. package/lib/module/headless/index.js +1 -1
  184. package/lib/module/headless/index.js.map +1 -1
  185. package/lib/module/mock/index.js +3 -0
  186. package/lib/module/mock/index.js.map +1 -1
  187. package/lib/module/renderer/Canvas.js +5 -4
  188. package/lib/module/renderer/Canvas.js.map +1 -1
  189. package/lib/module/renderer/Container.d.ts +1 -1
  190. package/lib/module/renderer/Container.js +2 -1
  191. package/lib/module/renderer/Container.js.map +1 -1
  192. package/lib/module/renderer/Offscreen.d.ts +1 -0
  193. package/lib/module/renderer/Offscreen.js +11 -3
  194. package/lib/module/renderer/Offscreen.js.map +1 -1
  195. package/lib/module/renderer/Reconciler.d.ts +1 -1
  196. package/lib/module/renderer/Reconciler.js +7 -4
  197. package/lib/module/renderer/Reconciler.js.map +1 -1
  198. package/lib/module/skia/types/Matrix4.d.ts +2 -2
  199. package/lib/module/skia/types/Matrix4.js.map +1 -1
  200. package/lib/module/skia/types/Shader/Shader.d.ts +1 -1
  201. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  202. package/lib/module/skia/web/JsiSkPath.d.ts +2 -2
  203. package/lib/module/skia/web/JsiSkPath.js +10 -2
  204. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  205. package/lib/module/views/SkiaJSDomView.d.ts +31 -0
  206. package/lib/module/views/SkiaJSDomView.js +136 -0
  207. package/lib/module/views/SkiaJSDomView.js.map +1 -0
  208. package/lib/module/views/SkiaJSDomView.web.d.ts +1 -0
  209. package/lib/module/views/SkiaJSDomView.web.js +2 -0
  210. package/lib/module/views/SkiaJSDomView.web.js.map +1 -0
  211. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +3 -2
  212. package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
  213. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +1 -0
  214. package/lib/typescript/src/external/reanimated/textures.d.ts +5 -0
  215. package/lib/typescript/src/renderer/Container.d.ts +1 -1
  216. package/lib/typescript/src/renderer/Offscreen.d.ts +1 -0
  217. package/lib/typescript/src/renderer/Reconciler.d.ts +1 -1
  218. package/lib/typescript/src/skia/types/Matrix4.d.ts +2 -2
  219. package/lib/typescript/src/skia/types/Shader/Shader.d.ts +1 -1
  220. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +2 -2
  221. package/lib/typescript/src/views/SkiaJSDomView.d.ts +31 -0
  222. package/lib/typescript/src/views/SkiaJSDomView.web.d.ts +1 -0
  223. package/libs/android/arm64-v8a/libskia.a +0 -0
  224. package/libs/android/arm64-v8a/libskottie.a +0 -0
  225. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  226. package/libs/android/arm64-v8a/libsksg.a +0 -0
  227. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  228. package/libs/android/arm64-v8a/libskunicode.a +0 -0
  229. package/libs/android/arm64-v8a/libsvg.a +0 -0
  230. package/libs/android/armeabi-v7a/libskia.a +0 -0
  231. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  232. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  233. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  234. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  235. package/libs/android/armeabi-v7a/libskunicode.a +0 -0
  236. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  237. package/libs/android/x86/libskia.a +0 -0
  238. package/libs/android/x86/libskottie.a +0 -0
  239. package/libs/android/x86/libskparagraph.a +0 -0
  240. package/libs/android/x86/libsksg.a +0 -0
  241. package/libs/android/x86/libskshaper.a +0 -0
  242. package/libs/android/x86/libskunicode.a +0 -0
  243. package/libs/android/x86/libsvg.a +0 -0
  244. package/libs/android/x86_64/libskia.a +0 -0
  245. package/libs/android/x86_64/libskottie.a +0 -0
  246. package/libs/android/x86_64/libskparagraph.a +0 -0
  247. package/libs/android/x86_64/libsksg.a +0 -0
  248. package/libs/android/x86_64/libskshaper.a +0 -0
  249. package/libs/android/x86_64/libskunicode.a +0 -0
  250. package/libs/android/x86_64/libsvg.a +0 -0
  251. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  252. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  253. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  254. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  255. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  256. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  257. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  258. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  259. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  260. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  261. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  262. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  263. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  264. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  265. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  266. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  267. package/package.json +1 -1
  268. package/src/dom/nodes/JsiSkDOM.ts +55 -56
  269. package/src/external/reanimated/index.ts +1 -0
  270. package/src/external/reanimated/interpolators.ts +17 -3
  271. package/src/external/reanimated/moduleWrapper.ts +1 -0
  272. package/src/external/reanimated/textures.tsx +50 -0
  273. package/src/headless/index.ts +1 -1
  274. package/src/mock/index.ts +3 -0
  275. package/src/renderer/Canvas.tsx +4 -3
  276. package/src/renderer/Container.tsx +3 -2
  277. package/src/renderer/Offscreen.tsx +12 -3
  278. package/src/renderer/Reconciler.tsx +5 -2
  279. package/src/skia/types/Matrix4.ts +2 -2
  280. package/src/skia/types/Shader/Shader.ts +6 -1
  281. package/src/skia/web/JsiSkPath.ts +23 -3
  282. package/src/views/SkiaJSDomView.tsx +126 -0
  283. package/src/views/SkiaJSDomView.web.tsx +1 -0
  284. package/android/cpp/jni/include/JniSkiaDrawView.h +0 -90
  285. package/cpp/rnskia/RNSkJsView.cpp +0 -236
  286. package/cpp/rnskia/RNSkJsView.h +0 -121
  287. package/cpp/skia/include/gpu/GrSurfaceInfo.h +0 -142
  288. package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +0 -107
  289. package/cpp/skia/include/private/gpu/ganesh/GrMockTypesPriv.h +0 -32
  290. package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +0 -83
  291. package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +0 -47
  292. package/cpp/skia/include/private/gpu/vk/VulkanTypesPriv.h +0 -57
  293. package/cpp/skia/include/utils/SkBase64.h +0 -53
  294. package/cpp/skia/modules/skcms/skcms_internal.h +0 -56
@@ -1,4 +1,4 @@
1
- import type { CanvasKit, Path } from "canvaskit-wasm";
1
+ import type { CanvasKit, Matrix3x3, Path } from "canvaskit-wasm";
2
2
 
3
3
  import { PathVerb } from "../types";
4
4
  import type {
@@ -11,6 +11,7 @@ import type {
11
11
  SkRect,
12
12
  InputRRect,
13
13
  StrokeOpts,
14
+ InputMatrix,
14
15
  } from "../types";
15
16
 
16
17
  import { getEnum, HostObject, optEnum } from "./Host";
@@ -339,8 +340,27 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
339
340
  return result === null ? result : this;
340
341
  }
341
342
 
342
- transform(m3: SkMatrix) {
343
- this.ref.transform(Array.isArray(m3) ? m3 : JsiSkMatrix.fromValue(m3));
343
+ transform(m: InputMatrix) {
344
+ let matrix =
345
+ m instanceof JsiSkMatrix
346
+ ? Array.from(JsiSkMatrix.fromValue<Matrix3x3>(m))
347
+ : (m as Exclude<InputMatrix, SkMatrix>);
348
+ if (matrix.length === 16) {
349
+ matrix = [
350
+ matrix[0],
351
+ matrix[1],
352
+ matrix[3],
353
+ matrix[4],
354
+ matrix[5],
355
+ matrix[7],
356
+ matrix[12],
357
+ matrix[13],
358
+ matrix[15],
359
+ ];
360
+ } else if (matrix.length !== 9) {
361
+ throw new Error(`Invalid matrix length: ${matrix.length}`);
362
+ }
363
+ this.ref.transform(matrix);
344
364
  return this;
345
365
  }
346
366
 
@@ -0,0 +1,126 @@
1
+ import React from "react";
2
+ import type { HostComponent } from "react-native";
3
+
4
+ import type { Skia, SkRect } from "../skia/types";
5
+ import { Platform } from "../Platform";
6
+ import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent";
7
+ import { JsiDrawingContext } from "../dom/types";
8
+
9
+ import { SkiaViewApi } from "./api";
10
+ import type { SkiaPictureViewProps, SkiaDomViewProps } from "./types";
11
+ import { SkiaViewNativeId } from "./SkiaViewNativeId";
12
+
13
+ const NativeSkiaPictureView: HostComponent<SkiaPictureViewProps> =
14
+ Platform.OS !== "web"
15
+ ? SkiaPictureViewNativeComponent
16
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ (null as any);
18
+
19
+ export class SkiaJSDomView extends React.Component<
20
+ SkiaDomViewProps & { Skia: Skia }
21
+ > {
22
+ constructor(props: SkiaDomViewProps & { Skia: Skia }) {
23
+ super(props);
24
+ this._nativeId = SkiaViewNativeId.current++;
25
+ const { root, onTouch, onSize } = props;
26
+ if (root) {
27
+ assertSkiaViewApi();
28
+ SkiaViewApi.setJsiProperty(this._nativeId, "root", root);
29
+ }
30
+ if (onTouch) {
31
+ assertSkiaViewApi();
32
+ SkiaViewApi.setJsiProperty(this._nativeId, "onTouch", onTouch);
33
+ }
34
+ if (onSize) {
35
+ assertSkiaViewApi();
36
+ SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
37
+ }
38
+ }
39
+
40
+ private _nativeId: number;
41
+
42
+ public get nativeId() {
43
+ return this._nativeId;
44
+ }
45
+
46
+ componentDidUpdate(prevProps: SkiaDomViewProps & { Skia: Skia }) {
47
+ const { root, onTouch, onSize } = this.props;
48
+ if (root !== prevProps.root && root !== undefined) {
49
+ assertSkiaViewApi();
50
+ this.draw();
51
+ }
52
+ if (onTouch !== prevProps.onTouch) {
53
+ assertSkiaViewApi();
54
+ SkiaViewApi.setJsiProperty(this._nativeId, "onTouch", onTouch);
55
+ }
56
+ if (onSize !== prevProps.onSize) {
57
+ assertSkiaViewApi();
58
+ SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Creates a snapshot from the canvas in the surface
64
+ * @param rect Rect to use as bounds. Optional.
65
+ * @returns An Image object.
66
+ */
67
+ public makeImageSnapshot(rect?: SkRect) {
68
+ assertSkiaViewApi();
69
+ return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);
70
+ }
71
+
72
+ /**
73
+ * Sends a redraw request to the native SkiaView.
74
+ */
75
+ public redraw() {
76
+ assertSkiaViewApi();
77
+ this.draw();
78
+ //SkiaViewApi.requestRedraw(this._nativeId);
79
+ }
80
+
81
+ private draw() {
82
+ const { root, Skia } = this.props;
83
+ if (root !== undefined) {
84
+ assertSkiaViewApi();
85
+ const rec = Skia.PictureRecorder();
86
+ const canvas = rec.beginRecording();
87
+ const ctx = new JsiDrawingContext(Skia, canvas);
88
+ root.render(ctx);
89
+ const picture = rec.finishRecordingAsPicture();
90
+ SkiaViewApi.setJsiProperty(this._nativeId, "picture", picture);
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Clear up the dom node when unmounting to release resources.
96
+ */
97
+ componentWillUnmount(): void {
98
+ assertSkiaViewApi();
99
+ SkiaViewApi.setJsiProperty(this._nativeId, "picture", null);
100
+ }
101
+
102
+ render() {
103
+ const { mode, debug = false, ...viewProps } = this.props;
104
+ return (
105
+ <NativeSkiaPictureView
106
+ collapsable={false}
107
+ nativeID={`${this._nativeId}`}
108
+ mode={mode}
109
+ debug={debug}
110
+ {...viewProps}
111
+ />
112
+ );
113
+ }
114
+ }
115
+
116
+ const assertSkiaViewApi = () => {
117
+ if (
118
+ SkiaViewApi === null ||
119
+ SkiaViewApi.setJsiProperty === null ||
120
+ SkiaViewApi.callJsiMethod === null ||
121
+ SkiaViewApi.requestRedraw === null ||
122
+ SkiaViewApi.makeImageSnapshot === null
123
+ ) {
124
+ throw Error("Skia View Api was not found.");
125
+ }
126
+ };
@@ -0,0 +1 @@
1
+ export { SkiaDomView as SkiaJSDomView } from "./SkiaDomView";
@@ -1,90 +0,0 @@
1
- #pragma once
2
-
3
- #include <memory>
4
- #include <string>
5
-
6
- #include <fbjni/fbjni.h>
7
- #include <jni.h>
8
- #include <jsi/jsi.h>
9
-
10
- #include <JniSkiaBaseView.h>
11
- #include <JniSkiaManager.h>
12
- #include <RNSkAndroidView.h>
13
- #include <RNSkJsView.h>
14
-
15
- #include <android/native_window.h>
16
- #include <android/native_window_jni.h>
17
- #include <fbjni/detail/Hybrid.h>
18
-
19
- namespace RNSkia {
20
- namespace jsi = facebook::jsi;
21
- namespace jni = facebook::jni;
22
-
23
- class JniSkiaDrawView : public jni::HybridClass<JniSkiaDrawView>,
24
- public JniSkiaBaseView {
25
- public:
26
- static auto constexpr kJavaDescriptor =
27
- "Lcom/shopify/reactnative/skia/SkiaDrawView;";
28
-
29
- static jni::local_ref<jhybriddata>
30
- initHybrid(jni::alias_ref<jhybridobject> jThis,
31
- jni::alias_ref<JniSkiaManager::javaobject> skiaManager) {
32
- return makeCxxInstance(jThis, skiaManager);
33
- }
34
-
35
- static void registerNatives() {
36
- registerHybrid(
37
- {makeNativeMethod("initHybrid", JniSkiaDrawView::initHybrid),
38
- makeNativeMethod("surfaceAvailable",
39
- JniSkiaDrawView::surfaceAvailable),
40
- makeNativeMethod("surfaceDestroyed",
41
- JniSkiaDrawView::surfaceDestroyed),
42
- makeNativeMethod("surfaceSizeChanged",
43
- JniSkiaDrawView::surfaceSizeChanged),
44
- makeNativeMethod("setMode", JniSkiaDrawView::setMode),
45
- makeNativeMethod("setDebugMode", JniSkiaDrawView::setDebugMode),
46
- makeNativeMethod("updateTouchPoints",
47
- JniSkiaDrawView::updateTouchPoints),
48
- makeNativeMethod("registerView", JniSkiaDrawView::registerView),
49
- makeNativeMethod("unregisterView", JniSkiaDrawView::unregisterView)});
50
- }
51
-
52
- protected:
53
- void updateTouchPoints(jni::JArrayDouble touches) override {
54
- JniSkiaBaseView::updateTouchPoints(touches);
55
- }
56
-
57
- void surfaceAvailable(jobject surface, int width, int height) override {
58
- JniSkiaBaseView::surfaceAvailable(surface, width, height);
59
- }
60
-
61
- void surfaceSizeChanged(int width, int height) override {
62
- JniSkiaBaseView::surfaceSizeChanged(width, height);
63
- }
64
-
65
- void surfaceDestroyed() override { JniSkiaBaseView::surfaceDestroyed(); }
66
-
67
- void setMode(std::string mode) override { JniSkiaBaseView::setMode(mode); }
68
-
69
- void setDebugMode(bool show) override { JniSkiaBaseView::setDebugMode(show); }
70
-
71
- void registerView(int nativeId) override {
72
- JniSkiaBaseView::registerView(nativeId);
73
- }
74
-
75
- void unregisterView() override { JniSkiaBaseView::unregisterView(); }
76
-
77
- private:
78
- friend HybridBase;
79
-
80
- explicit JniSkiaDrawView(
81
- jni::alias_ref<jhybridobject> jThis,
82
- jni::alias_ref<JniSkiaManager::javaobject> skiaManager)
83
- : JniSkiaBaseView(skiaManager,
84
- std::make_shared<RNSkAndroidView<RNSkia::RNSkJsView>>(
85
- skiaManager->cthis()->getPlatformContext())) {}
86
-
87
- jni::global_ref<javaobject> javaPart_;
88
- };
89
-
90
- } // namespace RNSkia
@@ -1,236 +0,0 @@
1
- #include <utility>
2
-
3
- #include "RNSkJsView.h"
4
-
5
- namespace RNSkia {
6
-
7
- RNSkJsRenderer::RNSkJsRenderer(std::function<void()> requestRedraw,
8
- std::shared_ptr<RNSkPlatformContext> context)
9
- : RNSkRenderer(requestRedraw),
10
- _jsiCanvas(std::make_shared<JsiSkCanvas>(context)),
11
- _platformContext(context),
12
- _infoObject(std::make_shared<RNSkInfoObject>()),
13
- _jsDrawingLock(std::make_shared<std::timed_mutex>()),
14
- _gpuDrawingLock(std::make_shared<std::timed_mutex>()),
15
- _jsTimingInfo("SKIA/JS"), _gpuTimingInfo("SKIA/GPU") {}
16
-
17
- bool RNSkJsRenderer::tryRender(
18
- std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
19
- // We render on the javascript thread.
20
- if (_jsDrawingLock->try_lock()) {
21
- _platformContext->runOnJavascriptThread(
22
- [weakSelf = weak_from_this(), canvasProvider]() {
23
- auto self = weakSelf.lock();
24
- if (self) {
25
- self->performDraw(canvasProvider);
26
- }
27
- });
28
- return true;
29
- } else {
30
- #ifdef DEBUG
31
- _jsTimingInfo.markSkipped();
32
- #endif
33
- return false;
34
- }
35
- }
36
-
37
- void RNSkJsRenderer::renderImmediate(
38
- std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
39
- // Get start time to be able to calculate animations etc.
40
- std::chrono::milliseconds ms =
41
- std::chrono::duration_cast<std::chrono::milliseconds>(
42
- std::chrono::system_clock::now().time_since_epoch());
43
-
44
- std::condition_variable cv;
45
- std::mutex m;
46
- std::unique_lock<std::mutex> lock(m);
47
-
48
- // We need to render on the javascript thread but block
49
- // until we're done rendering. Render immediate is used
50
- // to make images from the canvas.
51
- _platformContext->runOnJavascriptThread([canvasProvider, ms, &cv, &m,
52
- weakSelf = weak_from_this()]() {
53
- // Lock
54
- std::unique_lock<std::mutex> lock(m);
55
-
56
- auto self = weakSelf.lock();
57
- if (self) {
58
- canvasProvider->renderToCanvas([self, ms,
59
- canvasProvider](SkCanvas *canvas) {
60
- // Create jsi canvas
61
- auto jsiCanvas = std::make_shared<JsiSkCanvas>(self->_platformContext);
62
- jsiCanvas->setCanvas(canvas);
63
-
64
- self->drawInJsiCanvas(
65
- std::move(jsiCanvas), canvasProvider->getScaledWidth(),
66
- canvasProvider->getScaledHeight(), ms.count() / 1000);
67
- });
68
- }
69
-
70
- cv.notify_one();
71
- });
72
-
73
- cv.wait(lock);
74
- }
75
-
76
- void RNSkJsRenderer::setDrawCallback(
77
- std::shared_ptr<jsi::Function> drawCallback) {
78
- _drawCallback = drawCallback;
79
- }
80
-
81
- std::shared_ptr<RNSkInfoObject> RNSkJsRenderer::getInfoObject() {
82
- return _infoObject;
83
- }
84
-
85
- void RNSkJsRenderer::performDraw(
86
- std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
87
- // Start timing
88
- _jsTimingInfo.beginTiming();
89
-
90
- // Record the drawing operations on the JS thread so that we can
91
- // move the actual drawing onto the render thread later
92
- SkPictureRecorder recorder;
93
- SkRTreeFactory factory;
94
- SkCanvas *canvas =
95
- recorder.beginRecording(canvasProvider->getScaledWidth(),
96
- canvasProvider->getScaledHeight(), &factory);
97
-
98
- _jsiCanvas->setCanvas(canvas);
99
-
100
- // Get current milliseconds
101
- std::chrono::milliseconds ms =
102
- std::chrono::duration_cast<std::chrono::milliseconds>(
103
- std::chrono::system_clock::now().time_since_epoch());
104
-
105
- try {
106
- // Perform the javascript drawing
107
- drawInJsiCanvas(_jsiCanvas, canvasProvider->getScaledWidth(),
108
- canvasProvider->getScaledHeight(), ms.count() / 1000.0);
109
-
110
- } catch (...) {
111
- _jsTimingInfo.stopTiming();
112
- _jsDrawingLock->unlock();
113
- throw;
114
- }
115
-
116
- // Finish drawing operations
117
- auto p = recorder.finishRecordingAsPicture();
118
-
119
- _jsiCanvas->setCanvas(nullptr);
120
-
121
- // Calculate duration
122
- _jsTimingInfo.stopTiming();
123
-
124
- if (_gpuDrawingLock->try_lock()) {
125
-
126
- // Post drawing message to the main thread where the picture recorded
127
- // will be sent to the GPU/backend for rendering to screen.
128
- // TODO: Which thread should we render on? I think it should be main thread!
129
- auto gpuLock = _gpuDrawingLock;
130
- _platformContext->runOnMainThread([weakSelf = weak_from_this(),
131
- p = std::move(p), gpuLock,
132
- canvasProvider]() {
133
- auto self = weakSelf.lock();
134
- if (self) {
135
- // Draw the picture recorded on the real GPU canvas
136
- self->_gpuTimingInfo.beginTiming();
137
-
138
- canvasProvider->renderToCanvas(
139
- [p = std::move(p)](SkCanvas *canvas) { canvas->drawPicture(p); });
140
-
141
- self->_gpuTimingInfo.stopTiming();
142
- }
143
- // Unlock GPU drawing
144
- gpuLock->unlock();
145
- });
146
- } else {
147
- #ifdef DEBUG
148
- _gpuTimingInfo.markSkipped();
149
- #endif
150
- // Request a new redraw since the last frame was skipped.
151
- _requestRedraw();
152
- }
153
-
154
- // Unlock JS drawing
155
- _jsDrawingLock->unlock();
156
- }
157
-
158
- void RNSkJsRenderer::callJsDrawCallback(std::shared_ptr<JsiSkCanvas> jsiCanvas,
159
- int width, int height,
160
- double timestamp) {
161
-
162
- if (_drawCallback == nullptr) {
163
- return;
164
- }
165
-
166
- // Reset timing info
167
- _jsTimingInfo.reset();
168
- _gpuTimingInfo.reset();
169
-
170
- auto runtime = _platformContext->getJsRuntime();
171
-
172
- // Update info parameter
173
- _infoObject->beginDrawOperation(width, height, timestamp);
174
-
175
- // Set up arguments array
176
- std::vector<jsi::Value> args(2);
177
- args[0] = jsi::Object::createFromHostObject(*runtime, jsiCanvas);
178
- args[1] = jsi::Object::createFromHostObject(*runtime, _infoObject);
179
-
180
- // To be able to call the drawing function we'll wrap it once again
181
- _drawCallback->call(*runtime, static_cast<const jsi::Value *>(args.data()),
182
- static_cast<size_t>(2));
183
-
184
- // Reset touches
185
- _infoObject->endDrawOperation();
186
-
187
- // Draw debug overlays
188
- if (getShowDebugOverlays()) {
189
-
190
- // Display average rendering timer
191
- auto jsAvg = _jsTimingInfo.getAverage();
192
- // auto jsFps = _jsTimingInfo.getFps();
193
-
194
- auto gpuAvg = _gpuTimingInfo.getAverage();
195
- // auto gpuFps = _gpuTimingInfo.getFps();
196
-
197
- auto total = jsAvg + gpuAvg;
198
-
199
- // Build string
200
- std::ostringstream stream;
201
- stream << "js: " << jsAvg << "ms gpu: " << gpuAvg << "ms "
202
- << " total: " << total << "ms";
203
-
204
- std::string debugString = stream.str();
205
-
206
- // Set up debug font/paints
207
- auto font = SkFont();
208
- font.setSize(14);
209
- auto paint = SkPaint();
210
- paint.setColor(SkColors::kRed);
211
- jsiCanvas->getCanvas()->drawSimpleText(
212
- debugString.c_str(), debugString.size(), SkTextEncoding::kUTF8, 8, 18,
213
- font, paint);
214
- }
215
- }
216
-
217
- void RNSkJsRenderer::drawInJsiCanvas(std::shared_ptr<JsiSkCanvas> jsiCanvas,
218
- int width, int height, double time) {
219
-
220
- // Call the draw drawCallback and perform js based drawing
221
- auto skCanvas = jsiCanvas->getCanvas();
222
- if (_drawCallback != nullptr && skCanvas != nullptr) {
223
- // Make sure to scale correctly
224
- auto pd = _platformContext->getPixelDensity();
225
- skCanvas->clear(SK_ColorTRANSPARENT);
226
- skCanvas->save();
227
- skCanvas->scale(pd, pd);
228
-
229
- // Call draw function.
230
- callJsDrawCallback(jsiCanvas, width / pd, height / pd, time);
231
-
232
- skCanvas->restore();
233
- }
234
- }
235
-
236
- } // namespace RNSkia
@@ -1,121 +0,0 @@
1
- #pragma once
2
-
3
- #include <functional>
4
- #include <memory>
5
- #include <mutex>
6
- #include <string>
7
- #include <unordered_map>
8
- #include <vector>
9
-
10
- #include <jsi/jsi.h>
11
-
12
- #include "JsiValueWrapper.h"
13
- #include "RNSkView.h"
14
-
15
- #include "JsiSkCanvas.h"
16
- #include "RNSkInfoParameter.h"
17
- #include "RNSkLog.h"
18
- #include "RNSkPlatformContext.h"
19
- #include "RNSkTimingInfo.h"
20
-
21
- #pragma clang diagnostic push
22
- #pragma clang diagnostic ignored "-Wdocumentation"
23
-
24
- #include "SkBBHFactory.h"
25
- #include "SkCanvas.h"
26
- #include "SkPictureRecorder.h"
27
-
28
- #pragma clang diagnostic pop
29
-
30
- class SkPicture;
31
- class SkRect;
32
- class SkImage;
33
-
34
- namespace RNSkia {
35
- class JsiSkCanvas;
36
- namespace jsi = facebook::jsi;
37
-
38
- class RNSkJsRenderer : public RNSkRenderer,
39
- public std::enable_shared_from_this<RNSkJsRenderer> {
40
- public:
41
- RNSkJsRenderer(std::function<void()> requestRedraw,
42
- std::shared_ptr<RNSkPlatformContext> context);
43
-
44
- bool tryRender(std::shared_ptr<RNSkCanvasProvider> canvasProvider) override;
45
-
46
- void
47
- renderImmediate(std::shared_ptr<RNSkCanvasProvider> canvasProvider) override;
48
-
49
- void setDrawCallback(std::shared_ptr<jsi::Function> drawCallback);
50
-
51
- std::shared_ptr<RNSkInfoObject> getInfoObject();
52
-
53
- private:
54
- void performDraw(std::shared_ptr<RNSkCanvasProvider> canvasProvider);
55
-
56
- void callJsDrawCallback(std::shared_ptr<JsiSkCanvas> jsiCanvas, int width,
57
- int height, double timestamp);
58
-
59
- void drawInJsiCanvas(std::shared_ptr<JsiSkCanvas> jsiCanvas, int width,
60
- int height, double time);
61
-
62
- std::shared_ptr<RNSkPlatformContext> _platformContext;
63
- std::shared_ptr<jsi::Function> _drawCallback;
64
- std::shared_ptr<JsiSkCanvas> _jsiCanvas;
65
- std::shared_ptr<std::timed_mutex> _jsDrawingLock;
66
- std::shared_ptr<std::timed_mutex> _gpuDrawingLock;
67
- std::shared_ptr<RNSkInfoObject> _infoObject;
68
- RNSkTimingInfo _jsTimingInfo;
69
- RNSkTimingInfo _gpuTimingInfo;
70
- };
71
-
72
- class RNSkJsView : public RNSkView {
73
- public:
74
- /**
75
- * Constructor
76
- */
77
- RNSkJsView(std::shared_ptr<RNSkPlatformContext> context,
78
- std::shared_ptr<RNSkCanvasProvider> canvasProvider)
79
- : RNSkView(context, canvasProvider,
80
- std::make_shared<RNSkJsRenderer>(
81
- std::bind(&RNSkJsView::requestRedraw, this), context)) {}
82
-
83
- void updateTouchState(std::vector<RNSkTouchInfo> &touches) override {
84
- std::static_pointer_cast<RNSkJsRenderer>(getRenderer())
85
- ->getInfoObject()
86
- ->updateTouches(touches);
87
- RNSkView::updateTouchState(touches);
88
- }
89
-
90
- void setJsiProperties(
91
- std::unordered_map<std::string, RNJsi::JsiValueWrapper> &props) override {
92
-
93
- RNSkView::setJsiProperties(props);
94
-
95
- for (auto &prop : props) {
96
- if (prop.first == "drawCallback") {
97
- if (prop.second.isUndefinedOrNull()) {
98
- // Clear drawcallback
99
- std::static_pointer_cast<RNSkJsRenderer>(getRenderer())
100
- ->setDrawCallback(nullptr);
101
- requestRedraw();
102
- continue;
103
-
104
- } else if (prop.second.getType() !=
105
- RNJsi::JsiWrapperValueType::Function) {
106
- // We expect a function for the draw callback custom property
107
- throw std::runtime_error(
108
- "Expected a function for the drawCallback custom property.");
109
- }
110
-
111
- // Save callback
112
- std::static_pointer_cast<RNSkJsRenderer>(getRenderer())
113
- ->setDrawCallback(prop.second.getAsFunction());
114
-
115
- // Request redraw
116
- requestRedraw();
117
- }
118
- }
119
- }
120
- };
121
- } // namespace RNSkia