@shopify/react-native-skia 2.6.5 → 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 (250) hide show
  1. package/android/CMakeLists.txt +1 -0
  2. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerDelegate.java +35 -0
  3. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerInterface.java +17 -0
  4. package/cpp/api/JsiSkCanvas.h +33 -0
  5. package/cpp/api/JsiSkImage.h +12 -4
  6. package/cpp/api/JsiSkSurface.h +5 -1
  7. package/cpp/rnwgpu/api/GPU.cpp +0 -3
  8. package/cpp/rnwgpu/api/GPUAdapter.cpp +9 -5
  9. package/cpp/rnwgpu/api/GPUDevice.cpp +55 -4
  10. package/cpp/rnwgpu/api/GPUDevice.h +6 -0
  11. package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
  12. package/cpp/rnwgpu/api/GPUSharedFence.cpp +80 -0
  13. package/cpp/rnwgpu/api/GPUSharedFence.h +53 -0
  14. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +64 -11
  15. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +13 -8
  16. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +58 -0
  17. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +51 -0
  18. package/cpp/skia/include/android/GrAHardwareBufferUtils.h +1 -1
  19. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +1 -1
  20. package/cpp/skia/include/android/SkAnimatedImage.h +1 -1
  21. package/cpp/skia/include/codec/SkCodec.h +0 -8
  22. package/cpp/skia/include/codec/SkEncodedOrigin.h +1 -1
  23. package/cpp/skia/include/codec/SkPngRustDecoder.h +1 -1
  24. package/cpp/skia/include/core/SkBitmap.h +2 -8
  25. package/cpp/skia/include/core/SkCPURecorder.h +3 -1
  26. package/cpp/skia/include/core/SkCanvasVirtualEnforcer.h +1 -1
  27. package/cpp/skia/include/core/SkColorType.h +5 -3
  28. package/cpp/skia/include/core/SkContourMeasure.h +1 -1
  29. package/cpp/skia/include/core/SkCoverageMode.h +1 -1
  30. package/cpp/skia/include/core/SkCubicMap.h +1 -1
  31. package/cpp/skia/include/core/SkExecutor.h +1 -1
  32. package/cpp/skia/include/core/SkFont.h +15 -0
  33. package/cpp/skia/include/core/SkFontArguments.h +6 -1
  34. package/cpp/skia/include/core/SkFontMetrics.h +1 -1
  35. package/cpp/skia/include/core/SkFontMgr.h +36 -1
  36. package/cpp/skia/include/core/SkFontParameters.h +1 -1
  37. package/cpp/skia/include/core/SkFontScanner.h +1 -1
  38. package/cpp/skia/include/core/SkFontTypes.h +1 -1
  39. package/cpp/skia/include/core/SkM44.h +1 -1
  40. package/cpp/skia/include/core/SkMilestone.h +1 -1
  41. package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +1 -1
  42. package/cpp/skia/include/core/SkPathBuilder.h +10 -4
  43. package/cpp/skia/include/core/SkPathIter.h +1 -1
  44. package/cpp/skia/include/core/SkPathTypes.h +1 -1
  45. package/cpp/skia/include/core/SkPixelRef.h +4 -1
  46. package/cpp/skia/include/core/SkRecorder.h +2 -1
  47. package/cpp/skia/include/core/SkRegion.h +7 -1
  48. package/cpp/skia/include/core/SkSamplingOptions.h +1 -1
  49. package/cpp/skia/include/core/SkSerialProcs.h +8 -1
  50. package/cpp/skia/include/core/SkShader.h +3 -5
  51. package/cpp/skia/include/core/SkSpan.h +1 -1
  52. package/cpp/skia/include/core/SkStream.h +1 -1
  53. package/cpp/skia/include/core/SkStrikeRef.h +80 -0
  54. package/cpp/skia/include/core/SkTileMode.h +1 -1
  55. package/cpp/skia/include/core/SkVertices.h +1 -1
  56. package/cpp/skia/include/core/SkYUVAPixmaps.h +3 -5
  57. package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
  58. package/cpp/skia/include/docs/SkXPSDocument.h +1 -1
  59. package/cpp/skia/include/effects/SkGradient.h +1 -1
  60. package/cpp/skia/include/effects/SkHighContrastFilter.h +1 -1
  61. package/cpp/skia/include/effects/SkShaderMaskFilter.h +1 -1
  62. package/cpp/skia/include/effects/SkTrimPathEffect.h +1 -1
  63. package/cpp/skia/include/encode/SkEncoder.h +1 -1
  64. package/cpp/skia/include/encode/SkJpegEncoder.h +1 -1
  65. package/cpp/skia/include/encode/SkPngEncoder.h +1 -1
  66. package/cpp/skia/include/encode/SkPngRustEncoder.h +1 -1
  67. package/cpp/skia/include/encode/SkWebpEncoder.h +1 -1
  68. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  69. package/cpp/skia/include/gpu/MutableTextureState.h +1 -1
  70. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +1 -1
  71. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +6 -62
  72. package/cpp/skia/include/gpu/ganesh/GrContextThreadSafeProxy.h +1 -1
  73. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +1 -1
  74. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +1 -1
  75. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +2 -1
  76. package/cpp/skia/include/gpu/ganesh/mock/GrMockBackendSurface.h +59 -0
  77. package/cpp/skia/include/gpu/ganesh/mock/GrMockTypes.h +1 -1
  78. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlBackendContext.h +1 -1
  79. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlTypes.h +1 -1
  80. package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +1 -1
  81. package/cpp/skia/include/gpu/graphite/Context.h +11 -4
  82. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +6 -0
  83. package/cpp/skia/include/gpu/graphite/Image.h +82 -9
  84. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +7 -2
  85. package/cpp/skia/include/gpu/graphite/Recorder.h +6 -4
  86. package/cpp/skia/include/gpu/graphite/precompile/PrecompileColorFilter.h +11 -1
  87. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +1 -0
  88. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +1 -1
  89. package/cpp/skia/include/gpu/mtl/MtlMemoryAllocator.h +1 -1
  90. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
  91. package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +1 -1
  92. package/cpp/skia/include/gpu/vk/VulkanTypes.h +1 -1
  93. package/cpp/skia/include/ports/SkCFObject.h +1 -1
  94. package/cpp/skia/include/ports/SkFontMgr_Fontations.h +1 -1
  95. package/cpp/skia/include/ports/SkFontMgr_android_ndk.h +1 -1
  96. package/cpp/skia/include/ports/SkFontMgr_data.h +1 -1
  97. package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +1 -1
  98. package/cpp/skia/include/ports/SkFontMgr_mac_ct.h +1 -1
  99. package/cpp/skia/include/ports/SkFontScanner_Fontations.h +1 -1
  100. package/cpp/skia/include/ports/SkFontScanner_FreeType.h +1 -1
  101. package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
  102. package/cpp/skia/include/private/SkExif.h +1 -1
  103. package/cpp/skia/include/private/SkGainmapInfo.h +1 -1
  104. package/cpp/skia/include/private/SkGainmapShader.h +1 -1
  105. package/cpp/skia/include/private/SkHdrMetadata.h +21 -0
  106. package/cpp/skia/include/private/SkJpegGainmapEncoder.h +1 -1
  107. package/cpp/skia/include/private/SkPixelStorage.h +37 -0
  108. package/cpp/skia/include/private/SkXmp.h +1 -1
  109. package/cpp/skia/include/private/base/SkAssert.h +6 -5
  110. package/cpp/skia/include/private/base/SkContainers.h +1 -1
  111. package/cpp/skia/include/private/base/SkFeatures.h +30 -30
  112. package/cpp/skia/include/private/base/SkLog.h +1 -7
  113. package/cpp/skia/include/private/base/SkLogPriority.h +4 -5
  114. package/cpp/skia/include/private/base/SkMacros.h +1 -1
  115. package/cpp/skia/include/private/base/SkMalloc.h +1 -1
  116. package/cpp/skia/include/private/base/SkSafe32.h +1 -1
  117. package/cpp/skia/include/private/base/SkSpan_impl.h +1 -1
  118. package/cpp/skia/include/private/base/SkTDArray.h +13 -1
  119. package/cpp/skia/include/private/base/SkTPin.h +1 -1
  120. package/cpp/skia/include/private/base/SkTo.h +1 -1
  121. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +1 -1
  122. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +1 -1
  123. package/cpp/skia/include/private/chromium/SkCodecsICCProfileChromium.h +52 -0
  124. package/cpp/skia/include/private/chromium/SkExifChromium.h +26 -0
  125. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
  126. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
  127. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +2 -1
  128. package/cpp/skia/include/private/gpu/vk/SkiaVulkan.h +1 -1
  129. package/cpp/skia/include/sksl/SkSLDebugTrace.h +1 -1
  130. package/cpp/skia/include/third_party/vulkan/vulkan/vk_icd.h +41 -51
  131. package/cpp/skia/include/third_party/vulkan/vulkan/vk_layer.h +42 -53
  132. package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -1
  133. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +158 -154
  134. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +68 -65
  135. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +90 -87
  136. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +9 -9
  137. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +2 -2
  138. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +82 -79
  139. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +24 -24
  140. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +2 -2
  141. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +95 -96
  142. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std.h +151 -0
  143. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std_decode.h +68 -0
  144. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +1 -1
  145. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +5 -1
  146. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +7 -1
  147. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +291 -158
  148. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +13174 -10113
  149. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +23 -19
  150. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +159 -165
  151. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +22 -19
  152. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +3 -1
  153. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +3 -1
  154. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +94 -88
  155. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ohos.h +120 -0
  156. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +55 -51
  157. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +18 -15
  158. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +23 -19
  159. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +31 -1
  160. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +5 -1
  161. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +27 -27
  162. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +20 -16
  163. package/cpp/skia/include/utils/SkEventTracer.h +6 -1
  164. package/cpp/skia/include/utils/SkOrderedFontMgr.h +1 -1
  165. package/cpp/skia/include/utils/SkShadowUtils.h +1 -1
  166. package/cpp/skia/include/utils/SkTextUtils.h +1 -1
  167. package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +20 -4
  168. package/cpp/skia/modules/skcms/src/Transform_inl.h +11 -15
  169. package/cpp/skia/modules/skcms/src/skcms_public.h +2 -0
  170. package/cpp/skia/modules/skottie/include/ExternalLayer.h +1 -1
  171. package/cpp/skia/modules/skottie/include/Skottie.h +1 -1
  172. package/cpp/skia/modules/skottie/include/SkottieProperty.h +1 -1
  173. package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
  174. package/cpp/skia/modules/skottie/include/TextShaper.h +1 -1
  175. package/cpp/skia/modules/skottie/src/SkottieValue.h +1 -1
  176. package/cpp/skia/modules/skottie/src/animator/Animator.h +1 -1
  177. package/cpp/skia/modules/skottie/src/text/Font.h +1 -1
  178. package/cpp/skia/modules/skottie/src/text/TextAdapter.h +1 -1
  179. package/cpp/skia/modules/skottie/src/text/TextAnimator.h +3 -2
  180. package/cpp/skia/modules/skottie/src/text/TextValue.h +1 -1
  181. package/cpp/skia/modules/skparagraph/include/DartTypes.h +1 -1
  182. package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
  183. package/cpp/skia/modules/skparagraph/include/FontCollection.h +5 -1
  184. package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
  185. package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
  186. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +1 -1
  187. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +1 -1
  188. package/cpp/skia/modules/skparagraph/include/ParagraphPainter.h +1 -1
  189. package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +12 -5
  190. package/cpp/skia/modules/skparagraph/include/TextShadow.h +1 -1
  191. package/cpp/skia/modules/skparagraph/include/TextStyle.h +1 -1
  192. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -1
  193. package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +1 -1
  194. package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +1 -1
  195. package/cpp/skia/modules/sksg/include/SkSGDraw.h +1 -1
  196. package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +1 -1
  197. package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +1 -1
  198. package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +1 -1
  199. package/cpp/skia/modules/sksg/include/SkSGGradient.h +1 -1
  200. package/cpp/skia/modules/sksg/include/SkSGGroup.h +1 -1
  201. package/cpp/skia/modules/sksg/include/SkSGImage.h +1 -1
  202. package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +1 -1
  203. package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +1 -1
  204. package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
  205. package/cpp/skia/modules/sksg/include/SkSGNode.h +1 -1
  206. package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +1 -1
  207. package/cpp/skia/modules/sksg/include/SkSGPaint.h +1 -1
  208. package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
  209. package/cpp/skia/modules/sksg/include/SkSGPlane.h +1 -1
  210. package/cpp/skia/modules/sksg/include/SkSGRect.h +1 -1
  211. package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +1 -1
  212. package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +1 -1
  213. package/cpp/skia/modules/sksg/include/SkSGScene.h +1 -1
  214. package/cpp/skia/modules/sksg/include/SkSGText.h +1 -1
  215. package/cpp/skia/modules/sksg/include/SkSGTransform.h +1 -1
  216. package/cpp/skia/modules/skshaper/include/SkShaper_coretext.h +8 -1
  217. package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
  218. package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
  219. package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
  220. package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
  221. package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
  222. package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
  223. package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
  224. package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
  225. package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
  226. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  227. package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
  228. package/cpp/skia/modules/svg/include/SkSVGFeMerge.h +1 -1
  229. package/cpp/skia/modules/svg/include/SkSVGFeMorphology.h +1 -1
  230. package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
  231. package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
  232. package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
  233. package/cpp/skia/modules/svg/include/SkSVGFilterContext.h +1 -1
  234. package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
  235. package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
  236. package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
  237. package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +1 -1
  238. package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
  239. package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
  240. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  241. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  242. package/cpp/skia/src/base/SkAutoLocaleSetter.h +94 -0
  243. package/cpp/skia/src/base/SkUTF.h +1 -1
  244. package/lib/commonjs/skia/types/WebGPU.d.ts +70 -5
  245. package/lib/commonjs/skia/types/WebGPU.js.map +1 -1
  246. package/lib/module/skia/types/WebGPU.d.ts +70 -5
  247. package/lib/module/skia/types/WebGPU.js.map +1 -1
  248. package/lib/typescript/src/skia/types/WebGPU.d.ts +70 -5
  249. package/package.json +5 -5
  250. package/src/skia/types/WebGPU.ts +83 -5
