@shopify/react-native-skia 2.6.4 → 2.6.6

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 (338) hide show
  1. package/android/CMakeLists.txt +8 -4
  2. package/android/build.gradle +22 -3
  3. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +62 -0
  4. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerDelegate.java +35 -0
  5. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerInterface.java +17 -0
  6. package/apple/RNSkApplePlatformContext.h +2 -0
  7. package/apple/RNSkApplePlatformContext.mm +71 -0
  8. package/apple/RNWebGPUAppleNativeBuffer.mm +33 -0
  9. package/cpp/api/JsiNativeBuffer.h +9 -1
  10. package/cpp/api/JsiSkAnimatedImageFactory.h +1 -1
  11. package/cpp/api/JsiSkApi.h +2 -2
  12. package/cpp/api/JsiSkCanvas.h +34 -1
  13. package/cpp/api/JsiSkDataFactory.h +1 -1
  14. package/cpp/api/JsiSkFont.h +1 -1
  15. package/cpp/api/JsiSkFontMgr.h +1 -1
  16. package/cpp/api/JsiSkHostObjects.h +3 -3
  17. package/cpp/api/JsiSkImage.h +14 -6
  18. package/cpp/api/JsiSkImageFactory.h +2 -2
  19. package/cpp/api/JsiSkPath.h +1 -1
  20. package/cpp/api/JsiSkPathFactory.h +1 -1
  21. package/cpp/api/JsiSkSurface.h +18 -6
  22. package/cpp/api/JsiSkTypeface.h +1 -1
  23. package/cpp/api/JsiSkTypefaceFontProvider.h +1 -1
  24. package/cpp/api/JsiSkiaContext.h +2 -2
  25. package/cpp/api/JsiTextureInfo.h +1 -1
  26. package/cpp/api/JsiVideo.h +2 -2
  27. package/cpp/api/recorder/Drawings.h +1 -1
  28. package/cpp/api/recorder/JsiRecorder.h +4 -4
  29. package/cpp/api/recorder/RNRecorder.h +1 -1
  30. package/cpp/jsi/ViewProperty.h +1 -1
  31. package/cpp/rnskia/RNDawnContext.h +13 -0
  32. package/cpp/rnskia/RNDawnUtils.h +11 -1
  33. package/cpp/rnskia/RNSkJsiViewApi.h +2 -2
  34. package/cpp/rnskia/RNSkManager.cpp +88 -2
  35. package/cpp/rnskia/RNSkPictureView.h +4 -4
  36. package/cpp/rnskia/RNSkPlatformContext.h +7 -0
  37. package/cpp/rnskia/RNSkView.h +9 -6
  38. package/cpp/rnwgpu/ArrayBuffer.h +51 -7
  39. package/cpp/rnwgpu/api/AppleNativeBuffer.h +22 -0
  40. package/cpp/rnwgpu/api/Convertors.h +33 -11
  41. package/cpp/rnwgpu/api/GPU.cpp +0 -3
  42. package/cpp/rnwgpu/api/GPUAdapter.cpp +37 -7
  43. package/cpp/rnwgpu/api/GPUBuffer.h +1 -1
  44. package/cpp/rnwgpu/api/GPUDevice.cpp +84 -6
  45. package/cpp/rnwgpu/api/GPUDevice.h +12 -0
  46. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +139 -0
  47. package/cpp/rnwgpu/api/GPUExternalTexture.h +52 -2
  48. package/cpp/rnwgpu/api/GPUQueue.cpp +50 -45
  49. package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
  50. package/cpp/rnwgpu/api/GPUSharedFence.cpp +80 -0
  51. package/cpp/rnwgpu/api/GPUSharedFence.h +53 -0
  52. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +135 -0
  53. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +75 -0
  54. package/cpp/rnwgpu/api/ImageBitmap.h +62 -0
  55. package/cpp/rnwgpu/api/NativeBufferUtils.h +87 -0
  56. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +4 -1
  57. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +1 -1
  58. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +56 -0
  59. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +10 -0
  60. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +43 -24
  61. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +9 -9
  62. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +1 -1
  63. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +2 -2
  64. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +58 -0
  65. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +51 -0
  66. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +73 -0
  67. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +1 -1
  68. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +1 -1
  69. package/cpp/skia/include/android/GrAHardwareBufferUtils.h +1 -1
  70. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +1 -1
  71. package/cpp/skia/include/android/SkAnimatedImage.h +1 -1
  72. package/cpp/skia/include/codec/SkCodec.h +0 -8
  73. package/cpp/skia/include/codec/SkEncodedOrigin.h +1 -1
  74. package/cpp/skia/include/codec/SkPngRustDecoder.h +1 -1
  75. package/cpp/skia/include/core/SkBitmap.h +2 -8
  76. package/cpp/skia/include/core/SkCPURecorder.h +3 -1
  77. package/cpp/skia/include/core/SkCanvasVirtualEnforcer.h +1 -1
  78. package/cpp/skia/include/core/SkColorType.h +5 -3
  79. package/cpp/skia/include/core/SkContourMeasure.h +1 -1
  80. package/cpp/skia/include/core/SkCoverageMode.h +1 -1
  81. package/cpp/skia/include/core/SkCubicMap.h +1 -1
  82. package/cpp/skia/include/core/SkExecutor.h +1 -1
  83. package/cpp/skia/include/core/SkFont.h +15 -0
  84. package/cpp/skia/include/core/SkFontArguments.h +6 -1
  85. package/cpp/skia/include/core/SkFontMetrics.h +1 -1
  86. package/cpp/skia/include/core/SkFontMgr.h +36 -1
  87. package/cpp/skia/include/core/SkFontParameters.h +1 -1
  88. package/cpp/skia/include/core/SkFontScanner.h +1 -1
  89. package/cpp/skia/include/core/SkFontTypes.h +1 -1
  90. package/cpp/skia/include/core/SkM44.h +1 -1
  91. package/cpp/skia/include/core/SkMilestone.h +1 -1
  92. package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +1 -1
  93. package/cpp/skia/include/core/SkPathBuilder.h +10 -4
  94. package/cpp/skia/include/core/SkPathIter.h +1 -1
  95. package/cpp/skia/include/core/SkPathTypes.h +1 -1
  96. package/cpp/skia/include/core/SkPixelRef.h +4 -1
  97. package/cpp/skia/include/core/SkRecorder.h +2 -1
  98. package/cpp/skia/include/core/SkRegion.h +17 -6
  99. package/cpp/skia/include/core/SkSamplingOptions.h +1 -1
  100. package/cpp/skia/include/core/SkSerialProcs.h +8 -1
  101. package/cpp/skia/include/core/SkShader.h +3 -5
  102. package/cpp/skia/include/core/SkSpan.h +1 -1
  103. package/cpp/skia/include/core/SkStream.h +1 -1
  104. package/cpp/skia/include/core/SkStrikeRef.h +80 -0
  105. package/cpp/skia/include/core/SkTileMode.h +1 -1
  106. package/cpp/skia/include/core/SkVertices.h +1 -1
  107. package/cpp/skia/include/core/SkYUVAPixmaps.h +3 -5
  108. package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
  109. package/cpp/skia/include/docs/SkXPSDocument.h +1 -1
  110. package/cpp/skia/include/effects/SkGradient.h +1 -1
  111. package/cpp/skia/include/effects/SkHighContrastFilter.h +1 -1
  112. package/cpp/skia/include/effects/SkRuntimeEffect.h +2 -2
  113. package/cpp/skia/include/effects/SkShaderMaskFilter.h +1 -1
  114. package/cpp/skia/include/effects/SkTrimPathEffect.h +1 -1
  115. package/cpp/skia/include/encode/SkEncoder.h +1 -1
  116. package/cpp/skia/include/encode/SkJpegEncoder.h +1 -1
  117. package/cpp/skia/include/encode/SkPngEncoder.h +1 -1
  118. package/cpp/skia/include/encode/SkPngRustEncoder.h +1 -1
  119. package/cpp/skia/include/encode/SkWebpEncoder.h +1 -1
  120. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  121. package/cpp/skia/include/gpu/MutableTextureState.h +1 -1
  122. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +1 -1
  123. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +6 -62
  124. package/cpp/skia/include/gpu/ganesh/GrContextThreadSafeProxy.h +1 -1
  125. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +1 -1
  126. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +1 -1
  127. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +2 -1
  128. package/cpp/skia/include/gpu/ganesh/mock/GrMockBackendSurface.h +59 -0
  129. package/cpp/skia/include/gpu/ganesh/mock/GrMockTypes.h +1 -1
  130. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlBackendContext.h +1 -1
  131. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlTypes.h +1 -1
  132. package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +1 -1
  133. package/cpp/skia/include/gpu/graphite/Context.h +12 -5
  134. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +6 -0
  135. package/cpp/skia/include/gpu/graphite/Image.h +82 -9
  136. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +7 -2
  137. package/cpp/skia/include/gpu/graphite/Recorder.h +6 -4
  138. package/cpp/skia/include/gpu/graphite/precompile/PrecompileColorFilter.h +11 -1
  139. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +1 -0
  140. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +1 -1
  141. package/cpp/skia/include/gpu/mtl/MtlMemoryAllocator.h +1 -1
  142. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
  143. package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +1 -1
  144. package/cpp/skia/include/gpu/vk/VulkanTypes.h +1 -1
  145. package/cpp/skia/include/ports/SkCFObject.h +1 -1
  146. package/cpp/skia/include/ports/SkFontMgr_Fontations.h +1 -1
  147. package/cpp/skia/include/ports/SkFontMgr_android_ndk.h +1 -1
  148. package/cpp/skia/include/ports/SkFontMgr_data.h +1 -1
  149. package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +1 -1
  150. package/cpp/skia/include/ports/SkFontMgr_mac_ct.h +1 -1
  151. package/cpp/skia/include/ports/SkFontScanner_Fontations.h +1 -1
  152. package/cpp/skia/include/ports/SkFontScanner_FreeType.h +1 -1
  153. package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
  154. package/cpp/skia/include/private/SkExif.h +1 -1
  155. package/cpp/skia/include/private/SkGainmapInfo.h +1 -1
  156. package/cpp/skia/include/private/SkGainmapShader.h +1 -1
  157. package/cpp/skia/include/private/SkHdrMetadata.h +21 -0
  158. package/cpp/skia/include/private/SkJpegGainmapEncoder.h +1 -1
  159. package/cpp/skia/include/private/SkPixelStorage.h +37 -0
  160. package/cpp/skia/include/private/SkXmp.h +1 -1
  161. package/cpp/skia/include/private/base/SkAssert.h +6 -5
  162. package/cpp/skia/include/private/base/SkContainers.h +1 -1
  163. package/cpp/skia/include/private/base/SkFeatures.h +30 -30
  164. package/cpp/skia/include/private/base/SkLog.h +1 -7
  165. package/cpp/skia/include/private/base/SkLogPriority.h +4 -5
  166. package/cpp/skia/include/private/base/SkMacros.h +1 -1
  167. package/cpp/skia/include/private/base/SkMalloc.h +1 -1
  168. package/cpp/skia/include/private/base/SkSafe32.h +1 -1
  169. package/cpp/skia/include/private/base/SkSpan_impl.h +1 -1
  170. package/cpp/skia/include/private/base/SkTDArray.h +13 -1
  171. package/cpp/skia/include/private/base/SkTPin.h +1 -1
  172. package/cpp/skia/include/private/base/SkTo.h +1 -1
  173. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +1 -1
  174. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +1 -1
  175. package/cpp/skia/include/private/chromium/SkCodecsICCProfileChromium.h +52 -0
  176. package/cpp/skia/include/private/chromium/SkExifChromium.h +26 -0
  177. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
  178. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
  179. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +2 -1
  180. package/cpp/skia/include/private/gpu/vk/SkiaVulkan.h +1 -1
  181. package/cpp/skia/include/sksl/SkSLDebugTrace.h +1 -1
  182. package/cpp/skia/include/third_party/vulkan/vulkan/vk_icd.h +41 -51
  183. package/cpp/skia/include/third_party/vulkan/vulkan/vk_layer.h +42 -53
  184. package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -1
  185. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +158 -154
  186. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +68 -65
  187. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +90 -87
  188. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +9 -9
  189. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +2 -2
  190. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +82 -79
  191. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +24 -24
  192. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +2 -2
  193. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +95 -96
  194. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std.h +151 -0
  195. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std_decode.h +68 -0
  196. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +1 -1
  197. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +5 -1
  198. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +7 -1
  199. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +291 -158
  200. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +13174 -10113
  201. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +23 -19
  202. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +159 -165
  203. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +22 -19
  204. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +3 -1
  205. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +3 -1
  206. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +94 -88
  207. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ohos.h +120 -0
  208. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +55 -51
  209. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +18 -15
  210. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +23 -19
  211. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +31 -1
  212. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +5 -1
  213. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +27 -27
  214. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +20 -16
  215. package/cpp/skia/include/utils/SkEventTracer.h +6 -1
  216. package/cpp/skia/include/utils/SkOrderedFontMgr.h +1 -1
  217. package/cpp/skia/include/utils/SkShadowUtils.h +1 -1
  218. package/cpp/skia/include/utils/SkTextUtils.h +1 -1
  219. package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +20 -4
  220. package/cpp/skia/modules/skcms/src/Transform_inl.h +11 -15
  221. package/cpp/skia/modules/skcms/src/skcms_public.h +2 -0
  222. package/cpp/skia/modules/skottie/include/ExternalLayer.h +1 -1
  223. package/cpp/skia/modules/skottie/include/Skottie.h +1 -1
  224. package/cpp/skia/modules/skottie/include/SkottieProperty.h +1 -1
  225. package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
  226. package/cpp/skia/modules/skottie/include/TextShaper.h +1 -1
  227. package/cpp/skia/modules/skottie/src/SkottieValue.h +1 -1
  228. package/cpp/skia/modules/skottie/src/animator/Animator.h +1 -1
  229. package/cpp/skia/modules/skottie/src/text/Font.h +1 -1
  230. package/cpp/skia/modules/skottie/src/text/TextAdapter.h +1 -1
  231. package/cpp/skia/modules/skottie/src/text/TextAnimator.h +3 -2
  232. package/cpp/skia/modules/skottie/src/text/TextValue.h +1 -1
  233. package/cpp/skia/modules/skparagraph/include/DartTypes.h +1 -1
  234. package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
  235. package/cpp/skia/modules/skparagraph/include/FontCollection.h +5 -1
  236. package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
  237. package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
  238. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +1 -1
  239. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +1 -1
  240. package/cpp/skia/modules/skparagraph/include/ParagraphPainter.h +1 -1
  241. package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +12 -5
  242. package/cpp/skia/modules/skparagraph/include/TextShadow.h +1 -1
  243. package/cpp/skia/modules/skparagraph/include/TextStyle.h +1 -1
  244. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -1
  245. package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +1 -1
  246. package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +1 -1
  247. package/cpp/skia/modules/sksg/include/SkSGDraw.h +1 -1
  248. package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +1 -1
  249. package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +1 -1
  250. package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +1 -1
  251. package/cpp/skia/modules/sksg/include/SkSGGradient.h +1 -1
  252. package/cpp/skia/modules/sksg/include/SkSGGroup.h +1 -1
  253. package/cpp/skia/modules/sksg/include/SkSGImage.h +1 -1
  254. package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +1 -1
  255. package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +1 -1
  256. package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
  257. package/cpp/skia/modules/sksg/include/SkSGNode.h +1 -1
  258. package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +1 -1
  259. package/cpp/skia/modules/sksg/include/SkSGPaint.h +1 -1
  260. package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
  261. package/cpp/skia/modules/sksg/include/SkSGPlane.h +1 -1
  262. package/cpp/skia/modules/sksg/include/SkSGRect.h +1 -1
  263. package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +1 -1
  264. package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +1 -1
  265. package/cpp/skia/modules/sksg/include/SkSGScene.h +1 -1
  266. package/cpp/skia/modules/sksg/include/SkSGText.h +1 -1
  267. package/cpp/skia/modules/sksg/include/SkSGTransform.h +1 -1
  268. package/cpp/skia/modules/skshaper/include/SkShaper_coretext.h +8 -1
  269. package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
  270. package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
  271. package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
  272. package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
  273. package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
  274. package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
  275. package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
  276. package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
  277. package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
  278. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  279. package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
  280. package/cpp/skia/modules/svg/include/SkSVGFeMerge.h +1 -1
  281. package/cpp/skia/modules/svg/include/SkSVGFeMorphology.h +1 -1
  282. package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
  283. package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
  284. package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
  285. package/cpp/skia/modules/svg/include/SkSVGFilterContext.h +1 -1
  286. package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
  287. package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
  288. package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
  289. package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +1 -1
  290. package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
  291. package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
  292. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  293. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  294. package/cpp/skia/src/base/SkAutoLocaleSetter.h +94 -0
  295. package/cpp/skia/src/base/SkUTF.h +1 -1
  296. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +10 -1
  297. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  298. package/lib/commonjs/skia/types/WebGPU.d.ts +153 -0
  299. package/lib/commonjs/skia/types/WebGPU.js +6 -0
  300. package/lib/commonjs/skia/types/WebGPU.js.map +1 -0
  301. package/lib/commonjs/skia/types/index.d.ts +1 -0
  302. package/lib/commonjs/skia/types/index.js +11 -0
  303. package/lib/commonjs/skia/types/index.js.map +1 -1
  304. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
  305. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js +19 -0
  306. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js.map +1 -1
  307. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  308. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +10 -1
  309. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  310. package/lib/module/skia/types/WebGPU.d.ts +153 -0
  311. package/lib/module/skia/types/WebGPU.js +2 -0
  312. package/lib/module/skia/types/WebGPU.js.map +1 -0
  313. package/lib/module/skia/types/index.d.ts +1 -0
  314. package/lib/module/skia/types/index.js +1 -0
  315. package/lib/module/skia/types/index.js.map +1 -1
  316. package/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
  317. package/lib/module/skia/web/JsiSkNativeBufferFactory.js +19 -0
  318. package/lib/module/skia/web/JsiSkNativeBufferFactory.js.map +1 -1
  319. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  320. package/lib/module/web/LoadSkiaWeb.js +1 -2
  321. package/lib/module/web/LoadSkiaWeb.js.map +1 -1
  322. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +1 -0
  323. package/lib/typescript/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
  324. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +1 -0
  325. package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
  326. package/lib/typescript/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
  327. package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +10 -1
  328. package/lib/typescript/src/skia/types/WebGPU.d.ts +153 -0
  329. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  330. package/lib/typescript/src/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
  331. package/package.json +14 -12
  332. package/react-native-skia.podspec +59 -7
  333. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +10 -1
  334. package/src/skia/types/WebGPU.ts +186 -0
  335. package/src/skia/types/index.ts +1 -0
  336. package/src/skia/web/JsiSkNativeBufferFactory.ts +20 -0
  337. package/src/skia/web/JsiSkPath.ts +8 -2
  338. package/scripts/install-libs.js +0 -133
