@shopify/react-native-skia 2.6.4 → 2.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +8 -4
- package/android/build.gradle +22 -3
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +62 -0
- 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/RNSkApplePlatformContext.h +2 -0
- package/apple/RNSkApplePlatformContext.mm +71 -0
- package/apple/RNWebGPUAppleNativeBuffer.mm +33 -0
- package/cpp/api/JsiNativeBuffer.h +9 -1
- package/cpp/api/JsiSkAnimatedImageFactory.h +1 -1
- package/cpp/api/JsiSkApi.h +2 -2
- package/cpp/api/JsiSkCanvas.h +34 -1
- package/cpp/api/JsiSkDataFactory.h +1 -1
- package/cpp/api/JsiSkFont.h +1 -1
- package/cpp/api/JsiSkFontMgr.h +1 -1
- package/cpp/api/JsiSkHostObjects.h +3 -3
- package/cpp/api/JsiSkImage.h +14 -6
- package/cpp/api/JsiSkImageFactory.h +2 -2
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkSurface.h +18 -6
- package/cpp/api/JsiSkTypeface.h +1 -1
- package/cpp/api/JsiSkTypefaceFontProvider.h +1 -1
- package/cpp/api/JsiSkiaContext.h +2 -2
- package/cpp/api/JsiTextureInfo.h +1 -1
- package/cpp/api/JsiVideo.h +2 -2
- package/cpp/api/recorder/Drawings.h +1 -1
- package/cpp/api/recorder/JsiRecorder.h +4 -4
- package/cpp/api/recorder/RNRecorder.h +1 -1
- package/cpp/jsi/ViewProperty.h +1 -1
- package/cpp/rnskia/RNDawnContext.h +13 -0
- package/cpp/rnskia/RNDawnUtils.h +11 -1
- package/cpp/rnskia/RNSkJsiViewApi.h +2 -2
- package/cpp/rnskia/RNSkManager.cpp +88 -2
- package/cpp/rnskia/RNSkPictureView.h +4 -4
- package/cpp/rnskia/RNSkPlatformContext.h +7 -0
- package/cpp/rnskia/RNSkView.h +9 -6
- package/cpp/rnwgpu/ArrayBuffer.h +51 -7
- package/cpp/rnwgpu/api/AppleNativeBuffer.h +22 -0
- package/cpp/rnwgpu/api/Convertors.h +33 -11
- package/cpp/rnwgpu/api/GPU.cpp +0 -3
- package/cpp/rnwgpu/api/GPUAdapter.cpp +37 -7
- package/cpp/rnwgpu/api/GPUBuffer.h +1 -1
- package/cpp/rnwgpu/api/GPUDevice.cpp +84 -6
- package/cpp/rnwgpu/api/GPUDevice.h +12 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.cpp +139 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +52 -2
- package/cpp/rnwgpu/api/GPUQueue.cpp +50 -45
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
- package/cpp/rnwgpu/api/GPUSharedFence.cpp +80 -0
- package/cpp/rnwgpu/api/GPUSharedFence.h +53 -0
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +135 -0
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +75 -0
- package/cpp/rnwgpu/api/ImageBitmap.h +62 -0
- package/cpp/rnwgpu/api/NativeBufferUtils.h +87 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +4 -1
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +10 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +43 -24
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +9 -9
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +2 -2
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +73 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +1 -1
- 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 +17 -6
- 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/SkRuntimeEffect.h +2 -2
- 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 +12 -5
- 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/NativeBuffer/NativeBufferFactory.d.ts +10 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/commonjs/skia/types/WebGPU.d.ts +153 -0
- package/lib/commonjs/skia/types/WebGPU.js +6 -0
- package/lib/commonjs/skia/types/WebGPU.js.map +1 -0
- package/lib/commonjs/skia/types/index.d.ts +1 -0
- package/lib/commonjs/skia/types/index.js +11 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js +19 -0
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +10 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/module/skia/types/WebGPU.d.ts +153 -0
- package/lib/module/skia/types/WebGPU.js +2 -0
- package/lib/module/skia/types/WebGPU.js.map +1 -0
- package/lib/module/skia/types/index.d.ts +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
- package/lib/module/skia/web/JsiSkNativeBufferFactory.js +19 -0
- package/lib/module/skia/web/JsiSkNativeBufferFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/web/LoadSkiaWeb.js +1 -2
- package/lib/module/web/LoadSkiaWeb.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
- package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +10 -1
- package/lib/typescript/src/skia/types/WebGPU.d.ts +153 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkNativeBufferFactory.d.ts +1 -0
- package/package.json +14 -12
- package/react-native-skia.podspec +59 -7
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +10 -1
- package/src/skia/types/WebGPU.ts +186 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkNativeBufferFactory.ts +20 -0
- package/src/skia/web/JsiSkPath.ts +8 -2
- package/scripts/install-libs.js +0 -133
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include <vector>
|
|
8
8
|
|
|
9
9
|
#include "Convertors.h"
|
|
10
|
+
#include "NativeBufferUtils.h"
|
|
10
11
|
#include "jsi2/JSIConverter.h"
|
|
11
12
|
|
|
12
13
|
#include "GPUFeatures.h"
|
|
@@ -234,8 +235,83 @@ std::shared_ptr<GPUPipelineLayout> GPUDevice::createPipelineLayout(
|
|
|
234
235
|
|
|
235
236
|
std::shared_ptr<GPUExternalTexture> GPUDevice::importExternalTexture(
|
|
236
237
|
std::shared_ptr<GPUExternalTextureDescriptor> descriptor) {
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
// The import / begin-access / descriptor-build logic, plus the matching
|
|
239
|
+
// EndAccess, all live on GPUExternalTexture so the begin/end lifecycle stays
|
|
240
|
+
// in one translation unit (see GPUExternalTexture.cpp).
|
|
241
|
+
return GPUExternalTexture::Create(_instance, std::move(descriptor));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
std::shared_ptr<GPUSharedTextureMemory> GPUDevice::importSharedTextureMemory(
|
|
245
|
+
std::shared_ptr<GPUSharedTextureMemoryDescriptor> descriptor) {
|
|
246
|
+
if (!descriptor || descriptor->handle == 0) {
|
|
247
|
+
throw std::runtime_error(
|
|
248
|
+
"GPUDevice::importSharedTextureMemory(): handle must be a non-null "
|
|
249
|
+
"native buffer pointer (from Skia.NativeBuffer.MakeFromImage)");
|
|
250
|
+
}
|
|
251
|
+
void *bufferPtr =
|
|
252
|
+
reinterpret_cast<void *>(static_cast<uintptr_t>(descriptor->handle));
|
|
253
|
+
std::string label = descriptor->label.value_or("");
|
|
254
|
+
|
|
255
|
+
auto memory = importNativeBufferAsSharedTextureMemory(
|
|
256
|
+
_instance, bufferPtr, label, /*outWidth=*/nullptr, /*outHeight=*/nullptr);
|
|
257
|
+
if (memory == nullptr) {
|
|
258
|
+
throw std::runtime_error(
|
|
259
|
+
"GPUDevice::importSharedTextureMemory(): ImportSharedTextureMemory "
|
|
260
|
+
"returned null - is the 'shared-texture-memory-iosurface' (Apple) or "
|
|
261
|
+
"'shared-texture-memory-ahardware-buffer' (Android) feature enabled on "
|
|
262
|
+
"the device?");
|
|
263
|
+
}
|
|
264
|
+
return std::make_shared<GPUSharedTextureMemory>(std::move(memory),
|
|
265
|
+
std::move(label));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
std::shared_ptr<GPUSharedFence> GPUDevice::importSharedFence(
|
|
269
|
+
std::shared_ptr<GPUSharedFenceDescriptor> descriptor) {
|
|
270
|
+
if (!descriptor || descriptor->handle == nullptr) {
|
|
271
|
+
throw std::runtime_error("GPUDevice::importSharedFence(): handle must be a "
|
|
272
|
+
"non-null native handle");
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
wgpu::SharedFenceDescriptor desc{};
|
|
276
|
+
std::string label = descriptor->label.value_or("");
|
|
277
|
+
if (!label.empty()) {
|
|
278
|
+
desc.label = wgpu::StringView(label.c_str(), label.size());
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// The chained platform descriptor must outlive the synchronous
|
|
282
|
+
// ImportSharedFence() below; declare them all and chain the matching one.
|
|
283
|
+
wgpu::SharedFenceMTLSharedEventDescriptor mtlDesc{};
|
|
284
|
+
wgpu::SharedFenceSyncFDDescriptor syncFdDesc{};
|
|
285
|
+
wgpu::SharedFenceVkSemaphoreOpaqueFDDescriptor vkFdDesc{};
|
|
286
|
+
|
|
287
|
+
const std::string &type = descriptor->type;
|
|
288
|
+
if (type == "mtl-shared-event") {
|
|
289
|
+
// handle is an id<MTLSharedEvent> pointer.
|
|
290
|
+
mtlDesc.sharedEvent = descriptor->handle;
|
|
291
|
+
desc.nextInChain = &mtlDesc;
|
|
292
|
+
} else if (type == "sync-fd") {
|
|
293
|
+
// handle is an OS file descriptor.
|
|
294
|
+
syncFdDesc.handle =
|
|
295
|
+
static_cast<int>(reinterpret_cast<uintptr_t>(descriptor->handle));
|
|
296
|
+
desc.nextInChain = &syncFdDesc;
|
|
297
|
+
} else if (type == "vk-semaphore-opaque-fd") {
|
|
298
|
+
vkFdDesc.handle =
|
|
299
|
+
static_cast<int>(reinterpret_cast<uintptr_t>(descriptor->handle));
|
|
300
|
+
desc.nextInChain = &vkFdDesc;
|
|
301
|
+
} else {
|
|
302
|
+
throw std::runtime_error(
|
|
303
|
+
"GPUDevice::importSharedFence(): unsupported fence type '" + type +
|
|
304
|
+
"' (expected 'mtl-shared-event', 'sync-fd' or "
|
|
305
|
+
"'vk-semaphore-opaque-fd')");
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
auto fence = _instance.ImportSharedFence(&desc);
|
|
309
|
+
if (fence == nullptr) {
|
|
310
|
+
throw std::runtime_error(
|
|
311
|
+
"GPUDevice::importSharedFence(): ImportSharedFence returned null - is "
|
|
312
|
+
"the matching 'shared-fence-*' feature enabled on the device?");
|
|
313
|
+
}
|
|
314
|
+
return std::make_shared<GPUSharedFence>(std::move(fence), std::move(label));
|
|
239
315
|
}
|
|
240
316
|
|
|
241
317
|
async::AsyncTaskHandle GPUDevice::createComputePipelineAsync(
|
|
@@ -262,7 +338,7 @@ async::AsyncTaskHandle GPUDevice::createComputePipelineAsync(
|
|
|
262
338
|
&desc, wgpu::CallbackMode::AllowProcessEvents,
|
|
263
339
|
[pipelineHolder, resolve,
|
|
264
340
|
reject](wgpu::CreatePipelineAsyncStatus status,
|
|
265
|
-
wgpu::ComputePipeline pipeline,
|
|
341
|
+
wgpu::ComputePipeline pipeline, wgpu::StringView msg) {
|
|
266
342
|
if (status == wgpu::CreatePipelineAsyncStatus::Success && pipeline) {
|
|
267
343
|
pipelineHolder->_instance = pipeline;
|
|
268
344
|
resolve([pipelineHolder](jsi::Runtime &runtime) mutable {
|
|
@@ -271,7 +347,8 @@ async::AsyncTaskHandle GPUDevice::createComputePipelineAsync(
|
|
|
271
347
|
});
|
|
272
348
|
} else {
|
|
273
349
|
std::string error =
|
|
274
|
-
msg ? std::string(msg)
|
|
350
|
+
msg.length ? std::string(msg.data, msg.length)
|
|
351
|
+
: "Failed to create compute pipeline";
|
|
275
352
|
reject(std::move(error));
|
|
276
353
|
}
|
|
277
354
|
});
|
|
@@ -303,7 +380,7 @@ async::AsyncTaskHandle GPUDevice::createRenderPipelineAsync(
|
|
|
303
380
|
&desc, wgpu::CallbackMode::AllowProcessEvents,
|
|
304
381
|
[pipelineHolder, resolve,
|
|
305
382
|
reject](wgpu::CreatePipelineAsyncStatus status,
|
|
306
|
-
wgpu::RenderPipeline pipeline,
|
|
383
|
+
wgpu::RenderPipeline pipeline, wgpu::StringView msg) {
|
|
307
384
|
if (status == wgpu::CreatePipelineAsyncStatus::Success && pipeline) {
|
|
308
385
|
pipelineHolder->_instance = pipeline;
|
|
309
386
|
resolve([pipelineHolder](jsi::Runtime &runtime) mutable {
|
|
@@ -312,7 +389,8 @@ async::AsyncTaskHandle GPUDevice::createRenderPipelineAsync(
|
|
|
312
389
|
});
|
|
313
390
|
} else {
|
|
314
391
|
std::string error =
|
|
315
|
-
msg ? std::string(msg)
|
|
392
|
+
msg.length ? std::string(msg.data, msg.length)
|
|
393
|
+
: "Failed to create render pipeline";
|
|
316
394
|
reject(std::move(error));
|
|
317
395
|
}
|
|
318
396
|
});
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
#include "GPURenderPipeline.h"
|
|
38
38
|
#include "GPUSampler.h"
|
|
39
39
|
#include "GPUShaderModule.h"
|
|
40
|
+
#include "GPUSharedFence.h"
|
|
41
|
+
#include "GPUSharedTextureMemory.h"
|
|
40
42
|
#include "GPUSupportedLimits.h"
|
|
41
43
|
#include "GPUTexture.h"
|
|
42
44
|
#include "descriptors/GPUBindGroupDescriptor.h"
|
|
@@ -51,6 +53,8 @@
|
|
|
51
53
|
#include "descriptors/GPURenderPipelineDescriptor.h"
|
|
52
54
|
#include "descriptors/GPUSamplerDescriptor.h"
|
|
53
55
|
#include "descriptors/GPUShaderModuleDescriptor.h"
|
|
56
|
+
#include "descriptors/GPUSharedFenceDescriptor.h"
|
|
57
|
+
#include "descriptors/GPUSharedTextureMemoryDescriptor.h"
|
|
54
58
|
#include "descriptors/GPUTextureDescriptor.h"
|
|
55
59
|
|
|
56
60
|
namespace rnwgpu {
|
|
@@ -120,6 +124,10 @@ public:
|
|
|
120
124
|
std::optional<std::shared_ptr<GPUSamplerDescriptor>> descriptor);
|
|
121
125
|
std::shared_ptr<GPUExternalTexture> importExternalTexture(
|
|
122
126
|
std::shared_ptr<GPUExternalTextureDescriptor> descriptor);
|
|
127
|
+
std::shared_ptr<GPUSharedTextureMemory> importSharedTextureMemory(
|
|
128
|
+
std::shared_ptr<GPUSharedTextureMemoryDescriptor> descriptor);
|
|
129
|
+
std::shared_ptr<GPUSharedFence>
|
|
130
|
+
importSharedFence(std::shared_ptr<GPUSharedFenceDescriptor> descriptor);
|
|
123
131
|
std::shared_ptr<GPUBindGroupLayout> createBindGroupLayout(
|
|
124
132
|
std::shared_ptr<GPUBindGroupLayoutDescriptor> descriptor);
|
|
125
133
|
std::shared_ptr<GPUPipelineLayout>
|
|
@@ -173,6 +181,10 @@ public:
|
|
|
173
181
|
&GPUDevice::createSampler);
|
|
174
182
|
installMethod(runtime, prototype, "importExternalTexture",
|
|
175
183
|
&GPUDevice::importExternalTexture);
|
|
184
|
+
installMethod(runtime, prototype, "importSharedTextureMemory",
|
|
185
|
+
&GPUDevice::importSharedTextureMemory);
|
|
186
|
+
installMethod(runtime, prototype, "importSharedFence",
|
|
187
|
+
&GPUDevice::importSharedFence);
|
|
176
188
|
installMethod(runtime, prototype, "createBindGroupLayout",
|
|
177
189
|
&GPUDevice::createBindGroupLayout);
|
|
178
190
|
installMethod(runtime, prototype, "createPipelineLayout",
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#include "GPUExternalTexture.h"
|
|
2
|
+
|
|
3
|
+
#include <cmath>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <utility>
|
|
7
|
+
|
|
8
|
+
#include "NativeBufferUtils.h"
|
|
9
|
+
#include "descriptors/GPUExternalTextureDescriptor.h"
|
|
10
|
+
|
|
11
|
+
namespace rnwgpu {
|
|
12
|
+
|
|
13
|
+
// Identity gamut (same primaries) as a 3x3 column-major matrix.
|
|
14
|
+
static const float kIdentityGamutMatrix[9] = {
|
|
15
|
+
1.0f, 0.0f, 0.0f, //
|
|
16
|
+
0.0f, 1.0f, 0.0f, //
|
|
17
|
+
0.0f, 0.0f, 1.0f, //
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Identity transfer (y = x). The native buffers produced by Skia's NativeBuffer
|
|
21
|
+
// API are single-plane BGRA/RGBA already in the render target's color space, so
|
|
22
|
+
// no conversion is wanted. Dawn dereferences the transfer-function arrays
|
|
23
|
+
// unconditionally (ComputeExternalTextureParams), so these must be non-null.
|
|
24
|
+
static const float kIdentityTransferParams[7] = {
|
|
25
|
+
1.0f, // G
|
|
26
|
+
1.0f, // A
|
|
27
|
+
0.0f, // B
|
|
28
|
+
0.0f, // C
|
|
29
|
+
0.0f, // D
|
|
30
|
+
0.0f, // E
|
|
31
|
+
0.0f, // F
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Map a rotation in degrees (0 / 90 / 180 / 270) to Dawn's enum. Anything that
|
|
35
|
+
// isn't a clean multiple of 90 snaps to the nearest quadrant; Dawn only
|
|
36
|
+
// supports those four steps for external textures.
|
|
37
|
+
static wgpu::ExternalTextureRotation toExternalTextureRotation(double degrees) {
|
|
38
|
+
int quadrant = static_cast<int>(std::lround(degrees / 90.0));
|
|
39
|
+
quadrant = ((quadrant % 4) + 4) % 4;
|
|
40
|
+
switch (quadrant) {
|
|
41
|
+
case 1:
|
|
42
|
+
return wgpu::ExternalTextureRotation::Rotate90Degrees;
|
|
43
|
+
case 2:
|
|
44
|
+
return wgpu::ExternalTextureRotation::Rotate180Degrees;
|
|
45
|
+
case 3:
|
|
46
|
+
return wgpu::ExternalTextureRotation::Rotate270Degrees;
|
|
47
|
+
default:
|
|
48
|
+
return wgpu::ExternalTextureRotation::Rotate0Degrees;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
std::shared_ptr<GPUExternalTexture> GPUExternalTexture::Create(
|
|
53
|
+
wgpu::Device device,
|
|
54
|
+
std::shared_ptr<GPUExternalTextureDescriptor> descriptor) {
|
|
55
|
+
if (!descriptor || descriptor->source == 0) {
|
|
56
|
+
throw std::runtime_error(
|
|
57
|
+
"GPUExternalTexture::Create(): descriptor.source (a native buffer "
|
|
58
|
+
"pointer from Skia.NativeBuffer.MakeFromImage) is required");
|
|
59
|
+
}
|
|
60
|
+
void *bufferPtr =
|
|
61
|
+
reinterpret_cast<void *>(static_cast<uintptr_t>(descriptor->source));
|
|
62
|
+
std::string label = descriptor->label.value_or("external-texture");
|
|
63
|
+
|
|
64
|
+
// 1. Import the native buffer as SharedTextureMemory and read its dimensions.
|
|
65
|
+
uint32_t width = 0;
|
|
66
|
+
uint32_t height = 0;
|
|
67
|
+
wgpu::SharedTextureMemory memory = importNativeBufferAsSharedTextureMemory(
|
|
68
|
+
device, bufferPtr, label, &width, &height);
|
|
69
|
+
if (memory == nullptr) {
|
|
70
|
+
throw std::runtime_error(
|
|
71
|
+
"GPUExternalTexture::Create(): ImportSharedTextureMemory returned "
|
|
72
|
+
"null");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 2. Create the texture from the surface (Dawn picks the single-plane
|
|
76
|
+
// BGRA/RGBA format).
|
|
77
|
+
auto texture = memory.CreateTexture();
|
|
78
|
+
if (texture == nullptr) {
|
|
79
|
+
throw std::runtime_error(
|
|
80
|
+
"GPUExternalTexture::Create(): CreateTexture returned null");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 3. Begin access. The matching EndAccess runs when the GPUExternalTexture is
|
|
84
|
+
// destroyed (explicitly via destroy() or at GC).
|
|
85
|
+
wgpu::SharedTextureMemoryBeginAccessDescriptor begin{};
|
|
86
|
+
begin.initialized = true;
|
|
87
|
+
begin.concurrentRead = false;
|
|
88
|
+
#if defined(__ANDROID__)
|
|
89
|
+
// Dawn's Vulkan backend requires the acquired VkImageLayout to be chained.
|
|
90
|
+
// UNDEFINED (= 0) on both ends is the canonical "no prior GPU producer"
|
|
91
|
+
// pattern (matches GPUSharedTextureMemory::beginAccess).
|
|
92
|
+
wgpu::SharedTextureMemoryVkImageLayoutBeginState vkBegin{};
|
|
93
|
+
vkBegin.oldLayout = 0;
|
|
94
|
+
vkBegin.newLayout = 0;
|
|
95
|
+
begin.nextInChain = &vkBegin;
|
|
96
|
+
#endif
|
|
97
|
+
if (!memory.BeginAccess(texture, &begin)) {
|
|
98
|
+
throw std::runtime_error(
|
|
99
|
+
"GPUExternalTexture::Create(): BeginAccess failed");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 4. Single-plane view (the whole BGRA/RGBA surface).
|
|
103
|
+
auto plane0 = texture.CreateView();
|
|
104
|
+
|
|
105
|
+
// 5. Build the ExternalTextureDescriptor. The surface is already RGB in the
|
|
106
|
+
// target color space, so pass it through with identity transfer/gamut.
|
|
107
|
+
wgpu::ExternalTextureDescriptor extDesc{};
|
|
108
|
+
if (!label.empty()) {
|
|
109
|
+
extDesc.label = wgpu::StringView(label.c_str(), label.size());
|
|
110
|
+
}
|
|
111
|
+
extDesc.plane0 = plane0;
|
|
112
|
+
extDesc.gamutConversionMatrix = kIdentityGamutMatrix;
|
|
113
|
+
extDesc.srcTransferFunctionParameters = kIdentityTransferParams;
|
|
114
|
+
extDesc.dstTransferFunctionParameters = kIdentityTransferParams;
|
|
115
|
+
extDesc.cropOrigin = {0, 0};
|
|
116
|
+
extDesc.cropSize = {width, height};
|
|
117
|
+
extDesc.apparentSize = {width, height};
|
|
118
|
+
extDesc.mirrored = descriptor->mirrored.value_or(false);
|
|
119
|
+
extDesc.rotation =
|
|
120
|
+
toExternalTextureRotation(descriptor->rotation.value_or(0));
|
|
121
|
+
|
|
122
|
+
auto external = device.CreateExternalTexture(&extDesc);
|
|
123
|
+
if (external == nullptr) {
|
|
124
|
+
wgpu::SharedTextureMemoryEndAccessState state{};
|
|
125
|
+
#if defined(__ANDROID__)
|
|
126
|
+
wgpu::SharedTextureMemoryVkImageLayoutEndState vkEnd{};
|
|
127
|
+
state.nextInChain = &vkEnd;
|
|
128
|
+
#endif
|
|
129
|
+
(void)memory.EndAccess(texture, &state);
|
|
130
|
+
throw std::runtime_error(
|
|
131
|
+
"GPUExternalTexture::Create(): CreateExternalTexture returned null");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return std::make_shared<GPUExternalTexture>(
|
|
135
|
+
std::move(external), std::move(memory), std::move(texture),
|
|
136
|
+
std::move(label));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
} // namespace rnwgpu
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <memory>
|
|
3
4
|
#include <string>
|
|
5
|
+
#include <utility>
|
|
4
6
|
|
|
5
7
|
#include "descriptors/Unions.h"
|
|
6
8
|
|
|
@@ -12,16 +14,61 @@ namespace rnwgpu {
|
|
|
12
14
|
|
|
13
15
|
namespace jsi = facebook::jsi;
|
|
14
16
|
|
|
17
|
+
struct GPUExternalTextureDescriptor;
|
|
18
|
+
|
|
15
19
|
class GPUExternalTexture : public NativeObject<GPUExternalTexture> {
|
|
16
20
|
public:
|
|
17
21
|
static constexpr const char *CLASS_NAME = "GPUExternalTexture";
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
// Import a native buffer (via descriptor.source, a CVPixelBufferRef /
|
|
24
|
+
// AHardwareBuffer* from Skia's NativeBuffer API) as a GPUExternalTexture on
|
|
25
|
+
// `device`: imports the native surface as SharedTextureMemory, begins access,
|
|
26
|
+
// and wraps the resulting wgpu::ExternalTexture together with the resources
|
|
27
|
+
// whose lifetime it owns. The matching EndAccess runs in destroy() / the
|
|
28
|
+
// destructor. Defined in GPUExternalTexture.cpp.
|
|
29
|
+
static std::shared_ptr<GPUExternalTexture>
|
|
30
|
+
Create(wgpu::Device device,
|
|
31
|
+
std::shared_ptr<GPUExternalTextureDescriptor> descriptor);
|
|
32
|
+
|
|
33
|
+
// Construct from an already-built wgpu::ExternalTexture plus the underlying
|
|
34
|
+
// shared-memory resources we need to keep alive. The wrapper takes ownership
|
|
35
|
+
// of the SharedTextureMemory + Texture and calls EndAccess on destruction so
|
|
36
|
+
// the producer (the native buffer's surface) can reclaim it.
|
|
37
|
+
GPUExternalTexture(wgpu::ExternalTexture instance,
|
|
38
|
+
wgpu::SharedTextureMemory memory, wgpu::Texture texture,
|
|
39
|
+
std::string label)
|
|
40
|
+
: NativeObject(CLASS_NAME), _instance(std::move(instance)),
|
|
41
|
+
_memory(std::move(memory)), _texture(std::move(texture)),
|
|
42
|
+
_label(std::move(label)) {}
|
|
43
|
+
|
|
44
|
+
~GPUExternalTexture() override { destroy(); }
|
|
21
45
|
|
|
22
46
|
public:
|
|
23
47
|
std::string getBrand() { return CLASS_NAME; }
|
|
24
48
|
|
|
49
|
+
// End the shared-memory access window and release the underlying resources.
|
|
50
|
+
// Idempotent: safe to call more than once, and the destructor calls it as a
|
|
51
|
+
// garbage-collection fallback. Call it right after the queue.submit() that
|
|
52
|
+
// sampled this texture (never before): a GPUExternalTexture's access window
|
|
53
|
+
// is owned by this wrapper's lifetime, not by submit, so without an explicit
|
|
54
|
+
// destroy() the producer's surface stays claimed until GC runs. EndAccess is
|
|
55
|
+
// the designed post-submit call: Dawn keeps the texture alive for in-flight
|
|
56
|
+
// GPU work via the fences it returns.
|
|
57
|
+
void destroy() {
|
|
58
|
+
if (_memory && _texture) {
|
|
59
|
+
wgpu::SharedTextureMemoryEndAccessState state{};
|
|
60
|
+
#if defined(__ANDROID__)
|
|
61
|
+
// Dawn's Vulkan backend requires the released VkImageLayout to be chained
|
|
62
|
+
// (matches BeginAccess in GPUExternalTexture::Create).
|
|
63
|
+
wgpu::SharedTextureMemoryVkImageLayoutEndState vkEnd{};
|
|
64
|
+
state.nextInChain = &vkEnd;
|
|
65
|
+
#endif
|
|
66
|
+
(void)_memory.EndAccess(_texture, &state);
|
|
67
|
+
}
|
|
68
|
+
_texture = nullptr;
|
|
69
|
+
_memory = nullptr;
|
|
70
|
+
}
|
|
71
|
+
|
|
25
72
|
std::string getLabel() { return _label; }
|
|
26
73
|
void setLabel(const std::string &label) {
|
|
27
74
|
_label = label;
|
|
@@ -33,12 +80,15 @@ public:
|
|
|
33
80
|
installGetterSetter(runtime, prototype, "label",
|
|
34
81
|
&GPUExternalTexture::getLabel,
|
|
35
82
|
&GPUExternalTexture::setLabel);
|
|
83
|
+
installMethod(runtime, prototype, "destroy", &GPUExternalTexture::destroy);
|
|
36
84
|
}
|
|
37
85
|
|
|
38
86
|
inline const wgpu::ExternalTexture get() { return _instance; }
|
|
39
87
|
|
|
40
88
|
private:
|
|
41
89
|
wgpu::ExternalTexture _instance;
|
|
90
|
+
wgpu::SharedTextureMemory _memory;
|
|
91
|
+
wgpu::Texture _texture;
|
|
42
92
|
std::string _label;
|
|
43
93
|
};
|
|
44
94
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "GPUQueue.h"
|
|
2
2
|
|
|
3
|
+
#include <cstring>
|
|
3
4
|
#include <limits>
|
|
4
5
|
#include <memory>
|
|
5
6
|
#include <vector>
|
|
@@ -103,51 +104,55 @@ void GPUQueue::copyExternalImageToTexture(
|
|
|
103
104
|
std::shared_ptr<GPUImageCopyExternalImage> source,
|
|
104
105
|
std::shared_ptr<GPUImageCopyTextureTagged> destination,
|
|
105
106
|
std::shared_ptr<GPUExtent3D> size) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
107
|
+
if (!source || source->source == nullptr) {
|
|
108
|
+
throw std::runtime_error("GPUQueue::copyExternalImageToTexture(): "
|
|
109
|
+
"source.source (ImageBitmap) is required");
|
|
110
|
+
}
|
|
111
|
+
// ImageBitmap holds decoded, row-major RGBA8 pixels. We upload them with
|
|
112
|
+
// WriteTexture (a CPU staging copy) rather than a GPU blit; that is enough
|
|
113
|
+
// for the common "decode an image, sample it" path and avoids needing a
|
|
114
|
+
// source GPUTexture.
|
|
115
|
+
const auto &pixels = source->source->data();
|
|
116
|
+
auto width = static_cast<uint32_t>(source->source->getWidth());
|
|
117
|
+
auto height = static_cast<uint32_t>(source->source->getHeight());
|
|
118
|
+
if (pixels.empty() || width == 0 || height == 0) {
|
|
119
|
+
throw std::runtime_error("GPUQueue::copyExternalImageToTexture(): "
|
|
120
|
+
"ImageBitmap has no pixels (was it closed?)");
|
|
121
|
+
}
|
|
122
|
+
auto bytesPerPixel = static_cast<uint32_t>(
|
|
123
|
+
pixels.size() / (static_cast<size_t>(width) * height));
|
|
124
|
+
uint32_t rowSize = bytesPerPixel * width;
|
|
125
|
+
|
|
126
|
+
wgpu::TexelCopyTextureInfo dst{};
|
|
127
|
+
wgpu::TexelCopyBufferLayout layout{};
|
|
128
|
+
wgpu::Extent3D sz{};
|
|
129
|
+
Convertor conv;
|
|
130
|
+
auto dataLayout = std::make_shared<GPUImageDataLayout>(
|
|
131
|
+
GPUImageDataLayout{std::optional<double>{0.0},
|
|
132
|
+
std::optional<double>{static_cast<double>(rowSize)},
|
|
133
|
+
std::optional<double>{static_cast<double>(height)}});
|
|
134
|
+
if (!conv(dst.aspect, destination->aspect) ||
|
|
135
|
+
!conv(dst.mipLevel, destination->mipLevel) ||
|
|
136
|
+
!conv(dst.origin, destination->origin) ||
|
|
137
|
+
!conv(dst.texture, destination->texture) || !conv(layout, dataLayout) ||
|
|
138
|
+
!conv(sz, size)) {
|
|
139
|
+
throw std::runtime_error(
|
|
140
|
+
"Invalid input for GPUQueue::copyExternalImageToTexture()");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (source->flipY.value_or(false)) {
|
|
144
|
+
// Flip rows so the image is uploaded bottom-up (matches the WebGPU
|
|
145
|
+
// copyExternalImageToTexture flipY semantics).
|
|
146
|
+
std::vector<uint8_t> flippedData(pixels.size());
|
|
147
|
+
for (uint32_t row = 0; row < height; ++row) {
|
|
148
|
+
std::memcpy(flippedData.data() + (height - 1 - row) * rowSize,
|
|
149
|
+
pixels.data() + row * rowSize, rowSize);
|
|
150
|
+
}
|
|
151
|
+
_instance.WriteTexture(&dst, flippedData.data(), flippedData.size(),
|
|
152
|
+
&layout, &sz);
|
|
153
|
+
} else {
|
|
154
|
+
_instance.WriteTexture(&dst, pixels.data(), pixels.size(), &layout, &sz);
|
|
155
|
+
}
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
void GPUQueue::writeTexture(std::shared_ptr<GPUImageCopyTexture> destination,
|
|
@@ -18,7 +18,7 @@ async::AsyncTaskHandle GPUShaderModule::getCompilationInfo() {
|
|
|
18
18
|
wgpu::CallbackMode::AllowProcessEvents,
|
|
19
19
|
[result, resolve,
|
|
20
20
|
reject](wgpu::CompilationInfoRequestStatus status,
|
|
21
|
-
const wgpu::CompilationInfo *compilationInfo)
|
|
21
|
+
const wgpu::CompilationInfo *compilationInfo) {
|
|
22
22
|
if (status != wgpu::CompilationInfoRequestStatus::Success ||
|
|
23
23
|
compilationInfo == nullptr) {
|
|
24
24
|
reject("Failed to get compilation info");
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#include "GPUSharedFence.h"
|
|
2
|
+
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#if defined(__ANDROID__)
|
|
7
|
+
#include <fcntl.h>
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
namespace rnwgpu {
|
|
11
|
+
|
|
12
|
+
namespace {
|
|
13
|
+
|
|
14
|
+
// Kebab-case names matching the shared-fence-* feature strings (see Unions.h /
|
|
15
|
+
// GPUFeatures.h).
|
|
16
|
+
std::string sharedFenceTypeToString(wgpu::SharedFenceType type) {
|
|
17
|
+
switch (type) {
|
|
18
|
+
case wgpu::SharedFenceType::MTLSharedEvent:
|
|
19
|
+
return "mtl-shared-event";
|
|
20
|
+
case wgpu::SharedFenceType::SyncFD:
|
|
21
|
+
return "sync-fd";
|
|
22
|
+
case wgpu::SharedFenceType::VkSemaphoreOpaqueFD:
|
|
23
|
+
return "vk-semaphore-opaque-fd";
|
|
24
|
+
case wgpu::SharedFenceType::VkSemaphoreZirconHandle:
|
|
25
|
+
return "vk-semaphore-zircon-handle";
|
|
26
|
+
case wgpu::SharedFenceType::DXGISharedHandle:
|
|
27
|
+
return "dxgi-shared-handle";
|
|
28
|
+
case wgpu::SharedFenceType::EGLSync:
|
|
29
|
+
return "egl-sync";
|
|
30
|
+
default:
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
} // namespace
|
|
36
|
+
|
|
37
|
+
jsi::Value GPUSharedFence::exportInfo(jsi::Runtime &runtime, const jsi::Value &,
|
|
38
|
+
const jsi::Value *, size_t) {
|
|
39
|
+
wgpu::SharedFenceExportInfo info{};
|
|
40
|
+
uint64_t handle = 0;
|
|
41
|
+
|
|
42
|
+
#if defined(__APPLE__)
|
|
43
|
+
// Apple: the handle is an id<MTLSharedEvent> pointer.
|
|
44
|
+
wgpu::SharedFenceMTLSharedEventExportInfo mtlInfo{};
|
|
45
|
+
info.nextInChain = &mtlInfo;
|
|
46
|
+
_instance.ExportInfo(&info);
|
|
47
|
+
handle = reinterpret_cast<uint64_t>(mtlInfo.sharedEvent);
|
|
48
|
+
#elif defined(__ANDROID__)
|
|
49
|
+
// Android: the handle is an OS file descriptor (sync_fd). Dawn's ExportInfo
|
|
50
|
+
// returns a BORROWED fd: it is owned by the SharedFence and closed when the
|
|
51
|
+
// fence is destroyed. This exported handle is documented as caller-owned (the
|
|
52
|
+
// caller must close() it), so dup() it. Without the dup the same fd is closed
|
|
53
|
+
// twice (once by the caller and once by Dawn on fence destruction), tripping
|
|
54
|
+
// Android's fdsan (double-close abort).
|
|
55
|
+
wgpu::SharedFenceSyncFDExportInfo fdInfo{};
|
|
56
|
+
info.nextInChain = &fdInfo;
|
|
57
|
+
_instance.ExportInfo(&info);
|
|
58
|
+
int exportedFd = fdInfo.handle >= 0
|
|
59
|
+
? ::fcntl(fdInfo.handle, F_DUPFD_CLOEXEC, 0)
|
|
60
|
+
: fdInfo.handle;
|
|
61
|
+
handle = static_cast<uint64_t>(static_cast<uint32_t>(exportedFd));
|
|
62
|
+
#else
|
|
63
|
+
// react-native-skia only targets Apple (Metal) and Android (Vulkan). On any
|
|
64
|
+
// other platform there is no native handle convention to expose, so fail
|
|
65
|
+
// loudly rather than handing back a meaningless handle of 0.
|
|
66
|
+
throw jsi::JSError(runtime,
|
|
67
|
+
"GPUSharedFence::export(): unsupported platform (only "
|
|
68
|
+
"Apple/Metal and Android/Vulkan are supported)");
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
jsi::Object result(runtime);
|
|
72
|
+
result.setProperty(
|
|
73
|
+
runtime, "type",
|
|
74
|
+
jsi::String::createFromUtf8(runtime, sharedFenceTypeToString(info.type)));
|
|
75
|
+
result.setProperty(runtime, "handle",
|
|
76
|
+
jsi::BigInt::fromUint64(runtime, handle));
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "jsi2/NativeObject.h"
|
|
7
|
+
|
|
8
|
+
#include "webgpu/webgpu_cpp.h"
|
|
9
|
+
|
|
10
|
+
namespace rnwgpu {
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
// Wraps a wgpu::SharedFence: a native GPU sync primitive (id<MTLSharedEvent> on
|
|
15
|
+
// Apple, sync-fd / VkSemaphore on Android).
|
|
16
|
+
class GPUSharedFence : public NativeObject<GPUSharedFence> {
|
|
17
|
+
public:
|
|
18
|
+
static constexpr const char *CLASS_NAME = "GPUSharedFence";
|
|
19
|
+
|
|
20
|
+
explicit GPUSharedFence(wgpu::SharedFence instance, std::string label)
|
|
21
|
+
: NativeObject(CLASS_NAME), _instance(std::move(instance)),
|
|
22
|
+
_label(std::move(label)) {}
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
26
|
+
|
|
27
|
+
// export() -> { type, handle }: exposes the native handle (as a BigInt) so
|
|
28
|
+
// app code can wait on or signal the fence. The caller owns the returned
|
|
29
|
+
// handle (e.g. an exported sync-fd must be close()d).
|
|
30
|
+
jsi::Value exportInfo(jsi::Runtime &runtime, const jsi::Value &thisVal,
|
|
31
|
+
const jsi::Value *args, size_t count);
|
|
32
|
+
|
|
33
|
+
std::string getLabel() { return _label; }
|
|
34
|
+
void setLabel(const std::string &label) {
|
|
35
|
+
_label = label;
|
|
36
|
+
_instance.SetLabel(_label.c_str());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
40
|
+
installGetter(runtime, prototype, "__brand", &GPUSharedFence::getBrand);
|
|
41
|
+
installMethod(runtime, prototype, "export", &GPUSharedFence::exportInfo);
|
|
42
|
+
installGetterSetter(runtime, prototype, "label", &GPUSharedFence::getLabel,
|
|
43
|
+
&GPUSharedFence::setLabel);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
inline wgpu::SharedFence get() { return _instance; }
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
wgpu::SharedFence _instance;
|
|
50
|
+
std::string _label;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace rnwgpu
|