@@ -0,0 +1,94 @@
1
+ /*
2
+ * Copyright 2015 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkAutoLocaleSetter_DEFINED
9
+ #define SkAutoLocaleSetter_DEFINED
10
+
11
+ #include "include/private/base/SkNoncopyable.h"
12
+
13
+ #if defined(SK_BUILD_FOR_WIN)
14
+ #include <optional>
15
+ #include <string>
16
+ #endif
17
+
18
+ #if !defined(SK_BUILD_FOR_ANDROID)
19
+ #include <locale.h>
20
+ #endif
21
+
22
+ #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
23
+ #include <xlocale.h>
24
+ #include <cstring>
25
+ #define HAVE_XLOCALE 1
26
+ #else
27
+ #define HAVE_XLOCALE 0
28
+ #endif
29
+
30
+ #if defined(SK_BUILD_FOR_ANDROID) || defined(__UCLIBC__) || defined(_NEWLIB_VERSION)
31
+ #define HAVE_LOCALE_T 0
32
+ #else
33
+ #define HAVE_LOCALE_T 1
34
+ #endif
35
+
36
+ /**
37
+ * Helper class for ensuring that we don't use the wrong locale when building shaders. Android
38
+ * doesn't support locale in the NDK, so this is a no-op there.
39
+ */
40
+ class SkAutoLocaleSetter : public SkNoncopyable {
41
+ public:
42
+ SkAutoLocaleSetter (const char* name) {
43
+ #if defined(SK_BUILD_FOR_WIN)
44
+ fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
45
+ char* oldLocale = setlocale(LC_ALL, name);
46
+ if (oldLocale) {
47
+ fOldLocale.emplace(oldLocale);
48
+ }
49
+ #elif HAVE_LOCALE_T
50
+ #if HAVE_XLOCALE
51
+ // In xlocale nullptr means the C locale.
52
+ if (0 == strcmp(name, "C")) {
53
+ name = nullptr;
54
+ }
55
+ #endif
56
+ fLocale = newlocale(LC_ALL_MASK, name, nullptr);
57
+ if (fLocale) {
58
+ fOldLocale = uselocale(fLocale);
59
+ } else {
60
+ fOldLocale = static_cast<locale_t>(nullptr);
61
+ }
62
+ #else
63
+ (void) name; // suppress unused param warning.
64
+ #endif
65
+ }
66
+
67
+ ~SkAutoLocaleSetter () {
68
+ #if defined(SK_BUILD_FOR_WIN)
69
+ if (fOldLocale) {
70
+ setlocale(LC_ALL, fOldLocale->c_str());
71
+ }
72
+ _configthreadlocale(fOldPerThreadLocale);
73
+ #elif HAVE_LOCALE_T
74
+ if (fLocale) {
75
+ uselocale(fOldLocale);
76
+ freelocale(fLocale);
77
+ }
78
+ #endif
79
+ }
80
+
81
+ private:
82
+ #if defined(SK_BUILD_FOR_WIN)
83
+ int fOldPerThreadLocale;
84
+ std::optional<std::string> fOldLocale;
85
+ #elif HAVE_LOCALE_T
86
+ locale_t fOldLocale;
87
+ locale_t fLocale;
88
+ #endif
89
+ };
90
+
91
+ #undef HAVE_LOCALE_T
92
+ #undef HAVE_XLOCALE
93
+
94
+ #endif
@@ -1,4 +1,4 @@
1
- // Copyright 2018 Google LLC.
1
+ // Copyright 2018 Google LLC
2
2
  // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