@@ -0,0 +1,135 @@
1
+ #include "GPUSharedTextureMemory.h"
2
+
3
+ #include <cstdint>
4
+ #include <memory>
5
+ #include <optional>
6
+ #include <stdexcept>
7
+ #include <string>
8
+ #include <vector>
9
+
10
+ #include "Convertors.h"
11
+
12
+ namespace rnwgpu {
13
+
14
+ std::shared_ptr<GPUTexture> GPUSharedTextureMemory::createTexture(
15
+ std::optional<std::shared_ptr<GPUTextureDescriptor>> descriptor) {
16
+ if (!descriptor.has_value() || descriptor.value() == nullptr) {
17
+ auto texture = _instance.CreateTexture();
18
+ // The texture aliases the shared memory; it doesn't own GPU allocation, so
19
+ // it doesn't report memory pressure.
20
+ return std::make_shared<GPUTexture>(texture, "", false);
21
+ }
22
+
23
+ wgpu::TextureDescriptor desc{};
24
+ Convertor conv;
25
+ if (!conv(desc, descriptor.value())) {
26
+ throw std::runtime_error(
27
+ "GPUSharedTextureMemory::createTexture(): Error with "
28
+ "GPUTextureDescriptor");
29
+ }
30
+ auto texture = _instance.CreateTexture(&desc);
31
+ return std::make_shared<GPUTexture>(
32
+ texture, descriptor.value()->label.value_or(""), false);
33
+ }
34
+
35
+ void GPUSharedTextureMemory::beginAccess(
36
+ std::shared_ptr<GPUTexture> texture, bool initialized,
37
+ std::optional<std::vector<std::shared_ptr<GPUSharedFenceState>>> fences) {
38
+ if (!texture) {
39
+ throw std::runtime_error(
40
+ "GPUSharedTextureMemory::beginAccess(): texture is null");
41
+ }
42
+ wgpu::SharedTextureMemoryBeginAccessDescriptor desc{};
43
+ desc.initialized = initialized;
44
+ desc.concurrentRead = false;
45
+
46
+ // Built in lockstep so fenceCount covers both arrays, and kept in locals so
47
+ // the raw pointers outlive the synchronous BeginAccess() below.
48
+ std::vector<wgpu::SharedFence> rawFences;
49
+ std::vector<uint64_t> values;
50
+ if (fences.has_value()) {
51
+ for (const auto &state : *fences) {
52
+ if (state && state->fence) {
53
+ rawFences.push_back(state->fence->get());
54
+ values.push_back(state->signaledValue);
55
+ }
56
+ }
57
+ }
58
+ if (!rawFences.empty()) {
59
+ desc.fenceCount = rawFences.size();
60
+ desc.fences = rawFences.data();
61
+ desc.signaledValues = values.data();
62
+ } else {
63
+ desc.fenceCount = 0;
64
+ desc.fences = nullptr;
65
+ desc.signaledValues = nullptr;
66
+ }
67
+
68
+ #if defined(__ANDROID__)
69
+ // Dawn's Vulkan backend (AHardwareBuffer) validates that the begin-access
70
+ // descriptor chains a SharedTextureMemoryVkImageLayoutBeginState specifying
71
+ // the VkImageLayout to acquire the image into. UNDEFINED (= 0) on both ends
72
+ // is the canonical "no prior GPU producer" pattern: Dawn performs an
73
+ // external-queue acquire from VK_QUEUE_FAMILY_EXTERNAL which preserves the
74
+ // AHB contents, then transitions to whatever layout the texture's actual
75
+ // usage requires.
76
+ wgpu::SharedTextureMemoryVkImageLayoutBeginState vkLayout{};
77
+ vkLayout.oldLayout = 0;
78
+ vkLayout.newLayout = 0;
79
+ desc.nextInChain = &vkLayout;
80
+ #endif
81
+
82
+ auto status = _instance.BeginAccess(texture->get(), &desc);
83
+ if (!status) {
84
+ throw std::runtime_error("GPUSharedTextureMemory::beginAccess() failed");
85
+ }
86
+ }
87
+
88
+ jsi::Value GPUSharedTextureMemory::endAccess(jsi::Runtime &runtime,
89
+ const jsi::Value &,
90
+ const jsi::Value *args,
91
+ size_t count) {
92
+ if (count < 1 || !args[0].isObject()) {
93
+ throw jsi::JSError(
94
+ runtime, "GPUSharedTextureMemory::endAccess(): expected (texture)");
95
+ }
96
+ auto texture = GPUTexture::fromValue(runtime, args[0]);
97
+
98
+ wgpu::SharedTextureMemoryEndAccessState state{};
99
+
100
+ #if defined(__ANDROID__)
101
+ // Dawn's Vulkan backend writes the released old/new VkImageLayouts back into
102
+ // a chained SharedTextureMemoryVkImageLayoutEndState; validation requires
103
+ // the chain even when the caller doesn't read the values.
104
+ wgpu::SharedTextureMemoryVkImageLayoutEndState vkLayout{};
105
+ state.nextInChain = &vkLayout;
106
+ #endif
107
+
108
+ auto status = _instance.EndAccess(texture->get(), &state);
109
+ if (!status) {
110
+ throw jsi::JSError(runtime, "GPUSharedTextureMemory::endAccess() failed");
111
+ }
112
+
113
+ // Copy each wgpu::SharedFence (ref-counted) into its own GPUSharedFence
114
+ // wrapper before `state` is destroyed.
115
+ jsi::Array fences(runtime, state.fenceCount);
116
+ for (size_t i = 0; i < state.fenceCount; i++) {
117
+ wgpu::SharedFence fence = state.fences[i];
118
+ auto wrapper = std::make_shared<GPUSharedFence>(std::move(fence), "");
119
+ jsi::Object entry(runtime);
120
+ entry.setProperty(runtime, "fence",
121
+ GPUSharedFence::create(runtime, std::move(wrapper)));
122
+ entry.setProperty(
123
+ runtime, "signaledValue",
124
+ jsi::BigInt::fromUint64(runtime, state.signaledValues[i]));
125
+ fences.setValueAtIndex(runtime, i, std::move(entry));
126
+ }
127
+
128
+ jsi::Object result(runtime);
129
+ result.setProperty(runtime, "initialized",
130
+ jsi::Value(static_cast<bool>(state.initialized)));
131
+ result.setProperty(runtime, "fences", std::move(fences));
132
+ return result;
133
+ }
134
+
135
+ } // namespace rnwgpu
@@ -0,0 +1,75 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <memory>
5
+ #include <optional>
6
+ #include <string>
7
+ #include <vector>
8
+
9
+ #include "jsi2/NativeObject.h"
10
+
11
+ #include "webgpu/webgpu_cpp.h"
12
+
13
+ #include "GPUSharedFence.h"
14
+ #include "GPUTexture.h"
15
+ #include "descriptors/GPUSharedFenceState.h"
16
+ #include "descriptors/GPUTextureDescriptor.h"
17
+
18
+ namespace rnwgpu {
19
+
20
+ namespace jsi = facebook::jsi;
21
+
22
+ class GPUSharedTextureMemory : public NativeObject<GPUSharedTextureMemory> {
23
+ public:
24
+ static constexpr const char *CLASS_NAME = "GPUSharedTextureMemory";
25
+
26
+ explicit GPUSharedTextureMemory(wgpu::SharedTextureMemory instance,
27
+ std::string label)
28
+ : NativeObject(CLASS_NAME), _instance(std::move(instance)),
29
+ _label(std::move(label)) {}
30
+
31
+ public:
32
+ std::string getBrand() { return CLASS_NAME; }
33
+
34
+ std::shared_ptr<GPUTexture> createTexture(
35
+ std::optional<std::shared_ptr<GPUTextureDescriptor>> descriptor);
36
+
37
+ // Optional `fences` are wait fences: Dawn waits for each to reach its
38
+ // signaledValue before writing the surface. Throws on failure.
39
+ void beginAccess(
40
+ std::shared_ptr<GPUTexture> texture, bool initialized,
41
+ std::optional<std::vector<std::shared_ptr<GPUSharedFenceState>>> fences);
42
+
43
+ // endAccess(texture) -> { initialized, fences: { fence, signaledValue }[] }
44
+ // Surfaces the fences Dawn produced for the access. Throws on failure.
45
+ jsi::Value endAccess(jsi::Runtime &runtime, const jsi::Value &thisVal,
46
+ const jsi::Value *args, size_t count);
47
+
48
+ std::string getLabel() { return _label; }
49
+ void setLabel(const std::string &label) {
50
+ _label = label;
51
+ _instance.SetLabel(_label.c_str());
52
+ }
53
+
54
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
55
+ installGetter(runtime, prototype, "__brand",
56
+ &GPUSharedTextureMemory::getBrand);
57
+ installMethod(runtime, prototype, "createTexture",
58
+ &GPUSharedTextureMemory::createTexture);
59
+ installMethod(runtime, prototype, "beginAccess",
60
+ &GPUSharedTextureMemory::beginAccess);
61
+ installMethod(runtime, prototype, "endAccess",
62
+ &GPUSharedTextureMemory::endAccess);
63
+ installGetterSetter(runtime, prototype, "label",
64
+ &GPUSharedTextureMemory::getLabel,
65
+ &GPUSharedTextureMemory::setLabel);
66
+ }
67
+
68
+ inline const wgpu::SharedTextureMemory get() { return _instance; }
69
+
70
+ private:
71
+ wgpu::SharedTextureMemory _instance;
72
+ std::string _label;
73
+ };
74
+
75
+ } // namespace rnwgpu
@@ -0,0 +1,62 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <memory>
5
+ #include <utility>
6
+ #include <vector>
7
+
8
+ #include "jsi2/NativeObject.h"
9
+
10
+ namespace rnwgpu {
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ // DRAFT — compile-unverified. Minimal ImageBitmap holding decoded, unpremul
15
+ // RGBA8 pixels plus its dimensions. Produced by the global createImageBitmap()
16
+ // binding (see RNSkManager.cpp). Decoding is done with Skia's own codec, so no
17
+ // platform-specific image decoder is required.
18
+ //
19
+ // FOLLOW-UP: to make an ImageBitmap usable as a copyExternalImageToTexture
20
+ // source, uncomment the `source` field + ImageBitmap converter in
21
+ // rnwgpu/api/descriptors/GPUImageCopyExternalImage.h and upload `data()` in
22
+ // GPUQueue::copyExternalImageToTexture. That GPU wiring is intentionally out of
23
+ // scope for this draft.
24
+ class ImageBitmap : public NativeObject<ImageBitmap> {
25
+ public:
26
+ static constexpr const char *CLASS_NAME = "ImageBitmap";
27
+
28
+ ImageBitmap(std::vector<uint8_t> data, size_t width, size_t height)
29
+ : NativeObject(CLASS_NAME), _data(std::move(data)), _width(width),
30
+ _height(height) {}
31
+
32
+ size_t getWidth() { return _width; }
33
+
34
+ size_t getHeight() { return _height; }
35
+
36
+ // Per the spec, close() releases the bitmap's underlying pixels and zeroes
37
+ // its dimensions. Idempotent.
38
+ void close() {
39
+ _data.clear();
40
+ _data.shrink_to_fit();
41
+ _width = 0;
42
+ _height = 0;
43
+ }
44
+
45
+ // Decoded, unpremultiplied RGBA8 pixels (row-major, width*height*4 bytes).
46
+ const std::vector<uint8_t> &data() const { return _data; }
47
+
48
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
49
+ installGetter(runtime, prototype, "width", &ImageBitmap::getWidth);
50
+ installGetter(runtime, prototype, "height", &ImageBitmap::getHeight);
51
+ installMethod(runtime, prototype, "close", &ImageBitmap::close);
52
+ }
53
+
54
+ size_t getMemoryPressure() override { return _data.size(); }
55
+
56
+ private:
57
+ std::vector<uint8_t> _data;
58
+ size_t _width;
59
+ size_t _height;
60
+ };
61
+
62
+ } // namespace rnwgpu
@@ -0,0 +1,87 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <stdexcept>
5
+ #include <string>
6
+
7
+ #include "webgpu/webgpu_cpp.h"
8
+
9
+ #if defined(__APPLE__)
10
+ #include "AppleNativeBuffer.h"
11
+ #elif defined(__ANDROID__)
12
+ #include <android/hardware_buffer.h>
13
+ #endif
14
+
15
+ namespace rnwgpu {
16
+
17
+ // Import a Skia NativeBuffer pointer (a CVPixelBufferRef on Apple, an
18
+ // AHardwareBuffer* on Android, as returned by Skia.NativeBuffer.MakeFromImage /
19
+ // MakeTestBuffer) as a wgpu::SharedTextureMemory on `device`. When non-null,
20
+ // outWidth/outHeight receive the surface dimensions. Returns a null
21
+ // SharedTextureMemory if the import itself fails (the caller decides how to
22
+ // report that); throws std::runtime_error for pre-import failures (a buffer
23
+ // with no IOSurface, or an unsupported platform).
24
+ //
25
+ // The platform-specific chained descriptor only needs to outlive the
26
+ // ImportSharedTextureMemory call, so it lives entirely within this function.
27
+ // Shared by GPUDevice::importSharedTextureMemory and
28
+ // GPUExternalTexture::Create.
29
+ inline wgpu::SharedTextureMemory importNativeBufferAsSharedTextureMemory(
30
+ const wgpu::Device &device, void *bufferPtr, const std::string &label,
31
+ uint32_t *outWidth, uint32_t *outHeight) {
32
+ wgpu::SharedTextureMemoryDescriptor memDesc{};
33
+ if (!label.empty()) {
34
+ memDesc.label = wgpu::StringView(label.c_str(), label.size());
35
+ }
36
+
37
+ uint32_t width = 0;
38
+ uint32_t height = 0;
39
+ wgpu::SharedTextureMemory memory;
40
+
41
+ #if defined(__APPLE__)
42
+ // Skia's NativeBuffer is a CVPixelBufferRef; extract its backing IOSurface
43
+ // (and dimensions) in Objective-C++ since CoreVideo isn't available here.
44
+ void *ioSurface = GetIOSurfaceFromNativeBuffer(bufferPtr, &width, &height);
45
+ if (ioSurface == nullptr) {
46
+ throw std::runtime_error(
47
+ "importNativeBufferAsSharedTextureMemory(): native "
48
+ "buffer has no IOSurface");
49
+ }
50
+ wgpu::SharedTextureMemoryIOSurfaceDescriptor platformDesc{};
51
+ platformDesc.ioSurface = ioSurface;
52
+ // Default off: enabling it propagates StorageBinding into properties.usage,
53
+ // which then forces memory.createTexture() (no-descriptor form) to validate
54
+ // the format against storage capabilities. bgra8unorm (the standard
55
+ // CVPixelBuffer format) only supports storage when the device opts into the
56
+ // bgra8unorm-storage feature, so unconditionally setting this here breaks the
57
+ // common sample-only case.
58
+ platformDesc.allowStorageBinding = false;
59
+ memDesc.nextInChain = &platformDesc;
60
+ memory = device.ImportSharedTextureMemory(&memDesc);
61
+ #elif defined(__ANDROID__)
62
+ auto *ahb = reinterpret_cast<AHardwareBuffer *>(bufferPtr);
63
+ AHardwareBuffer_Desc ahbDesc = {};
64
+ AHardwareBuffer_describe(ahb, &ahbDesc);
65
+ width = ahbDesc.width;
66
+ height = ahbDesc.height;
67
+ wgpu::SharedTextureMemoryAHardwareBufferDescriptor platformDesc{};
68
+ platformDesc.handle = ahb;
69
+ memDesc.nextInChain = &platformDesc;
70
+ memory = device.ImportSharedTextureMemory(&memDesc);
71
+ #else
72
+ (void)device;
73
+ (void)bufferPtr;
74
+ throw std::runtime_error(
75
+ "importNativeBufferAsSharedTextureMemory(): unsupported platform");
76
+ #endif
77
+
78
+ if (outWidth != nullptr) {
79
+ *outWidth = width;
80
+ }
81
+ if (outHeight != nullptr) {
82
+ *outHeight = height;
83
+ }
84
+ return memory;
85
+ }
86
+
87
+ } // namespace rnwgpu
@@ -20,7 +20,7 @@ struct GPUBindGroupEntry {
20
20
  std::shared_ptr<GPUSampler> sampler = nullptr;
21
21
  std::shared_ptr<GPUTextureView> textureView = nullptr;
22
22
  std::shared_ptr<GPUBufferBinding> buffer = nullptr;
23
- // external textures
23
+ std::shared_ptr<GPUExternalTexture> externalTexture = nullptr;
24
24
  };
