@shopify/react-native-skia 2.9.1 → 2.10.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 (387) hide show
  1. package/android/CMakeLists.txt +8 -46
  2. package/android/build.gradle +33 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
  4. package/cpp/api/JsiNativeBuffer.h +23 -24
  5. package/cpp/api/JsiSkAnimatedImage.h +24 -25
  6. package/cpp/api/JsiSkAnimatedImageFactory.h +18 -17
  7. package/cpp/api/JsiSkApi.h +254 -96
  8. package/cpp/api/JsiSkCanvas.h +141 -266
  9. package/cpp/api/JsiSkColor.h +7 -5
  10. package/cpp/api/JsiSkColorFilter.h +15 -8
  11. package/cpp/api/JsiSkColorFilterFactory.h +49 -67
  12. package/cpp/api/JsiSkContourMeasure.h +31 -38
  13. package/cpp/api/JsiSkContourMeasureIter.h +20 -23
  14. package/cpp/api/JsiSkConverters.h +410 -0
  15. package/cpp/api/JsiSkData.h +13 -7
  16. package/cpp/api/JsiSkDataFactory.h +27 -32
  17. package/cpp/api/JsiSkFont.h +123 -192
  18. package/cpp/api/JsiSkFontMgr.h +33 -26
  19. package/cpp/api/JsiSkFontMgrFactory.h +12 -11
  20. package/cpp/api/JsiSkFontStyle.h +14 -12
  21. package/cpp/api/JsiSkImage.h +90 -79
  22. package/cpp/api/JsiSkImageFactory.h +93 -95
  23. package/cpp/api/JsiSkImageFilter.h +21 -11
  24. package/cpp/api/JsiSkImageFilterFactory.h +375 -629
  25. package/cpp/api/JsiSkImageInfo.h +25 -25
  26. package/cpp/api/JsiSkMaskFilter.h +21 -11
  27. package/cpp/api/JsiSkMaskFilterFactory.h +17 -17
  28. package/cpp/api/JsiSkMatrix.h +51 -88
  29. package/cpp/api/JsiSkNativeObjects.h +387 -0
  30. package/cpp/api/JsiSkPaint.h +104 -142
  31. package/cpp/api/JsiSkParagraph.h +54 -64
  32. package/cpp/api/JsiSkParagraphBuilder.h +43 -68
  33. package/cpp/api/JsiSkParagraphBuilderFactory.h +20 -24
  34. package/cpp/api/JsiSkPath.h +242 -350
  35. package/cpp/api/JsiSkPathBuilder.h +153 -273
  36. package/cpp/api/JsiSkPathBuilderFactory.h +19 -20
  37. package/cpp/api/JsiSkPathEffect.h +21 -11
  38. package/cpp/api/JsiSkPathEffectFactory.h +61 -80
  39. package/cpp/api/JsiSkPathFactory.h +148 -238
  40. package/cpp/api/JsiSkPicture.h +32 -27
  41. package/cpp/api/JsiSkPictureFactory.h +21 -26
  42. package/cpp/api/JsiSkPictureRecorder.h +27 -29
  43. package/cpp/api/JsiSkPoint.h +20 -23
  44. package/cpp/api/JsiSkRRect.h +24 -32
  45. package/cpp/api/JsiSkRSXform.h +31 -48
  46. package/cpp/api/JsiSkRect.h +40 -50
  47. package/cpp/api/JsiSkRuntimeEffect.h +85 -92
  48. package/cpp/api/JsiSkRuntimeEffectFactory.h +14 -18
  49. package/cpp/api/JsiSkRuntimeShaderBuilder.h +28 -30
  50. package/cpp/api/JsiSkSVG.h +15 -15
  51. package/cpp/api/JsiSkSVGFactory.h +17 -20
  52. package/cpp/api/JsiSkShader.h +15 -8
  53. package/cpp/api/JsiSkShaderFactory.h +159 -238
  54. package/cpp/api/JsiSkSkottie.h +131 -143
  55. package/cpp/api/JsiSkSurface.h +29 -32
  56. package/cpp/api/JsiSkSurfaceFactory.h +18 -20
  57. package/cpp/api/JsiSkTextBlob.h +15 -8
  58. package/cpp/api/JsiSkTextBlobFactory.h +40 -66
  59. package/cpp/api/JsiSkTypeface.h +25 -22
  60. package/cpp/api/JsiSkTypefaceFactory.h +17 -15
  61. package/cpp/api/JsiSkTypefaceFontProvider.h +43 -39
  62. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +13 -12
  63. package/cpp/api/JsiSkVertices.h +23 -22
  64. package/cpp/api/JsiSkiaContext.h +22 -23
  65. package/cpp/api/JsiSkottieFactory.h +16 -17
  66. package/cpp/api/JsiVideo.h +43 -81
  67. package/cpp/api/recorder/Convertor.h +31 -61
  68. package/cpp/api/recorder/DataTypes.h +8 -16
  69. package/cpp/api/recorder/JsiRecorder.h +83 -55
  70. package/cpp/api/recorder/RNRecorder.h +1 -1
  71. package/cpp/jsi/BoxedNativeObject.h +146 -0
  72. package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
  73. package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -31
  74. package/cpp/{jsi2 → jsi}/NativeObject.h +131 -152
  75. package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
  76. package/cpp/jsi/RuntimeAwareCache.h +26 -8
  77. package/cpp/jsi/ViewProperty.h +5 -11
  78. package/cpp/rnskia/RNDawnContext.h +18 -2
  79. package/cpp/rnskia/RNDawnInterop.cpp +19 -0
  80. package/cpp/rnskia/RNDawnUtils.h +18 -1
  81. package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
  82. package/cpp/rnskia/RNSkManager.cpp +9 -168
  83. package/cpp/rnskia/RNSkPictureView.h +1 -1
  84. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
  85. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
  86. package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
  87. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  88. package/lib/commonjs/mock/index.js +0 -1
  89. package/lib/commonjs/mock/index.js.map +1 -1
  90. package/lib/commonjs/skia/NativeSetup.js +4 -0
  91. package/lib/commonjs/skia/NativeSetup.js.map +1 -1
  92. package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
  93. package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
  94. package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
  95. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
  96. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  97. package/lib/commonjs/skia/types/Skia.d.ts +5 -15
  98. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  99. package/lib/commonjs/skia/types/index.d.ts +0 -1
  100. package/lib/commonjs/skia/types/index.js +0 -11
  101. package/lib/commonjs/skia/types/index.js.map +1 -1
  102. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  103. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  104. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  105. package/lib/commonjs/skia/web/JsiSkia.js +1 -4
  106. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  107. package/lib/commonjs/sksg/Container.native.js +20 -1
  108. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  109. package/lib/commonjs/views/index.d.ts +0 -1
  110. package/lib/commonjs/views/index.js +0 -11
  111. package/lib/commonjs/views/index.js.map +1 -1
  112. package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  113. package/lib/module/external/reanimated/renderHelpers.js +29 -0
  114. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  115. package/lib/module/mock/index.js +0 -1
  116. package/lib/module/mock/index.js.map +1 -1
  117. package/lib/module/skia/NativeSetup.js +4 -0
  118. package/lib/module/skia/NativeSetup.js.map +1 -1
  119. package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  120. package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
  121. package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
  122. package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
  123. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  124. package/lib/module/skia/types/Skia.d.ts +5 -15
  125. package/lib/module/skia/types/Skia.js.map +1 -1
  126. package/lib/module/skia/types/index.d.ts +0 -1
  127. package/lib/module/skia/types/index.js +0 -1
  128. package/lib/module/skia/types/index.js.map +1 -1
  129. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  130. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  131. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  132. package/lib/module/skia/web/JsiSkia.js +1 -4
  133. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  134. package/lib/module/sksg/Container.native.js +21 -2
  135. package/lib/module/sksg/Container.native.js.map +1 -1
  136. package/lib/module/views/index.d.ts +0 -1
  137. package/lib/module/views/index.js +0 -1
  138. package/lib/module/views/index.js.map +1 -1
  139. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  140. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  141. package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
  142. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  143. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
  144. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  145. package/lib/typescript/lib/module/mock/index.d.ts +0 -2
  146. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
  147. package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  148. package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
  149. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  150. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
  151. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  152. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
  153. package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
  154. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
  155. package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
  156. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  157. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
  158. package/lib/typescript/src/views/index.d.ts +0 -1
  159. package/package.json +8 -5
  160. package/react-native-skia.podspec +38 -5
  161. package/src/external/reanimated/renderHelpers.ts +30 -0
  162. package/src/mock/index.ts +0 -1
  163. package/src/skia/NativeSetup.ts +5 -0
  164. package/src/skia/SkiaWorkletSerialization.ts +67 -0
  165. package/src/skia/types/Image/ImageFactory.ts +15 -6
  166. package/src/skia/types/Skia.ts +5 -15
  167. package/src/skia/types/index.ts +0 -1
  168. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  169. package/src/skia/web/JsiSkia.ts +2 -5
  170. package/src/sksg/Container.native.ts +40 -2
  171. package/src/views/index.ts +0 -1
  172. package/android/cpp/jni/JniWebGPUView.cpp +0 -112
  173. package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
  174. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
  175. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
  176. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
  177. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
  178. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
  179. package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
  180. package/apple/SkiaPlatformContext.h +0 -20
  181. package/apple/SkiaPlatformContext.mm +0 -21
  182. package/apple/SkiaWebGPUView.mm +0 -81
  183. package/apple/WebGPUMetalView.mm +0 -136
  184. package/cpp/api/JsiSkHostObjects.h +0 -257
  185. package/cpp/jsi/JsiHostObject.cpp +0 -137
  186. package/cpp/jsi/JsiHostObject.h +0 -385
  187. package/cpp/rnwgpu/ArrayBuffer.h +0 -117
  188. package/cpp/rnwgpu/Canvas.h +0 -50
  189. package/cpp/rnwgpu/PlatformContext.h +0 -18
  190. package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
  191. package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
  192. package/cpp/rnwgpu/api/Convertors.h +0 -783
  193. package/cpp/rnwgpu/api/External.h +0 -12
  194. package/cpp/rnwgpu/api/GPU.cpp +0 -162
  195. package/cpp/rnwgpu/api/GPU.h +0 -60
  196. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -240
  197. package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
  198. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
  199. package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
  200. package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
  201. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
  202. package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
  203. package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
  204. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
  205. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
  206. package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
  207. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
  208. package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
  209. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
  210. package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
  211. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
  212. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
  213. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
  214. package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
  215. package/cpp/rnwgpu/api/GPUDevice.cpp +0 -614
  216. package/cpp/rnwgpu/api/GPUDevice.h +0 -258
  217. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
  218. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
  219. package/cpp/rnwgpu/api/GPUError.h +0 -35
  220. package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
  221. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
  222. package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
  223. package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
  224. package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
  225. package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
  226. package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
  227. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
  228. package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
  229. package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
  230. package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
  231. package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
  232. package/cpp/rnwgpu/api/GPUQueue.h +0 -84
  233. package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
  234. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
  235. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
  236. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
  237. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
  238. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
  239. package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
  240. package/cpp/rnwgpu/api/GPUSampler.h +0 -44
  241. package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
  242. package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
  243. package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
  244. package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
  245. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
  246. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
  247. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
  248. package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
  249. package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
  250. package/cpp/rnwgpu/api/GPUTexture.h +0 -162
  251. package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
  252. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
  253. package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
  254. package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
  255. package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
  256. package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
  257. package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
  258. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
  259. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
  260. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
  261. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
  262. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
  263. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
  264. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
  265. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
  266. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
  267. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
  268. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
  269. package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
  270. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
  271. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
  272. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
  273. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
  274. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
  275. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
  276. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
  277. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
  278. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
  279. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
  280. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
  281. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
  282. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
  283. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
  284. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
  285. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
  286. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
  287. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
  288. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
  289. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
  290. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
  291. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
  292. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
  293. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
  294. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
  295. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
  296. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
  297. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
  298. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
  299. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
  300. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
  301. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
  302. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
  303. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
  304. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
  305. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
  306. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
  307. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
  308. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
  309. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
  310. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
  311. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
  312. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
  313. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
  314. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
  315. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
  316. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
  317. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
  318. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
  319. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
  320. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
  321. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
  322. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -214
  323. package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
  324. package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
  325. package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
  326. package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
  327. package/lib/commonjs/skia/types/WebGPU.js +0 -105
  328. package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
  329. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
  330. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
  331. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
  332. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  333. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
  334. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  335. package/lib/commonjs/specs/utils.d.ts +0 -1
  336. package/lib/commonjs/specs/utils.js +0 -11
  337. package/lib/commonjs/specs/utils.js.map +0 -1
  338. package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
  339. package/lib/commonjs/views/WebGPUCanvas.js +0 -79
  340. package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
  341. package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
  342. package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
  343. package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
  344. package/lib/module/skia/types/WebGPU.d.ts +0 -184
  345. package/lib/module/skia/types/WebGPU.js +0 -99
  346. package/lib/module/skia/types/WebGPU.js.map +0 -1
  347. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
  348. package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
  349. package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
  350. package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  351. package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
  352. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  353. package/lib/module/specs/utils.d.ts +0 -1
  354. package/lib/module/specs/utils.js +0 -5
  355. package/lib/module/specs/utils.js.map +0 -1
  356. package/lib/module/views/WebGPUCanvas.d.ts +0 -33
  357. package/lib/module/views/WebGPUCanvas.js +0 -70
  358. package/lib/module/views/WebGPUCanvas.js.map +0 -1
  359. package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
  360. package/lib/module/views/WebGPUCanvas.web.js +0 -12
  361. package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
  362. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
  363. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
  364. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
  365. package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
  366. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
  367. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
  368. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
  369. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
  370. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
  371. package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
  372. package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
  373. package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
  374. package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
  375. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
  376. package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  377. package/lib/typescript/src/specs/utils.d.ts +0 -1
  378. package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
  379. package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
  380. package/src/skia/types/WebGPU.ts +0 -226
  381. package/src/specs/WebGPUViewNativeComponent.ts +0 -11
  382. package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
  383. package/src/specs/utils.ts +0 -4
  384. package/src/views/WebGPUCanvas.tsx +0 -125
  385. package/src/views/WebGPUCanvas.web.tsx +0 -36
  386. /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
  387. /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