3
  #ifndef SkUTF_DEFINED
4
4
  #define SkUTF_DEFINED
@@ -24,6 +24,62 @@ export interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBas
24
24
  export interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {
25
25
  handle: NativeBuffer;
26
26
  }
27
+ /**
28
+ * The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
29
+ * matching the `shared-fence-*` device feature names. Limited to the kinds
30
+ * react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
31
+ * accepts these and `export()` reports them.
32
+ */
33
+ export type GPUSharedFenceType = "mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
34
+ /**
35
+ * Descriptor for {@link GPUDevice.importSharedFence}.
36
+ */
37
+ export interface GPUSharedFenceDescriptor {
38
+ /**
39
+ * The fence kind to import. Must match a `shared-fence-*` feature enabled on
40
+ * the device.
41
+ */
42
+ type: GPUSharedFenceType;
43
+ /**
44
+ * The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for
45
+ * `"mtl-shared-event"`, or an OS file descriptor for the `*-fd` kinds.
46
+ */
47
+ handle: bigint;
48
+ label?: string;
49
+ }
50
+ export interface GPUSharedFenceExportInfo {
51
+ type: GPUSharedFenceType;
52
+ /**
53
+ * An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a
54
+ * BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed
55
+ * once consumed.
56
+ */
57
+ handle: bigint;
58
+ }
59
+ /**
60
+ * A native GPU synchronization primitive shared across queues/APIs. Produced by
61
+ * {@link GPUSharedTextureMemory.endAccess}, consumed by
62
+ * {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
63
+ * fence with {@link GPUDevice.importSharedFence}.
64
+ */
65
+ export interface GPUSharedFence {
66
+ readonly __brand: "GPUSharedFence";
67
+ label: string;
68
+ export(): GPUSharedFenceExportInfo;
69
+ }
70
+ /** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
71
+ export interface GPUSharedFenceState {
72
+ fence: GPUSharedFence;
73
+ signaledValue: bigint;
74
+ }
75
+ /**
76
+ * The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
77
+ * at its `signaledValue` once Dawn's GPU work for the access completes.
78
+ */
79
+ export interface GPUSharedTextureMemoryEndAccessState {
80
+ initialized: boolean;
81
+ fences: GPUSharedFenceState[];
82
+ }
27
83
  /**
28
84
  * Shared texture memory imported from a platform native buffer via
29
85
  * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
@@ -36,14 +92,16 @@ export interface GPUSharedTextureMemory extends GPUObjectBase {
36
92
  /**
37
93
  * Acquire the memory for GPU access. `initialized` marks whether the existing
38
94
  * contents should be preserved (pass `true` for an already-rendered frame).
39
- * Returns `false` if access could not be acquired.
95
+ * Optional `fences` are wait fences: Dawn waits for each to reach its
96
+ * `signaledValue` before writing the surface. Throws if the access could not
97
+ * be acquired.
40
98
  */