25
25
 
26
26
  } // namespace rnwgpu
@@ -45,6 +45,9 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
45
45
  } else if (obj.hasNativeState<rnwgpu::GPUTextureView>(runtime)) {
46
46
  result->textureView =
47
47
  obj.getNativeState<rnwgpu::GPUTextureView>(runtime);
48
+ } else if (obj.hasNativeState<rnwgpu::GPUExternalTexture>(runtime)) {
49
+ result->externalTexture =
50
+ obj.getNativeState<rnwgpu::GPUExternalTexture>(runtime);
48
51
  } else if (obj.hasNativeState<rnwgpu::GPUBuffer>(runtime)) {
49
52
  auto binding = std::make_shared<rnwgpu::GPUBufferBinding>();
50
53
  binding->buffer = obj.getNativeState<rnwgpu::GPUBuffer>(runtime);
@@ -7,7 +7,7 @@
7
7
 
8
8
  #include "jsi2/JSIConverter.h"
9
9
 
10
- #include "GPUDevice.h"
10
+ #include "rnwgpu/api/GPUDevice.h"
11
11
 
12
12
  namespace jsi = facebook::jsi;
13
13
 
@@ -0,0 +1,56 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+ #include <vector>
6
+
7
+ #include "webgpu/webgpu_cpp.h"
8
+
9
+ #include "jsi2/JSIConverter.h"
10
+
11
+ namespace jsi = facebook::jsi;
12
+
13
+ namespace rnwgpu {
14
+
15
+ // Non-standard, Dawn-only. Mirrors wgpu::DawnTogglesDescriptor field-for-field
16
+ // so the mapping to the native chained struct is 1:1. Chained onto the
17
+ // wgpu::DeviceDescriptor in GPUAdapter::requestDevice.
18
+ struct GPUDawnTogglesDescriptor {
19
+ std::optional<std::vector<std::string>> enabledToggles; // Iterable<string>
20
+ std::optional<std::vector<std::string>> disabledToggles; // Iterable<string>
21
+ };
22
+
23
+ } // namespace rnwgpu
24
+
25
+ namespace rnwgpu {
26
+
27
+ template <>
28
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUDawnTogglesDescriptor>> {
29
+ static std::shared_ptr<rnwgpu::GPUDawnTogglesDescriptor>
30
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
31
+ auto result = std::make_unique<rnwgpu::GPUDawnTogglesDescriptor>();
32
+ if (!outOfBounds && arg.isObject()) {
33
+ auto value = arg.getObject(runtime);
34
+ if (value.hasProperty(runtime, "enabledToggles")) {
35
+ auto prop = value.getProperty(runtime, "enabledToggles");
36
+ result->enabledToggles =
37
+ JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(
38
+ runtime, prop, false);
39
+ }
40
+ if (value.hasProperty(runtime, "disabledToggles")) {
41
+ auto prop = value.getProperty(runtime, "disabledToggles");
42
+ result->disabledToggles =
43
+ JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(
44
+ runtime, prop, false);
45
+ }
46
+ }
47
+ return result;
48
+ }
49
+ static jsi::Value
50
+ toJSI(jsi::Runtime &runtime,
51
+ std::shared_ptr<rnwgpu::GPUDawnTogglesDescriptor> arg) {
52
+ throw std::runtime_error("Invalid GPUDawnTogglesDescriptor::toJSI()");
53
+ }
54
+ };
55
+
56
+ } // namespace rnwgpu
@@ -9,6 +9,7 @@
9
9
 
