react-native-skia 3.0.1 → 3.0.3
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/Package.swift +14 -13
- package/README.md +19 -2
- package/android/CMakeLists.txt +13 -42
- package/android/build.gradle +54 -63
- package/android/cpp/jni/JniLoad.cpp +2 -4
- package/android/cpp/jni/include/JniSkiaView.h +123 -0
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp} +45 -100
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h} +24 -22
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -83
- package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -8
- package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +1 -2
- package/android/src/main/java/com/reactnative/skia/SkiaSurfaceView.java +1 -3
- package/android/src/main/java/com/reactnative/skia/SkiaTextureView.java +1 -17
- package/android/src/main/java/com/reactnative/skia/{SkiaBaseView.java → SkiaView.java} +78 -16
- package/android/src/main/java/com/reactnative/skia/SkiaViewManager.java +85 -0
- package/apple/MetalLayerColorSpace.mm +10 -12
- package/apple/RNSkApplePlatformContext.h +12 -14
- package/apple/RNSkApplePlatformContext.mm +19 -112
- package/apple/RNSkMetalCanvasProvider.h +14 -19
- package/apple/RNSkMetalCanvasProvider.mm +39 -70
- package/apple/RNSkiaModule.mm +10 -0
- package/apple/SkiaView.h +20 -0
- package/apple/SkiaView.mm +210 -0
- package/cpp/api/JsiSkApi.h +2 -13
- package/cpp/api/JsiSkCanvas.h +4 -18
- package/cpp/api/JsiSkGraphiteContext.h +1 -5
- package/cpp/api/JsiSkGraphiteRecording.h +1 -5
- package/cpp/api/JsiSkImage.h +7 -41
- package/cpp/api/JsiSkImageFactory.h +0 -14
- package/cpp/api/JsiSkSurface.h +2 -16
- package/cpp/api/JsiSkSurfaceFactory.h +0 -8
- package/cpp/rnskia/RNDawnContext.h +3 -2
- package/cpp/rnskia/RNDawnInterop.cpp +0 -4
- package/cpp/rnskia/RNDawnUtils.h +12 -1
- package/cpp/rnskia/RNDawnWindowContext.cpp +12 -1
- package/cpp/rnskia/RNDawnWindowContext.h +19 -7
- package/cpp/rnskia/RNMetalLayerColorSpace.h +4 -2
- package/cpp/rnskia/RNSkCanvasProvider.h +231 -0
- package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
- package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
- package/cpp/rnskia/RNSkGraphiteTarget.h +396 -0
- package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
- package/cpp/rnskia/RNSkPlatformContext.h +17 -15
- package/cpp/rnskia/RNSkView.h +362 -246
- package/jestSetup.js +1 -3
- package/lib/commonjs/Platform/Platform.web.js +1 -1
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/index.d.ts +1 -3
- package/lib/commonjs/index.js +3 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +15 -12
- package/lib/commonjs/renderer/Canvas.js +25 -21
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
- package/lib/commonjs/skia/types/Graphite.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +1 -2
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
- package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
- package/lib/commonjs/views/SkiaPictureView.js +12 -10
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
- package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
- package/lib/commonjs/views/SkiaView.web.js.map +1 -0
- package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
- package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
- package/lib/commonjs/views/android.d.ts +6 -0
- package/lib/commonjs/views/android.js +17 -0
- package/lib/commonjs/views/android.js.map +1 -0
- package/lib/commonjs/views/types.d.ts +3 -12
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +1 -1
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.js +1 -1
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/index.d.ts +1 -3
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock/index.js +0 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +15 -12
- package/lib/module/renderer/Canvas.js +25 -20
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/Graphite.d.ts +3 -3
- package/lib/module/skia/types/Graphite.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +1 -2
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/module/specs/NativeSkiaModule.web.js +5 -9
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/module/views/SkiaGraphiteView.js +23 -12
- package/lib/module/views/SkiaGraphiteView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.d.ts +4 -1
- package/lib/module/views/SkiaPictureView.js +12 -10
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.web.d.ts +12 -0
- package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
- package/lib/module/views/SkiaView.web.js.map +1 -0
- package/lib/module/views/SkiaWebRenderer.js +1 -1
- package/lib/module/views/SkiaWebRenderer.js.map +1 -1
- package/lib/module/views/android.d.ts +6 -0
- package/lib/module/views/android.js +10 -0
- package/lib/module/views/android.js.map +1 -0
- package/lib/module/views/types.d.ts +3 -12
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -3
- package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
- package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
- package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
- package/lib/typescript/src/views/android.d.ts +6 -0
- package/lib/typescript/src/views/types.d.ts +3 -12
- package/package.json +5 -13
- package/react-native-skia.podspec +34 -58
- package/src/Platform/Platform.web.tsx +1 -1
- package/src/external/reanimated/interpolators.ts +1 -1
- package/src/index.ts +1 -3
- package/src/mock/index.ts +0 -1
- package/src/renderer/Canvas.tsx +24 -28
- package/src/skia/types/Graphite.ts +3 -3
- package/src/skia/types/Image/ImageFactory.ts +2 -2
- package/src/skia/types/Skia.ts +1 -2
- package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
- package/src/specs/NativeSkiaModule.web.ts +9 -21
- package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
- package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
- package/src/views/SkiaGraphiteView.tsx +27 -16
- package/src/views/SkiaPictureView.tsx +11 -10
- package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
- package/src/views/SkiaWebRenderer.ts +1 -1
- package/src/views/android.ts +16 -0
- package/src/views/types.ts +3 -14
- package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
- package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
- package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
- package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
- package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
- package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
- package/android/cpp/rnskia-android/gl/Context.h +0 -80
- package/android/cpp/rnskia-android/gl/Display.h +0 -123
- package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
- package/android/cpp/rnskia-android/gl/Error.h +0 -8
- package/android/cpp/rnskia-android/gl/Surface.h +0 -43
- package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
- package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
- package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
- package/apple/MetalContext.h +0 -116
- package/apple/MetalContext.mm +0 -38
- package/apple/MetalWindowContext.h +0 -42
- package/apple/MetalWindowContext.mm +0 -95
- package/apple/RNSkAppleView.h +0 -49
- package/apple/RNSkAppleView.mm +0 -35
- package/apple/SkiaCVPixelBufferUtils.h +0 -122
- package/apple/SkiaCVPixelBufferUtils.mm +0 -535
- package/apple/SkiaGraphiteView.h +0 -26
- package/apple/SkiaGraphiteView.mm +0 -180
- package/apple/SkiaPictureView.h +0 -7
- package/apple/SkiaPictureView.mm +0 -70
- package/apple/SkiaUIView.h +0 -31
- package/apple/SkiaUIView.mm +0 -164
- package/cpp/rnskia/RNSkGraphiteView.h +0 -708
- package/cpp/rnskia/RNSkPictureView.cpp +0 -69
- package/cpp/rnskia/RNSkPictureView.h +0 -211
- package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
- package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
- package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
- package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
- package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
- package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
- package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/module/renderer/DefaultCanvas.js +0 -34
- package/lib/module/renderer/DefaultCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/module/renderer/GraphiteCanvas.js +0 -57
- package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
- package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/module/views/SkiaPictureView.web.js +0 -156
- package/lib/module/views/SkiaPictureView.web.js.map +0 -1
- package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
- package/libs/.graphite +0 -1
- package/src/renderer/DefaultCanvas.tsx +0 -41
- package/src/renderer/GraphiteCanvas.tsx +0 -61
- package/src/renderer/GraphiteCanvas.web.tsx +0 -3
- package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
- package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
- package/src/views/SkiaPictureView.web.tsx +0 -224
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["global","SkiaViewApi","views","deferedPictures","unregisteredViews","Set","deferedOnSize","web","registerView","nativeId","view","delete","setPicture","unregisterView","add","setJsiProperty","name","value","id","has","size","getSize","width","height","requestRedraw","_this$views","redraw","applyUpdates","makeImageSnapshot","rect","Error","makeGraphiteContext","getContext","makeImageSnapshotAsync","Promise","resolve","reject","result"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n} from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\n\n/** What the web view registers under its native id. */\nexport interface SkiaWebViewHandle {\n /** Shows a picture: the frame of a <Canvas> or a <SkiaPictureView>. */\n setPicture(picture: SkPicture): void;\n /** The recording side of the view, see SkiaGraphiteView. */\n getContext(): SkGraphiteContext;\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 type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaWebViewHandle>;\n deferedPictures: Record<string, SkPicture>;\n unregisteredViews: Set<string>;\n registerView(nativeId: string, view: SkiaWebViewHandle): void;\n unregisterView(nativeId: string): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n unregisteredViews: new Set<string>(),\n deferedOnSize: {},\n web: true,\n registerView(nativeId: string, view: SkiaWebViewHandle) {\n this.unregisteredViews.delete(nativeId);\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId]) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n delete this.deferedPictures[nativeId];\n }\n this.views[nativeId] = view;\n },\n unregisterView(nativeId: string) {\n // Views must be removed on unmount: the handle's closures capture the\n // canvas element, so a stale entry retains the whole detached DOM tree.\n this.unregisteredViews.add(nativeId);\n delete this.views[nativeId];\n delete this.deferedPictures[nativeId];\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n const id = `${nativeId}`;\n const view = this.views[id];\n if (view) {\n view.setPicture(value);\n } else if (!this.unregisteredViews.has(id)) {\n this.deferedPictures[id] = value;\n }\n // Otherwise the view has unmounted (e.g. a trailing animation frame):\n // drop the picture instead of deferring it for an id that will never\n // register again, which would retain it forever.\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n // The view may already have unmounted (e.g. a trailing animation frame).\n this.views[`${nativeId}`]?.redraw();\n },\n applyUpdates() {\n // Web canvases are driven from JS (see Container.web.ts); there is no\n // view-owned recorder to update.\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n const view = this.views[`${nativeId}`];\n if (!view) {\n throw new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n );\n }\n return view.makeImageSnapshot(rect);\n },\n makeGraphiteContext(nativeId: number) {\n const view = this.views[`${nativeId}`];\n if (!view) {\n throw new Error(\n `Cannot make a Graphite context: no view with nativeID ${nativeId} is mounted`\n );\n }\n return view.getContext();\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const view = this.views[`${nativeId}`];\n if (!view) {\n reject(\n new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n )\n );\n return;\n }\n const result = view.makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n\n// eslint-disable-next-line import/no-default-export\nexport default {};\n"],"mappings":"AAAA;;AASA;;AAgCAA,MAAM,CAACC,WAAW,GAAG;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,eAAe,EAAE,CAAC,CAAC;EACnBC,iBAAiB,EAAE,IAAIC,GAAG,CAAS,CAAC;EACpCC,aAAa,EAAE,CAAC,CAAC;EACjBC,GAAG,EAAE,IAAI;EACTC,YAAYA,CAACC,QAAgB,EAAEC,IAAuB,EAAE;IACtD,IAAI,CAACN,iBAAiB,CAACO,MAAM,CAACF,QAAQ,CAAC;IACvC;IACA,IAAI,IAAI,CAACN,eAAe,CAACM,QAAQ,CAAC,EAAE;MAClCC,IAAI,CAACE,UAAU,CAAC,IAAI,CAACT,eAAe,CAACM,QAAQ,CAAc,CAAC;MAC5D,OAAO,IAAI,CAACN,eAAe,CAACM,QAAQ,CAAC;IACvC;IACA,IAAI,CAACP,KAAK,CAACO,QAAQ,CAAC,GAAGC,IAAI;EAC7B,CAAC;EACDG,cAAcA,CAACJ,QAAgB,EAAE;IAC/B;IACA;IACA,IAAI,CAACL,iBAAiB,CAACU,GAAG,CAACL,QAAQ,CAAC;IACpC,OAAO,IAAI,CAACP,KAAK,CAACO,QAAQ,CAAC;IAC3B,OAAO,IAAI,CAACN,eAAe,CAACM,QAAQ,CAAC;EACvC,CAAC;EACD;EACAM,cAAcA,CAACN,QAAgB,EAAEO,IAAY,EA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EACDE,mBAAmBA,CAACtB,QAAgB,EAAE;IACpC,MAAMC,IAAI,GAAG,IAAI,CAACR,KAAK,CAAC,GAAGO,QAAQ,EAAE,CAAC;IACtC,IAAI,CAACC,IAAI,EAAE;MACT,MAAM,IAAIoB,KAAK,CACb,yDAAyDrB,QAAQ,aACnE,CAAC;IACH;IACA,OAAOC,IAAI,CAACsB,UAAU,CAAC,CAAC;EAC1B,CAAC;EACDC,sBAAsBA,CAACxB,QAAgB,EAAEoB,IAAa,EAAE;IACtD,OAAO,IAAIK,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAM1B,IAAI,GAAG,IAAI,CAACR,KAAK,CAAC,GAAGO,QAAQ,EAAE,CAAC;MACtC,IAAI,CAACC,IAAI,EAAE;QACT0B,MAAM,CACJ,IAAIN,KAAK,CACP,kDAAkDrB,QAAQ,4CAC5D,CACF,CAAC;QACD;MACF;MACA,MAAM4B,MAAM,GAAG3B,IAAI,CAACkB,iBAAiB,CAACC,IAAI,CAAC;MAC3C,IAAIQ,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIN,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;;AAEpB;AACA,eAAe,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { type ViewProps } from "react-native";
|
|
2
2
|
import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
|
|
3
3
|
export interface NativeProps extends ViewProps {
|
|
4
|
-
debug?: boolean;
|
|
5
4
|
opaque?: boolean;
|
|
6
|
-
colorSpace?: string;
|
|
7
5
|
highBitDepth?: boolean;
|
|
8
|
-
androidWarmup?: boolean;
|
|
9
6
|
androidSurfaceType?: WithDefault<"auto" | "SurfaceView" | "TextureView", "auto">;
|
|
10
7
|
androidZOrderOnTop?: WithDefault<boolean, false>;
|
|
11
8
|
pointerEvents?: WithDefault<"auto" | "none" | "box-none" | "box-only", "auto">;
|
|
@@ -4,5 +4,5 @@ import { codegenNativeComponent } from "react-native";
|
|
|
4
4
|
// @ts-ignore - pointerEvents needs to be redeclared for codegen to generate native bindings
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line import/no-default-export
|
|
7
|
-
export default codegenNativeComponent("
|
|
8
|
-
//# sourceMappingURL=
|
|
7
|
+
export default codegenNativeComponent("SkiaView");
|
|
8
|
+
//# sourceMappingURL=SkiaViewNativeComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["SkiaViewNativeComponent.ts"],"sourcesContent":["import { codegenNativeComponent, 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 opaque?: boolean;\n highBitDepth?: boolean;\n androidSurfaceType?: WithDefault<\n \"auto\" | \"SurfaceView\" | \"TextureView\",\n \"auto\"\n >;\n androidZOrderOnTop?: WithDefault<boolean, false>;\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>(\"SkiaView\");\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAwB,cAAc;;AAGrE;AACA;;AAeA;AACA,eAAeA,sBAAsB,CAAc,UAAU,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ViewProps } from "react-native";
|
|
2
|
+
export interface NativeProps extends ViewProps {
|
|
3
|
+
opaque?: boolean;
|
|
4
|
+
highBitDepth?: boolean;
|
|
5
|
+
nativeID: string;
|
|
6
|
+
androidSurfaceType?: "auto" | "SurfaceView" | "TextureView";
|
|
7
|
+
androidZOrderOnTop?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const SkiaViewNativeComponent: ({ nativeID, onLayout, opaque: _opaque, highBitDepth: _highBitDepth, androidSurfaceType: _androidSurfaceType, androidZOrderOnTop: _androidZOrderOnTop, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("../views/SkiaView.web").SkiaViewProps>;
|
|
10
|
+
export default SkiaViewNativeComponent;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { SkiaView } from "../views/SkiaView.web";
|
|
3
|
+
const SkiaViewNativeComponent = ({
|
|
4
|
+
nativeID,
|
|
5
|
+
onLayout,
|
|
6
|
+
// Surface settings, never reach the DOM
|
|
7
|
+
opaque: _opaque,
|
|
8
|
+
highBitDepth: _highBitDepth,
|
|
9
|
+
androidSurfaceType: _androidSurfaceType,
|
|
10
|
+
androidZOrderOnTop: _androidZOrderOnTop,
|
|
11
|
+
...viewProps
|
|
12
|
+
}) => {
|
|
13
|
+
return /*#__PURE__*/createElement(SkiaView, {
|
|
14
|
+
nativeID,
|
|
15
|
+
onLayout,
|
|
16
|
+
...viewProps
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
// eslint-disable-next-line import/no-default-export
|
|
20
|
+
export default SkiaViewNativeComponent;
|
|
21
|
+
//# sourceMappingURL=SkiaViewNativeComponent.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElement","SkiaView","SkiaViewNativeComponent","nativeID","onLayout","opaque","_opaque","highBitDepth","_highBitDepth","androidSurfaceType","_androidSurfaceType","androidZOrderOnTop","_androidZOrderOnTop","viewProps"],"sources":["SkiaViewNativeComponent.web.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport { createElement } from \"react\";\n\nimport { SkiaView } from \"../views/SkiaView.web\";\n\nexport interface NativeProps extends ViewProps {\n opaque?: boolean;\n highBitDepth?: boolean;\n nativeID: string;\n androidSurfaceType?: \"auto\" | \"SurfaceView\" | \"TextureView\";\n androidZOrderOnTop?: boolean;\n}\n\nconst SkiaViewNativeComponent = ({\n nativeID,\n onLayout,\n // Surface settings, never reach the DOM\n opaque: _opaque,\n highBitDepth: _highBitDepth,\n androidSurfaceType: _androidSurfaceType,\n androidZOrderOnTop: _androidZOrderOnTop,\n ...viewProps\n}: NativeProps) => {\n return createElement(SkiaView, {\n nativeID,\n onLayout,\n ...viewProps,\n });\n};\n// eslint-disable-next-line import/no-default-export\nexport default SkiaViewNativeComponent;\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,OAAO;AAErC,SAASC,QAAQ,QAAQ,uBAAuB;AAUhD,MAAMC,uBAAuB,GAAGA,CAAC;EAC/BC,QAAQ;EACRC,QAAQ;EACR;EACAC,MAAM,EAAEC,OAAO;EACfC,YAAY,EAAEC,aAAa;EAC3BC,kBAAkB,EAAEC,mBAAmB;EACvCC,kBAAkB,EAAEC,mBAAmB;EACvC,GAAGC;AACQ,CAAC,KAAK;EACjB,oBAAOb,aAAa,CAACC,QAAQ,EAAE;IAC7BE,QAAQ;IACRC,QAAQ;IACR,GAAGS;EACL,CAAC,CAAC;AACJ,CAAC;AACD;AACA,eAAeX,uBAAuB","ignoreList":[]}
|
|
@@ -13,8 +13,7 @@ export interface SkiaGraphiteViewProps extends SkiaGraphiteViewNativeProps {
|
|
|
13
13
|
ref?: React.Ref<SkiaGraphiteViewRef>;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* A view
|
|
17
|
-
*
|
|
18
|
-
* nothing. See {@link SkGraphiteContext}.
|
|
16
|
+
* A view whose frames are recorded from JavaScript, on any runtime, through
|
|
17
|
+
* the context of its ref. See {@link SkGraphiteContext}.
|
|
19
18
|
*/
|
|
20
|
-
export declare const SkiaGraphiteView: ({
|
|
19
|
+
export declare const SkiaGraphiteView: ({ opaque, highBitDepth, android, ref, ...viewProps }: SkiaGraphiteViewProps) => React.JSX.Element;
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useImperativeHandle, useMemo, useRef } from "react";
|
|
3
|
-
import
|
|
3
|
+
import SkiaViewNativeComponent from "../specs/SkiaViewNativeComponent";
|
|
4
|
+
import { Platform } from "../Platform";
|
|
4
5
|
import { SkiaViewApi } from "./api";
|
|
6
|
+
import { androidNativeProps } from "./android";
|
|
5
7
|
import { SkiaViewNativeId } from "./SkiaViewNativeId";
|
|
8
|
+
// The layout is known synchronously on the new architecture;
|
|
9
|
+
// getBoundingClientRect became stable in React Native 0.83. On the web the
|
|
10
|
+
// view measures itself (see SkiaView.web).
|
|
11
|
+
const measureLayout = view => {
|
|
12
|
+
if (Platform.OS === "web") {
|
|
13
|
+
return {
|
|
14
|
+
width: 0,
|
|
15
|
+
height: 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const host = view;
|
|
19
|
+
return host.getBoundingClientRect ? host.getBoundingClientRect() : host.unstable_getBoundingClientRect();
|
|
20
|
+
};
|
|
21
|
+
|
|
6
22
|
/**
|
|
7
|
-
* A view
|
|
8
|
-
*
|
|
9
|
-
* nothing. See {@link SkGraphiteContext}.
|
|
23
|
+
* A view whose frames are recorded from JavaScript, on any runtime, through
|
|
24
|
+
* the context of its ref. See {@link SkGraphiteContext}.
|
|
10
25
|
*/
|
|
11
26
|
export const SkiaGraphiteView = ({
|
|
12
|
-
debug = false,
|
|
13
27
|
opaque = false,
|
|
14
28
|
highBitDepth = false,
|
|
29
|
+
android,
|
|
15
30
|
ref,
|
|
16
31
|
...viewProps
|
|
17
32
|
}) => {
|
|
@@ -21,25 +36,21 @@ export const SkiaGraphiteView = ({
|
|
|
21
36
|
getNativeId: () => nativeId,
|
|
22
37
|
getContext: () => {
|
|
23
38
|
assertSkiaViewApi();
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
39
|
const view = viewRef.current;
|
|
26
40
|
if (!view) {
|
|
27
41
|
throw new Error("SkiaGraphiteView: getContext() was called before the view was mounted.");
|
|
28
42
|
}
|
|
29
|
-
|
|
30
|
-
// getBoundingClientRect became stable in React Native 0.83.
|
|
31
|
-
const size = "getBoundingClientRect" in view ? view.getBoundingClientRect() : view.unstable_getBoundingClientRect();
|
|
43
|
+
const size = measureLayout(view);
|
|
32
44
|
return SkiaViewApi.makeGraphiteContext(nativeId, size.width, size.height, opaque, highBitDepth);
|
|
33
45
|
}
|
|
34
46
|
}), [nativeId, opaque, highBitDepth]);
|
|
35
|
-
return /*#__PURE__*/React.createElement(
|
|
47
|
+
return /*#__PURE__*/React.createElement(SkiaViewNativeComponent, _extends({
|
|
36
48
|
ref: viewRef,
|
|
37
49
|
collapsable: false,
|
|
38
50
|
nativeID: `${nativeId}`,
|
|
39
|
-
debug: debug,
|
|
40
51
|
opaque: opaque,
|
|
41
52
|
highBitDepth: highBitDepth
|
|
42
|
-
}, viewProps));
|
|
53
|
+
}, androidNativeProps(android), viewProps));
|
|
43
54
|
};
|
|
44
55
|
const assertSkiaViewApi = () => {
|
|
45
56
|
if (SkiaViewApi === null || SkiaViewApi.makeGraphiteContext === null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useImperativeHandle","useMemo","useRef","
|
|
1
|
+
{"version":3,"names":["React","useImperativeHandle","useMemo","useRef","SkiaViewNativeComponent","Platform","SkiaViewApi","androidNativeProps","SkiaViewNativeId","measureLayout","view","OS","width","height","host","getBoundingClientRect","unstable_getBoundingClientRect","SkiaGraphiteView","opaque","highBitDepth","android","ref","viewProps","nativeId","current","viewRef","getNativeId","getContext","assertSkiaViewApi","Error","size","makeGraphiteContext","createElement","_extends","collapsable","nativeID"],"sources":["SkiaGraphiteView.tsx"],"sourcesContent":["import React, { useImperativeHandle, useMemo, useRef } from \"react\";\n\nimport type { SkGraphiteContext } from \"../skia/types\";\nimport SkiaViewNativeComponent from \"../specs/SkiaViewNativeComponent\";\nimport { Platform } from \"../Platform\";\n\nimport { SkiaViewApi } from \"./api\";\nimport { androidNativeProps } from \"./android\";\nimport type { SkiaGraphiteViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nexport interface SkiaGraphiteViewRef {\n /**\n * The recording side of the view. Call it once the view is mounted. The\n * returned context can be captured into worklets and used from any runtime.\n */\n getContext(): SkGraphiteContext;\n getNativeId(): number;\n}\n\nexport interface SkiaGraphiteViewProps extends SkiaGraphiteViewNativeProps {\n ref?: React.Ref<SkiaGraphiteViewRef>;\n}\n\n// The layout is known synchronously on the new architecture;\n// getBoundingClientRect became stable in React Native 0.83. On the web the\n// view measures itself (see SkiaView.web).\nconst measureLayout = (view: unknown) => {\n if (Platform.OS === \"web\") {\n return { width: 0, height: 0 };\n }\n const host = view as {\n getBoundingClientRect?: () => { width: number; height: number };\n unstable_getBoundingClientRect: () => { width: number; height: number };\n };\n return host.getBoundingClientRect\n ? host.getBoundingClientRect()\n : host.unstable_getBoundingClientRect();\n};\n\n/**\n * A view whose frames are recorded from JavaScript, on any runtime, through\n * the context of its ref. See {@link SkGraphiteContext}.\n */\nexport const SkiaGraphiteView = ({\n opaque = false,\n highBitDepth = false,\n android,\n ref,\n ...viewProps\n}: SkiaGraphiteViewProps) => {\n const nativeId = useMemo(() => SkiaViewNativeId.current++, []);\n const viewRef =\n useRef<React.ComponentRef<typeof SkiaViewNativeComponent>>(null);\n useImperativeHandle(\n ref,\n () => ({\n getNativeId: () => nativeId,\n getContext: () => {\n assertSkiaViewApi();\n const view = viewRef.current;\n if (!view) {\n throw new Error(\n \"SkiaGraphiteView: getContext() was called before the view was mounted.\"\n );\n }\n const size = measureLayout(view);\n return SkiaViewApi.makeGraphiteContext(\n nativeId,\n size.width,\n size.height,\n opaque,\n highBitDepth\n );\n },\n }),\n [nativeId, opaque, highBitDepth]\n );\n return (\n <SkiaViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n opaque={opaque}\n highBitDepth={highBitDepth}\n {...androidNativeProps(android)}\n {...viewProps}\n />\n );\n};\n\nconst assertSkiaViewApi = () => {\n if (SkiaViewApi === null || SkiaViewApi.makeGraphiteContext === null) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAGnE,OAAOC,uBAAuB,MAAM,kCAAkC;AACtE,SAASC,QAAQ,QAAQ,aAAa;AAEtC,SAASC,WAAW,QAAQ,OAAO;AACnC,SAASC,kBAAkB,QAAQ,WAAW;AAE9C,SAASC,gBAAgB,QAAQ,oBAAoB;AAerD;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,IAAa,IAAK;EACvC,IAAIL,QAAQ,CAACM,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO;MAAEC,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;EAChC;EACA,MAAMC,IAAI,GAAGJ,IAGZ;EACD,OAAOI,IAAI,CAACC,qBAAqB,GAC7BD,IAAI,CAACC,qBAAqB,CAAC,CAAC,GAC5BD,IAAI,CAACE,8BAA8B,CAAC,CAAC;AAC3C,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,MAAM,GAAG,KAAK;EACdC,YAAY,GAAG,KAAK;EACpBC,OAAO;EACPC,GAAG;EACH,GAAGC;AACkB,CAAC,KAAK;EAC3B,MAAMC,QAAQ,GAAGrB,OAAO,CAAC,MAAMM,gBAAgB,CAACgB,OAAO,EAAE,EAAE,EAAE,CAAC;EAC9D,MAAMC,OAAO,GACXtB,MAAM,CAAqD,IAAI,CAAC;EAClEF,mBAAmB,CACjBoB,GAAG,EACH,OAAO;IACLK,WAAW,EAAEA,CAAA,KAAMH,QAAQ;IAC3BI,UAAU,EAAEA,CAAA,KAAM;MAChBC,iBAAiB,CAAC,CAAC;MACnB,MAAMlB,IAAI,GAAGe,OAAO,CAACD,OAAO;MAC5B,IAAI,CAACd,IAAI,EAAE;QACT,MAAM,IAAImB,KAAK,CACb,wEACF,CAAC;MACH;MACA,MAAMC,IAAI,GAAGrB,aAAa,CAACC,IAAI,CAAC;MAChC,OAAOJ,WAAW,CAACyB,mBAAmB,CACpCR,QAAQ,EACRO,IAAI,CAAClB,KAAK,EACVkB,IAAI,CAACjB,MAAM,EACXK,MAAM,EACNC,YACF,CAAC;IACH;EACF,CAAC,CAAC,EACF,CAACI,QAAQ,EAAEL,MAAM,EAAEC,YAAY,CACjC,CAAC;EACD,oBACEnB,KAAA,CAAAgC,aAAA,CAAC5B,uBAAuB,EAAA6B,QAAA;IACtBZ,GAAG,EAAEI,OAAQ;IACbS,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGZ,QAAQ,EAAG;IACxBL,MAAM,EAAEA,MAAO;IACfC,YAAY,EAAEA;EAAa,GACvBZ,kBAAkB,CAACa,OAAO,CAAC,EAC3BE,SAAS,CACd,CAAC;AAEN,CAAC;AAED,MAAMM,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IAAItB,WAAW,KAAK,IAAI,IAAIA,WAAW,CAACyB,mBAAmB,KAAK,IAAI,EAAE;IACpE,MAAMF,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
|
|
@@ -3,8 +3,11 @@ import type { SkRect } from "../skia/types";
|
|
|
3
3
|
import type { SkiaPictureViewNativeProps } from "./types";
|
|
4
4
|
interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
|
|
5
5
|
mode?: "default" | "continuous";
|
|
6
|
-
androidWarmup?: boolean;
|
|
7
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* A view showing a picture. The picture is handed to the native view, which
|
|
9
|
+
* records it once (and again on every redraw) for its surface.
|
|
10
|
+
*/
|
|
8
11
|
export declare class SkiaPictureView extends React.Component<SkiaPictureViewProps> {
|
|
9
12
|
private requestId;
|
|
10
13
|
constructor(props: SkiaPictureViewProps);
|
|
@@ -3,10 +3,14 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
3
3
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
4
4
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
5
|
import React from "react";
|
|
6
|
-
import
|
|
6
|
+
import SkiaViewNativeComponent from "../specs/SkiaViewNativeComponent";
|
|
7
7
|
import { SkiaViewApi } from "./api";
|
|
8
|
+
import { androidNativeProps } from "./android";
|
|
8
9
|
import { SkiaViewNativeId } from "./SkiaViewNativeId";
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* A view showing a picture. The picture is handed to the native view, which
|
|
12
|
+
* records it once (and again on every redraw) for its surface.
|
|
13
|
+
*/
|
|
10
14
|
export class SkiaPictureView extends React.Component {
|
|
11
15
|
constructor(props) {
|
|
12
16
|
super(props);
|
|
@@ -66,21 +70,19 @@ export class SkiaPictureView extends React.Component {
|
|
|
66
70
|
}
|
|
67
71
|
render() {
|
|
68
72
|
const {
|
|
69
|
-
mode,
|
|
70
|
-
|
|
73
|
+
mode: _mode,
|
|
74
|
+
picture: _picture,
|
|
71
75
|
opaque = false,
|
|
72
76
|
highBitDepth = false,
|
|
73
|
-
|
|
77
|
+
android,
|
|
74
78
|
...viewProps
|
|
75
79
|
} = this.props;
|
|
76
|
-
return /*#__PURE__*/React.createElement(
|
|
80
|
+
return /*#__PURE__*/React.createElement(SkiaViewNativeComponent, _extends({
|
|
77
81
|
collapsable: false,
|
|
78
82
|
nativeID: `${this._nativeId}`,
|
|
79
|
-
debug: debug,
|
|
80
83
|
opaque: opaque,
|
|
81
|
-
highBitDepth: highBitDepth
|
|
82
|
-
|
|
83
|
-
}, viewProps));
|
|
84
|
+
highBitDepth: highBitDepth
|
|
85
|
+
}, androidNativeProps(android), viewProps));
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
const assertSkiaViewApi = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","SkiaViewNativeComponent","SkiaViewApi","androidNativeProps","SkiaViewNativeId","SkiaPictureView","Component","constructor","props","_defineProperty","_nativeId","current","picture","assertSkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","bind","makeImageSnapshot","rect","requestRedraw","render","_mode","_picture","opaque","highBitDepth","android","viewProps","createElement","_extends","collapsable","nativeID","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaViewNativeComponent from \"../specs/SkiaViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport { androidNativeProps } from \"./android\";\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\ninterface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\n/**\n * A view showing a picture. The picture is handed to the native view, which\n * records it once (and again on every redraw) for its surface.\n */\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n private requestId = 0;\n\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n this.tick();\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n this.tick();\n }\n\n componentWillUnmount() {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const {\n mode: _mode,\n picture: _picture,\n opaque = false,\n highBitDepth = false,\n android,\n ...viewProps\n } = this.props;\n return (\n <SkiaViewNativeComponent\n collapsable={false}\n nativeID={`${this._nativeId}`}\n opaque={opaque}\n highBitDepth={highBitDepth}\n {...androidNativeProps(android)}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,uBAAuB,MAAM,kCAAkC;AAEtE,SAASC,WAAW,QAAQ,OAAO;AACnC,SAASC,kBAAkB,QAAQ,WAAW;AAE9C,SAASC,gBAAgB,QAAQ,oBAAoB;AAMrD;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAASL,KAAK,CAACM,SAAS,CAAuB;EAGzEC,WAAWA,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,o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AMA,CAAA,EAAG;IACdT,iBAAiB,CAAC,CAAC;IACnBX,WAAW,CAAC0B,aAAa,CAAC,IAAI,CAAClB,SAAS,CAAC;EAC3C;EAEAmB,MAAMA,CAAA,EAAG;IACP,MAAM;MACJN,IAAI,EAAEO,KAAK;MACXlB,OAAO,EAAEmB,QAAQ;MACjBC,MAAM,GAAG,KAAK;MACdC,YAAY,GAAG,KAAK;MACpBC,OAAO;MACP,GAAGC;IACL,CAAC,GAAG,IAAI,CAAC3B,KAAK;IACd,oBACER,KAAA,CAAAoC,aAAA,CAACnC,uBAAuB,EAAAoC,QAAA;MACtBC,WAAW,EAAE,KAAM;MACnBC,QAAQ,EAAE,GAAG,IAAI,CAAC7B,SAAS,EAAG;MAC9BsB,MAAM,EAAEA,MAAO;MACfC,YAAY,EAAEA;IAAa,GACvB9B,kBAAkB,CAAC+B,OAAO,CAAC,EAC3BC,SAAS,CACd,CAAC;EAEN;AACF;AAEA,MAAMtB,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEX,WAAW,KAAK,IAAI,IACpBA,WAAW,CAACY,cAAc,KAAK,IAAI,IACnCZ,WAAW,CAAC0B,aAAa,KAAK,IAAI,IAClC1B,WAAW,CAACwB,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMc,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ViewProps } from "react-native";
|
|
3
|
+
import type { SkiaWebViewHandle } from "../specs/NativeSkiaModule.web";
|
|
4
|
+
export interface SkiaViewHandle extends SkiaWebViewHandle {
|
|
5
|
+
/** The canvas element, for Reanimated's measure(). */
|
|
6
|
+
readonly canvasRef: () => HTMLCanvasElement | null;
|
|
7
|
+
}
|
|
8
|
+
export interface SkiaViewProps extends ViewProps {
|
|
9
|
+
ref?: React.Ref<SkiaViewHandle>;
|
|
10
|
+
__destroyWebGLContextAfterRender?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const SkiaView: (props: SkiaViewProps) => React.JSX.Element;
|
|
@@ -9,12 +9,14 @@ import { Platform } from "../Platform";
|
|
|
9
9
|
import { SkiaViewNativeId } from "./SkiaViewNativeId";
|
|
10
10
|
import { useSkiaWebRenderer } from "./SkiaWebRenderer";
|
|
11
11
|
|
|
12
|
-
// The web has no Graphite:
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
12
|
+
// The web has no Graphite: the view paints pictures on a WebGL canvas (with
|
|
13
|
+
// context-loss recovery and the destroy-context-after-render mode). It shows
|
|
14
|
+
// one of two kinds of content. The picture of a <Canvas> or a
|
|
15
|
+
// <SkiaPictureView> is a whole frame: the latest one wins. The recordings
|
|
16
|
+
// submitted through the view's context (SkiaGraphiteView) keep their native
|
|
17
|
+
// semantics, presented in submission order and never dropped, with one
|
|
18
|
+
// difference: the surface starts cleared on every frame, so a recording draws
|
|
19
|
+
// the whole frame rather than a delta.
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* A frame recorded on the web. The view holds it while it is queued or on
|
|
@@ -99,12 +101,14 @@ class WebGraphiteContext {
|
|
|
99
101
|
dispose() {}
|
|
100
102
|
[Symbol.dispose]() {}
|
|
101
103
|
}
|
|
102
|
-
export const
|
|
104
|
+
export const SkiaView = props => {
|
|
103
105
|
const {
|
|
104
106
|
ref,
|
|
105
107
|
onLayout
|
|
106
108
|
} = props;
|
|
107
109
|
const canvasRef = useRef(null);
|
|
110
|
+
// The picture of a <Canvas> or a <SkiaPictureView>: a whole frame.
|
|
111
|
+
const pictureRef = useRef(null);
|
|
108
112
|
// Recordings submitted since the last frame, in order, and the frame on
|
|
109
113
|
// screen, replayed when the surface is recreated.
|
|
110
114
|
const queueRef = useRef([]);
|
|
@@ -113,9 +117,9 @@ export const SkiaGraphiteView = props => {
|
|
|
113
117
|
const nativeId = useMemo(() => props.nativeID !== undefined ? Number(props.nativeID) : SkiaViewNativeId.current++, [props.nativeID]);
|
|
114
118
|
const isStatic = props.__destroyWebGLContextAfterRender === true;
|
|
115
119
|
|
|
116
|
-
// Presents
|
|
117
|
-
// painted yet (unmeasured canvas, lost context) stays queued for
|
|
118
|
-
// opportunity.
|
|
120
|
+
// Presents the recordings submitted since the last frame. A frame that
|
|
121
|
+
// cannot be painted yet (unmeasured canvas, lost context) stays queued for
|
|
122
|
+
// the next opportunity.
|
|
119
123
|
const present = useCallback(renderer => {
|
|
120
124
|
const frame = queueRef.current;
|
|
121
125
|
if (frame.length === 0) {
|
|
@@ -130,9 +134,14 @@ export const SkiaGraphiteView = props => {
|
|
|
130
134
|
shownRef.current = frame;
|
|
131
135
|
previous.forEach(recording => recording.release());
|
|
132
136
|
}, []);
|
|
137
|
+
|
|
138
|
+
// Paints what the view holds: pending recordings first, else the picture,
|
|
139
|
+
// else the frame on screen again (the surface was recreated).
|
|
133
140
|
const paint = useCallback(renderer => {
|
|
134
141
|
if (queueRef.current.length > 0) {
|
|
135
142
|
present(renderer);
|
|
143
|
+
} else if (pictureRef.current) {
|
|
144
|
+
renderer.draw([pictureRef.current]);
|
|
136
145
|
} else if (shownRef.current.length > 0) {
|
|
137
146
|
renderer.draw(shownRef.current.map(recording => recording.picture));
|
|
138
147
|
}
|
|
@@ -141,25 +150,37 @@ export const SkiaGraphiteView = props => {
|
|
|
141
150
|
paint,
|
|
142
151
|
onLayout
|
|
143
152
|
});
|
|
153
|
+
|
|
154
|
+
// Draws are flushed from a microtask rather than an animation frame: the
|
|
155
|
+
// browser composites once per frame either way, and painting right away
|
|
156
|
+
// keeps a frame produced inside an animation callback (the Reanimated
|
|
157
|
+
// mapper, a frame loop) from slipping to the next one. Deferring to the
|
|
158
|
+
// next animation frame would alternate between "flush pending in this
|
|
159
|
+
// frame" and "flush scheduled for the next frame", halving the effective
|
|
160
|
+
// frame rate. Without a renderer yet (an unmeasured canvas), the content
|
|
161
|
+
// stays held and is painted by the renderer once it exists, so it is
|
|
162
|
+
// never lost.
|
|
144
163
|
const flush = useCallback(() => {
|
|
145
164
|
flushScheduledRef.current = false;
|
|
146
165
|
if (rendererRef.current) {
|
|
147
|
-
|
|
166
|
+
paint(rendererRef.current);
|
|
148
167
|
}
|
|
149
|
-
}, [
|
|
150
|
-
|
|
151
|
-
// Frames are presented from a microtask rather than an animation frame:
|
|
152
|
-
// the browser composites once per frame either way, and painting right
|
|
153
|
-
// away keeps a frame recorded inside an animation callback from slipping
|
|
154
|
-
// to the next one (see SkiaPictureView.web).
|
|
155
|
-
const submit = useCallback(recording => {
|
|
156
|
-
recording.retain();
|
|
157
|
-
queueRef.current.push(recording);
|
|
168
|
+
}, [paint, rendererRef]);
|
|
169
|
+
const redraw = useCallback(() => {
|
|
158
170
|
if (!flushScheduledRef.current) {
|
|
159
171
|
flushScheduledRef.current = true;
|
|
160
172
|
queueMicrotask(flush);
|
|
161
173
|
}
|
|
162
174
|
}, [flush]);
|
|
175
|
+
const setPicture = useCallback(picture => {
|
|
176
|
+
pictureRef.current = picture;
|
|
177
|
+
redraw();
|
|
178
|
+
}, [redraw]);
|
|
179
|
+
const submit = useCallback(recording => {
|
|
180
|
+
recording.retain();
|
|
181
|
+
queueRef.current.push(recording);
|
|
182
|
+
redraw();
|
|
183
|
+
}, [redraw]);
|
|
163
184
|
const getSize = useCallback(() => {
|
|
164
185
|
var _canvasRef$current, _canvasRef$current2;
|
|
165
186
|
return {
|
|
@@ -171,17 +192,23 @@ export const SkiaGraphiteView = props => {
|
|
|
171
192
|
getSize,
|
|
172
193
|
submit
|
|
173
194
|
}), [getSize, submit]);
|
|
174
|
-
const redraw = useCallback(() => {
|
|
175
|
-
if (rendererRef.current) {
|
|
176
|
-
paint(rendererRef.current);
|
|
177
|
-
}
|
|
178
|
-
}, [paint, rendererRef]);
|
|
179
195
|
const makeImageSnapshot = useCallback(rect => {
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
196
|
+
const renderer = rendererRef.current;
|
|
197
|
+
if (!renderer) {
|
|
182
198
|
return null;
|
|
183
199
|
}
|
|
184
|
-
|
|
200
|
+
let frame;
|
|
201
|
+
if (queueRef.current.length > 0) {
|
|
202
|
+
frame = queueRef.current.map(recording => recording.picture);
|
|
203
|
+
} else if (pictureRef.current) {
|
|
204
|
+
frame = [pictureRef.current];
|
|
205
|
+
} else {
|
|
206
|
+
frame = shownRef.current.map(recording => recording.picture);
|
|
207
|
+
}
|
|
208
|
+
if (frame.length === 0) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
return renderer.makeImageSnapshot(frame, rect);
|
|
185
212
|
}, [rendererRef]);
|
|
186
213
|
const measure = useCallback(callback => {
|
|
187
214
|
if (canvasRef.current) {
|
|
@@ -191,7 +218,11 @@ export const SkiaGraphiteView = props => {
|
|
|
191
218
|
left: 0,
|
|
192
219
|
top: 0
|
|
193
220
|
};
|
|
194
|
-
callback(
|
|
221
|
+
callback(
|
|
222
|
+
// x, y are relative to the parent
|
|
223
|
+
rect.left - parentRect.left, rect.top - parentRect.top, rect.width, rect.height,
|
|
224
|
+
// pageX, pageY are absolute screen coordinates
|
|
225
|
+
rect.left + window.scrollX, rect.top + window.scrollY);
|
|
195
226
|
}
|
|
196
227
|
}, []);
|
|
197
228
|
const measureInWindow = useCallback(callback => {
|
|
@@ -200,13 +231,27 @@ export const SkiaGraphiteView = props => {
|
|
|
200
231
|
callback(rect.left, rect.top, rect.width, rect.height);
|
|
201
232
|
}
|
|
202
233
|
}, []);
|
|
234
|
+
|
|
235
|
+
// No flush cancellation is needed on unmount: a microtask queued before
|
|
236
|
+
// unmount runs within the same task, and flush no-ops once the
|
|
237
|
+
// layout-effect cleanup has nulled rendererRef.
|
|
238
|
+
|
|
203
239
|
useImperativeHandle(ref, () => ({
|
|
240
|
+
setPicture,
|
|
204
241
|
getContext,
|
|
205
|
-
|
|
206
|
-
|
|
242
|
+
getSize,
|
|
243
|
+
redraw,
|
|
244
|
+
makeImageSnapshot,
|
|
245
|
+
measure,
|
|
246
|
+
measureInWindow,
|
|
247
|
+
get canvasRef() {
|
|
248
|
+
return () => canvasRef.current;
|
|
249
|
+
}
|
|
250
|
+
}), [setPicture, getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow]);
|
|
207
251
|
useEffect(() => {
|
|
208
252
|
const api = global.SkiaViewApi;
|
|
209
253
|
api.registerView(`${nativeId}`, {
|
|
254
|
+
setPicture,
|
|
210
255
|
getContext,
|
|
211
256
|
getSize,
|
|
212
257
|
redraw,
|
|
@@ -215,9 +260,11 @@ export const SkiaGraphiteView = props => {
|
|
|
215
260
|
measureInWindow
|
|
216
261
|
});
|
|
217
262
|
return () => {
|
|
263
|
+
// Views must be removed on unmount: the handle's closures capture the
|
|
264
|
+
// canvas element, so a stale entry retains the whole detached DOM tree.
|
|
218
265
|
api.unregisterView(`${nativeId}`);
|
|
219
266
|
};
|
|
220
|
-
}, [getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow, nativeId]);
|
|
267
|
+
}, [setPicture, getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow, nativeId]);
|
|
221
268
|
|
|
222
269
|
// Let go of the recordings the view holds.
|
|
223
270
|
useEffect(() => () => {
|
|
@@ -227,9 +274,6 @@ export const SkiaGraphiteView = props => {
|
|
|
227
274
|
shownRef.current = [];
|
|
228
275
|
}, []);
|
|
229
276
|
const {
|
|
230
|
-
debug: _debug,
|
|
231
|
-
opaque: _opaque,
|
|
232
|
-
highBitDepth: _highBitDepth,
|
|
233
277
|
ref: _ref,
|
|
234
278
|
onLayout: _onLayout,
|
|
235
279
|
nativeID: _nativeID,
|
|
@@ -251,4 +295,4 @@ export const SkiaGraphiteView = props => {
|
|
|
251
295
|
}
|
|
252
296
|
}));
|
|
253
297
|
};
|
|
254
|
-
//# sourceMappingURL=
|
|
298
|
+
//# sourceMappingURL=SkiaView.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useMemo","useRef","JsiSkPictureRecorder","Platform","SkiaViewNativeId","useSkiaWebRenderer","WebGraphiteRecording","constructor","picture","_defineProperty","retain","holds","release","disposed","dispose","Symbol","WebGraphiteContext","target","width","getSize","height","beginRecording","recorder","Error","CanvasKit","PictureRecorder","x","y","finishRecording","finishRecordingAsPicture","submit","recording","SkiaView","props","ref","onLayout","canvasRef","pictureRef","queueRef","shownRef","flushScheduledRef","nativeId","nativeID","undefined","Number","current","isStatic","__destroyWebGLContextAfterRender","present","renderer","frame","length","draw","map","previous","forEach","paint","rendererRef","flush","redraw","queueMicrotask","setPicture","push","_canvasRef$current","_canvasRef$current2","clientWidth","clientHeight","getContext","makeImageSnapshot","rect","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","window","scrollX","scrollY","measureInWindow","api","global","SkiaViewApi","registerView","unregisterView","_ref","_onLayout","_nativeID","_isStatic","viewProps","createElement","View","_extends","key","style","display"],"sources":["SkiaView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nimport type {\n SkCanvas,\n SkGraphiteContext,\n SkGraphiteRecording,\n SkImage,\n SkPicture,\n SkRect,\n} from \"../skia/types\";\nimport { JsiSkPictureRecorder } from \"../skia/web/JsiSkPictureRecorder\";\nimport { Platform } from \"../Platform\";\nimport type {\n ISkiaViewApiWeb,\n SkiaWebViewHandle,\n} from \"../specs/NativeSkiaModule.web\";\n\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\nimport { useSkiaWebRenderer } from \"./SkiaWebRenderer\";\nimport type { Renderer, WebFrame } from \"./SkiaWebRenderer\";\n\n// The web has no Graphite: the view paints pictures on a WebGL canvas (with\n// context-loss recovery and the destroy-context-after-render mode). It shows\n// one of two kinds of content. The picture of a <Canvas> or a\n// <SkiaPictureView> is a whole frame: the latest one wins. The recordings\n// submitted through the view's context (SkiaGraphiteView) keep their native\n// semantics, presented in submission order and never dropped, with one\n// difference: the surface starts cleared on every frame, so a recording draws\n// the whole frame rather than a delta.\n\nexport interface SkiaViewHandle extends SkiaWebViewHandle {\n /** The canvas element, for Reanimated's measure(). */\n readonly canvasRef: () => HTMLCanvasElement | null;\n}\n\nexport interface SkiaViewProps extends ViewProps {\n ref?: React.Ref<SkiaViewHandle>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\n/**\n * A frame recorded on the web. The view holds it while it is queued or on\n * screen: disposing it then only marks it, the picture is deleted once the\n * view lets go of it.\n */\nclass WebGraphiteRecording implements SkGraphiteRecording {\n readonly __typename__ = \"GraphiteRecording\" as const;\n private holds = 0;\n private disposed = false;\n\n constructor(readonly picture: SkPicture) {}\n\n retain() {\n this.holds++;\n }\n\n release() {\n this.holds--;\n if (this.disposed && this.holds === 0) {\n this.picture.dispose();\n }\n }\n\n dispose() {\n if (this.disposed) {\n return;\n }\n this.disposed = true;\n if (this.holds === 0) {\n this.picture.dispose();\n }\n }\n\n [Symbol.dispose]() {\n this.dispose();\n }\n}\n\ninterface RecordingTarget {\n getSize(): { width: number; height: number };\n submit(recording: WebGraphiteRecording): void;\n}\n\nclass WebGraphiteContext implements SkGraphiteContext {\n readonly __typename__ = \"GraphiteContext\" as const;\n private recorder: JsiSkPictureRecorder | null = null;\n\n constructor(private readonly target: RecordingTarget) {}\n\n get width() {\n return this.target.getSize().width;\n }\n\n get height() {\n return this.target.getSize().height;\n }\n\n beginRecording(): SkCanvas {\n if (this.recorder) {\n throw new Error(\n \"SkiaGraphiteView: a recording is already open, call finishRecording() first.\"\n );\n }\n const { width, height } = this.target.getSize();\n if (width <= 0 || height <= 0) {\n throw new Error(\"SkiaGraphiteView: the view has no size yet.\");\n }\n this.recorder = new JsiSkPictureRecorder(\n CanvasKit,\n new CanvasKit.PictureRecorder()\n );\n return this.recorder.beginRecording({ x: 0, y: 0, width, height });\n }\n\n finishRecording(): SkGraphiteRecording {\n if (!this.recorder) {\n throw new Error(\n \"SkiaGraphiteView: no recording is open, call beginRecording() first.\"\n );\n }\n const picture = this.recorder.finishRecordingAsPicture();\n this.recorder.dispose();\n this.recorder = null;\n return new WebGraphiteRecording(picture);\n }\n\n submit(recording: SkGraphiteRecording) {\n if (!(recording instanceof WebGraphiteRecording)) {\n throw new Error(\n \"SkiaGraphiteView: submit() expects a recording from finishRecording().\"\n );\n }\n this.target.submit(recording);\n }\n\n dispose() {}\n\n [Symbol.dispose]() {}\n}\n\nexport const SkiaView = (props: SkiaViewProps) => {\n const { ref, onLayout } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n // The picture of a <Canvas> or a <SkiaPictureView>: a whole frame.\n const pictureRef = useRef<SkPicture | null>(null);\n // Recordings submitted since the last frame, in order, and the frame on\n // screen, replayed when the surface is recreated.\n const queueRef = useRef<WebGraphiteRecording[]>([]);\n const shownRef = useRef<WebGraphiteRecording[]>([]);\n const flushScheduledRef = useRef(false);\n const nativeId = useMemo(\n () =>\n props.nativeID !== undefined\n ? Number(props.nativeID)\n : SkiaViewNativeId.current++,\n [props.nativeID]\n );\n\n const isStatic = props.__destroyWebGLContextAfterRender === true;\n\n // Presents the recordings submitted since the last frame. A frame that\n // cannot be painted yet (unmeasured canvas, lost context) stays queued for\n // the next opportunity.\n const present = useCallback((renderer: Renderer) => {\n const frame = queueRef.current;\n if (frame.length === 0) {\n return;\n }\n queueRef.current = [];\n if (!renderer.draw(frame.map((recording) => recording.picture))) {\n queueRef.current = frame;\n return;\n }\n const previous = shownRef.current;\n shownRef.current = frame;\n previous.forEach((recording) => recording.release());\n }, []);\n\n // Paints what the view holds: pending recordings first, else the picture,\n // else the frame on screen again (the surface was recreated).\n const paint = useCallback(\n (renderer: Renderer) => {\n if (queueRef.current.length > 0) {\n present(renderer);\n } else if (pictureRef.current) {\n renderer.draw([pictureRef.current]);\n } else if (shownRef.current.length > 0) {\n renderer.draw(shownRef.current.map((recording) => recording.picture));\n }\n },\n [present]\n );\n const rendererRef = useSkiaWebRenderer(canvasRef, isStatic, {\n paint,\n onLayout,\n });\n\n // Draws are flushed from a microtask rather than an animation frame: the\n // browser composites once per frame either way, and painting right away\n // keeps a frame produced inside an animation callback (the Reanimated\n // mapper, a frame loop) from slipping to the next one. Deferring to the\n // next animation frame would alternate between \"flush pending in this\n // frame\" and \"flush scheduled for the next frame\", halving the effective\n // frame rate. Without a renderer yet (an unmeasured canvas), the content\n // stays held and is painted by the renderer once it exists, so it is\n // never lost.\n const flush = useCallback(() => {\n flushScheduledRef.current = false;\n if (rendererRef.current) {\n paint(rendererRef.current);\n }\n }, [paint, rendererRef]);\n\n const redraw = useCallback(() => {\n if (!flushScheduledRef.current) {\n flushScheduledRef.current = true;\n queueMicrotask(flush);\n }\n }, [flush]);\n\n const setPicture = useCallback(\n (picture: SkPicture) => {\n pictureRef.current = picture;\n redraw();\n },\n [redraw]\n );\n\n const submit = useCallback(\n (recording: WebGraphiteRecording) => {\n recording.retain();\n queueRef.current.push(recording);\n redraw();\n },\n [redraw]\n );\n\n const getSize = useCallback(\n () => ({\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n }),\n []\n );\n\n const getContext = useCallback(\n (): SkGraphiteContext => new WebGraphiteContext({ getSize, submit }),\n [getSize, submit]\n );\n\n const makeImageSnapshot = useCallback(\n (rect?: SkRect): SkImage | null => {\n const renderer = rendererRef.current;\n if (!renderer) {\n return null;\n }\n let frame: WebFrame;\n if (queueRef.current.length > 0) {\n frame = queueRef.current.map((recording) => recording.picture);\n } else if (pictureRef.current) {\n frame = [pictureRef.current];\n } else {\n frame = shownRef.current.map((recording) => recording.picture);\n }\n if (frame.length === 0) {\n return null;\n }\n return renderer.makeImageSnapshot(frame, rect);\n },\n [rendererRef]\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 callback(\n // x, y are relative to the parent\n rect.left - parentRect.left,\n rect.top - parentRect.top,\n rect.width,\n rect.height,\n // pageX, pageY are absolute screen coordinates\n rect.left + window.scrollX,\n rect.top + window.scrollY\n );\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 callback(rect.left, rect.top, rect.width, rect.height);\n }\n },\n []\n );\n\n // No flush cancellation is needed on unmount: a microtask queued before\n // unmount runs within the same task, and flush no-ops once the\n // layout-effect cleanup has nulled rendererRef.\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n ]\n );\n\n useEffect(() => {\n const api = global.SkiaViewApi as ISkiaViewApiWeb;\n api.registerView(`${nativeId}`, {\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n });\n return () => {\n // Views must be removed on unmount: the handle's closures capture the\n // canvas element, so a stale entry retains the whole detached DOM tree.\n api.unregisterView(`${nativeId}`);\n };\n }, [\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n nativeId,\n ]);\n\n // Let go of the recordings the view holds.\n useEffect(\n () => () => {\n queueRef.current.forEach((recording) => recording.release());\n queueRef.current = [];\n shownRef.current.forEach((recording) => recording.release());\n shownRef.current = [];\n },\n []\n );\n\n const {\n ref: _ref,\n onLayout: _onLayout,\n nativeID: _nativeID,\n __destroyWebGLContextAfterRender: _isStatic,\n ...viewProps\n } = props;\n return (\n <Platform.View nativeID={`${nativeId}`} {...viewProps}>\n <canvas\n // A canvas element is bound to one context kind for life (WebGL for\n // the live renderer, 2D for the static one), so switching renderers\n // needs a fresh element.\n key={isStatic ? \"static\" : \"webgl\"}\n ref={canvasRef}\n style={{ display: \"block\", width: \"100%\", height: \"100%\" }}\n />\n </Platform.View>\n );\n};\n"],"mappings":";;;;AAAA;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AAWd,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,QAAQ,QAAQ,aAAa;AAMtC,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,kBAAkB,QAAQ,mBAAmB;;AAGtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,CAAgC;EAKxDC,WAAWA,CAAUC,OAAkB,EAAE;IAAA,KAApBA,OAAkB,GAAlBA,OAAkB;IAAAC,eAAA,uBAJf,mBAAmB;IAAAA,eAAA,gBAC3B,CAAC;IAAAA,eAAA,mBACE,KAAK;EAEkB;EAE1CC,MAAMA,CAAA,EAAG;IACP,IAAI,CAACC,KAAK,EAAE;EACd;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAACD,KAAK,EAAE;IACZ,IAAI,IAAI,CAACE,QAAQ,IAAI,IAAI,CAACF,KAAK,KAAK,CAAC,EAAE;MACrC,IAAI,CAACH,OAAO,CAACM,OAAO,CAAC,CAAC;IACxB;EACF;EAEAA,OAAOA,CAAA,EAAG;IACR,IAAI,IAAI,CAACD,QAAQ,EAAE;MACjB;IACF;IACA,IAAI,CAACA,QAAQ,GAAG,IAAI;IACpB,IAAI,IAAI,CAACF,KAAK,KAAK,CAAC,EAAE;MACpB,IAAI,CAACH,OAAO,CAACM,OAAO,CAAC,CAAC;IACxB;EACF;EAEA,CAACC,MAAM,CAACD,OAAO,IAAI;IACjB,IAAI,CAACA,OAAO,CAAC,CAAC;EAChB;AACF;A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xC,QAAQ,CACT,CAAC;;EAEF;EACA3C,SAAS,CACP,MAAM,MAAM;IACVwC,QAAQ,CAACO,OAAO,CAACU,OAAO,CAAExB,SAAS,IAAKA,SAAS,CAACnB,OAAO,CAAC,CAAC,CAAC;IAC5D0B,QAAQ,CAACO,OAAO,GAAG,EAAE;IACrBN,QAAQ,CAACM,OAAO,CAACU,OAAO,CAAExB,SAAS,IAAKA,SAAS,CAACnB,OAAO,CAAC,CAAC,CAAC;IAC5D2B,QAAQ,CAACM,OAAO,GAAG,EAAE;EACvB,CAAC,EACD,EACF,CAAC;EAED,MAAM;IACJX,GAAG,EAAEqD,IAAI;IACTpD,QAAQ,EAAEqD,SAAS;IACnB9C,QAAQ,EAAE+C,SAAS;IACnB1C,gCAAgC,EAAE2C,SAAS;IAC3C,GAAGC;EACL,CAAC,GAAG1D,KAAK;EACT,oBACErC,KAAA,CAAAgG,aAAA,CAACzF,QAAQ,CAAC0F,IAAI,EAAAC,QAAA;IAACpD,QAAQ,EAAE,GAAGD,QAAQ;EAAG,GAAKkD,SAAS,gBACnD/F,KAAA,CAAAgG,aAAA;IACE;IACA;IACA;IACAG,GAAG,EAAEjD,QAAQ,GAAG,QAAQ,GAAG,OAAQ;IACnCZ,GAAG,EAAEE,SAAU;IACf4D,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAE/E,KAAK,EAAE,MAAM;MAAEE,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
6
6
|
import { useLayoutEffect, useRef } from "react";
|
|
7
7
|
import { JsiSkSurface } from "../skia/web/JsiSkSurface";
|
|
8
8
|
|
|
9
|
-
// The WebGL renderers behind the web
|
|
9
|
+
// The WebGL renderers behind the web view (SkiaView.web):
|
|
10
10
|
// a <canvas> element, its WebGL context and the CanvasKit surface built on
|
|
11
11
|
// it, with the context-loss handling and the "destroy the context after each
|
|
12
12
|
// draw" mode that keeps a page under the browser's live-context limit.
|