41
- beginAccess(texture: GPUTexture, initialized: boolean): boolean;
99
+ beginAccess(texture: GPUTexture, initialized: boolean, fences?: GPUSharedFenceState[]): void;
42
100
  /**
43
- * Release the memory after the GPU work that accessed it has been submitted.
44
- * Returns `false` on failure.
101
+ * Release the memory after the GPU work that accessed it has been submitted,
102
+ * and return the fences Dawn produced for the access. Throws on failure.
45
103
  */
46
- endAccess(texture: GPUTexture): boolean;
104
+ endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
47
105
  }
48
106
  /**
49
107
  * Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to
@@ -84,5 +142,12 @@ declare global {
84
142
  * begin/end access window yourself.
85
143
  */
86
144
  importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
145
+ /**
146
+ * Skia extension: import a native synchronization primitive (an
147
+ * `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a
148
+ * {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The
149
+ * matching `shared-fence-*` feature must be enabled on the device.
150
+ */
151
+ importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
87
152
  }
88
153
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["WebGPU.ts"],"sourcesContent":["import type { NativeBuffer } from \"./NativeBuffer\";\n\n// Skia's Graphite/Dawn backend extends the standard WebGPU API (typed by\n// @webgpu/types) with a few Skia- and Dawn-specific entry points. These are\n// only available on native (SK_GRAPHITE) builds, reachable through\n// `Skia.getDevice()`.\n//\n// The exported interfaces below describe the descriptors and objects those\n// entry points use; the `declare global` block augments the standard WebGPU\n// interfaces so the new methods are typed without casting to `any`.\n\n/**\n * Descriptor for {@link GPUDevice.importExternalTexture} when the source is a\n * Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).\n *\n * `source` is the handle returned by `Skia.NativeBuffer.MakeFromImage`: a\n * `CVPixelBufferRef` on Apple, an `AHardwareBuffer*` on Android. The caller\n * owns its lifetime (release it with `Skia.NativeBuffer.Release`) and must keep\n * it alive until the imported texture is destroyed.\n */\nexport interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBase {\n source: NativeBuffer;\n /** Rotation applied while sampling, in degrees. One of 0 | 90 | 180 | 270. */\n rotation?: number;\n /** Mirror horizontally while sampling. */\n mirrored?: boolean;\n}\n\n/**\n * Descriptor for {@link GPUDevice.importSharedTextureMemory}. `handle` is the\n * NativeBuffer returned by `Skia.NativeBuffer.MakeFromImage` (see\n * {@link SkiaGPUExternalTextureDescriptor} for the platform-specific types and\n * lifetime rules).\n */\nexport interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {\n handle: NativeBuffer;\n}\n\n/**\n * Shared texture memory imported from a platform native buffer via\n * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases\n * the memory, then bracket the GPU work that touches it with\n * {@link GPUSharedTextureMemory.beginAccess} / {@link GPUSharedTextureMemory.endAccess}.\n */\nexport interface GPUSharedTextureMemory extends GPUObjectBase {\n /** Create a texture that aliases the shared memory. */\n createTexture(descriptor?: GPUTextureDescriptor): GPUTexture;\n /**\n * Acquire the memory for GPU access. `initialized` marks whether the existing\n * contents should be preserved (pass `true` for an already-rendered frame).\n * Returns `false` if access could not be acquired.\n */\n beginAccess(texture: GPUTexture, initialized: boolean): boolean;\n /**\n * Release the memory after the GPU work that accessed it has been submitted.\n * Returns `false` on failure.\n */\n endAccess(texture: GPUTexture): boolean;\n}\n\n/**\n * Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to\n * `adapter.requestDevice`. This is a non-spec, Dawn-only extension; see Dawn's\n * toggle list for valid names.\n */\nexport interface GPUDawnTogglesDescriptor {\n enabledToggles?: string[];\n disabledToggles?: string[];\n}\n\ndeclare global {\n interface GPUDeviceDescriptor {\n /** Dawn-specific toggles (Skia/Graphite extension, non-spec). */\n dawnToggles?: GPUDawnTogglesDescriptor;\n }\n\n interface GPUExternalTexture {\n /**\n * Skia extension: end the imported buffer's shared-memory access window and\n * release the underlying resources. Call right after the `queue.submit()`\n * that sampled this texture (never before). Idempotent, and also runs at\n * garbage collection as a fallback.\n */\n destroy(): void;\n }\n\n interface GPUDevice {\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as a {@link GPUExternalTexture}, sampled\n * with `texture_external` in WGSL. The returned texture owns the\n * shared-memory access window; call `destroy()` on it after the sampling\n * `queue.submit()`.\n */\n importExternalTexture(\n descriptor: SkiaGPUExternalTextureDescriptor\n ): GPUExternalTexture;\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as {@link GPUSharedTextureMemory}, the\n * lower-level path that lets you create an aliasing texture and manage the\n * begin/end access window yourself.\n */\n importSharedTextureMemory(\n descriptor: GPUSharedTextureMemoryDescriptor\n ): GPUSharedTextureMemory;\n }\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["WebGPU.ts"],"sourcesContent":["import type { NativeBuffer } from \"./NativeBuffer\";\n\n// Skia's Graphite/Dawn backend extends the standard WebGPU API (typed by\n// @webgpu/types) with a few Skia- and Dawn-specific entry points. These are\n// only available on native (SK_GRAPHITE) builds, reachable through\n// `Skia.getDevice()`.\n//\n// The exported interfaces below describe the descriptors and objects those\n// entry points use; the `declare global` block augments the standard WebGPU\n// interfaces so the new methods are typed without casting to `any`.\n\n/**\n * Descriptor for {@link GPUDevice.importExternalTexture} when the source is a\n * Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).\n *\n * `source` is the handle returned by `Skia.NativeBuffer.MakeFromImage`: a\n * `CVPixelBufferRef` on Apple, an `AHardwareBuffer*` on Android. The caller\n * owns its lifetime (release it with `Skia.NativeBuffer.Release`) and must keep\n * it alive until the imported texture is destroyed.\n */\nexport interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBase {\n source: NativeBuffer;\n /** Rotation applied while sampling, in degrees. One of 0 | 90 | 180 | 270. */\n rotation?: number;\n /** Mirror horizontally while sampling. */\n mirrored?: boolean;\n}\n\n/**\n * Descriptor for {@link GPUDevice.importSharedTextureMemory}. `handle` is the\n * NativeBuffer returned by `Skia.NativeBuffer.MakeFromImage` (see\n * {@link SkiaGPUExternalTextureDescriptor} for the platform-specific types and\n * lifetime rules).\n */\nexport interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {\n handle: NativeBuffer;\n}\n\n/**\n * The kind of native synchronization primitive a {@link GPUSharedFence} wraps,\n * matching the `shared-fence-*` device feature names. Limited to the kinds\n * react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`\n * accepts these and `export()` reports them.\n */\nexport type GPUSharedFenceType =\n | \"mtl-shared-event\"\n | \"sync-fd\"\n | \"vk-semaphore-opaque-fd\";\n\n/**\n * Descriptor for {@link GPUDevice.importSharedFence}.\n */\nexport interface GPUSharedFenceDescriptor {\n /**\n * The fence kind to import. Must match a `shared-fence-*` feature enabled on\n * the device.\n */\n type: GPUSharedFenceType;\n /**\n * The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for\n * `\"mtl-shared-event\"`, or an OS file descriptor for the `*-fd` kinds.\n */\n handle: bigint;\n label?: string;\n}\n\nexport interface GPUSharedFenceExportInfo {\n type: GPUSharedFenceType;\n /**\n * An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a\n * BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed\n * once consumed.\n */\n handle: bigint;\n}\n\n/**\n * A native GPU synchronization primitive shared across queues/APIs. Produced by\n * {@link GPUSharedTextureMemory.endAccess}, consumed by\n * {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's\n * fence with {@link GPUDevice.importSharedFence}.\n */\nexport interface GPUSharedFence {\n readonly __brand: \"GPUSharedFence\";\n label: string;\n export(): GPUSharedFenceExportInfo;\n}\n\n/** A fence and the timeline value to wait for (0n for binary sync-fd fences). */\nexport interface GPUSharedFenceState {\n fence: GPUSharedFence;\n signaledValue: bigint;\n}\n\n/**\n * The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled\n * at its `signaledValue` once Dawn's GPU work for the access completes.\n */\nexport interface GPUSharedTextureMemoryEndAccessState {\n initialized: boolean;\n fences: GPUSharedFenceState[];\n}\n\n/**\n * Shared texture memory imported from a platform native buffer via\n * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases\n * the memory, then bracket the GPU work that touches it with\n * {@link GPUSharedTextureMemory.beginAccess} / {@link GPUSharedTextureMemory.endAccess}.\n */\nexport interface GPUSharedTextureMemory extends GPUObjectBase {\n /** Create a texture that aliases the shared memory. */\n createTexture(descriptor?: GPUTextureDescriptor): GPUTexture;\n /**\n * Acquire the memory for GPU access. `initialized` marks whether the existing\n * contents should be preserved (pass `true` for an already-rendered frame).\n * Optional `fences` are wait fences: Dawn waits for each to reach its\n * `signaledValue` before writing the surface. Throws if the access could not\n * be acquired.\n */\n beginAccess(\n texture: GPUTexture,\n initialized: boolean,\n fences?: GPUSharedFenceState[]\n ): void;\n /**\n * Release the memory after the GPU work that accessed it has been submitted,\n * and return the fences Dawn produced for the access. Throws on failure.\n */\n endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;\n}\n\n/**\n * Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to\n * `adapter.requestDevice`. This is a non-spec, Dawn-only extension; see Dawn's\n * toggle list for valid names.\n */\nexport interface GPUDawnTogglesDescriptor {\n enabledToggles?: string[];\n disabledToggles?: string[];\n}\n\ndeclare global {\n interface GPUDeviceDescriptor {\n /** Dawn-specific toggles (Skia/Graphite extension, non-spec). */\n dawnToggles?: GPUDawnTogglesDescriptor;\n }\n\n interface GPUExternalTexture {\n /**\n * Skia extension: end the imported buffer's shared-memory access window and\n * release the underlying resources. Call right after the `queue.submit()`\n * that sampled this texture (never before). Idempotent, and also runs at\n * garbage collection as a fallback.\n */\n destroy(): void;\n }\n\n interface GPUDevice {\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as a {@link GPUExternalTexture}, sampled\n * with `texture_external` in WGSL. The returned texture owns the\n * shared-memory access window; call `destroy()` on it after the sampling\n * `queue.submit()`.\n */\n importExternalTexture(\n descriptor: SkiaGPUExternalTextureDescriptor\n ): GPUExternalTexture;\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as {@link GPUSharedTextureMemory}, the\n * lower-level path that lets you create an aliasing texture and manage the\n * begin/end access window yourself.\n */\n importSharedTextureMemory(\n descriptor: GPUSharedTextureMemoryDescriptor\n ): GPUSharedTextureMemory;\n /**\n * Skia extension: import a native synchronization primitive (an\n * `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a\n * {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The\n * matching `shared-fence-*` feature must be enabled on the device.\n */\n importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;\n }\n}\n"],"mappings":"","ignoreList":[]}
@@ -24,6 +24,62 @@ export interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBas
24
24
  export interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {
25
25
  handle: NativeBuffer;
26
26
  }