10
10
  #include "jsi2/JSIConverter.h"
11
11
 
12
+ #include "GPUDawnTogglesDescriptor.h"
12
13
  #include "GPUQueueDescriptor.h"
13
14
 
14
15
  namespace jsi = facebook::jsi;
@@ -23,6 +24,9 @@ struct GPUDeviceDescriptor {
23
24
  std::optional<std::shared_ptr<GPUQueueDescriptor>>
24
25
  defaultQueue; // GPUQueueDescriptor
25
26
  std::optional<std::string> label; // string
27
+ // Non-standard Dawn-only device toggles, chained onto the wgpu::Device
28
+ // descriptor in GPUAdapter::requestDevice.
29
+ std::optional<std::shared_ptr<GPUDawnTogglesDescriptor>> dawnToggles;
26
30
  };
27
31
 
28
32
  } // namespace rnwgpu
@@ -86,6 +90,12 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDeviceDescriptor>> {
86
90
  result->label = JSIConverter<std::optional<std::string>>::fromJSI(
87
91
  runtime, prop, false);
88
92
  }
93
+ if (value.hasProperty(runtime, "dawnToggles")) {
94
+ auto prop = value.getProperty(runtime, "dawnToggles");
95
+ result->dawnToggles = JSIConverter<std::optional<
96
+ std::shared_ptr<GPUDawnTogglesDescriptor>>>::fromJSI(runtime, prop,
97
+ false);
98
+ }
89
99
  }