@@ -7,8 +7,8 @@
7
7
  #include <string>
8
8
  #include <variant>
9
9
 
10
- #include "api/JsiSkPicture.h"
11
10
  #include "RuntimeLifecycleMonitor.h"
11
+ #include "api/JsiSkPicture.h"
12
12
 
13
13
  namespace RNJsi {
14
14
  namespace jsi = facebook::jsi;
@@ -38,16 +38,10 @@ private:
38
38
  class ViewProperty {
39
39
  public:
40
40
  ViewProperty(jsi::Runtime &runtime, const jsi::Value &value) {
41
- if (value.isObject()) {
42
- auto object = value.asObject(runtime);
43
- if (object.isHostObject(runtime)) {
44
- auto hostObject = object.asHostObject(runtime);
45
- auto jsiPicture =
46
- std::dynamic_pointer_cast<RNSkia::JsiSkPicture>(hostObject);
47
- if (jsiPicture) {
48
- _value = jsiPicture->getObject();
49
- }
50
- }
41
+ auto jsiPicture =
42
+ RNSkia::tryGetJsiObject<RNSkia::JsiSkPicture>(runtime, value);
43
+ if (jsiPicture) {
44
+ _value = jsiPicture->getObject();
51
45
  }
52
46
  }
53
47
 
@@ -366,8 +366,9 @@ private:
366
366
  std::mutex _mutex;
367
367
 
368
368
  DawnContext() {
369
- DawnProcTable backendProcs = dawn::native::GetProcs();
370
- dawnProcSetProcs(&backendProcs);
369
+ // No dawnProcSetProcs() here: the monolithic libwebgpu_dawn (shared with
370
+ // react-native-webgpu) exposes the real wgpu* C entry points directly
371
+ // rather than the settable dawn_proc trampoline, which it does not ship.
371
372
  static const auto kTimedWaitAny = wgpu::InstanceFeatureName::TimedWaitAny;
372
373
 
373
374
  wgpu::InstanceDescriptor instanceDesc{.requiredFeatureCount = 1,
@@ -376,6 +377,21 @@ private:
376
377
  // For limits:
377
378
  wgpu::InstanceLimits limits{.timedWaitAnyMaxCount = 64};
378
379
  instanceDesc.requiredLimits = &limits;
380
+
381
+ // Same instance-stage toggles react-native-webgpu sets on its own
382
+ // instance: when webgpu adopts this instance (rnskia_getWGPUInstance),
383
+ // its external-texture path expects experimental adapter features to be
384
+ // visible. These only un-hide features in adapter.features; nothing
385
+ // becomes active unless a device requests it.
386
+ static const char *const kInstanceToggles[] = {
387
+ "allow_unsafe_apis",
388
+ "expose_wgsl_experimental_features",
389
+ };
390
+ wgpu::DawnTogglesDescriptor instanceToggles;
391
+ instanceToggles.enabledToggleCount = std::size(kInstanceToggles);
392
+ instanceToggles.enabledToggles = kInstanceToggles;
393
+ instanceDesc.nextInChain = &instanceToggles;
394
+
379
395
  instance = std::make_unique<dawn::native::Instance>(&instanceDesc);
380
396
 
381
397
  backendContext = DawnUtils::createDawnBackendContext(instance.get());
@@ -0,0 +1,19 @@
1
+ #ifdef SK_GRAPHITE
2
+
3
+ #include "RNDawnContext.h"
4
+
5
+ // Runtime discovery surface for react-native-webgpu.
6
+ //
7
+ // webgpu looks this symbol up with dlsym(RTLD_DEFAULT, ...) when it creates
8
+ // its GPU object and, when found, adopts the returned instance instead of
9
+ // creating its own. Sharing one wgpu::Instance across both packages makes
10
+ // pointer-based device handoff (RNWebGPU.importDevice(Skia.getNativeDevice()))
11
+ // sound: async callbacks of imported devices settle on the instance webgpu
12
+ // pumps. Plain C, default visibility: no C++ ABI surface, works across
13
+ // separately compiled pods, and stays dlsym-able under -fvisibility=hidden.
14
+ extern "C" __attribute__((visibility("default"))) WGPUInstance
15
+ rnskia_getWGPUInstance() {
16
+ return RNSkia::DawnContext::getInstance().getWGPUInstance().Get();
17
+ }
18
+
19
+ #endif
@@ -1,8 +1,11 @@
1
1
  #pragma once
2
2
 
3
+ #if defined(__APPLE__)
4
+ #include <TargetConditionals.h>
5
+ #endif
6
+
3
7
  #include "webgpu/webgpu_cpp.h"
4
8
 
5
- #include "dawn/dawn_proc.h"
6
9
  #include "dawn/native/DawnNative.h"
7
10
 
8
11
  #include "include/core/SkColorType.h"
@@ -115,6 +118,20 @@ requestDevice(dawn::native::Adapter &nativeAdapter,
115
118
  wgpu::DawnTogglesDescriptor togglesDesc;
116
119
  togglesDesc.enabledToggleCount = std::size(kToggles);
117
120
  togglesDesc.enabledToggles = kToggles;
121
+ #if defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR
122
+ // The iOS Simulator only advertises MTLFeatureSet_iOS_GPUFamily2, so Dawn
123
+ // defaults disable_base_instance/disable_base_vertex on and then rejects
124
+ // every draw with a non-zero firstInstance or baseVertex, which Graphite
125
+ // emits routinely. The simulator forwards Metal calls to the host GPU,
126
+ // which does support base vertex/instance drawing, so force the toggles
127
+ // off. Device builds are unaffected: Graphite-capable iPhones and iPads
128
+ // are all GPUFamily3+. (Same override as react-native-webgpu; see
129
+ // https://issues.chromium.org/issues/42241591.)
130
+ static constexpr const char *kDisabledToggles[] = {"disable_base_instance",
131
+ "disable_base_vertex"};
132
+ togglesDesc.disabledToggleCount = std::size(kDisabledToggles);
133
+ togglesDesc.disabledToggles = kDisabledToggles;
134
+ #endif
118
135
 
119
136
  wgpu::DeviceDescriptor desc;
120
137
  desc.requiredFeatureCount = features.size();
@@ -13,7 +13,8 @@
13
13
  #include "RNSkPictureView.h"
14
14
  #include "RNSkPlatformContext.h"
15
15
  #include "RNSkView.h"
16
- #include "jsi/JsiHostObject.h"
16
+ #include "api/JsiSkNativeObjects.h"
17
+ #include "jsi/JsiPromises.h"
17
18
  #include "jsi/ViewProperty.h"
18
19
  #include <jsi/jsi.h>
19
20
 
@@ -92,9 +93,10 @@ private:
92
93
  std::unordered_set<size_t> _unregistered;
93
94
  };
94
95
 
95
- class RNSkJsiViewApi : public RNJsi::JsiHostObject,
96
- public std::enable_shared_from_this<RNSkJsiViewApi> {
96
+ class RNSkJsiViewApi : public JsiSkNativeObject<RNSkJsiViewApi> {
97
97
  public:
98
+ static constexpr const char *CLASS_NAME = "ViewApi";
99
+
98
100
  /**
99
101
  Sets a custom property on a view given a view id. The property name/value
100
102
  will be stored in a map alongside the id of the view and propagated to the
@@ -199,7 +201,7 @@ public:
199
201
  "Could not create image from current surface.");
200
202
  return jsi::Value::undefined();
201
203
  }
202
- return jsi::Object::createFromHostObject(
204
+ return makeJsiObject(
203
205
  runtime, std::make_shared<JsiSkImage>(_platformContext, image));
204
206
  }
205
207
  throw jsi::JSError(runtime, "No Skia View currently available.");
@@ -245,7 +247,7 @@ public:
245
247
  promise->reject("Failed to make snapshot from view.");
246
248
  return;
247
249
  }
248
- promise->resolve(jsi::Object::createFromHostObject(
250
+ promise->resolve(makeJsiObject(
249
251
  runtime, std::make_shared<JsiSkImage>(std::move(context),
250
252
  std::move(image))));
251
253
  });
@@ -286,18 +288,25 @@ public:
286
288
  return sizeObj;
287
289
  }
288
290
 
289
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(RNSkJsiViewApi, setJsiProperty),
290
- JSI_EXPORT_FUNC(RNSkJsiViewApi, requestRedraw),
291
- JSI_EXPORT_FUNC(RNSkJsiViewApi, makeImageSnapshotAsync),
292
- JSI_EXPORT_FUNC(RNSkJsiViewApi, makeImageSnapshot),
293
- JSI_EXPORT_FUNC(RNSkJsiViewApi, size))
291
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
292
+ installHostMethod(runtime, prototype, "setJsiProperty",
293
+ &RNSkJsiViewApi::setJsiProperty);
294
+ installHostMethod(runtime, prototype, "requestRedraw",
295
+ &RNSkJsiViewApi::requestRedraw);
296
+ installHostMethod(runtime, prototype, "makeImageSnapshotAsync",
297
+ &RNSkJsiViewApi::makeImageSnapshotAsync);
298
+ installHostMethod(runtime, prototype, "makeImageSnapshot",
299
+ &RNSkJsiViewApi::makeImageSnapshot);
300
+ installHostMethod(runtime, prototype, "size", &RNSkJsiViewApi::size);
301
+ }
294
302
 
295
303
  /**
296
304
  * Constructor
297
305
  * @param platformContext Platform context
298
306
  */
299
307
  explicit RNSkJsiViewApi(std::shared_ptr<RNSkPlatformContext> platformContext)
300
- : JsiHostObject(), _platformContext(platformContext) {}
308
+ : JsiSkNativeObject<RNSkJsiViewApi>(platformContext),
309
+ _platformContext(platformContext) {}
301
310
 
302
311
  /**
303
312
  Call to remove all draw view infos
@@ -5,33 +5,12 @@
5
5
 
6
6
  #include <jsi/jsi.h>
7
7
 
8
- #include "api/JsiSkApi.h"
9
8
  #include "RNSkJsiViewApi.h"
10
9
  #include "RNSkView.h"
10
+ #include "api/JsiSkApi.h"
11
11
 
12
12
  #include "jsi/RuntimeAwareCache.h"
13
13
 
14
- #ifdef SK_GRAPHITE
15
- #include "RNDawnContext.h"
16
- #include "rnwgpu/ArrayBuffer.h"
17
- #include "rnwgpu/api/GPU.h"
18
- #include "rnwgpu/api/GPUUncapturedErrorEvent.h"
19
- #include "rnwgpu/api/ImageBitmap.h"
20
- #include "rnwgpu/api/RNWebGPU.h"
21
- #include "rnwgpu/api/descriptors/GPUBufferUsage.h"
22
- #include "rnwgpu/api/descriptors/GPUColorWrite.h"
23
- #include "rnwgpu/api/descriptors/GPUMapMode.h"
24
- #include "rnwgpu/api/descriptors/GPUShaderStage.h"
25
- #include "rnwgpu/api/descriptors/GPUTextureUsage.h"
26
- #include "rnwgpu/api/WebGPUConstants.h"
27
- #include "rnwgpu/async/RuntimeContext.h"
28
- #include "jsi2/Promise.h"
29
-
30
- #include "include/core/SkData.h"
31
- #include "include/core/SkImage.h"
32
- #include "include/core/SkImageInfo.h"
33
- #endif
34
-
35
14
  namespace RNSkia {
36
15
  namespace jsi = facebook::jsi;
37
16
 
@@ -43,7 +22,7 @@ RNSkManager::RNSkManager(
43
22
  _jsCallInvoker(jsCallInvoker),
44
23
  _viewApi(std::make_shared<RNSkJsiViewApi>(platformContext)) {
45
24
 
46
- // Register main runtime (used by both Skia and WebGPU bindings)
25
+ // Register main runtime
47
26
  RNJsi::BaseRuntimeAwareCache::setMainJsRuntime(_jsRuntime);
48
27
 
49
28
  // Install bindings
@@ -51,12 +30,6 @@ RNSkManager::RNSkManager(
51
30
  }
52
31
 
53
32
  RNSkManager::~RNSkManager() {
54
- #ifdef SK_GRAPHITE
55
- // Drop all canvas registry entries: after a reload the JS side restarts its
56
- // contextId counter, and stale entries would alias new canvases onto dead
57
- // surfaces.
58
- rnwgpu::SurfaceRegistry::getInstance().clear();
59
- #endif
60
33
  // Free up any references
61
34
  _viewApi = nullptr;
62
35
  _jsRuntime = nullptr;
@@ -82,146 +55,14 @@ void RNSkManager::installBindings() {
82
55
  // provided runtime.
83
56
  auto skiaApi = std::make_shared<JsiSkApi>(_platformContext);
84
57
  _jsRuntime->global().setProperty(
85
- *_jsRuntime, "SkiaApi",
86
- jsi::Object::createFromHostObject(*_jsRuntime, std::move(skiaApi)));
87
-
88
- _jsRuntime->global().setProperty(
89
- *_jsRuntime, "SkiaViewApi",
90
- jsi::Object::createFromHostObject(*_jsRuntime, _viewApi));
91
-
92
- #ifdef SK_GRAPHITE
93
- // Register the main runtime + its CallInvoker so spontaneous events
94
- // (device.lost / uncapturederror) on main-runtime devices can be delivered to
95
- // the JS thread without the ProcessEvents pump. Worklet-runtime devices have
96
- // no invoker (best-effort; see the RuntimeContext "Threading model" doc).
97
- rnwgpu::async::RuntimeContext::registerMainRuntime(_jsRuntime, _jsCallInvoker);
98
-
99
- // Install WebGPU constructors
100
- rnwgpu::GPU::installConstructor(*_jsRuntime);
101
- rnwgpu::GPUUncapturedErrorEvent::installConstructor(*_jsRuntime);
102
- // Create and expose navigator.gpu using DawnContext's instance
103
- auto &dawnContext = DawnContext::getInstance();
104
- auto gpu =
105
- std::make_shared<rnwgpu::GPU>(*_jsRuntime, dawnContext.getWGPUInstance());
106
- auto navigatorValue =
107
- _jsRuntime->global().getProperty(*_jsRuntime, "navigator");
108
- if (navigatorValue.isObject()) {
109
- auto navigator = navigatorValue.asObject(*_jsRuntime);
110
- navigator.setProperty(*_jsRuntime, "gpu",
111
- rnwgpu::GPU::create(*_jsRuntime, gpu));
112
- } else {
113
- // Create navigator object if it doesn't exist
114
- jsi::Object navigator(*_jsRuntime);
115
- navigator.setProperty(*_jsRuntime, "gpu",
116
- rnwgpu::GPU::create(*_jsRuntime, gpu));
117
- _jsRuntime->global().setProperty(*_jsRuntime, "navigator",
118
- std::move(navigator));
119
- }
120
-
121
- // Install WebGPU constant objects as plain JS objects on the main runtime.
122
- rnwgpu::installWebGPUConstants(*_jsRuntime);
123
-
124
- // Install a global `installWebGPU()` host function so worklet runtimes can get
125
- // the same constants. A host function captured into a worklet is serialized as
126
- // a SerializableHostFunction and re-created on the worklet runtime, so the body
127
- // runs there (its `rt` is the worklet runtime) and installs the constants on
128
- // that runtime. The constants come from the native wgpu::*Usage enums, so the
129
- // values stay a single source of truth across every runtime. Calling it on a
130
- // runtime that already has the globals is a safe, idempotent no-op.
131
- _jsRuntime->global().setProperty(
132
- *_jsRuntime, "installWebGPU",
133
- jsi::Function::createFromHostFunction(
134
- *_jsRuntime, jsi::PropNameID::forAscii(*_jsRuntime, "installWebGPU"),
135
- 0,
136
- [](jsi::Runtime &rt, const jsi::Value & /*thisVal*/,
137
- const jsi::Value * /*args*/, size_t /*count*/) -> jsi::Value {
138
- rnwgpu::installWebGPUConstants(rt);
139
- return jsi::Value::undefined();
140
- }));
58
+ *_jsRuntime, "SkiaApi", makeJsiObject(*_jsRuntime, std::move(skiaApi)));
141
59
 
142
- // Install RNWebGPU global object for WebGPU Canvas support
143
- auto rnWebGPU = std::make_shared<rnwgpu::RNWebGPU>(gpu, nullptr);
144
- _jsRuntime->global().setProperty(
145
- *_jsRuntime, "RNWebGPU", rnwgpu::RNWebGPU::create(*_jsRuntime, rnWebGPU));
146
-
147
- // DRAFT — compile-unverified. Install the ImageBitmap constructor (so
148
- // `instanceof ImageBitmap` works) and a global createImageBitmap() that
149
- // accepts the non-standard encoded-BufferSource overload.
150
- //
151
- // The BufferSource is run through the shared rnwgpu::ArrayBuffer converter,
152
- // which validates byteOffset/byteLength against the backing buffer and throws
153
- // synchronously on a spoofed / out-of-bounds view — so createImageBitmap()
154
- // rejects rather than reading out of bounds (see ArrayBufferBounds /
155
- // ImageBitmapBounds specs). Decoding uses Skia's own codec; no platform image
156
- // decoder is needed.
157
- rnwgpu::ImageBitmap::installConstructor(*_jsRuntime);
158
- _jsRuntime->global().setProperty(
159
- *_jsRuntime, "createImageBitmap",
160
- jsi::Function::createFromHostFunction(
161
- *_jsRuntime,
162
- jsi::PropNameID::forAscii(*_jsRuntime, "createImageBitmap"), 1,
163
- [](jsi::Runtime &rt, const jsi::Value & /*thisVal*/,
164
- const jsi::Value *args, size_t count) -> jsi::Value {
165
- if (count < 1 || !args[0].isObject()) {
166
- throw jsi::JSError(
167
- rt, "createImageBitmap requires a BufferSource argument");
168
- }
169
- // Only the encoded ArrayBuffer / ArrayBufferView overload is
170
- // supported here. Anything else (Blob, ImageData, …) is rejected.
171
- auto obj = args[0].getObject(rt);
172
- bool isBufferSource = obj.isArrayBuffer(rt);
173
- if (!isBufferSource && obj.hasProperty(rt, "buffer")) {
174
- auto bufferProp = obj.getProperty(rt, "buffer");
175
- isBufferSource =
176
- bufferProp.isObject() &&
177
- bufferProp.getObject(rt).isArrayBuffer(rt);
178
- }
179
- if (!isBufferSource) {
180
- throw jsi::JSError(rt, "createImageBitmap: unsupported source "
181
- "(expected an ArrayBuffer or TypedArray "
182
- "of encoded image bytes)");
183
- }
184
- // Validates bounds and THROWS synchronously on a spoofed view, so
185
- // the bad pointer never reaches the copy below.
186
- auto buffer =
187
- rnwgpu::JSIConverter<std::shared_ptr<rnwgpu::ArrayBuffer>>::
188
- fromJSI(rt, args[0], false);
189
- // Copy the encoded bytes off the JS-owned ArrayBuffer.
190
- const uint8_t *bytes = buffer->data();
191
- std::vector<uint8_t> encoded(bytes, bytes + buffer->size());
60
+ _jsRuntime->global().setProperty(*_jsRuntime, "SkiaViewApi",
61
+ makeJsiObject(*_jsRuntime, _viewApi));
192
62
 
193
- return rnwgpu::Promise::createPromise(
194
- rt, [encoded = std::move(encoded)](
195
- jsi::Runtime &runtime,
196
- std::shared_ptr<rnwgpu::Promise> promise) mutable {
197
- auto skData =
198
- SkData::MakeWithCopy(encoded.data(), encoded.size());
199
- auto image = SkImages::DeferredFromEncodedData(skData);
200
- if (image == nullptr) {
201
- promise->reject(
202
- "createImageBitmap: failed to decode image data");
203
- return;
204
- }
205
- const int w = image->width();
206
- const int h = image->height();
207
- auto info =
208
- SkImageInfo::Make(w, h, kRGBA_8888_SkColorType,
209
- kUnpremul_SkAlphaType);
210
- std::vector<uint8_t> pixels(info.computeMinByteSize());
211
- // nullptr context: decode/read on the CPU (raster).
212
- if (!image->readPixels(nullptr, info, pixels.data(),
213
- info.minRowBytes(), 0, 0)) {
214
- promise->reject(
215
- "createImageBitmap: failed to read decoded pixels");
216
- return;
217
- }
218
- auto bitmap = std::make_shared<rnwgpu::ImageBitmap>(
219
- std::move(pixels), static_cast<size_t>(w),
220
- static_cast<size_t>(h));
221
- promise->resolve(
222
- rnwgpu::ImageBitmap::create(runtime, bitmap));
223
- });
224
- }));
225
- #endif
63
+ // The WebGPU JS API (RNWebGPU, navigator.gpu, constants, createImageBitmap)
64
+ // is no longer installed here: react-native-webgpu is the single WebGPU API
65
+ // surface for React Native. Graphite keeps Dawn as an internal
66
+ // implementation detail only.
226
67
  }
227
68
  } // namespace RNSkia
@@ -13,9 +13,9 @@
13
13
  #include "RNSkView.h"
14
14
  #include "jsi/ViewProperty.h"
15
15
 
16
+ #include "RNSkPlatformContext.h"
16
17
  #include "api/JsiSkPicture.h"
17
18
  #include "utils/RNSkLog.h"
18
- #include "RNSkPlatformContext.h"
19
19
  #include "utils/RNSkTimingInfo.h"
20
20
 
21
21
  #pragma clang diagnostic push
@@ -21,6 +21,8 @@
21
21
  disallow_large_instanced_draw) \