27
+ /**
28
+ * The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
29
+ * matching the `shared-fence-*` device feature names. Limited to the kinds
30
+ * react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
31
+ * accepts these and `export()` reports them.
32
+ */
33
+ export type GPUSharedFenceType = "mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
34
+ /**
35
+ * Descriptor for {@link GPUDevice.importSharedFence}.
36
+ */
37
+ export interface GPUSharedFenceDescriptor {
38
+ /**
39
+ * The fence kind to import. Must match a `shared-fence-*` feature enabled on
40
+ * the device.
41
+ */
42
+ type: GPUSharedFenceType;
43
+ /**
44
+ * The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for
45
+ * `"mtl-shared-event"`, or an OS file descriptor for the `*-fd` kinds.
46
+ */
47
+ handle: bigint;
48
+ label?: string;
49
+ }
50
+ export interface GPUSharedFenceExportInfo {
51
+ type: GPUSharedFenceType;
52
+ /**
53
+ * An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a
54
+ * BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed
55
+ * once consumed.
56
+ */
57
+ handle: bigint;
58
+ }
59
+ /**
60
+ * A native GPU synchronization primitive shared across queues/APIs. Produced by
61
+ * {@link GPUSharedTextureMemory.endAccess}, consumed by
62
+ * {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
63
+ * fence with {@link GPUDevice.importSharedFence}.
64
+ */
65
+ export interface GPUSharedFence {
66
+ readonly __brand: "GPUSharedFence";
67
+ label: string;
68
+ export(): GPUSharedFenceExportInfo;
69
+ }
70
+ /** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
71
+ export interface GPUSharedFenceState {
72
+ fence: GPUSharedFence;
73
+ signaledValue: bigint;
74
+ }
75
+ /**
76
+ * The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
77
+ * at its `signaledValue` once Dawn's GPU work for the access completes.
78
+ */
79
+ export interface GPUSharedTextureMemoryEndAccessState {
80
+ initialized: boolean;
81
+ fences: GPUSharedFenceState[];
82
+ }
27
83
  /**
28
84
  * Shared texture memory imported from a platform native buffer via
29
85
  * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
@@ -36,14 +92,16 @@ export interface GPUSharedTextureMemory extends GPUObjectBase {
36
92
  /**
37
93
  * Acquire the memory for GPU access. `initialized` marks whether the existing
38
94
  * contents should be preserved (pass `true` for an already-rendered frame).
39
- * Returns `false` if access could not be acquired.
95
+ * Optional `fences` are wait fences: Dawn waits for each to reach its
96
+ * `signaledValue` before writing the surface. Throws if the access could not
97
+ * be acquired.
40
98
  */