90
100
 
91
101
  return result;
@@ -1,26 +1,36 @@
1
1
  #pragma once
2
2
 
3
+ #include <cstdint>
3
4
  #include <memory>
4
5
  #include <optional>
5
6
  #include <string>
6
- #include <variant>
7
7
 
8
8
  #include "webgpu/webgpu_cpp.h"
9
9
 
10
- #include "Convertors.h"
11
-
12
10
  #include "jsi2/JSIConverter.h"
13
11
 
14
12
  namespace jsi = facebook::jsi;
15
13
 
16
14
  namespace rnwgpu {
17
15
 
16
+ // Mirror of GPUExternalTextureDescriptor from the WebGPU spec, adapted to
17
+ // Skia's binding. Skia has no VideoFrame; instead `source` is a native buffer
18
+ // pointer (the BigInt returned by Skia.NativeBuffer.MakeFromImage): a
19
+ // CVPixelBufferRef on Apple, an AHardwareBuffer* on Android. The pointer's
20
+ // lifetime is owned by the caller (Skia.NativeBuffer.Release); the imported
21
+ // texture must not outlive it.
22
+ //
23
+ // We don't expose colorSpace yet; the C++ side picks dst-sRGB and identity
24
+ // gamut, the right default for "render this BGRA frame to an sRGB framebuffer".
25
+ //
26
+ // `rotation` / `mirrored` are a non-spec extension baked into Dawn's sampling
27
+ // transform. `rotation` is in degrees and must be one of 0 / 90 / 180 / 270.
18
28
  struct GPUExternalTextureDescriptor {
19
- // std::variant<std::shared_ptr<HTMLVideoElement>,
20
- // std::shared_ptr<VideoFrame>>
21
- // source; // | HTMLVideoElement | VideoFrame
22
- // std::optional<wgpu::DefinedColorSpace> colorSpace; // PredefinedColorSpace
23
- std::optional<std::string> label; // string
29
+ // native buffer pointer (CVPixelBufferRef / AHardwareBuffer*)
30
+ uint64_t source = 0;
31
+ std::optional<std::string> label;
32
+ std::optional<double> rotation;
33
+ std::optional<bool> mirrored;
24
34
  };
25
35
 
26
36
  } // namespace rnwgpu
