@shopify/react-native-skia 2.6.5 → 2.6.7
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.
- package/android/CMakeLists.txt +2 -2
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerDelegate.java +35 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerInterface.java +17 -0
- package/apple/RNSkiaModule.mm +8 -2
- package/apple/SkiaManager.mm +10 -5
- package/cpp/api/JsiSkApi.h +6 -6
- package/cpp/api/JsiSkCanvas.h +33 -0
- package/cpp/api/JsiSkImage.h +12 -4
- package/cpp/api/JsiSkMaskFilter.h +1 -0
- package/cpp/api/JsiSkSurface.h +5 -1
- package/cpp/jsi2/NativeObject.h +39 -0
- package/cpp/rnskia/RNSkManager.cpp +27 -11
- package/cpp/rnwgpu/SurfaceRegistry.h +33 -1
- package/cpp/rnwgpu/api/GPU.cpp +15 -15
- package/cpp/rnwgpu/api/GPU.h +6 -3
- package/cpp/rnwgpu/api/GPUAdapter.cpp +11 -7
- package/cpp/rnwgpu/api/GPUAdapter.h +3 -3
- package/cpp/rnwgpu/api/GPUBuffer.h +3 -3
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +13 -16
- package/cpp/rnwgpu/api/GPUCanvasContext.h +3 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +103 -17
- package/cpp/rnwgpu/api/GPUDevice.h +18 -3
- package/cpp/rnwgpu/api/GPUQueue.h +3 -3
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
- package/cpp/rnwgpu/api/GPUShaderModule.h +3 -3
- package/cpp/rnwgpu/api/GPUSharedFence.cpp +80 -0
- package/cpp/rnwgpu/api/GPUSharedFence.h +53 -0
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +64 -11
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +13 -8
- package/cpp/rnwgpu/api/WebGPUConstants.h +36 -0
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +51 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +55 -22
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +8 -5
- package/cpp/rnwgpu/async/RuntimeContext.cpp +194 -0
- package/cpp/rnwgpu/async/RuntimeContext.h +121 -0
- package/cpp/skia/include/android/GrAHardwareBufferUtils.h +1 -1
- package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +1 -1
- package/cpp/skia/include/android/SkAnimatedImage.h +1 -1
- package/cpp/skia/include/codec/SkCodec.h +0 -8
- package/cpp/skia/include/codec/SkEncodedOrigin.h +1 -1
- package/cpp/skia/include/codec/SkPngRustDecoder.h +1 -1
- package/cpp/skia/include/core/SkBitmap.h +2 -8
- package/cpp/skia/include/core/SkCPURecorder.h +3 -1
- package/cpp/skia/include/core/SkCanvasVirtualEnforcer.h +1 -1
- package/cpp/skia/include/core/SkColorType.h +5 -3
- package/cpp/skia/include/core/SkContourMeasure.h +1 -1
- package/cpp/skia/include/core/SkCoverageMode.h +1 -1
- package/cpp/skia/include/core/SkCubicMap.h +1 -1
- package/cpp/skia/include/core/SkExecutor.h +1 -1
- package/cpp/skia/include/core/SkFont.h +15 -0
- package/cpp/skia/include/core/SkFontArguments.h +6 -1
- package/cpp/skia/include/core/SkFontMetrics.h +1 -1
- package/cpp/skia/include/core/SkFontMgr.h +36 -1
- package/cpp/skia/include/core/SkFontParameters.h +1 -1
- package/cpp/skia/include/core/SkFontScanner.h +1 -1
- package/cpp/skia/include/core/SkFontTypes.h +1 -1
- package/cpp/skia/include/core/SkM44.h +1 -1
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +1 -1
- package/cpp/skia/include/core/SkPathBuilder.h +10 -4
- package/cpp/skia/include/core/SkPathIter.h +1 -1
- package/cpp/skia/include/core/SkPathTypes.h +1 -1
- package/cpp/skia/include/core/SkPixelRef.h +4 -1
- package/cpp/skia/include/core/SkRecorder.h +2 -1
- package/cpp/skia/include/core/SkRegion.h +7 -1
- package/cpp/skia/include/core/SkSamplingOptions.h +1 -1
- package/cpp/skia/include/core/SkSerialProcs.h +8 -1
- package/cpp/skia/include/core/SkShader.h +3 -5
- package/cpp/skia/include/core/SkSpan.h +1 -1
- package/cpp/skia/include/core/SkStream.h +1 -1
- package/cpp/skia/include/core/SkStrikeRef.h +80 -0
- package/cpp/skia/include/core/SkTileMode.h +1 -1
- package/cpp/skia/include/core/SkVertices.h +1 -1
- package/cpp/skia/include/core/SkYUVAPixmaps.h +3 -5
- package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
- package/cpp/skia/include/docs/SkXPSDocument.h +1 -1
- package/cpp/skia/include/effects/SkGradient.h +1 -1
- package/cpp/skia/include/effects/SkHighContrastFilter.h +1 -1
- package/cpp/skia/include/effects/SkShaderMaskFilter.h +1 -1
- package/cpp/skia/include/effects/SkTrimPathEffect.h +1 -1
- package/cpp/skia/include/encode/SkEncoder.h +1 -1
- package/cpp/skia/include/encode/SkJpegEncoder.h +1 -1
- package/cpp/skia/include/encode/SkPngEncoder.h +1 -1
- package/cpp/skia/include/encode/SkPngRustEncoder.h +1 -1
- package/cpp/skia/include/encode/SkWebpEncoder.h +1 -1
- package/cpp/skia/include/gpu/GpuTypes.h +2 -0
- package/cpp/skia/include/gpu/MutableTextureState.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +6 -62
- package/cpp/skia/include/gpu/ganesh/GrContextThreadSafeProxy.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +2 -1
- package/cpp/skia/include/gpu/ganesh/mock/GrMockBackendSurface.h +59 -0
- package/cpp/skia/include/gpu/ganesh/mock/GrMockTypes.h +1 -1
- package/cpp/skia/include/gpu/ganesh/mtl/GrMtlBackendContext.h +1 -1
- package/cpp/skia/include/gpu/ganesh/mtl/GrMtlTypes.h +1 -1
- package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +1 -1
- package/cpp/skia/include/gpu/graphite/Context.h +11 -4
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +6 -0
- package/cpp/skia/include/gpu/graphite/Image.h +82 -9
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +7 -2
- package/cpp/skia/include/gpu/graphite/Recorder.h +6 -4
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileColorFilter.h +11 -1
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +1 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +1 -1
- package/cpp/skia/include/gpu/mtl/MtlMemoryAllocator.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanTypes.h +1 -1
- package/cpp/skia/include/ports/SkCFObject.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_Fontations.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_android_ndk.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_data.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_mac_ct.h +1 -1
- package/cpp/skia/include/ports/SkFontScanner_Fontations.h +1 -1
- package/cpp/skia/include/ports/SkFontScanner_FreeType.h +1 -1
- package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
- package/cpp/skia/include/private/SkExif.h +1 -1
- package/cpp/skia/include/private/SkGainmapInfo.h +1 -1
- package/cpp/skia/include/private/SkGainmapShader.h +1 -1
- package/cpp/skia/include/private/SkHdrMetadata.h +21 -0
- package/cpp/skia/include/private/SkJpegGainmapEncoder.h +1 -1
- package/cpp/skia/include/private/SkPixelStorage.h +37 -0
- package/cpp/skia/include/private/SkXmp.h +1 -1
- package/cpp/skia/include/private/base/SkAssert.h +6 -5
- package/cpp/skia/include/private/base/SkContainers.h +1 -1
- package/cpp/skia/include/private/base/SkFeatures.h +30 -30
- package/cpp/skia/include/private/base/SkLog.h +1 -7
- package/cpp/skia/include/private/base/SkLogPriority.h +4 -5
- package/cpp/skia/include/private/base/SkMacros.h +1 -1
- package/cpp/skia/include/private/base/SkMalloc.h +1 -1
- package/cpp/skia/include/private/base/SkSafe32.h +1 -1
- package/cpp/skia/include/private/base/SkSpan_impl.h +1 -1
- package/cpp/skia/include/private/base/SkTDArray.h +13 -1
- package/cpp/skia/include/private/base/SkTPin.h +1 -1
- package/cpp/skia/include/private/base/SkTo.h +1 -1
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +1 -1
- package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +1 -1
- package/cpp/skia/include/private/chromium/SkCodecsICCProfileChromium.h +52 -0
- package/cpp/skia/include/private/chromium/SkExifChromium.h +26 -0
- package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +2 -1
- package/cpp/skia/include/private/gpu/vk/SkiaVulkan.h +1 -1
- package/cpp/skia/include/sksl/SkSLDebugTrace.h +1 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_icd.h +41 -51
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_layer.h +42 -53
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +158 -154
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +68 -65
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +90 -87
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +9 -9
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +2 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +82 -79
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +24 -24
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +2 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +95 -96
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std.h +151 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std_decode.h +68 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +1 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +5 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +7 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +291 -158
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +13174 -10113
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +23 -19
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +159 -165
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +22 -19
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +3 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +3 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +94 -88
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ohos.h +120 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +55 -51
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +18 -15
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +23 -19
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +31 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +5 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +27 -27
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +20 -16
- package/cpp/skia/include/utils/SkEventTracer.h +6 -1
- package/cpp/skia/include/utils/SkOrderedFontMgr.h +1 -1
- package/cpp/skia/include/utils/SkShadowUtils.h +1 -1
- package/cpp/skia/include/utils/SkTextUtils.h +1 -1
- package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +20 -4
- package/cpp/skia/modules/skcms/src/Transform_inl.h +11 -15
- package/cpp/skia/modules/skcms/src/skcms_public.h +2 -0
- package/cpp/skia/modules/skottie/include/ExternalLayer.h +1 -1
- package/cpp/skia/modules/skottie/include/Skottie.h +1 -1
- package/cpp/skia/modules/skottie/include/SkottieProperty.h +1 -1
- package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
- package/cpp/skia/modules/skottie/include/TextShaper.h +1 -1
- package/cpp/skia/modules/skottie/src/SkottieValue.h +1 -1
- package/cpp/skia/modules/skottie/src/animator/Animator.h +1 -1
- package/cpp/skia/modules/skottie/src/text/Font.h +1 -1
- package/cpp/skia/modules/skottie/src/text/TextAdapter.h +1 -1
- package/cpp/skia/modules/skottie/src/text/TextAnimator.h +3 -2
- package/cpp/skia/modules/skottie/src/text/TextValue.h +1 -1
- package/cpp/skia/modules/skparagraph/include/DartTypes.h +1 -1
- package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +5 -1
- package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphPainter.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +12 -5
- package/cpp/skia/modules/skparagraph/include/TextShadow.h +1 -1
- package/cpp/skia/modules/skparagraph/include/TextStyle.h +1 -1
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGDraw.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGradient.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGroup.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGImage.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGPaint.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGPlane.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGRect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGScene.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGText.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGTransform.h +1 -1
- package/cpp/skia/modules/skshaper/include/SkShaper_coretext.h +8 -1
- package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeMerge.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeMorphology.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFilterContext.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
- package/cpp/skia/src/base/SkAutoLocaleSetter.h +94 -0
- package/cpp/skia/src/base/SkUTF.h +1 -1
- package/lib/commonjs/skia/types/WebGPU.d.ts +101 -5
- package/lib/commonjs/skia/types/WebGPU.js +99 -0
- package/lib/commonjs/skia/types/WebGPU.js.map +1 -1
- package/lib/module/skia/types/WebGPU.d.ts +101 -5
- package/lib/module/skia/types/WebGPU.js +98 -1
- package/lib/module/skia/types/WebGPU.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +1 -0
- package/lib/typescript/lib/module/mock/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +31 -1
- package/lib/typescript/src/skia/types/WebGPU.d.ts +101 -5
- package/package.json +5 -5
- package/src/skia/types/WebGPU.ts +123 -5
- package/cpp/rnwgpu/async/AsyncDispatcher.h +0 -28
- package/cpp/rnwgpu/async/AsyncRunner.cpp +0 -182
- package/cpp/rnwgpu/async/AsyncRunner.h +0 -57
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +0 -23
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +0 -22
|
@@ -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,35 @@
|
|
|
1
1
|
import type { NativeBuffer } from "./NativeBuffer";
|
|
2
|
+
/**
|
|
3
|
+
* Make the WebGPU flag constants (`GPUBufferUsage`, `GPUColorWrite`,
|
|
4
|
+
* `GPUMapMode`, `GPUShaderStage`, `GPUTextureUsage`) available on the runtime
|
|
5
|
+
* that calls this.
|
|
6
|
+
*
|
|
7
|
+
* The native module installs these globals on the main JS runtime, but worklet
|
|
8
|
+
* runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame
|
|
9
|
+
* processors) start without them, so referencing the bare global inside a
|
|
10
|
+
* worklet yields `undefined`. Call `installWebGPU()` once at the top of a
|
|
11
|
+
* worklet to install them there:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { installWebGPU } from "@shopify/react-native-skia";
|
|
15
|
+
*
|
|
16
|
+
* const work = (device: GPUDevice) => {
|
|
17
|
+
* "worklet";
|
|
18
|
+
* installWebGPU();
|
|
19
|
+
* device.createBuffer({
|
|
20
|
+
* usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
21
|
+
* });
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* `installWebGPU` is a native host function. When captured into a worklet, the
|
|
26
|
+
* Worklets serializer re-creates it on the worklet runtime, so calling it there
|
|
27
|
+
* installs the constants on that runtime. The values come from the native
|
|
28
|
+
* `wgpu::*Usage` enums, so they stay a single source of truth across runtimes.
|
|
29
|
+
* Calling it on a runtime that already has the constants is a safe no-op, and on
|
|
30
|
+
* web (where the constants are always global) it is a no-op too.
|
|
31
|
+
*/
|
|
32
|
+
export declare const installWebGPU: () => void;
|
|
2
33
|
/**
|
|
3
34
|
* Descriptor for {@link GPUDevice.importExternalTexture} when the source is a
|
|
4
35
|
* Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).
|
|
@@ -24,6 +55,62 @@ export interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBas
|
|
|
24
55
|
export interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {
|
|
25
56
|
handle: NativeBuffer;
|
|
26
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
|
|
60
|
+
* matching the `shared-fence-*` device feature names. Limited to the kinds
|
|
61
|
+
* react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
|
|
62
|
+
* accepts these and `export()` reports them.
|
|
63
|
+
*/
|
|
64
|
+
export type GPUSharedFenceType = "mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
|
|
65
|
+
/**
|
|
66
|
+
* Descriptor for {@link GPUDevice.importSharedFence}.
|
|
67
|
+
*/
|
|
68
|
+
export interface GPUSharedFenceDescriptor {
|
|
69
|
+
/**
|
|
70
|
+
* The fence kind to import. Must match a `shared-fence-*` feature enabled on
|
|
71
|
+
* the device.
|
|
72
|
+
*/
|
|
73
|
+
type: GPUSharedFenceType;
|
|
74
|
+
/**
|
|
75
|
+
* The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for
|
|
76
|
+
* `"mtl-shared-event"`, or an OS file descriptor for the `*-fd` kinds.
|
|
77
|
+
*/
|
|
78
|
+
handle: bigint;
|
|
79
|
+
label?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface GPUSharedFenceExportInfo {
|
|
82
|
+
type: GPUSharedFenceType;
|
|
83
|
+
/**
|
|
84
|
+
* An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a
|
|
85
|
+
* BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed
|
|
86
|
+
* once consumed.
|
|
87
|
+
*/
|
|
88
|
+
handle: bigint;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A native GPU synchronization primitive shared across queues/APIs. Produced by
|
|
92
|
+
* {@link GPUSharedTextureMemory.endAccess}, consumed by
|
|
93
|
+
* {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
|
|
94
|
+
* fence with {@link GPUDevice.importSharedFence}.
|
|
95
|
+
*/
|
|
96
|
+
export interface GPUSharedFence {
|
|
97
|
+
readonly __brand: "GPUSharedFence";
|
|
98
|
+
label: string;
|
|
99
|
+
export(): GPUSharedFenceExportInfo;
|
|
100
|
+
}
|
|
101
|
+
/** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
|
|
102
|
+
export interface GPUSharedFenceState {
|
|
103
|
+
fence: GPUSharedFence;
|
|
104
|
+
signaledValue: bigint;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
|
|
108
|
+
* at its `signaledValue` once Dawn's GPU work for the access completes.
|
|
109
|
+
*/
|
|
110
|
+
export interface GPUSharedTextureMemoryEndAccessState {
|
|
111
|
+
initialized: boolean;
|
|
112
|
+
fences: GPUSharedFenceState[];
|
|
113
|
+
}
|
|
27
114
|
/**
|
|
28
115
|
* Shared texture memory imported from a platform native buffer via
|
|
29
116
|
* {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
|
|
@@ -36,14 +123,16 @@ export interface GPUSharedTextureMemory extends GPUObjectBase {
|
|
|
36
123
|
/**
|
|
37
124
|
* Acquire the memory for GPU access. `initialized` marks whether the existing
|
|
38
125
|
* contents should be preserved (pass `true` for an already-rendered frame).
|
|
39
|
-
*
|
|
126
|
+
* Optional `fences` are wait fences: Dawn waits for each to reach its
|
|
127
|
+
* `signaledValue` before writing the surface. Throws if the access could not
|
|
128
|
+
* be acquired.
|
|
40
129
|
*/
|
|
41
|
-
beginAccess(texture: GPUTexture, initialized: boolean):
|
|
130
|
+
beginAccess(texture: GPUTexture, initialized: boolean, fences?: GPUSharedFenceState[]): void;
|
|
42
131
|
/**
|
|
43
|
-
* Release the memory after the GPU work that accessed it has been submitted
|
|
44
|
-
*
|
|
132
|
+
* Release the memory after the GPU work that accessed it has been submitted,
|
|
133
|
+
* and return the fences Dawn produced for the access. Throws on failure.
|
|
45
134
|
*/
|
|
46
|
-
endAccess(texture: GPUTexture):
|
|
135
|
+
endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
|
|
47
136
|
}
|
|
48
137
|
/**
|
|
49
138
|
* Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to
|
|
@@ -84,5 +173,12 @@ declare global {
|
|
|
84
173
|
* begin/end access window yourself.
|
|
85
174
|
*/
|
|
86
175
|
importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
|
|
176
|
+
/**
|
|
177
|
+
* Skia extension: import a native synchronization primitive (an
|
|
178
|
+
* `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a
|
|
179
|
+
* {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The
|
|
180
|
+
* matching `shared-fence-*` feature must be enabled on the device.
|
|
181
|
+
*/
|
|
182
|
+
importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
|
|
87
183
|
}
|
|
88
184
|
}
|
|
@@ -3,4 +3,103 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.installWebGPU = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Make the WebGPU flag constants (`GPUBufferUsage`, `GPUColorWrite`,
|
|
9
|
+
* `GPUMapMode`, `GPUShaderStage`, `GPUTextureUsage`) available on the runtime
|
|
10
|
+
* that calls this.
|
|
11
|
+
*
|
|
12
|
+
* The native module installs these globals on the main JS runtime, but worklet
|
|
13
|
+
* runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame
|
|
14
|
+
* processors) start without them, so referencing the bare global inside a
|
|
15
|
+
* worklet yields `undefined`. Call `installWebGPU()` once at the top of a
|
|
16
|
+
* worklet to install them there:
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { installWebGPU } from "@shopify/react-native-skia";
|
|
20
|
+
*
|
|
21
|
+
* const work = (device: GPUDevice) => {
|
|
22
|
+
* "worklet";
|
|
23
|
+
* installWebGPU();
|
|
24
|
+
* device.createBuffer({
|
|
25
|
+
* usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
26
|
+
* });
|
|
27
|
+
* };
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* `installWebGPU` is a native host function. When captured into a worklet, the
|
|
31
|
+
* Worklets serializer re-creates it on the worklet runtime, so calling it there
|
|
32
|
+
* installs the constants on that runtime. The values come from the native
|
|
33
|
+
* `wgpu::*Usage` enums, so they stay a single source of truth across runtimes.
|
|
34
|
+
* Calling it on a runtime that already has the constants is a safe no-op, and on
|
|
35
|
+
* web (where the constants are always global) it is a no-op too.
|
|
36
|
+
*/
|
|
37
|
+
const installWebGPU = exports.installWebGPU = (() => {
|
|
38
|
+
const g = typeof global !== "undefined" ? global : undefined;
|
|
39
|
+
return g && typeof g.installWebGPU === "function" ? g.installWebGPU : () => {};
|
|
40
|
+
})();
|
|
41
|
+
|
|
42
|
+
// Skia's Graphite/Dawn backend extends the standard WebGPU API (typed by
|
|
43
|
+
// @webgpu/types) with a few Skia- and Dawn-specific entry points. These are
|
|
44
|
+
// only available on native (SK_GRAPHITE) builds, reachable through
|
|
45
|
+
// `Skia.getDevice()`.
|
|
46
|
+
//
|
|
47
|
+
// The exported interfaces below describe the descriptors and objects those
|
|
48
|
+
// entry points use; the `declare global` block augments the standard WebGPU
|
|
49
|
+
// interfaces so the new methods are typed without casting to `any`.
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Descriptor for {@link GPUDevice.importExternalTexture} when the source is a
|
|
53
|
+
* Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).
|
|
54
|
+
*
|
|
55
|
+
* `source` is the handle returned by `Skia.NativeBuffer.MakeFromImage`: a
|
|
56
|
+
* `CVPixelBufferRef` on Apple, an `AHardwareBuffer*` on Android. The caller
|
|
57
|
+
* owns its lifetime (release it with `Skia.NativeBuffer.Release`) and must keep
|
|
58
|
+
* it alive until the imported texture is destroyed.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Descriptor for {@link GPUDevice.importSharedTextureMemory}. `handle` is the
|
|
63
|
+
* NativeBuffer returned by `Skia.NativeBuffer.MakeFromImage` (see
|
|
64
|
+
* {@link SkiaGPUExternalTextureDescriptor} for the platform-specific types and
|
|
65
|
+
* lifetime rules).
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
|
|
70
|
+
* matching the `shared-fence-*` device feature names. Limited to the kinds
|
|
71
|
+
* react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
|
|
72
|
+
* accepts these and `export()` reports them.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Descriptor for {@link GPUDevice.importSharedFence}.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A native GPU synchronization primitive shared across queues/APIs. Produced by
|
|
81
|
+
* {@link GPUSharedTextureMemory.endAccess}, consumed by
|
|
82
|
+
* {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
|
|
83
|
+
* fence with {@link GPUDevice.importSharedFence}.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
|
|
90
|
+
* at its `signaledValue` once Dawn's GPU work for the access completes.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Shared texture memory imported from a platform native buffer via
|
|
95
|
+
* {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
|
|
96
|
+
* the memory, then bracket the GPU work that touches it with
|
|
97
|
+
* {@link GPUSharedTextureMemory.beginAccess} / {@link GPUSharedTextureMemory.endAccess}.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to
|
|
102
|
+
* `adapter.requestDevice`. This is a non-spec, Dawn-only extension; see Dawn's
|
|
103
|
+
* toggle list for valid names.
|
|
104
|
+
*/
|
|
6
105
|
//# sourceMappingURL=WebGPU.js.map
|
|
@@ -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 *
|
|
1
|
+
{"version":3,"names":["installWebGPU","exports","g","global","undefined"],"sources":["WebGPU.ts"],"sourcesContent":["import type { NativeBuffer } from \"./NativeBuffer\";\n\n/**\n * Make the WebGPU flag constants (`GPUBufferUsage`, `GPUColorWrite`,\n * `GPUMapMode`, `GPUShaderStage`, `GPUTextureUsage`) available on the runtime\n * that calls this.\n *\n * The native module installs these globals on the main JS runtime, but worklet\n * runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame\n * processors) start without them, so referencing the bare global inside a\n * worklet yields `undefined`. Call `installWebGPU()` once at the top of a\n * worklet to install them there:\n *\n * ```tsx\n * import { installWebGPU } from \"@shopify/react-native-skia\";\n *\n * const work = (device: GPUDevice) => {\n * \"worklet\";\n * installWebGPU();\n * device.createBuffer({\n * usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,\n * });\n * };\n * ```\n *\n * `installWebGPU` is a native host function. When captured into a worklet, the\n * Worklets serializer re-creates it on the worklet runtime, so calling it there\n * installs the constants on that runtime. The values come from the native\n * `wgpu::*Usage` enums, so they stay a single source of truth across runtimes.\n * Calling it on a runtime that already has the constants is a safe no-op, and on\n * web (where the constants are always global) it is a no-op too.\n */\nexport const installWebGPU: () => void = (() => {\n const g =\n typeof global !== \"undefined\"\n ? (global as unknown as { installWebGPU?: () => void })\n : undefined;\n return g && typeof g.installWebGPU === \"function\"\n ? g.installWebGPU\n : () => {};\n})();\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":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAyB,GAAAC,OAAA,CAAAD,aAAA,GAAG,CAAC,MAAM;EAC9C,MAAME,CAAC,GACL,OAAOC,MAAM,KAAK,WAAW,GACxBA,MAAM,GACPC,SAAS;EACf,OAAOF,CAAC,IAAI,OAAOA,CAAC,CAACF,aAAa,KAAK,UAAU,GAC7CE,CAAC,CAACF,aAAa,GACf,MAAM,CAAC,CAAC;AACd,CAAC,EAAE,CAAC;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAMA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,4 +1,35 @@
|
|
|
1
1
|
import type { NativeBuffer } from "./NativeBuffer";
|
|
2
|
+
/**
|
|
3
|
+
* Make the WebGPU flag constants (`GPUBufferUsage`, `GPUColorWrite`,
|
|
4
|
+
* `GPUMapMode`, `GPUShaderStage`, `GPUTextureUsage`) available on the runtime
|
|
5
|
+
* that calls this.
|
|
6
|
+
*
|
|
7
|
+
* The native module installs these globals on the main JS runtime, but worklet
|
|
8
|
+
* runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame
|
|
9
|
+
* processors) start without them, so referencing the bare global inside a
|
|
10
|
+
* worklet yields `undefined`. Call `installWebGPU()` once at the top of a
|
|
11
|
+
* worklet to install them there:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { installWebGPU } from "@shopify/react-native-skia";
|
|
15
|
+
*
|
|
16
|
+
* const work = (device: GPUDevice) => {
|
|
17
|
+
* "worklet";
|
|
18
|
+
* installWebGPU();
|
|
19
|
+
* device.createBuffer({
|
|
20
|
+
* usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
21
|
+
* });
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* `installWebGPU` is a native host function. When captured into a worklet, the
|
|
26
|
+
* Worklets serializer re-creates it on the worklet runtime, so calling it there
|
|
27
|
+
* installs the constants on that runtime. The values come from the native
|
|
28
|
+
* `wgpu::*Usage` enums, so they stay a single source of truth across runtimes.
|
|
29
|
+
* Calling it on a runtime that already has the constants is a safe no-op, and on
|
|
30
|
+
* web (where the constants are always global) it is a no-op too.
|
|
31
|
+
*/
|
|
32
|
+
export declare const installWebGPU: () => void;
|
|
2
33
|
/**
|
|
3
34
|
* Descriptor for {@link GPUDevice.importExternalTexture} when the source is a
|
|
4
35
|
* Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).
|
|
@@ -24,6 +55,62 @@ export interface SkiaGPUExternalTextureDescriptor extends GPUObjectDescriptorBas
|
|
|
24
55
|
export interface GPUSharedTextureMemoryDescriptor extends GPUObjectDescriptorBase {
|
|
25
56
|
handle: NativeBuffer;
|
|
26
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
|
|
60
|
+
* matching the `shared-fence-*` device feature names. Limited to the kinds
|
|
61
|
+
* react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
|
|
62
|
+
* accepts these and `export()` reports them.
|
|
63
|
+
*/
|
|
64
|
+
export type GPUSharedFenceType = "mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
|
|
65
|
+
/**
|
|
66
|
+
* Descriptor for {@link GPUDevice.importSharedFence}.
|
|
67
|
+
*/
|
|
68
|
+
export interface GPUSharedFenceDescriptor {
|
|
69
|
+
/**
|
|
70
|
+
* The fence kind to import. Must match a `shared-fence-*` feature enabled on
|
|
71
|
+
* the device.
|
|
72
|
+
*/
|
|
73
|
+
type: GPUSharedFenceType;
|
|
74
|
+
/**
|
|
75
|
+
* The raw native handle as a BigInt: an `id<MTLSharedEvent>` pointer for
|
|
76
|
+
* `"mtl-shared-event"`, or an OS file descriptor for the `*-fd` kinds.
|
|
77
|
+
*/
|
|
78
|
+
handle: bigint;
|
|
79
|
+
label?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface GPUSharedFenceExportInfo {
|
|
82
|
+
type: GPUSharedFenceType;
|
|
83
|
+
/**
|
|
84
|
+
* An `id<MTLSharedEvent>` pointer (Apple) or file descriptor (Android), as a
|
|
85
|
+
* BigInt. The caller takes ownership; e.g. an exported sync-fd must be closed
|
|
86
|
+
* once consumed.
|
|
87
|
+
*/
|
|
88
|
+
handle: bigint;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A native GPU synchronization primitive shared across queues/APIs. Produced by
|
|
92
|
+
* {@link GPUSharedTextureMemory.endAccess}, consumed by
|
|
93
|
+
* {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
|
|
94
|
+
* fence with {@link GPUDevice.importSharedFence}.
|
|
95
|
+
*/
|
|
96
|
+
export interface GPUSharedFence {
|
|
97
|
+
readonly __brand: "GPUSharedFence";
|
|
98
|
+
label: string;
|
|
99
|
+
export(): GPUSharedFenceExportInfo;
|
|
100
|
+
}
|
|
101
|
+
/** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
|
|
102
|
+
export interface GPUSharedFenceState {
|
|
103
|
+
fence: GPUSharedFence;
|
|
104
|
+
signaledValue: bigint;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
|
|
108
|
+
* at its `signaledValue` once Dawn's GPU work for the access completes.
|
|
109
|
+
*/
|
|
110
|
+
export interface GPUSharedTextureMemoryEndAccessState {
|
|
111
|
+
initialized: boolean;
|
|
112
|
+
fences: GPUSharedFenceState[];
|
|
113
|
+
}
|
|
27
114
|
/**
|
|
28
115
|
* Shared texture memory imported from a platform native buffer via
|
|
29
116
|
* {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
|
|
@@ -36,14 +123,16 @@ export interface GPUSharedTextureMemory extends GPUObjectBase {
|
|
|
36
123
|
/**
|
|
37
124
|
* Acquire the memory for GPU access. `initialized` marks whether the existing
|
|
38
125
|
* contents should be preserved (pass `true` for an already-rendered frame).
|
|
39
|
-
*
|
|
126
|
+
* Optional `fences` are wait fences: Dawn waits for each to reach its
|
|
127
|
+
* `signaledValue` before writing the surface. Throws if the access could not
|
|
128
|
+
* be acquired.
|
|
40
129
|
*/
|
|
41
|
-
beginAccess(texture: GPUTexture, initialized: boolean):
|
|
130
|
+
beginAccess(texture: GPUTexture, initialized: boolean, fences?: GPUSharedFenceState[]): void;
|
|
42
131
|
/**
|
|
43
|
-
* Release the memory after the GPU work that accessed it has been submitted
|
|
44
|
-
*
|
|
132
|
+
* Release the memory after the GPU work that accessed it has been submitted,
|
|
133
|
+
* and return the fences Dawn produced for the access. Throws on failure.
|
|
45
134
|
*/
|
|
46
|
-
endAccess(texture: GPUTexture):
|
|
135
|
+
endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
|
|
47
136
|
}
|
|
48
137
|
/**
|
|
49
138
|
* Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to
|
|
@@ -84,5 +173,12 @@ declare global {
|
|
|
84
173
|
* begin/end access window yourself.
|
|
85
174
|
*/
|
|
86
175
|
importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
|
|
176
|
+
/**
|
|
177
|
+
* Skia extension: import a native synchronization primitive (an
|
|
178
|
+
* `id<MTLSharedEvent>` on Apple, a sync-fd / VkSemaphore on Android) as a
|
|
179
|
+
* {@link GPUSharedFence}, e.g. to wait on a fence a consumer produced. The
|
|
180
|
+
* matching `shared-fence-*` feature must be enabled on the device.
|
|
181
|
+
*/
|
|
182
|
+
importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
|
|
87
183
|
}
|
|
88
184
|
}
|
|
@@ -1,2 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Make the WebGPU flag constants (`GPUBufferUsage`, `GPUColorWrite`,
|
|
3
|
+
* `GPUMapMode`, `GPUShaderStage`, `GPUTextureUsage`) available on the runtime
|
|
4
|
+
* that calls this.
|
|
5
|
+
*
|
|
6
|
+
* The native module installs these globals on the main JS runtime, but worklet
|
|
7
|
+
* runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame
|
|
8
|
+
* processors) start without them, so referencing the bare global inside a
|
|
9
|
+
* worklet yields `undefined`. Call `installWebGPU()` once at the top of a
|
|
10
|
+
* worklet to install them there:
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { installWebGPU } from "@shopify/react-native-skia";
|
|
14
|
+
*
|
|
15
|
+
* const work = (device: GPUDevice) => {
|
|
16
|
+
* "worklet";
|
|
17
|
+
* installWebGPU();
|
|
18
|
+
* device.createBuffer({
|
|
19
|
+
* usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
20
|
+
* });
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* `installWebGPU` is a native host function. When captured into a worklet, the
|
|
25
|
+
* Worklets serializer re-creates it on the worklet runtime, so calling it there
|
|
26
|
+
* installs the constants on that runtime. The values come from the native
|
|
27
|
+
* `wgpu::*Usage` enums, so they stay a single source of truth across runtimes.
|
|
28
|
+
* Calling it on a runtime that already has the constants is a safe no-op, and on
|
|
29
|
+
* web (where the constants are always global) it is a no-op too.
|
|
30
|
+
*/
|
|
31
|
+
export const installWebGPU = (() => {
|
|
32
|
+
const g = typeof global !== "undefined" ? global : undefined;
|
|
33
|
+
return g && typeof g.installWebGPU === "function" ? g.installWebGPU : () => {};
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
// Skia's Graphite/Dawn backend extends the standard WebGPU API (typed by
|
|
37
|
+
// @webgpu/types) with a few Skia- and Dawn-specific entry points. These are
|
|
38
|
+
// only available on native (SK_GRAPHITE) builds, reachable through
|
|
39
|
+
// `Skia.getDevice()`.
|
|
40
|
+
//
|
|
41
|
+
// The exported interfaces below describe the descriptors and objects those
|
|
42
|
+
// entry points use; the `declare global` block augments the standard WebGPU
|
|
43
|
+
// interfaces so the new methods are typed without casting to `any`.
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Descriptor for {@link GPUDevice.importExternalTexture} when the source is a
|
|
47
|
+
* Skia NativeBuffer (Skia has no WebCodecs `VideoFrame`).
|
|
48
|
+
*
|
|
49
|
+
* `source` is the handle returned by `Skia.NativeBuffer.MakeFromImage`: a
|
|
50
|
+
* `CVPixelBufferRef` on Apple, an `AHardwareBuffer*` on Android. The caller
|
|
51
|
+
* owns its lifetime (release it with `Skia.NativeBuffer.Release`) and must keep
|
|
52
|
+
* it alive until the imported texture is destroyed.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Descriptor for {@link GPUDevice.importSharedTextureMemory}. `handle` is the
|
|
57
|
+
* NativeBuffer returned by `Skia.NativeBuffer.MakeFromImage` (see
|
|
58
|
+
* {@link SkiaGPUExternalTextureDescriptor} for the platform-specific types and
|
|
59
|
+
* lifetime rules).
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The kind of native synchronization primitive a {@link GPUSharedFence} wraps,
|
|
64
|
+
* matching the `shared-fence-*` device feature names. Limited to the kinds
|
|
65
|
+
* react-native-skia targets (iOS/Metal and Android/Vulkan); `importSharedFence`
|
|
66
|
+
* accepts these and `export()` reports them.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Descriptor for {@link GPUDevice.importSharedFence}.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A native GPU synchronization primitive shared across queues/APIs. Produced by
|
|
75
|
+
* {@link GPUSharedTextureMemory.endAccess}, consumed by
|
|
76
|
+
* {@link GPUSharedTextureMemory.beginAccess}, or imported from a consumer's
|
|
77
|
+
* fence with {@link GPUDevice.importSharedFence}.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/** A fence and the timeline value to wait for (0n for binary sync-fd fences). */
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The result of {@link GPUSharedTextureMemory.endAccess}: each fence is signaled
|
|
84
|
+
* at its `signaledValue` once Dawn's GPU work for the access completes.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Shared texture memory imported from a platform native buffer via
|
|
89
|
+
* {@link GPUDevice.importSharedTextureMemory}. Create a texture that aliases
|
|
90
|
+
* the memory, then bracket the GPU work that touches it with
|
|
91
|
+
* {@link GPUSharedTextureMemory.beginAccess} / {@link GPUSharedTextureMemory.endAccess}.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Dawn-specific toggles, passed via {@link GPUDeviceDescriptor.dawnToggles} to
|
|
96
|
+
* `adapter.requestDevice`. This is a non-spec, Dawn-only extension; see Dawn's
|
|
97
|
+
* toggle list for valid names.
|
|
98
|
+
*/
|
|
2
99
|
//# sourceMappingURL=WebGPU.js.map
|
|
@@ -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 *
|
|
1
|
+
{"version":3,"names":["installWebGPU","g","global","undefined"],"sources":["WebGPU.ts"],"sourcesContent":["import type { NativeBuffer } from \"./NativeBuffer\";\n\n/**\n * Make the WebGPU flag constants (`GPUBufferUsage`, `GPUColorWrite`,\n * `GPUMapMode`, `GPUShaderStage`, `GPUTextureUsage`) available on the runtime\n * that calls this.\n *\n * The native module installs these globals on the main JS runtime, but worklet\n * runtimes (Reanimated UI, dedicated worklet runtimes, Vision Camera frame\n * processors) start without them, so referencing the bare global inside a\n * worklet yields `undefined`. Call `installWebGPU()` once at the top of a\n * worklet to install them there:\n *\n * ```tsx\n * import { installWebGPU } from \"@shopify/react-native-skia\";\n *\n * const work = (device: GPUDevice) => {\n * \"worklet\";\n * installWebGPU();\n * device.createBuffer({\n * usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,\n * });\n * };\n * ```\n *\n * `installWebGPU` is a native host function. When captured into a worklet, the\n * Worklets serializer re-creates it on the worklet runtime, so calling it there\n * installs the constants on that runtime. The values come from the native\n * `wgpu::*Usage` enums, so they stay a single source of truth across runtimes.\n * Calling it on a runtime that already has the constants is a safe no-op, and on\n * web (where the constants are always global) it is a no-op too.\n */\nexport const installWebGPU: () => void = (() => {\n const g =\n typeof global !== \"undefined\"\n ? (global as unknown as { installWebGPU?: () => void })\n : undefined;\n return g && typeof g.installWebGPU === \"function\"\n ? g.installWebGPU\n : () => {};\n})();\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":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAyB,GAAG,CAAC,MAAM;EAC9C,MAAMC,CAAC,GACL,OAAOC,MAAM,KAAK,WAAW,GACxBA,MAAM,GACPC,SAAS;EACf,OAAOF,CAAC,IAAI,OAAOA,CAAC,CAACD,aAAa,KAAK,UAAU,GAC7CC,CAAC,CAACD,aAAa,GACf,MAAM,CAAC,CAAC;AACd,CAAC,EAAE,CAAC;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAMA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -306,6 +306,7 @@ export function Mock(CanvasKit: any): {
|
|
|
306
306
|
isNativeBufferAddr: (buffer: any) => buffer is BigInt;
|
|
307
307
|
isNativeBufferWeb: (buffer: any) => boolean;
|
|
308
308
|
isNativeBufferNode: (buffer: any) => buffer is ArrayBuffer;
|
|
309
|
+
installWebGPU: any;
|
|
309
310
|
LineBreakType: {};
|
|
310
311
|
VerticalTextAlign: {};
|
|
311
312
|
ResizePolicy: {};
|