41
- beginAccess(texture: GPUTexture, initialized: boolean): boolean;
99
+ beginAccess(texture: GPUTexture, initialized: boolean, fences?: GPUSharedFenceState[]): void;
42
100
  /**
43
- * Release the memory after the GPU work that accessed it has been submitted.
44
- * Returns `false` on failure.
101
+ * Release the memory after the GPU work that accessed it has been submitted,
102
+ * and return the fences Dawn produced for the access. Throws on failure.
45
103
  */
46
- endAccess(texture: GPUTexture): boolean;
104
+ endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
47
105
  }
48
106
  /**
49
107
  * Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to
@@ -84,5 +142,12 @@ declare global {
84
142
  * begin/end access window yourself.
85
143
  */
86
144
  importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
145
+ /**
146
+ * Skia extension: import a native synchronization primitive (an
147
+ * `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a
148
+ * {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The
149
+ * matching `shared-fence-*` feature must be enabled on the device.
150
+ */
151
+ importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
87
152
  }
88
153
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["WebGPU.ts"],"sourcesContent":["import type { NativeBuffer } from \"./NativeBuffer\";\n\n// Skia's Graphite/Dawn backend extends the standard WebGPU API (typed by\n// @webgpu/types) with a few Skia- and Dawn-specific entry points. These are\n// only available on native (SK_GRAPHITE) builds, reachable through\n// `Skia.getDevice()`.\n//\n// The exported interfaces below describe the descriptors and objects those\n// entry points use; the `declare global` block augments the standard WebGPU\n// interfaces so the new methods are typed without casting to `any`.\n\n/**\n * Descriptor for {@link GPUDevice.importExternalTexture} when the source is a\n * Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).\n *\n * `source` is the handle returned by `Skia.NativeBuffer.MakeFromImage`: a\n * `CVPixelBufferRef` on Apple, an `AHardwareBuffer*` on Android. The caller\n * owns its lifetime (release it with `Skia.NativeBuffer.Release`) and must keep\n * it alive until the imported texture is destroyed.\n */\nexport interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBase {\n source: NativeBuffer;\n /** Rotation applied while sampling, in degrees. One of 0 | 90 | 180 | 270. */\n rotation?: number;\n /** Mirror horizontally while sampling. */\n mirrored?: boolean;\n}\n\n/**\n * Descriptor for {@link GPUDevice.importSharedTextureMemory}. `handle` is the\n * NativeBuffer returned by `Skia.NativeBuffer.MakeFromImage` (see\n * {@link SkiaGPUExternalTextureDescriptor} for the platform-specific types and\n * lifetime rules).\n */\nexport interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {\n handle: NativeBuffer;\n}\n\n/**\n * Shared texture memory imported from a platform native buffer via\n * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases\n * the memory, then bracket the GPU work that touches it with\n * {@link GPUSharedTextureMemory.beginAccess} / {@link GPUSharedTextureMemory.endAccess}.\n */\nexport interface GPUSharedTextureMemory extends GPUObjectBase {\n /** Create a texture that aliases the shared memory. */\n createTexture(descriptor?: GPUTextureDescriptor): GPUTexture;\n /**\n * Acquire the memory for GPU access. `initialized` marks whether the existing\n * contents should be preserved (pass `true` for an already-rendered frame).\n * Returns `false` if access could not be acquired.\n */\n beginAccess(texture: GPUTexture, initialized: boolean): boolean;\n /**\n * Release the memory after the GPU work that accessed it has been submitted.\n * Returns `false` on failure.\n */\n endAccess(texture: GPUTexture): boolean;\n}\n\n/**\n * Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to\n * `adapter.requestDevice`. This is a non-spec, Dawn-only extension; see Dawn's\n * toggle list for valid names.\n */\nexport interface GPUDawnTogglesDescriptor {\n enabledToggles?: string[];\n disabledToggles?: string[];\n}\n\ndeclare global {\n interface GPUDeviceDescriptor {\n /** Dawn-specific toggles (Skia/Graphite extension, non-spec). */\n dawnToggles?: GPUDawnTogglesDescriptor;\n }\n\n interface GPUExternalTexture {\n /**\n * Skia extension: end the imported buffer's shared-memory access window and\n * release the underlying resources. Call right after the `queue.submit()`\n * that sampled this texture (never before). Idempotent, and also runs at\n * garbage collection as a fallback.\n */\n destroy(): void;\n }\n\n interface GPUDevice {\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as a {@link GPUExternalTexture}, sampled\n * with `texture_external` in WGSL. The returned texture owns the\n * shared-memory access window; call `destroy()` on it after the sampling\n * `queue.submit()`.\n */\n importExternalTexture(\n descriptor: SkiaGPUExternalTextureDescriptor\n ): GPUExternalTexture;\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as {@link GPUSharedTextureMemory}, the\n * lower-level path that lets you create an aliasing texture and manage the\n * begin/end access window yourself.\n */\n importSharedTextureMemory(\n descriptor: GPUSharedTextureMemoryDescriptor\n ): GPUSharedTextureMemory;\n }\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["WebGPU.ts"],"sourcesContent":["import type { NativeBuffer } from \"./NativeBuffer\";\n\n// Skia's Graphite/Dawn backend extends the standard WebGPU API (typed by\n// @webgpu/types) with a few Skia- and Dawn-specific entry points. These are\n// only available on native (SK_GRAPHITE) builds, reachable through\n// `Skia.getDevice()`.\n//\n// The exported interfaces below describe the descriptors and objects those\n// entry points use; the `declare global` block augments the standard WebGPU\n// interfaces so the new methods are typed without casting to `any`.\n\n/**\n * Descriptor for {@link GPUDevice.importExternalTexture} when the source is a\n * Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).\n *\n * `source` is the handle returned by `Skia.NativeBuffer.MakeFromImage`: a\n * `CVPixelBufferRef` on Apple, an `AHardwareBuffer*` on Android. The caller\n * owns its lifetime (release it with `Skia.NativeBuffer.Release`) and must keep\n * it alive until the imported texture is destroyed.\n */\nexport interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBase {\n source: NativeBuffer;\n /** Rotation applied while sampling, in degrees. One of 0 | 90 | 180 | 270. */\n rotation?: number;\n /** Mirror horizontally while sampling. */\n mirrored?: boolean;\n}\n\n/**\n * Descriptor for {@link GPUDevice.importSharedTextureMemory}. `handle` is the\n * NativeBuffer returned by `Skia.NativeBuffer.MakeFromImage` (see\n * {@link SkiaGPUExternalTextureDescriptor} for the platform-specific types and\n * lifetime rules).\n */\nexport interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {\n handle: NativeBuffer;\n}\n\n/**\n * The kind of native synchronization primitive a {@link GPUSharedFence} wraps,\n * matching the `shared-fence-*` device feature names. Limited to the kinds\n * react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`\n * accepts these and `export()` reports them.\n */\nexport type GPUSharedFenceType =\n | \"mtl-shared-event\"\n | \"sync-fd\"\n | \"vk-semaphore-opaque-fd\";\n\n/**\n * Descriptor for {@link GPUDevice.importSharedFence}.\n */\nexport interface GPUSharedFenceDescriptor {\n /**\n * The fence kind to import. Must match a `shared-fence-*` feature enabled on\n * the device.\n */\n type: GPUSharedFenceType;\n /**\n * The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for\n * `\"mtl-shared-event\"`, or an OS file descriptor for the `*-fd` kinds.\n */\n handle: bigint;\n label?: string;\n}\n\nexport interface GPUSharedFenceExportInfo {\n type: GPUSharedFenceType;\n /**\n * An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a\n * BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed\n * once consumed.\n */\n handle: bigint;\n}\n\n/**\n * A native GPU synchronization primitive shared across queues/APIs. Produced by\n * {@link GPUSharedTextureMemory.endAccess}, consumed by\n * {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's\n * fence with {@link GPUDevice.importSharedFence}.\n */\nexport interface GPUSharedFence {\n readonly __brand: \"GPUSharedFence\";\n label: string;\n export(): GPUSharedFenceExportInfo;\n}\n\n/** A fence and the timeline value to wait for (0n for binary sync-fd fences). */\nexport interface GPUSharedFenceState {\n fence: GPUSharedFence;\n signaledValue: bigint;\n}\n\n/**\n * The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled\n * at its `signaledValue` once Dawn's GPU work for the access completes.\n */\nexport interface GPUSharedTextureMemoryEndAccessState {\n initialized: boolean;\n fences: GPUSharedFenceState[];\n}\n\n/**\n * Shared texture memory imported from a platform native buffer via\n * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases\n * the memory, then bracket the GPU work that touches it with\n * {@link GPUSharedTextureMemory.beginAccess} / {@link GPUSharedTextureMemory.endAccess}.\n */\nexport interface GPUSharedTextureMemory extends GPUObjectBase {\n /** Create a texture that aliases the shared memory. */\n createTexture(descriptor?: GPUTextureDescriptor): GPUTexture;\n /**\n * Acquire the memory for GPU access. `initialized` marks whether the existing\n * contents should be preserved (pass `true` for an already-rendered frame).\n * Optional `fences` are wait fences: Dawn waits for each to reach its\n * `signaledValue` before writing the surface. Throws if the access could not\n * be acquired.\n */\n beginAccess(\n texture: GPUTexture,\n initialized: boolean,\n fences?: GPUSharedFenceState[]\n ): void;\n /**\n * Release the memory after the GPU work that accessed it has been submitted,\n * and return the fences Dawn produced for the access. Throws on failure.\n */\n endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;\n}\n\n/**\n * Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to\n * `adapter.requestDevice`. This is a non-spec, Dawn-only extension; see Dawn's\n * toggle list for valid names.\n */\nexport interface GPUDawnTogglesDescriptor {\n enabledToggles?: string[];\n disabledToggles?: string[];\n}\n\ndeclare global {\n interface GPUDeviceDescriptor {\n /** Dawn-specific toggles (Skia/Graphite extension, non-spec). */\n dawnToggles?: GPUDawnTogglesDescriptor;\n }\n\n interface GPUExternalTexture {\n /**\n * Skia extension: end the imported buffer's shared-memory access window and\n * release the underlying resources. Call right after the `queue.submit()`\n * that sampled this texture (never before). Idempotent, and also runs at\n * garbage collection as a fallback.\n */\n destroy(): void;\n }\n\n interface GPUDevice {\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as a {@link GPUExternalTexture}, sampled\n * with `texture_external` in WGSL. The returned texture owns the\n * shared-memory access window; call `destroy()` on it after the sampling\n * `queue.submit()`.\n */\n importExternalTexture(\n descriptor: SkiaGPUExternalTextureDescriptor\n ): GPUExternalTexture;\n /**\n * Skia extension: import a NativeBuffer (from\n * `Skia.NativeBuffer.MakeFromImage`) as {@link GPUSharedTextureMemory}, the\n * lower-level path that lets you create an aliasing texture and manage the\n * begin/end access window yourself.\n */\n importSharedTextureMemory(\n descriptor: GPUSharedTextureMemoryDescriptor\n ): GPUSharedTextureMemory;\n /**\n * Skia extension: import a native synchronization primitive (an\n * `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a\n * {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The\n * matching `shared-fence-*` feature must be enabled on the device.\n */\n importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;\n }\n}\n"],"mappings":"","ignoreList":[]}
@@ -24,6 +24,62 @@ export interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBas
24
24
  export interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {
25
25
  handle: NativeBuffer;
26
26
  }