@@ -31,23 +41,21 @@ template <>
31
41
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor>> {
32
42
  static std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor>
33
43
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
34
- auto result = std::make_unique<rnwgpu::GPUExternalTextureDescriptor>();
44
+ auto result = std::make_shared<rnwgpu::GPUExternalTextureDescriptor>();
35
45
  if (!outOfBounds && arg.isObject()) {
36
46
  auto value = arg.getObject(runtime);
37
47
  if (value.hasProperty(runtime, "source")) {
38
48
  auto prop = value.getProperty(runtime, "source");
39
- // result->source = JSIConverter<
40
- // std::variant<std::shared_ptr<HTMLVideoElement>,
41
- // std::shared_ptr<VideoFrame>>>::fromJSI(runtime,
42
- // prop,
43
- // false);
44
- }
45
- if (value.hasProperty(runtime, "colorSpace")) {
46
- auto prop = value.getProperty(runtime, "colorSpace");
47
- if (!prop.isUndefined()) {
48
- // result->colorSpace =
49
- // JSIConverter<std::optional<wgpu::definedColorSpace>>::fromJSI(
50
- // runtime, prop, false);
49
+ // The native buffer pointer arrives as a BigInt (uintptr_t value). It
50
+ // must be a BigInt: a JS number can't represent a 64-bit pointer
51
+ // without truncation, so we reject it rather than corrupt the address.
52
+ if (prop.isBigInt()) {
53
+ result->source = prop.asBigInt(runtime).asUint64(runtime);
54
+ } else if (!prop.isUndefined() && !prop.isNull()) {
55
+ throw jsi::JSError(
56
+ runtime, "GPUExternalTextureDescriptor.source must be a "
57
+ "NativeBuffer (BigInt) from "
58
+ "Skia.NativeBuffer.MakeFromImage / MakeTestBuffer");
51
59
  }
52
60
  }
53
61
  if (value.hasProperty(runtime, "label")) {
@@ -57,13 +65,24 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor>> {
57
65
  runtime, prop, false);
58
66
  }
59
67
  }
68
+ if (value.hasProperty(runtime, "rotation")) {
69
+ auto prop = value.getProperty(runtime, "rotation");
70
+ if (prop.isNumber()) {
71
+ result->rotation = prop.asNumber();
72
+ }
73
+ }
74
+ if (value.hasProperty(runtime, "mirrored")) {
75
+ auto prop = value.getProperty(runtime, "mirrored");
76
+ if (prop.isBool()) {
77
+ result->mirrored = prop.getBool();
78
+ }
79
+ }
60
80
  }
61
-
62
81
  return result;
63
82
  }