22
22
  GPU_OP(EMULATE_ABS_INT_FUNCTION, \
23
23
  emulate_abs_int_function) \
24
+ GPU_OP(ENSURE_PREVIOUS_FRAMEBUFFER_NOT_DELETED, \
25
+ ensure_previous_framebuffer_not_deleted) \
24
26
  GPU_OP(FLUSH_ON_FRAMEBUFFER_CHANGE, \
25
27
  flush_on_framebuffer_change) \
26
28
  GPU_OP(FORCE_UPDATE_SCISSOR_STATE_WHEN_BINDING_FBO0, \
@@ -1 +1,16 @@
1
1
  export declare let HAS_REANIMATED_3: boolean;
2
+ /**
3
+ * True when the worklets-based Reanimated integration is available
4
+ * (Reanimated 4 with react-native-worklets providing
5
+ * registerCustomSerializable). Skia objects use the JSI NativeState pattern
6
+ * and can only be transferred to worklet runtimes through a custom
7
+ * serializer, so on native the Reanimated integration requires Reanimated 4 —
8
+ * Reanimated 3 is not supported.
9
+ */
10
+ export declare let HAS_REANIMATED_4: boolean;
11
+ /**
12
+ * Major version of the installed react-native-reanimated package, or null if
13
+ * it is not installed. Used to give actionable diagnostics when the
14
+ * integration cannot be enabled.
15
+ */
16
+ export declare let REANIMATED_VERSION_MAJOR: number | null;
@@ -3,8 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.HAS_REANIMATED_3 = void 0;
6
+ exports.REANIMATED_VERSION_MAJOR = exports.HAS_REANIMATED_4 = exports.HAS_REANIMATED_3 = void 0;
7
7
  let HAS_REANIMATED_3 = exports.HAS_REANIMATED_3 = false;
8
+
9
+ /**
10
+ * True when the worklets-based Reanimated integration is available
11
+ * (Reanimated 4 with react-native-worklets providing
12
+ * registerCustomSerializable). Skia objects use the JSI NativeState pattern
13
+ * and can only be transferred to worklet runtimes through a custom
14
+ * serializer, so on native the Reanimated integration requires Reanimated 4 —
15
+ * Reanimated 3 is not supported.
16
+ */
17
+ let HAS_REANIMATED_4 = exports.HAS_REANIMATED_4 = false;
18
+
19
+ /**
20
+ * Major version of the installed react-native-reanimated package, or null if
21
+ * it is not installed. Used to give actionable diagnostics when the
22
+ * integration cannot be enabled.
23
+ */
24
+ let REANIMATED_VERSION_MAJOR = exports.REANIMATED_VERSION_MAJOR = null;
8
25
  try {
9
26
  // This logic is convoluted but necessary
10
27
  // In most systems, `require("react-native-reanimated")` throws an error, all is well.
@@ -15,6 +32,18 @@ try {
15
32
  if (reanimatedVersion && (reanimatedVersion >= "3.0.0" || reanimatedVersion.includes("3.0.0-"))) {
16
33
  exports.HAS_REANIMATED_3 = HAS_REANIMATED_3 = true;
17
34
  }
35
+ const majorVersion = parseInt(reanimatedVersion.split(".")[0], 10);
36
+ if (!isNaN(majorVersion)) {
37
+ exports.REANIMATED_VERSION_MAJOR = REANIMATED_VERSION_MAJOR = majorVersion;
38
+ }
39
+ if (majorVersion >= 4) {
40
+ try {
41
+ const worklets = require("react-native-worklets");
42
+ exports.HAS_REANIMATED_4 = HAS_REANIMATED_4 = typeof worklets.registerCustomSerializable === "function";
43
+ } catch (e) {
44
+ // react-native-worklets not installed
45
+ }
46
+ }
18
47
  } catch (e) {
19
48
  // do nothing
20
49
  }
@@ -1 +1 @@
1
- {"version":3,"names":["HAS_REANIMATED_3","exports","reanimatedVersion","require","version","includes","e"],"sources":["renderHelpers.ts"],"sourcesContent":["export let HAS_REANIMATED_3 = false;\n\ntry {\n // This logic is convoluted but necessary\n // In most systems, `require(\"react-native-reanimated\")` throws an error, all is well.\n // In webpack, in some configuration it will return an empty object.\n // So it will not throw an error and we need to check the version to know if it's there.\n const reanimatedVersion =\n require(\"react-native-reanimated/package.json\").version;\n require(\"react-native-reanimated\");\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n HAS_REANIMATED_3 = true;\n }\n} catch (e) {\n // do nothing\n}\n"],"mappings":";;;;;;AAAO,IAAIA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,KAAK;AAEnC,IAAI;EACF;EACA;EACA;EACA;EACA,MAAME,iBAAiB,GACrBC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EACzDD,OAAO,CAAC,yBAAyB,CAAC;EAClC,IACED,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,OAAA,CAAAD,gBAAA,GAAAA,gBAAgB,GAAG,IAAI;EACzB;AACF,CAAC,CAAC,OAAOM,CAAC,EAAE;EACV;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["HAS_REANIMATED_3","exports","HAS_REANIMATED_4","REANIMATED_VERSION_MAJOR","reanimatedVersion","require","version","includes","majorVersion","parseInt","split","isNaN","worklets","registerCustomSerializable","e"],"sources":["renderHelpers.ts"],"sourcesContent":["export let HAS_REANIMATED_3 = false;\n\n/**\n * True when the worklets-based Reanimated integration is available\n * (Reanimated 4 with react-native-worklets providing\n * registerCustomSerializable). Skia objects use the JSI NativeState pattern\n * and can only be transferred to worklet runtimes through a custom\n * serializer, so on native the Reanimated integration requires Reanimated 4 —\n * Reanimated 3 is not supported.\n */\nexport let HAS_REANIMATED_4 = false;\n\n/**\n * Major version of the installed react-native-reanimated package, or null if\n * it is not installed. Used to give actionable diagnostics when the\n * integration cannot be enabled.\n */\nexport let REANIMATED_VERSION_MAJOR: number | null = null;\n\ntry {\n // This logic is convoluted but necessary\n // In most systems, `require(\"react-native-reanimated\")` throws an error, all is well.\n // In webpack, in some configuration it will return an empty object.\n // So it will not throw an error and we need to check the version to know if it's there.\n const reanimatedVersion =\n require(\"react-native-reanimated/package.json\").version;\n require(\"react-native-reanimated\");\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n HAS_REANIMATED_3 = true;\n }\n const majorVersion = parseInt(reanimatedVersion.split(\".\")[0], 10);\n if (!isNaN(majorVersion)) {\n REANIMATED_VERSION_MAJOR = majorVersion;\n }\n if (majorVersion >= 4) {\n try {\n const worklets = require(\"react-native-worklets\");\n HAS_REANIMATED_4 =\n typeof worklets.registerCustomSerializable === \"function\";\n } catch (e) {\n // react-native-worklets not installed\n }\n }\n} catch (e) {\n // do nothing\n}\n"],"mappings":";;;;;;AAAO,IAAIA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,KAAK;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAIE,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,KAAK;;AAEnC;AACA;AACA;AACA;AACA;AACO,IAAIC,wBAAuC,GAAAF,OAAA,CAAAE,wBAAA,GAAG,IAAI;AAEzD,IAAI;EACF;EACA;EACA;EACA;EACA,MAAMC,iBAAiB,GACrBC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EACzDD,OAAO,CAAC,yBAAyB,CAAC;EAClC,IACED,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAN,OAAA,CAAAD,gBAAA,GAAAA,gBAAgB,GAAG,IAAI;EACzB;EACA,MAAMQ,YAAY,GAAGC,QAAQ,CAACL,iBAAiB,CAACM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;EAClE,IAAI,CAACC,KAAK,CAACH,YAAY,CAAC,EAAE;IACxBP,OAAA,CAAAE,wBAAA,GAAAA,wBAAwB,GAAGK,YAAY;EACzC;EACA,IAAIA,YAAY,IAAI,CAAC,EAAE;IACrB,IAAI;MACF,MAAMI,QAAQ,GAAGP,OAAO,CAAC,uBAAuB,CAAC;MACjDJ,OAAA,CAAAC,gBAAA,GAAAA,gBAAgB,GACd,OAAOU,QAAQ,CAACC,0BAA0B,KAAK,UAAU;IAC7D,CAAC,CAAC,OAAOC,CAAC,EAAE;MACV;IAAA;EAEJ;AACF,CAAC,CAAC,OAAOA,CAAC,EAAE;EACV;AAAA","ignoreList":[]}
@@ -29,7 +29,6 @@ const Mock = CanvasKit => {
29
29
  ...require("../dom/types"),
30
30
  ...require("../dom/nodes"),
31
31
  Canvas: require("react-native").View,
32
- WebGPUCanvas: require("react-native").View,
33
32
  getPreferredHighBitDepthCanvasFormat: () => "rgba16float",
34
33
  SkiaPictureView: require("react-native").View,
35
34
  JsiSkImage: _JsiSkImage.JsiSkImage,
@@ -1 +1 @@
1
- {"version":3,"names":["_web","require","_JsiSkImage","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","JsiSkApi","Skia","Canvas","View","WebGPUCanvas","getPreferredHighBitDepthCanvasFormat","SkiaPictureView","JsiSkImage","drawAsPicture","drawAsImage","drawAsImageFromPicture","useCanvasRef","useCanvasSize","ref","size","width","height","useValue","useComputedValue","useTiming","useLoop","useSpring","useClockValue","useValueEffect","isOnMainThread","isFabric","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG","useVideo","exports"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { JsiSkImage } from \"../skia/web/JsiSkImage\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n global.SkiaApi = JsiSkApi(CanvasKit);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n Canvas: require(\"react-native\").View,\n WebGPUCanvas: require(\"react-native\").View,\n getPreferredHighBitDepthCanvasFormat: () => \"rgba16float\",\n SkiaPictureView: require(\"react-native\").View,\n JsiSkImage: JsiSkImage,\n drawAsPicture: Noop,\n drawAsImage: Noop,\n drawAsImageFromPicture: Noop,\n useCanvasRef: NoopValue,\n useCanvasSize: () => ({\n ref: {\n current: 0,\n },\n size: {\n width: 0,\n height: 0,\n },\n }),\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n isOnMainThread: () => true,\n isFabric: true,\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n useVideo: () => null,\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA;AACA,MAAME,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAAEC,KAAK,EAAE;AAAE,CAAC,CAAC;AAErC,MAAMC,IAAI,GAAIC,SAAoB,IAAK;EAC5C;EACA;EACAC,MAAM,CAACC,OAAO,GAAG,IAAAC,aAAQ,EAACH,SAAS,CAAC;EACpC;EACA;EACA,MAAMI,IAAI,GAAGH,MAAM,CAACC,OAAO;EAC3B,OAAO;IACLE,IAAI;IACJ,GAAGb,OAAO,CAAC,wBAAwB,CAAC;IACpC,GAAGA,OAAO,CAAC,SAAS,CAAC;IACrB,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1Bc,MAAM,EAAEd,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IACpCC,YAAY,EAAEhB,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IAC1CE,oCAAoC,EAAEA,CAAA,KAAM,aAAa;IACzDC,eAAe,EAAElB,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IAC7CI,UAAU,EAAEA,sBAAU;IACtBC,aAAa,EAAElB,IAAI;IACnBmB,WAAW,EAAEnB,IAAI;IACjBoB,sBAAsB,EAAEpB,IAAI;IAC5BqB,YAAY,EAAEnB,SAAS;IACvBoB,aAAa,EAAEA,CAAA,MAAO;MACpBC,GAAG,EAAE;QACHpB,OAAO,EAAE;MACX,CAAC;MACDqB,IAAI,EAAE;QACJC,KAAK,EAAE,CAAC;QACRC,MAAM,EAAE;MACV;IACF,CAAC,CAAC;IACF;IACAC,QAAQ,EAAEzB,SAAS;IACnB0B,gBAAgB,EAAE1B,SAAS;IAC3B2B,SAAS,EAAE3B,SAAS;IACpB4B,OAAO,EAAE5B,SAAS;IAClB6B,SAAS,EAAE7B,SAAS;IACpB8B,aAAa,EAAE9B,SAAS;IACxB+B,cAAc,EAAEjC,IAAI;IACpB;IACAkC,cAAc,EAAEA,CAAA,KAAM,IAAI;IAC1BC,QAAQ,EAAE,IAAI;IACdC,QAAQ,EAAEhC,eAAe;IACzBiC,oBAAoB,EAAEjC,eAAe;IACrCkC,iBAAiB,EAAElC,eAAe;IAClCmC,eAAe,EAAEnC,eAAe;IAChCoC,0BAA0B,EAAEpC,eAAe;IAC3CqC,gBAAgB,EAAErC,eAAe;IACjCsC,cAAc,EAAEtC,eAAe;IAC/BuC,cAAc,EAAEvC,eAAe;IAC/BwC,aAAa,EAAExC,eAAe;IAC9ByC,SAAS,EAAEzC,eAAe;IAC1B0C,UAAU,EAAE9C,IAAI;IAChB+C,OAAO,EAAE/C,IAAI;IACbgD,OAAO,EAAEA,CAAA,KAAMrC,IAAI,CAACsC,IAAI,CAAChD,SAAS,EAAE,CAAC,CAAC;IACtCiD,QAAQ,EAAElD,IAAI;IACdmD,WAAW,EAAEA,CAAA,KAAM,IAAI;IACvBC,QAAQ,EAAEA,CAAA,KAAM,IAAI;IACpBC,MAAM,EAAEA,CAAA,KAAM,IAAI;IAClBC,QAAQ,EAAEA,CAAA,KAAM;EAClB,CAAC;AACH,CAAC;AAACC,OAAA,CAAAjD,IAAA,GAAAA,IAAA","ignoreList":[]}
1
+ {"version":3,"names":["_web","require","_JsiSkImage","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","JsiSkApi","Skia","Canvas","View","getPreferredHighBitDepthCanvasFormat","SkiaPictureView","JsiSkImage","drawAsPicture","drawAsImage","drawAsImageFromPicture","useCanvasRef","useCanvasSize","ref","size","width","height","useValue","useComputedValue","useTiming","useLoop","useSpring","useClockValue","useValueEffect","isOnMainThread","isFabric","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG","useVideo","exports"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { JsiSkImage } from \"../skia/web/JsiSkImage\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n global.SkiaApi = JsiSkApi(CanvasKit);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n Canvas: require(\"react-native\").View,\n getPreferredHighBitDepthCanvasFormat: () => \"rgba16float\",\n SkiaPictureView: require(\"react-native\").View,\n JsiSkImage: JsiSkImage,\n drawAsPicture: Noop,\n drawAsImage: Noop,\n drawAsImageFromPicture: Noop,\n useCanvasRef: NoopValue,\n useCanvasSize: () => ({\n ref: {\n current: 0,\n },\n size: {\n width: 0,\n height: 0,\n },\n }),\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n isOnMainThread: () => true,\n isFabric: true,\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n useVideo: () => null,\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA;AACA,MAAME,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAAEC,KAAK,EAAE;AAAE,CAAC,CAAC;AAErC,MAAMC,IAAI,GAAIC,SAAoB,IAAK;EAC5C;EACA;EACAC,MAAM,CAACC,OAAO,GAAG,IAAAC,aAAQ,EAACH,SAAS,CAAC;EACpC;EACA;EACA,MAAMI,IAAI,GAAGH,MAAM,CAACC,OAAO;EAC3B,OAAO;IACLE,IAAI;IACJ,GAAGb,OAAO,CAAC,wBAAwB,CAAC;IACpC,GAAGA,OAAO,CAAC,SAAS,CAAC;IACrB,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1Bc,MAAM,EAAEd,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IACpCC,oCAAoC,EAAEA,CAAA,KAAM,aAAa;IACzDC,eAAe,EAAEjB,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IAC7CG,UAAU,EAAEA,sBAAU;IACtBC,aAAa,EAAEjB,IAAI;IACnBkB,WAAW,EAAElB,IAAI;IACjBmB,sBAAsB,EAAEnB,IAAI;IAC5BoB,YAAY,EAAElB,SAAS;IACvBmB,aAAa,EAAEA,CAAA,MAAO;MACpBC,GAAG,EAAE;QACHnB,OAAO,EAAE;MACX,CAAC;MACDoB,IAAI,EAAE;QACJC,KAAK,EAAE,CAAC;QACRC,MAAM,EAAE;MACV;IACF,CAAC,CAAC;IACF;IACAC,QAAQ,EAAExB,SAAS;IACnByB,gBAAgB,EAAEzB,SAAS;IAC3B0B,SAAS,EAAE1B,SAAS;IACpB2B,OAAO,EAAE3B,SAAS;IAClB4B,SAAS,EAAE5B,SAAS;IACpB6B,aAAa,EAAE7B,SAAS;IACxB8B,cAAc,EAAEhC,IAAI;IACpB;IACAiC,cAAc,EAAEA,CAAA,KAAM,IAAI;IAC1BC,QAAQ,EAAE,IAAI;IACdC,QAAQ,EAAE/B,eAAe;IACzBgC,oBAAoB,EAAEhC,eAAe;IACrCiC,iBAAiB,EAAEjC,eAAe;IAClCkC,eAAe,EAAElC,eAAe;IAChCmC,0BAA0B,EAAEnC,eAAe;IAC3CoC,gBAAgB,EAAEpC,eAAe;IACjCqC,cAAc,EAAErC,eAAe;IAC/BsC,cAAc,EAAEtC,eAAe;IAC/BuC,aAAa,EAAEvC,eAAe;IAC9BwC,SAAS,EAAExC,eAAe;IAC1ByC,UAAU,EAAE7C,IAAI;IAChB8C,OAAO,EAAE9C,IAAI;IACb+C,OAAO,EAAEA,CAAA,KAAMpC,IAAI,CAACqC,IAAI,CAAC/C,SAAS,EAAE,CAAC,CAAC;IACtCgD,QAAQ,EAAEjD,IAAI;IACdkD,WAAW,EAAEA,CAAA,KAAM,IAAI;IACvBC,QAAQ,EAAEA,CAAA,KAAM,IAAI;IACpBC,MAAM,EAAEA,CAAA,KAAM,IAAI;IAClBC,QAAQ,EAAEA,CAAA,KAAM;EAClB,CAAC;AACH,CAAC;AAACC,OAAA,CAAAhD,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _Platform = require("../Platform");
4
4
  var _NativeSkiaModule = _interopRequireDefault(require("../specs/NativeSkiaModule"));
5
+ var _SkiaWorkletSerialization = require("./SkiaWorkletSerialization");
5
6
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
6
7
  if (_Platform.Platform.OS !== "web" && global.SkiaApi == null) {
7
8
  // Initialize RN Skia
@@ -13,5 +14,8 @@ if (_Platform.Platform.OS !== "web" && global.SkiaApi == null) {
13
14
  if (result !== true) {
14
15
  throw new Error(`Native Skia Module failed to correctly install JSI Bindings! Result: ${result}`);
15
16
  }
17
+ // Skia objects use the JSI NativeState pattern and need a custom
18
+ // serializer to be transferable to worklet runtimes (Reanimated).
19
+ (0, _SkiaWorkletSerialization.registerSkiaWorkletSerialization)();
16
20
  }
17
21
  //# sourceMappingURL=NativeSetup.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Platform","require","_NativeSkiaModule","_interopRequireDefault","e","__esModule","default","Platform","OS","global","SkiaApi","SkiaModule","NativeSkiaModule","install","Error","result"],"sources":["NativeSetup.ts"],"sourcesContent":["import { Platform } from \"../Platform\";\nimport NativeSkiaModule from \"../specs/NativeSkiaModule\";\n\nif (Platform.OS !== \"web\" && global.SkiaApi == null) {\n // Initialize RN Skia\n const SkiaModule = NativeSkiaModule;\n if (SkiaModule == null || typeof SkiaModule.install !== \"function\") {\n throw new Error(\n \"Native RNSkia Module cannot be found! Make sure you correctly \" +\n \"installed native dependencies and rebuilt your app.\"\n );\n }\n const result = SkiaModule.install();\n if (result !== true) {\n throw new Error(\n `Native Skia Module failed to correctly install JSI Bindings! Result: ${result}`\n );\n }\n}\n"],"mappings":";;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAyD,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzD,IAAIG,kBAAQ,CAACC,EAAE,KAAK,KAAK,IAAIC,MAAM,CAACC,OAAO,IAAI,IAAI,EAAE;EACnD;EACA,MAAMC,UAAU,GAAGC,yBAAgB;EACnC,IAAID,UAAU,IAAI,IAAI,IAAI,OAAOA,UAAU,CAACE,OAAO,KAAK,UAAU,EAAE;IAClE,MAAM,IAAIC,KAAK,CACb,gEAAgE,GAC9D,qDACJ,CAAC;EACH;EACA,MAAMC,MAAM,GAAGJ,UAAU,CAACE,OAAO,CAAC,CAAC;EACnC,IAAIE,MAAM,KAAK,IAAI,EAAE;IACnB,MAAM,IAAID,KAAK,CACb,wEAAwEC,MAAM,EAChF,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_Platform","require","_NativeSkiaModule","_interopRequireDefault","_SkiaWorkletSerialization","e","__esModule","default","Platform","OS","global","SkiaApi","SkiaModule","NativeSkiaModule","install","Error","result","registerSkiaWorkletSerialization"],"sources":["NativeSetup.ts"],"sourcesContent":["import { Platform } from \"../Platform\";\nimport NativeSkiaModule from \"../specs/NativeSkiaModule\";\n\nimport { registerSkiaWorkletSerialization } from \"./SkiaWorkletSerialization\";\n\nif (Platform.OS !== \"web\" && global.SkiaApi == null) {\n // Initialize RN Skia\n const SkiaModule = NativeSkiaModule;\n if (SkiaModule == null || typeof SkiaModule.install !== \"function\") {\n throw new Error(\n \"Native RNSkia Module cannot be found! Make sure you correctly \" +\n \"installed native dependencies and rebuilt your app.\"\n );\n }\n const result = SkiaModule.install();\n if (result !== true) {\n throw new Error(\n `Native Skia Module failed to correctly install JSI Bindings! Result: ${result}`\n );\n }\n // Skia objects use the JSI NativeState pattern and need a custom\n // serializer to be transferable to worklet runtimes (Reanimated).\n registerSkiaWorkletSerialization();\n}\n"],"mappings":";;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,yBAAA,GAAAH,OAAA;AAA8E,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9E,IAAIG,kBAAQ,CAACC,EAAE,KAAK,KAAK,IAAIC,MAAM,CAACC,OAAO,IAAI,IAAI,EAAE;EACnD;EACA,MAAMC,UAAU,GAAGC,yBAAgB;EACnC,IAAID,UAAU,IAAI,IAAI,IAAI,OAAOA,UAAU,CAACE,OAAO,KAAK,UAAU,EAAE;IAClE,MAAM,IAAIC,KAAK,CACb,gEAAgE,GAC9D,qDACJ,CAAC;EACH;EACA,MAAMC,MAAM,GAAGJ,UAAU,CAACE,OAAO,CAAC,CAAC;EACnC,IAAIE,MAAM,KAAK,IAAI,EAAE;IACnB,MAAM,IAAID,KAAK,CACb,wEAAwEC,MAAM,EAChF,CAAC;EACH;EACA;EACA;EACA,IAAAC,0DAAgC,EAAC,CAAC;AACpC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const registerSkiaWorkletSerialization: () => void;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.registerSkiaWorkletSerialization = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+
9
+ /**
10
+ * Skia and WebGPU API objects are implemented with the JSI NativeState
11
+ * pattern: plain JS objects with a shared prototype and native state
12
+ * attached. Worklets cannot serialize such objects by default (the prototype
13
+ * would be lost when moving them to another runtime), so we register a
14
+ * Custom Serializable that:
15
+ *
16
+ * - determine: detects native objects via the `__box` method installed on
17
+ * every Skia and WebGPU prototype (plain objects never reach the
18
+ * custom-serializable path, so this cannot misfire on user data).
19
+ * - pack: boxes the object into a HostObject wrapper that carries the native
20
+ * state and the class brand. HostObjects are transferred by reference.
21
+ * - unpack: unboxes on the target runtime, re-installing the class prototype
22
+ * there and re-attaching the same native state.
23
+ *
24
+ * See cpp/jsi/BoxedNativeObject.h for the native side.
25
+ *
26
+ * `react-native-worklets` (Reanimated 4) is required for this to work —
27
+ * without it, Skia and WebGPU objects cannot be captured in worklets or
28
+ * stored in shared values.
29
+ */
30
+
31
+ const determine = value => {
32
+ "worklet";
33
+
34
+ return typeof value.__box === "function";
35
+ };
36
+ const pack = value => {
37
+ "worklet";
38
+
39
+ return value.__box();
40
+ };
41
+ const unpack = packed => {
42
+ "worklet";
43
+
44
+ return packed.unbox();
45
+ };
46
+ const registerSkiaWorkletSerialization = () => {
47
+ try {
48
+ const worklets = require("react-native-worklets");
49
+ if (typeof worklets.registerCustomSerializable === "function") {
50
+ worklets.registerCustomSerializable({
51
+ name: "ReactNativeSkia",
52
+ determine,
53
+ pack,
54
+ unpack
55
+ });
56
+ } else {
57
+ console.error("React Native Skia requires react-native-worklets >= 0.7.0 " + "(registerCustomSerializable) to use Skia objects inside worklets. " + "Please upgrade react-native-worklets and react-native-reanimated.");
58
+ }
59
+ } catch (e) {
60
+ // react-native-worklets is not installed. This is fine for apps that do
61
+ // not use Reanimated: Skia objects simply cannot be used inside worklets
62
+ // or shared values in this configuration.
63
+ }
64
+ };
65
+ exports.registerSkiaWorkletSerialization = registerSkiaWorkletSerialization;
66
+ //# sourceMappingURL=SkiaWorkletSerialization.js.map