27
+ /**
28
+ * The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
29
+ * matching the `shared-fence-*` device feature names. Limited to the kinds
30
+ * react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
31
+ * accepts these and `export()` reports them.
32
+ */
33
+ export type GPUSharedFenceType = "mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
34
+ /**
35
+ * Descriptor for {@link GPUDevice.importSharedFence}.
36
+ */
37
+ export interface GPUSharedFenceDescriptor {
38
+ /**
39
+ * The fence kind to import. Must match a `shared-fence-*` feature enabled on
40
+ * the device.
41
+ */
42
+ type: GPUSharedFenceType;
43
+ /**
44
+ * The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for
45
+ * `"mtl-shared-event"`, or an OS file descriptor for the `*-fd` kinds.
46
+ */
47
+ handle: bigint;
48
+ label?: string;
49
+ }
50
+ export interface GPUSharedFenceExportInfo {
51
+ type: GPUSharedFenceType;
52
+ /**
53
+ * An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a
54
+ * BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed
55
+ * once consumed.
56
+ */
57
+ handle: bigint;
58
+ }
59
+ /**
60
+ * A native GPU synchronization primitive shared across queues/APIs. Produced by
61
+ * {@link GPUSharedTextureMemory.endAccess}, consumed by
62
+ * {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
63
+ * fence with {@link GPUDevice.importSharedFence}.
64
+ */
65
+ export interface GPUSharedFence {
66
+ readonly __brand: "GPUSharedFence";
67
+ label: string;
68
+ export(): GPUSharedFenceExportInfo;
69
+ }
70
+ /** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
71
+ export interface GPUSharedFenceState {
72
+ fence: GPUSharedFence;
73
+ signaledValue: bigint;
74
+ }
75
+ /**
76
+ * The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
77
+ * at its `signaledValue` once Dawn's GPU work for the access completes.
78
+ */
79
+ export interface GPUSharedTextureMemoryEndAccessState {
80
+ initialized: boolean;
81
+ fences: GPUSharedFenceState[];
82
+ }
27
83
  /**
28
84
  * Shared texture memory imported from a platform native buffer via
29
85
  * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
@@ -36,14 +92,16 @@ export interface GPUSharedTextureMemory extends GPUObjectBase {
36
92
  /**
37
93
  * Acquire the memory for GPU access. `initialized` marks whether the existing
38
94
  * contents should be preserved (pass `true` for an already-rendered frame).
39
- * Returns `false` if access could not be acquired.
95
+ * Optional `fences` are wait fences: Dawn waits for each to reach its
96
+ * `signaledValue` before writing the surface. Throws if the access could not
97
+ * be acquired.
40
98
  */