64
83
  static jsi::Value
65
- toJSI(jsi::Runtime &runtime,
66
- std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor> arg) {
84
+ toJSI(jsi::Runtime & /*runtime*/,
85
+ std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor> /*arg*/) {
67
86
  throw std::runtime_error("Invalid GPUExternalTextureDescriptor::toJSI()");
68
87
  }
69
88
  };
@@ -7,17 +7,18 @@
7
7
 
8
8
  #include "webgpu/webgpu_cpp.h"
9
9
 
10
- #include "Convertors.h"
10
+ #include "rnwgpu/api/Convertors.h"
11
11
  #include "jsi2/JSIConverter.h"
12
12
 
13
- #include "GPUOrigin2D.h"
13
+ #include "rnwgpu/api/GPUOrigin2D.h"
14
+ #include "rnwgpu/api/ImageBitmap.h"
14
15
 
15
16
  namespace jsi = facebook::jsi;
16
17
 
17
18
  namespace rnwgpu {
18
19
 
19
20
  struct GPUImageCopyExternalImage {
20
- // std::shared_ptr<ImageBitmap> source; // GPUImageCopyExternalImageSource
21
+ std::shared_ptr<ImageBitmap> source; // GPUImageCopyExternalImageSource
21
22
  std::optional<std::shared_ptr<GPUOrigin2D>> origin; // GPUOrigin2DStrict
22
23
  std::optional<bool> flipY; // boolean
23
24
  };
@@ -33,12 +34,11 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyExternalImage>> {
33
34
  auto result = std::make_unique<rnwgpu::GPUImageCopyExternalImage>();
34
35
  if (!outOfBounds && arg.isObject()) {
35
36
  auto obj = arg.getObject(runtime);
36
- // if (obj.hasProperty(runtime, "source")) {
37
- // auto prop = obj.getProperty(runtime, "source");
38
- // result->source =
39
- // JSIConverter<std::shared_ptr<ImageBitmap>>::fromJSI(
40
- // runtime, prop, false);
41
- // }
37
+ if (obj.hasProperty(runtime, "source")) {
38
+ auto prop = obj.getProperty(runtime, "source");
39
+ result->source = JSIConverter<std::shared_ptr<ImageBitmap>>::fromJSI(
40
+ runtime, prop, false);
41
+ }
42
42
  if (obj.hasProperty(runtime, "origin")) {
43
43
  auto prop = obj.getProperty(runtime, "origin");
44
44
  result->origin = JSIConverter<std::shared_ptr<GPUOrigin2D>>::fromJSI(
@@ -6,7 +6,7 @@
6
6
 
7
7
  #include "jsi2/JSIConverter.h"
8
8
 
9
- #include "GPUOrigin3D.h"
9
+ #include "rnwgpu/api/GPUOrigin3D.h"
10
10
  #include "rnwgpu/api/GPUTexture.h"
11
11
 
12
12
  namespace jsi = facebook::jsi;
@@ -6,8 +6,8 @@
6
6
 
7
7
  #include "jsi2/JSIConverter.h"
8
8
 
9
- #include "External.h"
10
- #include "GPUOrigin3D.h"
9
+ #include "rnwgpu/api/External.h"
10
+ #include "rnwgpu/api/GPUOrigin3D.h"
11
11
  #include "rnwgpu/api/GPUTexture.h"
12
12
 
13
13
  namespace jsi = facebook::jsi;