@shopify/react-native-skia 2.4.15 → 2.4.17
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 +69 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +19 -7
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +7 -0
- package/apple/RNSkApplePlatformContext.mm +4 -0
- package/cpp/api/JsiSkApi.h +31 -0
- package/cpp/api/JsiSkImageFactory.h +69 -1
- package/cpp/api/JsiSkImageFilter.h +1 -0
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/jsi/RuntimeAwareCache.h +0 -2
- package/cpp/jsi2/EnumMapper.h +45 -0
- package/cpp/jsi2/JSIConverter.h +468 -0
- package/cpp/jsi2/NativeObject.h +598 -0
- package/cpp/jsi2/Promise.cpp +44 -0
- package/cpp/jsi2/Promise.h +35 -0
- package/cpp/rnskia/RNDawnContext.h +114 -0
- package/cpp/rnskia/RNSkManager.cpp +41 -1
- package/cpp/rnwgpu/ArrayBuffer.h +68 -0
- package/cpp/rnwgpu/api/Convertors.h +761 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +129 -0
- package/cpp/rnwgpu/api/GPU.h +57 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +178 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +434 -0
- package/cpp/rnwgpu/api/GPUDevice.h +174 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
- package/cpp/rnwgpu/api/GPUError.h +35 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
- package/cpp/rnwgpu/api/GPUFeatures.h +212 -0
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
- package/cpp/rnwgpu/api/GPUQueue.h +84 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
- package/cpp/rnwgpu/api/GPUSampler.h +44 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +150 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +97 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +52 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +99 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +38 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +43 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +101 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +110 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +53 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1984 -0
- package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
- package/cpp/rnwgpu/async/AsyncRunner.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncRunner.h +56 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
- package/lib/commonjs/Platform/Platform.web.js +1 -2
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -4
- package/lib/commonjs/renderer/Canvas.js +4 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +1 -2
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/FitBox.js +1 -2
- package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/commonjs/skia/types/ContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +17 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +6 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +4 -4
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/web/WithSkiaWeb.js +1 -2
- package/lib/commonjs/web/WithSkiaWeb.js.map +1 -1
- package/lib/module/external/reanimated/buffers.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +1 -4
- package/lib/module/renderer/Canvas.js +3 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/ContourMeasure.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +17 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/module/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +6 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js +4 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +3 -2
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -4
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +17 -0
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/package.json +20 -16
- package/react-native-skia.podspec +52 -13
- package/scripts/install-skia.mjs +99 -48
- package/src/external/reanimated/buffers.ts +1 -1
- package/src/renderer/Canvas.tsx +3 -2
- package/src/skia/types/ContourMeasure.tsx +1 -2
- package/src/skia/types/Image/ImageFactory.ts +22 -0
- package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -2
- package/src/skia/types/Skia.ts +17 -0
- package/src/skia/web/JsiSkImageFactory.ts +8 -0
- package/src/skia/web/JsiSkia.ts +6 -0
- package/src/sksg/Recorder/commands/ColorFilters.ts +3 -2
- package/src/sksg/Recorder/commands/ImageFilters.ts +3 -2
- package/src/sksg/Recorder/commands/PathEffects.ts +3 -2
- package/src/sksg/Recorder/commands/Shaders.ts +3 -2
- package/src/specs/SkiaPictureViewNativeComponent.ts +7 -0
- package/src/views/SkiaPictureView.web.tsx +4 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ViewProps } from "react-native";
|
|
2
|
+
import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
|
|
2
3
|
export interface NativeProps extends ViewProps {
|
|
3
4
|
debug?: boolean;
|
|
4
5
|
opaque?: boolean;
|
|
5
6
|
colorSpace?: string;
|
|
6
7
|
androidWarmup?: boolean;
|
|
8
|
+
pointerEvents?: WithDefault<"auto" | "none" | "box-none" | "box-only", "auto">;
|
|
7
9
|
}
|
|
8
10
|
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
9
11
|
export default _default;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore - pointerEvents needs to be redeclared for codegen to generate native bindings
|
|
5
|
+
|
|
2
6
|
// eslint-disable-next-line import/no-default-export
|
|
3
7
|
export default codegenNativeComponent("SkiaPictureView");
|
|
4
8
|
//# sourceMappingURL=SkiaPictureViewNativeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n colorSpace?: string;\n androidWarmup?: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaPictureView\");\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { ViewProps } from \"react-native\";\nimport type { WithDefault } from \"react-native/Libraries/Types/CodegenTypes\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore - pointerEvents needs to be redeclared for codegen to generate native bindings\nexport interface NativeProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n colorSpace?: string;\n androidWarmup?: boolean;\n pointerEvents?: WithDefault<\n \"auto\" | \"none\" | \"box-none\" | \"box-only\",\n \"auto\"\n >;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaPictureView\");\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;;AAI5F;AACA;;AAYA;AACA,eAAeA,sBAAsB,CAAc,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","useEffect","useCallback","useImperativeHandle","JsiSkSurface","Platform","SkiaViewNativeId","dp2Pixel","pd","rect","undefined","x","y","width","height","WebGLRenderer","constructor","canvas","_defineProperty","onResize","makeImageSnapshot","picture","surface","getCanvas","clear","CanvasKit","TRANSPARENT","draw","ref","flush","clientWidth","clientHeight","MakeWebGLCanvasSurface","ctx","getContext","drawingBufferColorSpace","Error","Float32Array","of","save","scale","drawPicture","restore","dispose","_this$canvas","getExtension","loseContext","delete","StaticWebGLRenderer","cachedImage","renderPictureToSurface","tempCanvas","OffscreenCanvas","webglSurface","skiaCanvas","error","cleanupWebGLContext","renderResult","ctx2d","drawImage","console","_this$cachedImage","PixelRatio","SkiaPictureView","props","canvasRef","renderer","redrawRequestsRef","requestIdRef","pictureRef","onLayout","redraw","current","getSize","_canvasRef$current","_canvasRef$current2","setPicture","newPicture","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","pageX","window","scrollX","pageY","scrollY","measureInWindow","tick","requestAnimationFrame","onLayoutEvent","evt","__destroyWebGLContextAfterRender","_props$nativeID","nativeID","global","SkiaViewApi","registerView","cancelAnimationFrame","debug","_ref","viewProps","createElement","View","_extends","style","display","flex"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useImperativeHandle,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\ninterface Renderer {\n onResize(): void;\n draw(picture: SkPicture): void;\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\nclass WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n private pd: number\n ) {\n this.onResize();\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.surface) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(picture);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas, pd } = this;\n canvas.width = canvas.clientWidth * pd;\n canvas.height = canvas.clientHeight * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n const ctx = canvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(picture: SkPicture) {\n if (this.surface) {\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n canvas.drawPicture(picture);\n canvas.restore();\n this.surface.ref.flush();\n }\n }\n\n dispose(): void {\n if (this.surface) {\n this.canvas\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n this.surface.ref.delete();\n this.surface = null;\n }\n }\n}\n\nclass StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n private pd: number\n ) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderPictureToSurface(\n picture: SkPicture\n ): { surface: JsiSkSurface; tempCanvas: OffscreenCanvas } | null {\n const tempCanvas = new OffscreenCanvas(\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n let surface: JsiSkSurface | null = null;\n\n try {\n const webglSurface = CanvasKit.MakeWebGLCanvasSurface(tempCanvas);\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n\n if (!webglSurface) {\n throw new Error(\"Could not create WebGL surface\");\n }\n\n surface = new JsiSkSurface(CanvasKit, webglSurface);\n\n const skiaCanvas = surface.getCanvas();\n skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));\n skiaCanvas.save();\n skiaCanvas.scale(this.pd, this.pd);\n skiaCanvas.drawPicture(picture);\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas };\n } catch (error) {\n if (surface) {\n surface.ref.delete();\n }\n this.cleanupWebGLContext(tempCanvas);\n return null;\n }\n }\n\n private cleanupWebGLContext(tempCanvas: OffscreenCanvas): void {\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n const loseContext = ctx.getExtension(\"WEBGL_lose_context\");\n if (loseContext) {\n loseContext.loseContext();\n }\n }\n }\n\n draw(picture: SkPicture): void {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n throw new Error(\"Could not get 2D context\");\n }\n\n // Set canvas dimensions to match pixel density\n this.canvas.width = this.canvas.clientWidth * this.pd;\n this.canvas.height = this.canvas.clientHeight * this.pd;\n\n // Draw the tempCanvas scaled down to the display size\n ctx2d.drawImage(\n tempCanvas,\n 0,\n 0,\n tempCanvas.width,\n tempCanvas.height,\n 0,\n 0,\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n this.cleanupWebGLContext(tempCanvas);\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return null;\n }\n\n const { surface, tempCanvas } = renderResult;\n\n try {\n this.cachedImage = surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n surface.ref.delete();\n this.cleanupWebGLContext(tempCanvas);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\nconst pd = Platform.PixelRatio;\n\nexport interface SkiaPictureViewHandle {\n setPicture(picture: SkPicture): void;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n ref?: React.Ref<SkiaPictureViewHandle>;\n}\n\nexport const SkiaPictureView = (props: SkiaPictureViewProps) => {\n const { ref } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const renderer = useRef<Renderer | null>(null);\n const redrawRequestsRef = useRef(0);\n const requestIdRef = useRef(0);\n const pictureRef = useRef<SkPicture | null>(null);\n\n const { picture, onLayout } = props;\n\n const redraw = useCallback(() => {\n redrawRequestsRef.current++;\n }, []);\n\n const getSize = useCallback(() => {\n return {\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n };\n }, []);\n\n const setPicture = useCallback(\n (newPicture: SkPicture) => {\n pictureRef.current = newPicture;\n redraw();\n },\n [redraw]\n );\n\n const makeImageSnapshot = useCallback((rect?: SkRect) => {\n if (renderer.current && pictureRef.current) {\n return renderer.current.makeImageSnapshot(pictureRef.current, rect);\n }\n return null;\n }, []);\n\n const measure = useCallback(\n (\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n const parentElement = canvasRef.current.offsetParent as HTMLElement;\n const parentRect = parentElement?.getBoundingClientRect() || {\n left: 0,\n top: 0,\n };\n\n // x, y are relative to the parent\n const x = rect.left - parentRect.left;\n const y = rect.top - parentRect.top;\n\n // pageX, pageY are absolute screen coordinates\n const pageX = rect.left + window.scrollX;\n const pageY = rect.top + window.scrollY;\n\n callback(x, y, rect.width, rect.height, pageX, pageY);\n }\n },\n []\n );\n\n const measureInWindow = useCallback(\n (\n callback: (x: number, y: number, width: number, height: number) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n\n // x, y are the absolute coordinates in the window\n const x = rect.left;\n const y = rect.top;\n\n callback(x, y, rect.width, rect.height);\n }\n },\n []\n );\n\n const tick = useCallback(() => {\n if (redrawRequestsRef.current > 0) {\n redrawRequestsRef.current = 0;\n if (renderer.current && pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }\n requestIdRef.current = requestAnimationFrame(tick);\n }, []);\n\n const onLayoutEvent = useCallback(\n (evt: LayoutChangeEvent) => {\n const canvas = canvasRef.current;\n if (canvas) {\n renderer.current =\n props.__destroyWebGLContextAfterRender === true\n ? new StaticWebGLRenderer(canvas, pd)\n : new WebGLRenderer(canvas, pd);\n if (pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }\n if (onLayout) {\n onLayout(evt);\n }\n },\n [onLayout, props.__destroyWebGLContextAfterRender]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [setPicture, getSize, redraw, makeImageSnapshot, measure, measureInWindow]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n (global.SkiaViewApi as ISkiaViewApiWeb).registerView(nativeID, {\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n } as SkiaPictureViewHandle);\n }, [\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n props.nativeID,\n ]);\n\n useEffect(() => {\n if (props.picture) {\n setPicture(props.picture);\n }\n }, [setPicture, props.picture]);\n\n useEffect(() => {\n tick();\n return () => {\n cancelAnimationFrame(requestIdRef.current);\n if (renderer.current) {\n renderer.current.dispose();\n renderer.current = null;\n }\n };\n }, [tick]);\n\n useEffect(() => {\n if (renderer.current && pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }, [picture, redraw]);\n\n const { debug = false, ref: _ref, ...viewProps } = props;\n return (\n <Platform.View {...viewProps} onLayout={onLayoutEvent}>\n <canvas ref={canvasRef} style={{ display: \"flex\", flex: 1 }} />\n </Platform.View>\n );\n};\n"],"mappings":";;;;AAAA;AACA,OAAOA,KAAK,IACVC,MAAM,EACNC,SAAS,EACTC,WAAW,EACXC,mBAAmB,QACd,OAAO;AAId,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,QAAQ,QAAQ,aAAa;AAItC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,QAAQ,GAAGA,CAACC,EAAU,EAAEC,IAAa,KAAK;EAC9C,IAAI,CAACA,IAAI,EAAE;IACT,OAAOC,SAAS;EAClB;EACA,OAAO;IACLC,CAAC,EAAEF,IAAI,CAACE,CAAC,GAAGH,EAAE;IACdI,CAAC,EAAEH,IAAI,CAACG,CAAC,GAAGJ,EAAE;IACdK,KAAK,EAAEJ,IAAI,CAACI,KAAK,GAAGL,EAAE;IACtBM,MAAM,EAAEL,IAAI,CAACK,MAAM,GAAGN;EACxB,CAAC;AACH,CAAC;AASD,MAAMO,aAAa,CAAqB;EAGtCC,WAAWA,CACDC,MAAyB,EACzBT,EAAU,EAClB;IAAA,KAFQS,MAAyB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D,CAAC;AAEpB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useRef","useEffect","useCallback","useImperativeHandle","JsiSkSurface","Platform","SkiaViewNativeId","dp2Pixel","pd","rect","undefined","x","y","width","height","WebGLRenderer","constructor","canvas","_defineProperty","onResize","makeImageSnapshot","picture","surface","getCanvas","clear","CanvasKit","TRANSPARENT","draw","ref","flush","clientWidth","clientHeight","MakeWebGLCanvasSurface","ctx","getContext","drawingBufferColorSpace","Error","Float32Array","of","save","scale","drawPicture","restore","dispose","_this$canvas","getExtension","loseContext","delete","StaticWebGLRenderer","cachedImage","renderPictureToSurface","tempCanvas","OffscreenCanvas","webglSurface","skiaCanvas","error","cleanupWebGLContext","renderResult","ctx2d","drawImage","console","_this$cachedImage","PixelRatio","SkiaPictureView","props","canvasRef","renderer","redrawRequestsRef","requestIdRef","pictureRef","onLayout","redraw","current","getSize","_canvasRef$current","_canvasRef$current2","setPicture","newPicture","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","pageX","window","scrollX","pageY","scrollY","measureInWindow","tick","requestAnimationFrame","onLayoutEvent","evt","__destroyWebGLContextAfterRender","_props$nativeID","nativeID","global","SkiaViewApi","registerView","cancelAnimationFrame","debug","_ref","viewProps","createElement","View","_extends","style","display"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useImperativeHandle,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\ninterface Renderer {\n onResize(): void;\n draw(picture: SkPicture): void;\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\nclass WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n private pd: number\n ) {\n this.onResize();\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.surface) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(picture);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas, pd } = this;\n canvas.width = canvas.clientWidth * pd;\n canvas.height = canvas.clientHeight * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n const ctx = canvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(picture: SkPicture) {\n if (this.surface) {\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n canvas.drawPicture(picture);\n canvas.restore();\n this.surface.ref.flush();\n }\n }\n\n dispose(): void {\n if (this.surface) {\n this.canvas\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n this.surface.ref.delete();\n this.surface = null;\n }\n }\n}\n\nclass StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n private pd: number\n ) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderPictureToSurface(\n picture: SkPicture\n ): { surface: JsiSkSurface; tempCanvas: OffscreenCanvas } | null {\n const tempCanvas = new OffscreenCanvas(\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n let surface: JsiSkSurface | null = null;\n\n try {\n const webglSurface = CanvasKit.MakeWebGLCanvasSurface(tempCanvas);\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n\n if (!webglSurface) {\n throw new Error(\"Could not create WebGL surface\");\n }\n\n surface = new JsiSkSurface(CanvasKit, webglSurface);\n\n const skiaCanvas = surface.getCanvas();\n skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));\n skiaCanvas.save();\n skiaCanvas.scale(this.pd, this.pd);\n skiaCanvas.drawPicture(picture);\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas };\n } catch (error) {\n if (surface) {\n surface.ref.delete();\n }\n this.cleanupWebGLContext(tempCanvas);\n return null;\n }\n }\n\n private cleanupWebGLContext(tempCanvas: OffscreenCanvas): void {\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n const loseContext = ctx.getExtension(\"WEBGL_lose_context\");\n if (loseContext) {\n loseContext.loseContext();\n }\n }\n }\n\n draw(picture: SkPicture): void {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n throw new Error(\"Could not get 2D context\");\n }\n\n // Set canvas dimensions to match pixel density\n this.canvas.width = this.canvas.clientWidth * this.pd;\n this.canvas.height = this.canvas.clientHeight * this.pd;\n\n // Draw the tempCanvas scaled down to the display size\n ctx2d.drawImage(\n tempCanvas,\n 0,\n 0,\n tempCanvas.width,\n tempCanvas.height,\n 0,\n 0,\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n this.cleanupWebGLContext(tempCanvas);\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return null;\n }\n\n const { surface, tempCanvas } = renderResult;\n\n try {\n this.cachedImage = surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n surface.ref.delete();\n this.cleanupWebGLContext(tempCanvas);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\nconst pd = Platform.PixelRatio;\n\nexport interface SkiaPictureViewHandle {\n setPicture(picture: SkPicture): void;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n ref?: React.Ref<SkiaPictureViewHandle>;\n}\n\nexport const SkiaPictureView = (props: SkiaPictureViewProps) => {\n const { ref } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const renderer = useRef<Renderer | null>(null);\n const redrawRequestsRef = useRef(0);\n const requestIdRef = useRef(0);\n const pictureRef = useRef<SkPicture | null>(null);\n\n const { picture, onLayout } = props;\n\n const redraw = useCallback(() => {\n redrawRequestsRef.current++;\n }, []);\n\n const getSize = useCallback(() => {\n return {\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n };\n }, []);\n\n const setPicture = useCallback(\n (newPicture: SkPicture) => {\n pictureRef.current = newPicture;\n redraw();\n },\n [redraw]\n );\n\n const makeImageSnapshot = useCallback((rect?: SkRect) => {\n if (renderer.current && pictureRef.current) {\n return renderer.current.makeImageSnapshot(pictureRef.current, rect);\n }\n return null;\n }, []);\n\n const measure = useCallback(\n (\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n const parentElement = canvasRef.current.offsetParent as HTMLElement;\n const parentRect = parentElement?.getBoundingClientRect() || {\n left: 0,\n top: 0,\n };\n\n // x, y are relative to the parent\n const x = rect.left - parentRect.left;\n const y = rect.top - parentRect.top;\n\n // pageX, pageY are absolute screen coordinates\n const pageX = rect.left + window.scrollX;\n const pageY = rect.top + window.scrollY;\n\n callback(x, y, rect.width, rect.height, pageX, pageY);\n }\n },\n []\n );\n\n const measureInWindow = useCallback(\n (\n callback: (x: number, y: number, width: number, height: number) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n\n // x, y are the absolute coordinates in the window\n const x = rect.left;\n const y = rect.top;\n\n callback(x, y, rect.width, rect.height);\n }\n },\n []\n );\n\n const tick = useCallback(() => {\n if (redrawRequestsRef.current > 0) {\n redrawRequestsRef.current = 0;\n if (renderer.current && pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }\n requestIdRef.current = requestAnimationFrame(tick);\n }, []);\n\n const onLayoutEvent = useCallback(\n (evt: LayoutChangeEvent) => {\n const canvas = canvasRef.current;\n if (canvas) {\n renderer.current =\n props.__destroyWebGLContextAfterRender === true\n ? new StaticWebGLRenderer(canvas, pd)\n : new WebGLRenderer(canvas, pd);\n if (pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }\n if (onLayout) {\n onLayout(evt);\n }\n },\n [onLayout, props.__destroyWebGLContextAfterRender]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [setPicture, getSize, redraw, makeImageSnapshot, measure, measureInWindow]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n (global.SkiaViewApi as ISkiaViewApiWeb).registerView(nativeID, {\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n } as SkiaPictureViewHandle);\n }, [\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n props.nativeID,\n ]);\n\n useEffect(() => {\n if (props.picture) {\n setPicture(props.picture);\n }\n }, [setPicture, props.picture]);\n\n useEffect(() => {\n tick();\n return () => {\n cancelAnimationFrame(requestIdRef.current);\n if (renderer.current) {\n renderer.current.dispose();\n renderer.current = null;\n }\n };\n }, [tick]);\n\n useEffect(() => {\n if (renderer.current && pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }, [picture, redraw]);\n\n const { debug = false, ref: _ref, ...viewProps } = props;\n return (\n <Platform.View {...viewProps} onLayout={onLayoutEvent}>\n <canvas\n ref={canvasRef}\n style={{ display: \"block\", width: \"100%\", height: \"100%\" }}\n />\n </Platform.View>\n );\n};\n"],"mappings":";;;;AAAA;AACA,OAAOA,KAAK,IACVC,MAAM,EACNC,SAAS,EACTC,WAAW,EACXC,mBAAmB,QACd,OAAO;AAId,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,QAAQ,QAAQ,aAAa;AAItC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,QAAQ,GAAGA,CAACC,EAAU,EAAEC,IAAa,KAAK;EAC9C,IAAI,CAACA,IAAI,EAAE;IACT,OAAOC,SAAS;EAClB;EACA,OAAO;IACLC,CAAC,EAAEF,IAAI,CAACE,CAAC,GAAGH,EAAE;IACdI,CAAC,EAAEH,IAAI,CAACG,CAAC,GAAGJ,EAAE;IACdK,KAAK,EAAEJ,IAAI,CAACI,KAAK,GAAGL,EAAE;IACtBM,MAAM,EAAEL,IAAI,CAACK,MAAM,GAAGN;EACxB,CAAC;AACH,CAAC;AASD,MAAMO,aAAa,CAAqB;EAGtCC,WAAWA,CACDC,MAAyB,EACzBT,EAAU,EAClB;IAAA,KAFQS,MAAyB,GAAzBA,MAAyB;IAAA,KACzBT,EAAU,GAAVA,EAAU;IAAA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}
|
|
@@ -6,6 +6,8 @@ export class JsiSkImageFactory extends _Host.Host {
|
|
|
6
6
|
MakeImageFromEncoded(encoded: any): _JsiSkImage.JsiSkImage | null;
|
|
7
7
|
MakeImageFromNativeTextureUnstable(): jest.Mock<any, any, any>;
|
|
8
8
|
MakeImage(info: any, data: any, bytesPerRow: any): _JsiSkImage.JsiSkImage | null;
|
|
9
|
+
MakeImageFromTexture(_texture: any): jest.Mock<any, any, any>;
|
|
10
|
+
MakeTextureFromImage(_image: any): jest.Mock<any, any, any>;
|
|
9
11
|
}
|
|
10
12
|
import _Host = require("./Host");
|
|
11
13
|
import _JsiSkImage = require("./JsiSkImage");
|
|
@@ -36,6 +36,8 @@ export function JsiSkApi(CanvasKit: any): {
|
|
|
36
36
|
Video: (url?: any) => Promise<any>;
|
|
37
37
|
Context: (_surface: any, _width: any, _height: any) => jest.Mock<any, any, any>;
|
|
38
38
|
Recorder: () => jest.Mock<any, any, any>;
|
|
39
|
+
getDevice: () => jest.Mock<any, any, any>;
|
|
40
|
+
hasDevice: () => boolean;
|
|
39
41
|
};
|
|
40
42
|
import _JsiSkPoint = require("./JsiSkPoint");
|
|
41
43
|
import _JsiSkRRect = require("./JsiSkRRect");
|
|
@@ -17,5 +17,5 @@ export function Canvas({ debug, opaque, children, onSize, colorSpace, androidWar
|
|
|
17
17
|
androidWarmup?: boolean | undefined;
|
|
18
18
|
ref: any;
|
|
19
19
|
onLayout: any;
|
|
20
|
-
}): React.CElement<object, React.Component<object, {}, any> & import("react-native").
|
|
20
|
+
}): React.CElement<object, React.Component<object, {}, any> & import("react-native").ReactNativeElement>;
|
|
21
21
|
import React from "react";
|
|
@@ -35,4 +35,6 @@ export const Skia: {
|
|
|
35
35
|
Video: (url?: any) => Promise<any>;
|
|
36
36
|
Context: (_surface: any, _width: any, _height: any) => jest.Mock<any, any, any>;
|
|
37
37
|
Recorder: () => jest.Mock<any, any, any>;
|
|
38
|
+
getDevice: () => jest.Mock<any, any, any>;
|
|
39
|
+
hasDevice: () => boolean;
|
|
38
40
|
};
|
|
@@ -5,6 +5,8 @@ export class JsiSkImageFactory extends Host {
|
|
|
5
5
|
MakeImageFromEncoded(encoded: any): JsiSkImage | null;
|
|
6
6
|
MakeImageFromNativeTextureUnstable(): jest.Mock<any, any, any>;
|
|
7
7
|
MakeImage(info: any, data: any, bytesPerRow: any): JsiSkImage | null;
|
|
8
|
+
MakeImageFromTexture(_texture: any): jest.Mock<any, any, any>;
|
|
9
|
+
MakeTextureFromImage(_image: any): jest.Mock<any, any, any>;
|
|
8
10
|
}
|
|
9
11
|
import { Host } from "./Host";
|
|
10
12
|
import { JsiSkImage } from "./JsiSkImage";
|
|
@@ -35,6 +35,8 @@ export function JsiSkApi(CanvasKit: any): {
|
|
|
35
35
|
Video: (url?: any) => Promise<any>;
|
|
36
36
|
Context: (_surface: any, _width: any, _height: any) => jest.Mock<any, any, any>;
|
|
37
37
|
Recorder: () => jest.Mock<any, any, any>;
|
|
38
|
+
getDevice: () => jest.Mock<any, any, any>;
|
|
39
|
+
hasDevice: () => boolean;
|
|
38
40
|
};
|
|
39
41
|
import { JsiSkPoint } from "./JsiSkPoint";
|
|
40
42
|
import { JsiSkRRect } from "./JsiSkRRect";
|
|
@@ -16,6 +16,6 @@ export class SkiaPictureView extends React.Component<any, any, any> {
|
|
|
16
16
|
* Sends a redraw request to the native SkiaView.
|
|
17
17
|
*/
|
|
18
18
|
redraw(): void;
|
|
19
|
-
render(): React.CElement<object, React.Component<object, {}, any> & import("react-native").
|
|
19
|
+
render(): React.CElement<object, React.Component<object, {}, any> & import("react-native").ReactNativeElement>;
|
|
20
20
|
}
|
|
21
21
|
import React from "react";
|
|
@@ -4,7 +4,4 @@ export declare const notifyChange: <T>(value: SharedValue<T>) => void;
|
|
|
4
4
|
export declare const usePathValue: (cb: (path: SkPath) => void, init?: SkPath) => SharedValue<SkPath>;
|
|
5
5
|
export declare const useClock: () => SharedValue<number>;
|
|
6
6
|
export declare const usePathInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SharedValue<SkPath>;
|
|
7
|
-
export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
}>;
|
|
7
|
+
export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<SkPoint>;
|
|
@@ -78,4 +78,24 @@ export interface ImageFactory {
|
|
|
78
78
|
* @param bytesPerRow
|
|
79
79
|
*/
|
|
80
80
|
MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;
|
|
81
|
+
/**
|
|
82
|
+
* Creates an SkImage from a WebGPU texture.
|
|
83
|
+
* This allows using textures rendered by WebGPU in Skia drawings.
|
|
84
|
+
*
|
|
85
|
+
* Note: This method is only available when the Graphite backend is enabled.
|
|
86
|
+
*
|
|
87
|
+
* @param texture - A GPUTexture object from the WebGPU API
|
|
88
|
+
* @returns An SkImage wrapping the texture, or throws if the texture is invalid
|
|
89
|
+
*/
|
|
90
|
+
MakeImageFromTexture(texture: GPUTexture): SkImage;
|
|
91
|
+
/**
|
|
92
|
+
* Creates a WebGPU texture from an SkImage.
|
|
93
|
+
* This allows using Skia images in WebGPU rendering pipelines.
|
|
94
|
+
*
|
|
95
|
+
* Note: This method is only available when the Graphite backend is enabled.
|
|
96
|
+
*
|
|
97
|
+
* @param image - An SkImage to convert to a texture
|
|
98
|
+
* @returns A GPUTexture containing the image data, or throws if conversion fails
|
|
99
|
+
*/
|
|
100
|
+
MakeTextureFromImage(image: SkImage): GPUTexture;
|
|
81
101
|
}
|
|
@@ -84,4 +84,21 @@ export interface Skia {
|
|
|
84
84
|
Context(surface: bigint, width: number, height: number): SkiaContext;
|
|
85
85
|
NativeBuffer: NativeBufferFactory;
|
|
86
86
|
Recorder(): JsiRecorder;
|
|
87
|
+
/**
|
|
88
|
+
* Returns whether the Graphite backend is enabled and WebGPU is available.
|
|
89
|
+
*
|
|
90
|
+
* @returns true if Graphite/WebGPU is available, false otherwise
|
|
91
|
+
*/
|
|
92
|
+
hasDevice(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the shared WebGPU device used by Skia's Graphite backend.
|
|
95
|
+
* This allows direct access to the GPU device for WebGPU operations.
|
|
96
|
+
*
|
|
97
|
+
* Note: This method is only available when the Graphite backend is enabled.
|
|
98
|
+
* Use hasDevice() to check availability before calling this method.
|
|
99
|
+
*
|
|
100
|
+
* @returns The GPUDevice used by Skia
|
|
101
|
+
* @throws Error if Graphite backend is not enabled
|
|
102
|
+
*/
|
|
103
|
+
getDevice(): GPUDevice;
|
|
87
104
|
}
|
|
@@ -11,4 +11,6 @@ export declare class JsiSkImageFactory extends Host implements ImageFactory {
|
|
|
11
11
|
MakeImageFromEncoded(encoded: SkData): JsiSkImage | null;
|
|
12
12
|
MakeImageFromNativeTextureUnstable(): SkImage;
|
|
13
13
|
MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): JsiSkImage | null;
|
|
14
|
+
MakeImageFromTexture(_texture: GPUTexture): SkImage;
|
|
15
|
+
MakeTextureFromImage(_image: SkImage): GPUTexture;
|
|
14
16
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ViewProps } from "react-native";
|
|
2
|
+
import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
|
|
2
3
|
export interface NativeProps extends ViewProps {
|
|
3
4
|
debug?: boolean;
|
|
4
5
|
opaque?: boolean;
|
|
5
6
|
colorSpace?: string;
|
|
6
7
|
androidWarmup?: boolean;
|
|
8
|
+
pointerEvents?: WithDefault<"auto" | "none" | "box-none" | "box-only", "auto">;
|
|
7
9
|
}
|
|
8
10
|
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
9
11
|
export default _default;
|
package/package.json
CHANGED
|
@@ -8,25 +8,28 @@
|
|
|
8
8
|
"setup-skia-web": "scripts/setup-canvaskit.js"
|
|
9
9
|
},
|
|
10
10
|
"title": "React Native Skia",
|
|
11
|
-
"version": "2.4.
|
|
11
|
+
"version": "2.4.17",
|
|
12
12
|
"skia": {
|
|
13
|
-
"version": "
|
|
13
|
+
"version": "m144c",
|
|
14
14
|
"checksums": {
|
|
15
|
-
"android-armeabi-v7a": "
|
|
16
|
-
"android-arm64-v8a": "
|
|
17
|
-
"android-x86": "
|
|
18
|
-
"android-x86_64": "
|
|
19
|
-
"apple-xcframeworks": "
|
|
15
|
+
"android-armeabi-v7a": "e406c3e8103a2efb6a514ac91346d7f9f81adbae14dc2d0e302e84fb8c5f80f7",
|
|
16
|
+
"android-arm64-v8a": "75069b0f7c66ad3382553e947d583265de033cc856c394110243da098306955f",
|
|
17
|
+
"android-x86": "714b93a7bdf005a23699f47e6255e4e690086c52a1998c20196a46f95b709b09",
|
|
18
|
+
"android-x86_64": "5bd2972d13293b09b35e2c0149b7d103dc4fb0f2837c3dd169ce06795b812714",
|
|
19
|
+
"apple-ios-xcframeworks": "43f62ea742c55ecc57864505ff752a517fd2c31412a19914032d044ac4f987ee",
|
|
20
|
+
"apple-tvos-xcframeworks": "0f6b5c75b4e686e72f5cc8508e60074463f757ca7a0dcbd07e095c055a537c58",
|
|
21
|
+
"apple-macos-xcframeworks": "31f57bcf6caff1c268984609b0e4a2abd966bfa8ddcf074331d94e0f988f93d3"
|
|
20
22
|
}
|
|
21
23
|
},
|
|
22
24
|
"skia-graphite": {
|
|
23
|
-
"version": "
|
|
25
|
+
"version": "m142b",
|
|
24
26
|
"checksums": {
|
|
25
|
-
"android-armeabi-v7a": "
|
|
26
|
-
"android-arm64-v8a": "
|
|
27
|
-
"android-x86": "
|
|
28
|
-
"android-x86_64": "
|
|
29
|
-
"apple-xcframeworks": "
|
|
27
|
+
"android-armeabi-v7a": "3e40f44c804194fa0983c46903f834e8f834c6dd96534c7fa1b4ebb4f409527d",
|
|
28
|
+
"android-arm64-v8a": "d6c3035449fcf7ef13369b0d6c4ef41f3177d15074eeb195201e0ba4cfb2f527",
|
|
29
|
+
"android-x86": "6dc229847420b8a43c15098cdcb4fe45b2df20a38ad69f37e0aa91c832499c2a",
|
|
30
|
+
"android-x86_64": "ecae351d98af3b175d40d894520c2e3263034276bb0b0e9d2f9c19ba7dc046fa",
|
|
31
|
+
"apple-ios-xcframeworks": "6f60f03faaeebfb798615d09715040790ff95e75bf95028893ced6f514ab5196",
|
|
32
|
+
"apple-macos-xcframeworks": "07467cd1778053537528ed91c7a35d116e1a4644819f0aad8e06e7d884591dea"
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
35
|
"description": "High-performance React Native Graphics using Skia",
|
|
@@ -132,14 +135,15 @@
|
|
|
132
135
|
"pngjs": "6.0.0",
|
|
133
136
|
"prettier": "2.8.7",
|
|
134
137
|
"react": "19.0.0",
|
|
135
|
-
"react-native": "0.
|
|
138
|
+
"react-native": "0.83.1",
|
|
136
139
|
"react-native-builder-bob": "0.18.2",
|
|
137
|
-
"react-native-reanimated": "
|
|
140
|
+
"react-native-reanimated": "4.2.1",
|
|
141
|
+
"react-native-worklets": "0.7.1",
|
|
138
142
|
"rimraf": "3.0.2",
|
|
139
143
|
"semantic-release": "^24.1.0",
|
|
140
144
|
"semantic-release-yarn": "^3.0.2",
|
|
141
145
|
"ts-jest": "29.4.3",
|
|
142
|
-
"tsx": "^4.
|
|
146
|
+
"tsx": "^4.21.0",
|
|
143
147
|
"typescript": "^5.2.2",
|
|
144
148
|
"ws": "8.18.0"
|
|
145
149
|
},
|
|
@@ -4,6 +4,37 @@ require "json"
|
|
|
4
4
|
|
|
5
5
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
6
6
|
|
|
7
|
+
# Check if Skia prebuilt binaries are installed
|
|
8
|
+
# The postinstall script downloads these - if missing, the user needs to run it
|
|
9
|
+
skia_libs_path = File.join(__dir__, "libs/apple/ios")
|
|
10
|
+
unless File.exist?(skia_libs_path) && Dir.glob(File.join(skia_libs_path, "*.xcframework")).any?
|
|
11
|
+
Pod::UI.puts "\n"
|
|
12
|
+
Pod::UI.puts "┌─────────────────────────────────────────────────────────────────────────────┐".red
|
|
13
|
+
Pod::UI.puts "│ │".red
|
|
14
|
+
Pod::UI.puts "│ ERROR: Skia prebuilt binaries not found! │".red
|
|
15
|
+
Pod::UI.puts "│ │".red
|
|
16
|
+
Pod::UI.puts "│ The postinstall script has not run. This is required to download the │".red
|
|
17
|
+
Pod::UI.puts "│ Skia binaries. Some package managers (pnpm, bun, yarn berry) require │".red
|
|
18
|
+
Pod::UI.puts "│ explicit trust for packages with postinstall scripts. │".red
|
|
19
|
+
Pod::UI.puts "│ │".red
|
|
20
|
+
Pod::UI.puts "│ To fix this: │".red
|
|
21
|
+
Pod::UI.puts "│ │".red
|
|
22
|
+
Pod::UI.puts "│ • npm/yarn classic: Run 'npm rebuild @shopify/react-native-skia' or │".red
|
|
23
|
+
Pod::UI.puts "│ reinstall the package │".red
|
|
24
|
+
Pod::UI.puts "│ │".red
|
|
25
|
+
Pod::UI.puts "│ • bun: Run 'bun add --trust @shopify/react-native-skia' │".red
|
|
26
|
+
Pod::UI.puts "│ │".red
|
|
27
|
+
Pod::UI.puts "│ • pnpm: Add to package.json: │".red
|
|
28
|
+
Pod::UI.puts "│ \"pnpm\": { \"onlyBuiltDependencies\": [\"@shopify/react-native-skia\"] }│".red
|
|
29
|
+
Pod::UI.puts "│ Then reinstall the package │".red
|
|
30
|
+
Pod::UI.puts "│ │".red
|
|
31
|
+
Pod::UI.puts "│ See: https://shopify.github.io/react-native-skia/docs/getting-started/installation │".red
|
|
32
|
+
Pod::UI.puts "│ │".red
|
|
33
|
+
Pod::UI.puts "└─────────────────────────────────────────────────────────────────────────────┘".red
|
|
34
|
+
Pod::UI.puts "\n"
|
|
35
|
+
raise "Skia prebuilt binaries not found. Please run the postinstall script."
|
|
36
|
+
end
|
|
37
|
+
|
|
7
38
|
# Check if Graphite is available
|
|
8
39
|
# Detection method priority:
|
|
9
40
|
# 1. SK_GRAPHITE environment variable (explicit override, fastest)
|
|
@@ -34,15 +65,15 @@ preprocessor_defs = use_graphite ?
|
|
|
34
65
|
'$(inherited) SK_GRAPHITE=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1' :
|
|
35
66
|
'$(inherited) SK_METAL=1 SK_GANESH=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1'
|
|
36
67
|
|
|
37
|
-
# Define
|
|
38
|
-
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
# Define framework names (without paths)
|
|
69
|
+
framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
|
|
70
|
+
'libskunicode_core', 'libskunicode_libgrapheme',
|
|
71
|
+
'libskottie', 'libsksg']
|
|
72
|
+
|
|
73
|
+
# Build platform-specific framework paths
|
|
74
|
+
ios_frameworks = framework_names.map { |f| "libs/apple/ios/#{f}.xcframework" }
|
|
75
|
+
tvos_frameworks = framework_names.map { |f| "libs/apple/tvos/#{f}.xcframework" }
|
|
76
|
+
osx_frameworks = framework_names.map { |f| "libs/apple/macos/#{f}.xcframework" }
|
|
46
77
|
|
|
47
78
|
Pod::Spec.new do |s|
|
|
48
79
|
s.name = "react-native-skia"
|
|
@@ -66,12 +97,19 @@ Pod::Spec.new do |s|
|
|
|
66
97
|
'GCC_PREPROCESSOR_DEFINITIONS' => preprocessor_defs,
|
|
67
98
|
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
|
68
99
|
'DEFINES_MODULE' => 'YES',
|
|
69
|
-
"HEADER_SEARCH_PATHS" => '"$(PODS_TARGET_SRCROOT)/cpp/"/**'
|
|
100
|
+
"HEADER_SEARCH_PATHS" => '"$(PODS_TARGET_SRCROOT)/cpp/"/** "$(PODS_TARGET_SRCROOT)/cpp" "$(PODS_TARGET_SRCROOT)/cpp/jsi2" "$(PODS_TARGET_SRCROOT)/cpp/rnwgpu" "$(PODS_TARGET_SRCROOT)/cpp/rnwgpu/api" "$(PODS_TARGET_SRCROOT)/cpp/rnwgpu/api/descriptors" "$(PODS_TARGET_SRCROOT)/cpp/rnwgpu/async" "$(PODS_TARGET_SRCROOT)/cpp/dawn/include"'
|
|
70
101
|
}
|
|
71
102
|
|
|
72
103
|
s.frameworks = ['MetalKit', 'AVFoundation', 'AVKit', 'CoreMedia']
|
|
73
104
|
|
|
74
|
-
|
|
105
|
+
# Platform-specific vendored frameworks
|
|
106
|
+
s.ios.vendored_frameworks = ios_frameworks
|
|
107
|
+
s.osx.vendored_frameworks = osx_frameworks
|
|
108
|
+
|
|
109
|
+
# tvOS frameworks only available for non-Graphite builds
|
|
110
|
+
unless use_graphite
|
|
111
|
+
s.tvos.vendored_frameworks = tvos_frameworks
|
|
112
|
+
end
|
|
75
113
|
|
|
76
114
|
# All iOS cpp/h files
|
|
77
115
|
s.source_files = [
|
|
@@ -82,9 +120,10 @@ Pod::Spec.new do |s|
|
|
|
82
120
|
graphite_exclusions = [
|
|
83
121
|
'cpp/rnskia/RNDawnContext.h',
|
|
84
122
|
'cpp/rnskia/RNDawnUtils.h',
|
|
85
|
-
'cpp/rnskia/RNDawnWindowContext.h',
|
|
123
|
+
'cpp/rnskia/RNDawnWindowContext.h',
|
|
86
124
|
'cpp/rnskia/RNDawnWindowContext.cpp',
|
|
87
|
-
'cpp/rnskia/RNImageProvider.h'
|
|
125
|
+
'cpp/rnskia/RNImageProvider.h',
|
|
126
|
+
'cpp/rnwgpu/**/*.{h,cpp}'
|
|
88
127
|
]
|
|
89
128
|
s.exclude_files = graphite_exclusions unless use_graphite
|
|
90
129
|
|