41
- beginAccess(texture: GPUTexture, initialized: boolean): boolean;
99
+ beginAccess(texture: GPUTexture, initialized: boolean, fences?: GPUSharedFenceState[]): void;
42
100
  /**
43
- * Release the memory after the GPU work that accessed it has been submitted.
44
- * Returns `false` on failure.
101
+ * Release the memory after the GPU work that accessed it has been submitted,
102
+ * and return the fences Dawn produced for the access. Throws on failure.
45
103
  */
46
- endAccess(texture: GPUTexture): boolean;
104
+ endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
47
105
  }
48
106
  /**
49
107
  * Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to
@@ -84,5 +142,12 @@ declare global {
84
142
  * begin/end access window yourself.
85
143
  */
86
144
  importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
145
+ /**
146
+ * Skia extension: import a native synchronization primitive (an
147
+ * `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a
148
+ * {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The
149
+ * matching `shared-fence-*` feature must be enabled on the device.
150
+ */
151
+ importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
87
152
  }
88
153
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "setup-skia-web": "scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "2.6.5",
11
+ "version": "2.6.6",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",
@@ -131,10 +131,10 @@
131
131
  },
132
132
  "dependencies": {
133
133
  "canvaskit-wasm": "0.41.0",
134
- "react-native-skia-android": "147.1.0",
135
- "react-native-skia-apple-ios": "147.1.0",
136
- "react-native-skia-apple-macos": "147.1.0",
137
- "react-native-skia-apple-tvos": "147.1.0",
134
+ "react-native-skia-android": "150.0.0",
135
+ "react-native-skia-apple-ios": "150.0.0",
136
+ "react-native-skia-apple-macos": "150.0.0",
137
+ "react-native-skia-apple-tvos": "150.0.0",
138
138
  "react-reconciler": "0.31.0"
139
139
  },
140
140
  "eslintIgnore": [
@@ -36,6 +36,71 @@ export interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBas
36
36
  handle: NativeBuffer;
37
37
  }
38
38
 
39
+ /**
40
+ * The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
41
+ * matching the `shared-fence-*` device feature names. Limited to the kinds
42
+ * react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
43
+ * accepts these and `export()` reports them.
44
+ */
45
+ export type GPUSharedFenceType =
46
+ | "mtl-shared-event"
47
+ | "sync-fd"
48
+ | "vk-semaphore-opaque-fd";
49
+
50
+ /**
51
+ * Descriptor for {@link GPUDevice.importSharedFence}.
52
+ */
53
+ export interface GPUSharedFenceDescriptor {
54
+ /**
55
+ * The fence kind to import. Must match a `shared-fence-*` feature enabled on
56
+ * the device.
57
+ */
58
+ type: GPUSharedFenceType;
59
+ /**
60
+ * The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for
61
+ * `"mtl-shared-event"`, or an OS file descriptor for the `*-fd` kinds.
62
+ */
63
+ handle: bigint;
64
+ label?: string;
65
+ }
66
+
67
+ export interface GPUSharedFenceExportInfo {
68
+ type: GPUSharedFenceType;
69
+ /**
70
+ * An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a
71
+ * BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed
72
+ * once consumed.
73
+ */
74
+ handle: bigint;
75
+ }
76
+
77
+ /**
78
+ * A native GPU synchronization primitive shared across queues/APIs. Produced by
79
+ * {@link GPUSharedTextureMemory.endAccess}, consumed by
80
+ * {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
81
+ * fence with {@link GPUDevice.importSharedFence}.
82
+ */
83
+ export interface GPUSharedFence {
84
+ readonly __brand: "GPUSharedFence";
85
+ label: string;
86
+ export(): GPUSharedFenceExportInfo;
87
+ }
88
+
89
+ /** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
90
+ export interface GPUSharedFenceState {
91
+ fence: GPUSharedFence;
92
+ signaledValue: bigint;
93
+ }
94
+
95
+ /**
96
+ * The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
97
+ * at its `signaledValue` once Dawn's GPU work for the access completes.
98
+ */
99
+ export interface GPUSharedTextureMemoryEndAccessState {
100
+ initialized: boolean;
101
+ fences: GPUSharedFenceState[];
102
+ }
103
+
39
104
  /**
40
105
  * Shared texture memory imported from a platform native buffer via
41
106
  * {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
@@ -48,14 +113,20 @@ export interface GPUSharedTextureMemory extends GPUObjectBase {
48
113
  /**
49
114
  * Acquire the memory for GPU access. `initialized` marks whether the existing
50
115
  * contents should be preserved (pass `true` for an already-rendered frame).
51
- * Returns `false` if access could not be acquired.
116
+ * Optional `fences` are wait fences: Dawn waits for each to reach its
117
+ * `signaledValue` before writing the surface. Throws if the access could not
118
+ * be acquired.
52
119
  */
53
- beginAccess(texture: GPUTexture, initialized: boolean): boolean;
120
+ beginAccess(
121
+ texture: GPUTexture,
122
+ initialized: boolean,
123
+ fences?: GPUSharedFenceState[]
124
+ ): void;
54
125
  /**
55
- * Release the memory after the GPU work that accessed it has been submitted.
56
- * Returns `false` on failure.
126
+ * Release the memory after the GPU work that accessed it has been submitted,
127
+ * and return the fences Dawn produced for the access. Throws on failure.
57
128
  */
58
- endAccess(texture: GPUTexture): boolean;
129
+ endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
59
130
  }
60
131
 
61
132
  /**
@@ -104,5 +175,12 @@ declare global {
104
175
  importSharedTextureMemory(
105
176
  descriptor: GPUSharedTextureMemoryDescriptor
106
177
  ): GPUSharedTextureMemory;
178
+ /**
179
+ * Skia extension: import a native synchronization primitive (an
180
+ * `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a
181
+ * {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The
182
+ * matching `shared-fence-*` feature must be enabled on the device.
183
+ */
184
+ importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
107
185
  }
108
186
  }