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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.SkiaView = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _JsiSkPictureRecorder = require("../skia/web/JsiSkPictureRecorder");
|
|
9
9
|
var _Platform = require("../Platform");
|
|
@@ -14,12 +14,14 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
14
14
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
16
16
|
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); } /* global HTMLCanvasElement */
|
|
17
|
-
// The web has no Graphite:
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
17
|
+
// The web has no Graphite: the view paints pictures on a WebGL canvas (with
|
|
18
|
+
// context-loss recovery and the destroy-context-after-render mode). It shows
|
|
19
|
+
// one of two kinds of content. The picture of a <Canvas> or a
|
|
20
|
+
// <SkiaPictureView> is a whole frame: the latest one wins. The recordings
|
|
21
|
+
// submitted through the view's context (SkiaGraphiteView) keep their native
|
|
22
|
+
// semantics, presented in submission order and never dropped, with one
|
|
23
|
+
// difference: the surface starts cleared on every frame, so a recording draws
|
|
24
|
+
// the whole frame rather than a delta.
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* A frame recorded on the web. The view holds it while it is queued or on
|
|
@@ -104,12 +106,14 @@ class WebGraphiteContext {
|
|
|
104
106
|
dispose() {}
|
|
105
107
|
[Symbol.dispose]() {}
|
|
106
108
|
}
|
|
107
|
-
const
|
|
109
|
+
const SkiaView = props => {
|
|
108
110
|
const {
|
|
109
111
|
ref,
|
|
110
112
|
onLayout
|
|
111
113
|
} = props;
|
|
112
114
|
const canvasRef = (0, _react.useRef)(null);
|
|
115
|
+
// The picture of a <Canvas> or a <SkiaPictureView>: a whole frame.
|
|
116
|
+
const pictureRef = (0, _react.useRef)(null);
|
|
113
117
|
// Recordings submitted since the last frame, in order, and the frame on
|
|
114
118
|
// screen, replayed when the surface is recreated.
|
|
115
119
|
const queueRef = (0, _react.useRef)([]);
|
|
@@ -118,9 +122,9 @@ const SkiaGraphiteView = props => {
|
|
|
118
122
|
const nativeId = (0, _react.useMemo)(() => props.nativeID !== undefined ? Number(props.nativeID) : _SkiaViewNativeId.SkiaViewNativeId.current++, [props.nativeID]);
|
|
119
123
|
const isStatic = props.__destroyWebGLContextAfterRender === true;
|
|
120
124
|
|
|
121
|
-
// Presents
|
|
122
|
-
// painted yet (unmeasured canvas, lost context) stays queued for
|
|
123
|
-
// opportunity.
|
|
125
|
+
// Presents the recordings submitted since the last frame. A frame that
|
|
126
|
+
// cannot be painted yet (unmeasured canvas, lost context) stays queued for
|
|
127
|
+
// the next opportunity.
|
|
124
128
|
const present = (0, _react.useCallback)(renderer => {
|
|
125
129
|
const frame = queueRef.current;
|
|
126
130
|
if (frame.length === 0) {
|
|
@@ -135,9 +139,14 @@ const SkiaGraphiteView = props => {
|
|
|
135
139
|
shownRef.current = frame;
|
|
136
140
|
previous.forEach(recording => recording.release());
|
|
137
141
|
}, []);
|
|
142
|
+
|
|
143
|
+
// Paints what the view holds: pending recordings first, else the picture,
|
|
144
|
+
// else the frame on screen again (the surface was recreated).
|
|
138
145
|
const paint = (0, _react.useCallback)(renderer => {
|
|
139
146
|
if (queueRef.current.length > 0) {
|
|
140
147
|
present(renderer);
|
|
148
|
+
} else if (pictureRef.current) {
|
|
149
|
+
renderer.draw([pictureRef.current]);
|
|
141
150
|
} else if (shownRef.current.length > 0) {
|
|
142
151
|
renderer.draw(shownRef.current.map(recording => recording.picture));
|
|
143
152
|
}
|
|
@@ -146,25 +155,37 @@ const SkiaGraphiteView = props => {
|
|
|
146
155
|
paint,
|
|
147
156
|
onLayout
|
|
148
157
|
});
|
|
158
|
+
|
|
159
|
+
// Draws are flushed from a microtask rather than an animation frame: the
|
|
160
|
+
// browser composites once per frame either way, and painting right away
|
|
161
|
+
// keeps a frame produced inside an animation callback (the Reanimated
|
|
162
|
+
// mapper, a frame loop) from slipping to the next one. Deferring to the
|
|
163
|
+
// next animation frame would alternate between "flush pending in this
|
|
164
|
+
// frame" and "flush scheduled for the next frame", halving the effective
|
|
165
|
+
// frame rate. Without a renderer yet (an unmeasured canvas), the content
|
|
166
|
+
// stays held and is painted by the renderer once it exists, so it is
|
|
167
|
+
// never lost.
|
|
149
168
|
const flush = (0, _react.useCallback)(() => {
|
|
150
169
|
flushScheduledRef.current = false;
|
|
151
170
|
if (rendererRef.current) {
|
|
152
|
-
|
|
171
|
+
paint(rendererRef.current);
|
|
153
172
|
}
|
|
154
|
-
}, [
|
|
155
|
-
|
|
156
|
-
// Frames are presented from a microtask rather than an animation frame:
|
|
157
|
-
// the browser composites once per frame either way, and painting right
|
|
158
|
-
// away keeps a frame recorded inside an animation callback from slipping
|
|
159
|
-
// to the next one (see SkiaPictureView.web).
|
|
160
|
-
const submit = (0, _react.useCallback)(recording => {
|
|
161
|
-
recording.retain();
|
|
162
|
-
queueRef.current.push(recording);
|
|
173
|
+
}, [paint, rendererRef]);
|
|
174
|
+
const redraw = (0, _react.useCallback)(() => {
|
|
163
175
|
if (!flushScheduledRef.current) {
|
|
164
176
|
flushScheduledRef.current = true;
|
|
165
177
|
queueMicrotask(flush);
|
|
166
178
|
}
|
|
167
179
|
}, [flush]);
|
|
180
|
+
const setPicture = (0, _react.useCallback)(picture => {
|
|
181
|
+
pictureRef.current = picture;
|
|
182
|
+
redraw();
|
|
183
|
+
}, [redraw]);
|
|
184
|
+
const submit = (0, _react.useCallback)(recording => {
|
|
185
|
+
recording.retain();
|
|
186
|
+
queueRef.current.push(recording);
|
|
187
|
+
redraw();
|
|
188
|
+
}, [redraw]);
|
|
168
189
|
const getSize = (0, _react.useCallback)(() => {
|
|
169
190
|
var _canvasRef$current, _canvasRef$current2;
|
|
170
191
|
return {
|
|
@@ -176,17 +197,23 @@ const SkiaGraphiteView = props => {
|
|
|
176
197
|
getSize,
|
|
177
198
|
submit
|
|
178
199
|
}), [getSize, submit]);
|
|
179
|
-
const redraw = (0, _react.useCallback)(() => {
|
|
180
|
-
if (rendererRef.current) {
|
|
181
|
-
paint(rendererRef.current);
|
|
182
|
-
}
|
|
183
|
-
}, [paint, rendererRef]);
|
|
184
200
|
const makeImageSnapshot = (0, _react.useCallback)(rect => {
|
|
185
|
-
const
|
|
186
|
-
if (!
|
|
201
|
+
const renderer = rendererRef.current;
|
|
202
|
+
if (!renderer) {
|
|
187
203
|
return null;
|
|
188
204
|
}
|
|
189
|
-
|
|
205
|
+
let frame;
|
|
206
|
+
if (queueRef.current.length > 0) {
|
|
207
|
+
frame = queueRef.current.map(recording => recording.picture);
|
|
208
|
+
} else if (pictureRef.current) {
|
|
209
|
+
frame = [pictureRef.current];
|
|
210
|
+
} else {
|
|
211
|
+
frame = shownRef.current.map(recording => recording.picture);
|
|
212
|
+
}
|
|
213
|
+
if (frame.length === 0) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
return renderer.makeImageSnapshot(frame, rect);
|
|
190
217
|
}, [rendererRef]);
|
|
191
218
|
const measure = (0, _react.useCallback)(callback => {
|
|
192
219
|
if (canvasRef.current) {
|
|
@@ -196,7 +223,11 @@ const SkiaGraphiteView = props => {
|
|
|
196
223
|
left: 0,
|
|
197
224
|
top: 0
|
|
198
225
|
};
|
|
199
|
-
callback(
|
|
226
|
+
callback(
|
|
227
|
+
// x, y are relative to the parent
|
|
228
|
+
rect.left - parentRect.left, rect.top - parentRect.top, rect.width, rect.height,
|
|
229
|
+
// pageX, pageY are absolute screen coordinates
|
|
230
|
+
rect.left + window.scrollX, rect.top + window.scrollY);
|
|
200
231
|
}
|
|
201
232
|
}, []);
|
|
202
233
|
const measureInWindow = (0, _react.useCallback)(callback => {
|
|
@@ -205,13 +236,27 @@ const SkiaGraphiteView = props => {
|
|
|
205
236
|
callback(rect.left, rect.top, rect.width, rect.height);
|
|
206
237
|
}
|
|
207
238
|
}, []);
|
|
239
|
+
|
|
240
|
+
// No flush cancellation is needed on unmount: a microtask queued before
|
|
241
|
+
// unmount runs within the same task, and flush no-ops once the
|
|
242
|
+
// layout-effect cleanup has nulled rendererRef.
|
|
243
|
+
|
|
208
244
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
245
|
+
setPicture,
|
|
209
246
|
getContext,
|
|
210
|
-
|
|
211
|
-
|
|
247
|
+
getSize,
|
|
248
|
+
redraw,
|
|
249
|
+
makeImageSnapshot,
|
|
250
|
+
measure,
|
|
251
|
+
measureInWindow,
|
|
252
|
+
get canvasRef() {
|
|
253
|
+
return () => canvasRef.current;
|
|
254
|
+
}
|
|
255
|
+
}), [setPicture, getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow]);
|
|
212
256
|
(0, _react.useEffect)(() => {
|
|
213
257
|
const api = global.SkiaViewApi;
|
|
214
258
|
api.registerView(`${nativeId}`, {
|
|
259
|
+
setPicture,
|
|
215
260
|
getContext,
|
|
216
261
|
getSize,
|
|
217
262
|
redraw,
|
|
@@ -220,9 +265,11 @@ const SkiaGraphiteView = props => {
|
|
|
220
265
|
measureInWindow
|
|
221
266
|
});
|
|
222
267
|
return () => {
|
|
268
|
+
// Views must be removed on unmount: the handle's closures capture the
|
|
269
|
+
// canvas element, so a stale entry retains the whole detached DOM tree.
|
|
223
270
|
api.unregisterView(`${nativeId}`);
|
|
224
271
|
};
|
|
225
|
-
}, [getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow, nativeId]);
|
|
272
|
+
}, [setPicture, getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow, nativeId]);
|
|
226
273
|
|
|
227
274
|
// Let go of the recordings the view holds.
|
|
228
275
|
(0, _react.useEffect)(() => () => {
|
|
@@ -232,9 +279,6 @@ const SkiaGraphiteView = props => {
|
|
|
232
279
|
shownRef.current = [];
|
|
233
280
|
}, []);
|
|
234
281
|
const {
|
|
235
|
-
debug: _debug,
|
|
236
|
-
opaque: _opaque,
|
|
237
|
-
highBitDepth: _highBitDepth,
|
|
238
282
|
ref: _ref,
|
|
239
283
|
onLayout: _onLayout,
|
|
240
284
|
nativeID: _nativeID,
|
|
@@ -256,5 +300,5 @@ const SkiaGraphiteView = props => {
|
|
|
256
300
|
}
|
|
257
301
|
}));
|
|
258
302
|
};
|
|
259
|
-
exports.
|
|
260
|
-
//# sourceMappingURL=
|
|
303
|
+
exports.SkiaView = SkiaView;
|
|
304
|
+
//# sourceMappingURL=SkiaView.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_JsiSkPictureRecorder","_Platform","_SkiaViewNativeId","_SkiaWebRenderer","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","WebGraphiteRecording","constructor","picture","retain","holds","release","disposed","dispose","WebGraphiteContext","target","width","getSize","height","beginRecording","recorder","Error","JsiSkPictureRecorder","CanvasKit","PictureRecorder","x","y","finishRecording","finishRecordingAsPicture","submit","recording","SkiaView","props","ref","onLayout","canvasRef","useRef","pictureRef","queueRef","shownRef","flushScheduledRef","nativeId","useMemo","nativeID","undefined","SkiaViewNativeId","current","isStatic","__destroyWebGLContextAfterRender","present","useCallback","renderer","frame","draw","map","previous","forEach","paint","rendererRef","useSkiaWebRenderer","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","useImperativeHandle","useEffect","api","global","SkiaViewApi","registerView","unregisterView","_ref","_onLayout","_nativeID","_isStatic","viewProps","createElement","Platform","View","key","style","display","exports"],"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":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAiBA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAAuD,SAAAD,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAA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,OAAO,CAAE1B,SAAS,IAAKA,SAAS,CAACnB,OAAO,CAAC,CAAC,CAAC;IAC5D4B,QAAQ,CAACO,OAAO,GAAG,EAAE;EACvB,CAAC,EACD,EACF,CAAC;EAED,MAAM;IACJb,GAAG,EAAE0D,IAAI;IACTzD,QAAQ,EAAE0D,SAAS;IACnBjD,QAAQ,EAAEkD,SAAS;IACnB7C,gCAAgC,EAAE8C,SAAS;IAC3C,GAAGC;EACL,CAAC,GAAG/D,KAAK;EACT,oBACEtE,MAAA,CAAAiB,OAAA,CAAAqH,aAAA,CAAClI,SAAA,CAAAmI,QAAQ,CAACC,IAAI,EAAA9G,QAAA;IAACuD,QAAQ,EAAE,GAAGF,QAAQ;EAAG,GAAKsD,SAAS,gBACnDrI,MAAA,CAAAiB,OAAA,CAAAqH,aAAA;IACE;IACA;IACA;IACAG,GAAG,EAAEpD,QAAQ,GAAG,QAAQ,GAAG,OAAQ;IACnCd,GAAG,EAAEE,SAAU;IACfiE,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAErF,KAAK,EAAE,MAAM;MAAEE,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC;AAACoF,OAAA,CAAAvE,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ var _JsiSkSurface = require("../skia/web/JsiSkSurface");
|
|
|
9
9
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
11
|
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); } /* global HTMLCanvasElement, ResizeObserver, MediaQueryList */
|
|
12
|
-
// The WebGL renderers behind the web
|
|
12
|
+
// The WebGL renderers behind the web view (SkiaView.web):
|
|
13
13
|
// a <canvas> element, its WebGL context and the CanvasKit surface built on
|
|
14
14
|
// it, with the context-loss handling and the "destroy the context after each
|
|
15
15
|
// draw" mode that keeps a page under the browser's live-context limit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_JsiSkSurface","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","dp2Pixel","pd","rect","undefined","x","y","width","height","canvasWebGL","WeakMap","deleteContextHandle","handle","CanvasKit","deleteContext","MakeWebGLContext","WebGLRenderer","constructor","canvas","requestRedraw","release","restoreWanted","restoreRequest","setTimeout","_canvasWebGL$get","get","loseContext","restoreContext","acquire","entry","owner","addEventListener","onContextLost","onContextRestored","known","gl","isContextLost","lossAnnounced","_known$loseContext","GetWebGLContext","Error","trackContext","grContext","contextHandle","drawingBufferColorSpace","onResize","_canvas$getContext","getContext","getExtension","set","event","preventDefault","_this$surface","surface","ref","delete","releaseResourcesAndAbandonContext","_canvasWebGL$get$gl$i","_canvasWebGL$get2","makeImageSnapshot","frame","getCanvas","clear","TRANSPARENT","draw","flush","_this$surface2","window","devicePixelRatio","clientWidth","clientHeight","MakeOnScreenGLSurface","ColorSpace","SRGB","JsiSkSurface","Float32Array","of","save","scale","picture","drawPicture","restore","dispose","removeEventListener","clearTimeout","queueMicrotask","isConnected","_entry$loseContext","exports","StaticWebGLRenderer","cachedImage","renderFrameToSurface","tempCanvas","OffscreenCanvas","ctx","webglSurface","skiaCanvas","error","cleanupRenderResult","result","_result$surface","_result$tempCanvas$ge","renderResult","ctx2d","drawImage","console","_this$cachedImage","makeLayoutEvent","timeStamp","Date","now","nativeEvent","layout","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","isPropagationStopped","persist","stopPropagation","isTrusted","type","useSkiaWebRenderer","canvasRef","isStatic","host","rendererRef","useRef","hostRef","useLayoutEffect","current","renderer","paint","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","onLayout","left","top","contentRect","observe","media","onPixelDensityChange","watchPixelDensity","_media","matchMedia","query","_media2","disconnect"],"sources":["SkiaWebRenderer.ts"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport type { RefObject } from \"react\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport type { GrDirectContext, WebGLContextHandle } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\n// The WebGL renderers behind the web views (SkiaPictureView, SkiaGraphiteView):\n// a <canvas> element, its WebGL context and the CanvasKit surface built on\n// it, with the context-loss handling and the \"destroy the context after each\n// draw\" mode that keeps a page under the browser's live-context limit.\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\n/**\n * What a view paints: pictures in points, replayed in order onto a cleared\n * surface.\n */\nexport type WebFrame = SkPicture[];\n\nexport interface Renderer {\n onResize(): void;\n /**\n * Paints the frame. Returns false when there is nothing to paint on yet\n * (the canvas is unmeasured, the context is lost): the caller keeps the\n * frame for the next opportunity.\n */\n draw(frame: WebFrame): boolean;\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\n// A <canvas> element owns at most one WebGL context for its whole lifetime.\n// A renderer, on the other hand, lives as long as the layout effect that\n// creates it, which is shorter: React re-runs layout effects on a *preserved*\n// host node under StrictMode's DEV double-invoke and when an Activity/offscreen\n// subtree is hidden and revealed (#3976). What belongs to the element rather\n// than to a renderer is tracked here, per element:\n// - the context, so that a new renderer can tell whether the element already\n// has one (and whether it is lost) without calling getContext() itself,\n// which on a fresh element would create a context with the wrong attributes\n// (CanvasKit.GetWebGLContext requests its own);\n// - the WEBGL_lose_context extension, captured while the context is healthy:\n// getExtension() returns null on a lost context, and this object is the only\n// way to lose a context on purpose or to ask the browser to restore one;\n// - whether the browser has announced the loss of the context yet: a lost\n// context can only be restored once its webglcontextlost event has been\n// dispatched, and that event is asynchronous;\n// - the renderer currently attached to the element, if any.\ninterface CanvasWebGL {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n // The WEBGL_lose_context extension.\n loseContext: { loseContext(): void; restoreContext(): void } | null;\n lossAnnounced: boolean;\n owner: WebGLRenderer | null;\n}\nconst canvasWebGL = new WeakMap<HTMLCanvasElement, CanvasWebGL>();\n\n// Unregisters a context from CanvasKit's registry, which otherwise retains the\n// canvas element (and its detached DOM tree) forever (#3924).\nconst deleteContextHandle = (handle: WebGLContextHandle) => {\n CanvasKit.deleteContext(handle);\n // Making the now-deleted handle current clears CanvasKit's current-context\n // globals (GLctx/Module.ctx), which would otherwise keep referencing the\n // context (and the canvas) until another surface becomes current. With a\n // deleted handle this is a no-op that returns null without creating\n // anything.\n CanvasKit.MakeWebGLContext(handle);\n};\n\nexport class WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n private grContext: GrDirectContext | null = null;\n private contextHandle: WebGLContextHandle = 0;\n private pd = 1;\n // Set while the renderer is waiting for a lost context to be restored.\n private restoreWanted = false;\n private restoreRequest: ReturnType<typeof setTimeout> | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n // Called when the renderer becomes able to paint again and the current\n // frame should be drawn.\n private requestRedraw: () => void\n ) {\n const entry = canvasWebGL.get(canvas);\n if (entry) {\n entry.owner = this;\n }\n canvas.addEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.addEventListener(\"webglcontextrestored\", this.onContextRestored);\n this.acquire();\n }\n\n // Builds the GrDirectContext and the surface on the element's WebGL\n // context, creating the context first if the element has none.\n private acquire() {\n const { canvas } = this;\n const known = canvasWebGL.get(canvas);\n if (known?.gl.isContextLost()) {\n // Nothing can be built on a lost context: CanvasKit.GetWebGLContext\n // happily registers it, and MakeWebGLContext then faults inside wasm\n // (#3976). Ask the browser for it back and finish in onContextRestored;\n // if the loss hasn't been announced yet, onContextLost asks.\n this.restoreWanted = true;\n if (known.lossAnnounced) {\n known.loseContext?.restoreContext();\n }\n return;\n }\n const handle = CanvasKit.GetWebGLContext(canvas);\n if (!handle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n const entry = known ?? this.trackContext();\n let grContext: GrDirectContext | null = null;\n try {\n grContext = CanvasKit.MakeWebGLContext(handle);\n } finally {\n if (!grContext) {\n // Whether it returned null or threw, don't leave the registry\n // holding on to the canvas.\n deleteContextHandle(handle);\n }\n }\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n this.restoreWanted = false;\n this.contextHandle = handle;\n this.grContext = grContext;\n if (entry) {\n entry.gl.drawingBufferColorSpace = \"display-p3\";\n }\n this.onResize();\n }\n\n // CanvasKit just created the element's context; asking for it again hands\n // back the same object (the attributes are only honored the first time).\n private trackContext(): CanvasWebGL | null {\n const { canvas } = this;\n const gl = canvas.getContext(\"webgl2\") ?? canvas.getContext(\"webgl\");\n if (!gl) {\n return null;\n }\n const entry: CanvasWebGL = {\n gl,\n loseContext: gl.getExtension(\"WEBGL_lose_context\"),\n lossAnnounced: false,\n owner: this,\n };\n canvasWebGL.set(canvas, entry);\n // Browsers restore a lost context (evicted as the oldest one when the\n // page exceeds the active-context limit, or lost to a GPU reset) only if\n // the page called preventDefault() on the webglcontextlost event. A\n // renderer isn't necessarily attached when that happens (the canvas may\n // be in a hidden Activity), so these listeners live as long as the\n // element does. They are registered ahead of any renderer's, and the\n // loss can't be announced before they exist since the event is\n // asynchronous.\n canvas.addEventListener(\"webglcontextlost\", (event) => {\n event.preventDefault();\n entry.lossAnnounced = true;\n });\n canvas.addEventListener(\"webglcontextrestored\", () => {\n entry.lossAnnounced = false;\n });\n return entry;\n }\n\n // Frees everything built on the context. The context itself belongs to the\n // element, see dispose().\n private release() {\n this.surface?.ref.delete();\n this.surface = null;\n if (this.grContext) {\n this.grContext.releaseResourcesAndAbandonContext();\n this.grContext.delete();\n this.grContext = null;\n }\n if (this.contextHandle) {\n deleteContextHandle(this.contextHandle);\n this.contextHandle = 0;\n }\n }\n\n private isContextLost() {\n return canvasWebGL.get(this.canvas)?.gl.isContextLost() ?? false;\n }\n\n private onContextLost = () => {\n // The browser already dropped every GL object; drop our references to\n // them. Restoration is left to the browser (it restores an evicted\n // context as soon as a slot frees up), except when this renderer was\n // built on an already-lost context and is waiting to paint for the first\n // time: chasing an eviction from here would evict the next-oldest context\n // in turn, and with more live canvases than the browser allows the\n // canvases would endlessly evict each other.\n this.release();\n if (this.restoreWanted) {\n // The permission granted by preventDefault() is only recorded by the\n // browser once the event dispatch is over: a restoreContext() call\n // from inside the handler is refused, so ask from a later task.\n this.restoreRequest = setTimeout(() => {\n this.restoreRequest = null;\n canvasWebGL.get(this.canvas)?.loseContext?.restoreContext();\n }, 0);\n }\n };\n\n private onContextRestored = () => {\n this.acquire();\n this.requestRedraw();\n };\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.surface || this.isContextLost()) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(frame);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas } = this;\n if (!this.grContext || this.isContextLost()) {\n // Waiting for the context to be restored (the restore path resizes),\n // or the loss hasn't been announced yet and onContextLost is about to\n // release everything: either way there is nothing to build on.\n return;\n }\n this.pd = window.devicePixelRatio;\n canvas.width = canvas.clientWidth * this.pd;\n canvas.height = canvas.clientHeight * this.pd;\n this.surface?.ref.delete();\n this.surface = null;\n if (canvas.width === 0 || canvas.height === 0) {\n // The canvas hasn't been laid out yet (or is hidden). The view's\n // ResizeObserver calls us again as soon as it has a size.\n return;\n }\n // Reuse the existing WebGL context and GrDirectContext: only the surface\n // needs to be recreated when the canvas is resized.\n const surface = CanvasKit.MakeOnScreenGLSurface(\n this.grContext,\n canvas.width,\n canvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(frame: WebFrame) {\n if (!this.surface || this.isContextLost()) {\n return false;\n }\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(this.pd, this.pd);\n for (const picture of frame) {\n canvas.drawPicture(picture);\n }\n canvas.restore();\n this.surface.ref.flush();\n return true;\n }\n\n dispose(): void {\n const { canvas } = this;\n canvas.removeEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.removeEventListener(\"webglcontextrestored\", this.onContextRestored);\n if (this.restoreRequest !== null) {\n clearTimeout(this.restoreRequest);\n this.restoreRequest = null;\n }\n this.restoreWanted = false;\n this.release();\n // Free the drawing buffer, which CanvasKit requests with depth and stencil\n // attachments (about 8 bytes per pixel): a canvas that stays in the\n // document without a renderer, hidden in an Activity say, would otherwise\n // keep a full-size buffer around. The next renderer's onResize() sizes it\n // again.\n canvas.width = 0;\n canvas.height = 0;\n const entry = canvasWebGL.get(canvas);\n if (!entry) {\n return;\n }\n entry.owner = null;\n // Whether the element is going away is only known once the commit is\n // over: on a real unmount React runs this cleanup *before* removing the\n // node from the document, while StrictMode's double-invoke and an\n // Activity hide keep the node in place (and the former builds the next\n // renderer on it right away). Losing the context of a detached element\n // matters: it would otherwise stay alive until the element is garbage\n // collected, and browsers cap the number of live contexts per page\n // (16 in Chrome, which then evicts the oldest one, visible or not).\n queueMicrotask(() => {\n if (\n entry.owner === null &&\n !canvas.isConnected &&\n !entry.gl.isContextLost()\n ) {\n entry.loseContext?.loseContext();\n }\n });\n }\n}\n\ninterface TempRenderResult {\n surface: JsiSkSurface;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext;\n contextHandle: WebGLContextHandle;\n}\n\nexport class StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderFrameToSurface(frame: WebFrame): TempRenderResult | null {\n this.pd = window.devicePixelRatio;\n if (this.canvas.clientWidth === 0 || this.canvas.clientHeight === 0) {\n return null;\n }\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 let grContext: GrDirectContext | null = null;\n let contextHandle: WebGLContextHandle = 0;\n\n try {\n contextHandle = CanvasKit.GetWebGLContext(tempCanvas);\n if (!contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n grContext = CanvasKit.MakeWebGLContext(contextHandle);\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n const webglSurface = CanvasKit.MakeOnScreenGLSurface(\n grContext,\n tempCanvas.width,\n tempCanvas.height,\n CanvasKit.ColorSpace.SRGB\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 for (const picture of frame) {\n skiaCanvas.drawPicture(picture);\n }\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas, grContext, contextHandle };\n } catch (error) {\n this.cleanupRenderResult({\n surface,\n tempCanvas,\n grContext,\n contextHandle,\n });\n return null;\n }\n }\n\n private cleanupRenderResult(result: {\n surface: JsiSkSurface | null;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext | null;\n contextHandle: WebGLContextHandle;\n }): void {\n result.surface?.ref.delete();\n if (result.grContext) {\n result.grContext.releaseResourcesAndAbandonContext();\n result.grContext.delete();\n }\n result.tempCanvas\n .getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (result.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the OffscreenCanvas forever.\n CanvasKit.deleteContext(result.contextHandle);\n // Clear CanvasKit's current-context globals (see WebGLRenderer.dispose).\n CanvasKit.MakeWebGLContext(result.contextHandle);\n }\n }\n\n draw(frame: WebFrame) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return false;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n this.cleanupRenderResult(renderResult);\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.cleanupRenderResult(renderResult);\n return true;\n }\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return null;\n }\n\n try {\n this.cachedImage = renderResult.surface.makeImageSnapshot(\n dp2Pixel(this.pd, rect)\n );\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n this.cleanupRenderResult(renderResult);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\n// Mirrors the event react-native-web synthesizes for onLayout.\nexport const makeLayoutEvent = (\n x: number,\n y: number,\n width: number,\n height: number\n): LayoutChangeEvent => ({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x, y, width, height } },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n currentTarget: 0,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n target: 0,\n bubbles: false,\n cancelable: false,\n defaultPrevented: false,\n eventPhase: 0,\n isDefaultPrevented() {\n throw new Error(\"Method not supported on web.\");\n },\n isPropagationStopped() {\n throw new Error(\"Method not supported on web.\");\n },\n persist() {\n throw new Error(\"Method not supported on web.\");\n },\n preventDefault() {\n throw new Error(\"Method not supported on web.\");\n },\n stopPropagation() {\n throw new Error(\"Method not supported on web.\");\n },\n isTrusted: true,\n type: \"\",\n});\n\nexport interface WebRendererHost {\n /**\n * Paints the view's current content, if any, on a renderer that just got\n * (or got back) a surface: after a resize, a density change or a restored\n * context.\n */\n paint: (renderer: Renderer) => void;\n onLayout?: (event: LayoutChangeEvent) => void;\n}\n\n/**\n * Owns a renderer for the given <canvas> element for as long as the view is\n * mounted, and keeps its surface in step with the element's size and the\n * display's pixel density.\n *\n * The rendering lifecycle deliberately does not depend on layout events:\n * - The renderer is created synchronously on mount (the canvas element is\n * guaranteed to exist in useLayoutEffect; a zero size at that point is\n * fine, the surface is created once the canvas is measurable).\n * - A ResizeObserver on the canvas itself recreates the surface and repaints\n * synchronously (its callbacks run after layout, before paint), and is\n * also the source of the user-facing onLayout event.\n * - The renderer belongs to the layout effect, the WebGL context to the\n * <canvas> element, whose lifetime is longer; see WebGLRenderer for how\n * the two are reconciled.\n */\nexport const useSkiaWebRenderer = (\n canvasRef: RefObject<HTMLCanvasElement | null>,\n isStatic: boolean,\n host: WebRendererHost\n): RefObject<Renderer | null> => {\n const rendererRef = useRef<Renderer | null>(null);\n const hostRef = useRef(host);\n useLayoutEffect(() => {\n hostRef.current = host;\n }, [host]);\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer: Renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas, () => hostRef.current.paint(renderer));\n rendererRef.current = renderer;\n\n const paint = () => hostRef.current.paint(renderer);\n\n // The renderer constructor already sized the surface from the current\n // layout, so the observer's initial delivery only repaints if the size\n // changed in between.\n let lastWidth = canvas.clientWidth;\n let lastHeight = canvas.clientHeight;\n let lastPixelDensity = window.devicePixelRatio;\n const resizeIfNeeded = () => {\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n const pixelDensity = window.devicePixelRatio;\n if (\n width === lastWidth &&\n height === lastHeight &&\n pixelDensity === lastPixelDensity\n ) {\n return;\n }\n lastWidth = width;\n lastHeight = height;\n lastPixelDensity = pixelDensity;\n renderer.onResize();\n paint();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = hostRef.current.onLayout;\n if (layoutHandler) {\n const { left, top, width, height } = entries[0].contentRect;\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () => layoutHandler(makeLayoutEvent(left, top, width, height)),\n 0\n );\n }\n });\n observer.observe(canvas);\n\n // A pixel-density change with no CSS size change (browser zoom, moving\n // the window to another display) doesn't trigger the ResizeObserver:\n // watch it via matchMedia, re-arming the query for each new density.\n // This degrades gracefully where unsupported: without matchMedia or\n // MediaQueryList.addEventListener (older Safari), or where the query\n // never matches because the resolution feature is unknown (Safari < 16),\n // density-only changes simply don't repaint — everything else still does.\n let media: MediaQueryList | null = null;\n const onPixelDensityChange = () => {\n resizeIfNeeded();\n watchPixelDensity();\n };\n const watchPixelDensity = () => {\n media?.removeEventListener(\"change\", onPixelDensityChange);\n media = null;\n if (typeof window.matchMedia === \"function\") {\n const query = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n if (typeof query.addEventListener === \"function\") {\n media = query;\n media.addEventListener(\"change\", onPixelDensityChange);\n }\n }\n };\n watchPixelDensity();\n\n // Paint any content that was dispatched before the renderer existed.\n paint();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [canvasRef, isStatic]);\n\n return rendererRef;\n};\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAD,OAAA;AAAwD,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA,KAPxD;AASA;AACA;AACA;AACA;;AAEA,MAAMgB,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,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GAAGK,KAAK;UACbL,KAAK,CAACvH,gBAAgB,CAAC,QAAQ,EAAEwH,oBAAoB,CAAC;QACxD;MACF;IACF,CAAC;IACDC,iBAAiB,CAAC,CAAC;;IAEnB;IACAjB,KAAK,CAAC,CAAC;IAEP,OAAO,MAAM;MAAA,IAAAqB,OAAA;MACXf,QAAQ,CAACgB,UAAU,CAAC,CAAC;MACrB,CAAAD,OAAA,GAAAN,KAAK,cAAAM,OAAA,eAALA,OAAA,CAAOzE,mBAAmB,CAAC,QAAQ,EAAEoE,oBAAoB,CAAC;MAC1DtB,WAAW,CAACI,OAAO,GAAG,IAAI;MAC1BC,QAAQ,CAACpD,OAAO,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAAC4C,SAAS,EAAEC,QAAQ,CAAC,CAAC;EAEzB,OAAOE,WAAW;AACpB,CAAC;AAACzC,OAAA,CAAAqC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","require","_JsiSkSurface","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","dp2Pixel","pd","rect","undefined","x","y","width","height","canvasWebGL","WeakMap","deleteContextHandle","handle","CanvasKit","deleteContext","MakeWebGLContext","WebGLRenderer","constructor","canvas","requestRedraw","release","restoreWanted","restoreRequest","setTimeout","_canvasWebGL$get","get","loseContext","restoreContext","acquire","entry","owner","addEventListener","onContextLost","onContextRestored","known","gl","isContextLost","lossAnnounced","_known$loseContext","GetWebGLContext","Error","trackContext","grContext","contextHandle","drawingBufferColorSpace","onResize","_canvas$getContext","getContext","getExtension","set","event","preventDefault","_this$surface","surface","ref","delete","releaseResourcesAndAbandonContext","_canvasWebGL$get$gl$i","_canvasWebGL$get2","makeImageSnapshot","frame","getCanvas","clear","TRANSPARENT","draw","flush","_this$surface2","window","devicePixelRatio","clientWidth","clientHeight","MakeOnScreenGLSurface","ColorSpace","SRGB","JsiSkSurface","Float32Array","of","save","scale","picture","drawPicture","restore","dispose","removeEventListener","clearTimeout","queueMicrotask","isConnected","_entry$loseContext","exports","StaticWebGLRenderer","cachedImage","renderFrameToSurface","tempCanvas","OffscreenCanvas","ctx","webglSurface","skiaCanvas","error","cleanupRenderResult","result","_result$surface","_result$tempCanvas$ge","renderResult","ctx2d","drawImage","console","_this$cachedImage","makeLayoutEvent","timeStamp","Date","now","nativeEvent","layout","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","isPropagationStopped","persist","stopPropagation","isTrusted","type","useSkiaWebRenderer","canvasRef","isStatic","host","rendererRef","useRef","hostRef","useLayoutEffect","current","renderer","paint","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","onLayout","left","top","contentRect","observe","media","onPixelDensityChange","watchPixelDensity","_media","matchMedia","query","_media2","disconnect"],"sources":["SkiaWebRenderer.ts"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport type { RefObject } from \"react\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport type { GrDirectContext, WebGLContextHandle } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\n// The WebGL renderers behind the web view (SkiaView.web):\n// a <canvas> element, its WebGL context and the CanvasKit surface built on\n// it, with the context-loss handling and the \"destroy the context after each\n// draw\" mode that keeps a page under the browser's live-context limit.\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\n/**\n * What a view paints: pictures in points, replayed in order onto a cleared\n * surface.\n */\nexport type WebFrame = SkPicture[];\n\nexport interface Renderer {\n onResize(): void;\n /**\n * Paints the frame. Returns false when there is nothing to paint on yet\n * (the canvas is unmeasured, the context is lost): the caller keeps the\n * frame for the next opportunity.\n */\n draw(frame: WebFrame): boolean;\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\n// A <canvas> element owns at most one WebGL context for its whole lifetime.\n// A renderer, on the other hand, lives as long as the layout effect that\n// creates it, which is shorter: React re-runs layout effects on a *preserved*\n// host node under StrictMode's DEV double-invoke and when an Activity/offscreen\n// subtree is hidden and revealed (#3976). What belongs to the element rather\n// than to a renderer is tracked here, per element:\n// - the context, so that a new renderer can tell whether the element already\n// has one (and whether it is lost) without calling getContext() itself,\n// which on a fresh element would create a context with the wrong attributes\n// (CanvasKit.GetWebGLContext requests its own);\n// - the WEBGL_lose_context extension, captured while the context is healthy:\n// getExtension() returns null on a lost context, and this object is the only\n// way to lose a context on purpose or to ask the browser to restore one;\n// - whether the browser has announced the loss of the context yet: a lost\n// context can only be restored once its webglcontextlost event has been\n// dispatched, and that event is asynchronous;\n// - the renderer currently attached to the element, if any.\ninterface CanvasWebGL {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n // The WEBGL_lose_context extension.\n loseContext: { loseContext(): void; restoreContext(): void } | null;\n lossAnnounced: boolean;\n owner: WebGLRenderer | null;\n}\nconst canvasWebGL = new WeakMap<HTMLCanvasElement, CanvasWebGL>();\n\n// Unregisters a context from CanvasKit's registry, which otherwise retains the\n// canvas element (and its detached DOM tree) forever (#3924).\nconst deleteContextHandle = (handle: WebGLContextHandle) => {\n CanvasKit.deleteContext(handle);\n // Making the now-deleted handle current clears CanvasKit's current-context\n // globals (GLctx/Module.ctx), which would otherwise keep referencing the\n // context (and the canvas) until another surface becomes current. With a\n // deleted handle this is a no-op that returns null without creating\n // anything.\n CanvasKit.MakeWebGLContext(handle);\n};\n\nexport class WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n private grContext: GrDirectContext | null = null;\n private contextHandle: WebGLContextHandle = 0;\n private pd = 1;\n // Set while the renderer is waiting for a lost context to be restored.\n private restoreWanted = false;\n private restoreRequest: ReturnType<typeof setTimeout> | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n // Called when the renderer becomes able to paint again and the current\n // frame should be drawn.\n private requestRedraw: () => void\n ) {\n const entry = canvasWebGL.get(canvas);\n if (entry) {\n entry.owner = this;\n }\n canvas.addEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.addEventListener(\"webglcontextrestored\", this.onContextRestored);\n this.acquire();\n }\n\n // Builds the GrDirectContext and the surface on the element's WebGL\n // context, creating the context first if the element has none.\n private acquire() {\n const { canvas } = this;\n const known = canvasWebGL.get(canvas);\n if (known?.gl.isContextLost()) {\n // Nothing can be built on a lost context: CanvasKit.GetWebGLContext\n // happily registers it, and MakeWebGLContext then faults inside wasm\n // (#3976). Ask the browser for it back and finish in onContextRestored;\n // if the loss hasn't been announced yet, onContextLost asks.\n this.restoreWanted = true;\n if (known.lossAnnounced) {\n known.loseContext?.restoreContext();\n }\n return;\n }\n const handle = CanvasKit.GetWebGLContext(canvas);\n if (!handle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n const entry = known ?? this.trackContext();\n let grContext: GrDirectContext | null = null;\n try {\n grContext = CanvasKit.MakeWebGLContext(handle);\n } finally {\n if (!grContext) {\n // Whether it returned null or threw, don't leave the registry\n // holding on to the canvas.\n deleteContextHandle(handle);\n }\n }\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n this.restoreWanted = false;\n this.contextHandle = handle;\n this.grContext = grContext;\n if (entry) {\n entry.gl.drawingBufferColorSpace = \"display-p3\";\n }\n this.onResize();\n }\n\n // CanvasKit just created the element's context; asking for it again hands\n // back the same object (the attributes are only honored the first time).\n private trackContext(): CanvasWebGL | null {\n const { canvas } = this;\n const gl = canvas.getContext(\"webgl2\") ?? canvas.getContext(\"webgl\");\n if (!gl) {\n return null;\n }\n const entry: CanvasWebGL = {\n gl,\n loseContext: gl.getExtension(\"WEBGL_lose_context\"),\n lossAnnounced: false,\n owner: this,\n };\n canvasWebGL.set(canvas, entry);\n // Browsers restore a lost context (evicted as the oldest one when the\n // page exceeds the active-context limit, or lost to a GPU reset) only if\n // the page called preventDefault() on the webglcontextlost event. A\n // renderer isn't necessarily attached when that happens (the canvas may\n // be in a hidden Activity), so these listeners live as long as the\n // element does. They are registered ahead of any renderer's, and the\n // loss can't be announced before they exist since the event is\n // asynchronous.\n canvas.addEventListener(\"webglcontextlost\", (event) => {\n event.preventDefault();\n entry.lossAnnounced = true;\n });\n canvas.addEventListener(\"webglcontextrestored\", () => {\n entry.lossAnnounced = false;\n });\n return entry;\n }\n\n // Frees everything built on the context. The context itself belongs to the\n // element, see dispose().\n private release() {\n this.surface?.ref.delete();\n this.surface = null;\n if (this.grContext) {\n this.grContext.releaseResourcesAndAbandonContext();\n this.grContext.delete();\n this.grContext = null;\n }\n if (this.contextHandle) {\n deleteContextHandle(this.contextHandle);\n this.contextHandle = 0;\n }\n }\n\n private isContextLost() {\n return canvasWebGL.get(this.canvas)?.gl.isContextLost() ?? false;\n }\n\n private onContextLost = () => {\n // The browser already dropped every GL object; drop our references to\n // them. Restoration is left to the browser (it restores an evicted\n // context as soon as a slot frees up), except when this renderer was\n // built on an already-lost context and is waiting to paint for the first\n // time: chasing an eviction from here would evict the next-oldest context\n // in turn, and with more live canvases than the browser allows the\n // canvases would endlessly evict each other.\n this.release();\n if (this.restoreWanted) {\n // The permission granted by preventDefault() is only recorded by the\n // browser once the event dispatch is over: a restoreContext() call\n // from inside the handler is refused, so ask from a later task.\n this.restoreRequest = setTimeout(() => {\n this.restoreRequest = null;\n canvasWebGL.get(this.canvas)?.loseContext?.restoreContext();\n }, 0);\n }\n };\n\n private onContextRestored = () => {\n this.acquire();\n this.requestRedraw();\n };\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.surface || this.isContextLost()) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(frame);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas } = this;\n if (!this.grContext || this.isContextLost()) {\n // Waiting for the context to be restored (the restore path resizes),\n // or the loss hasn't been announced yet and onContextLost is about to\n // release everything: either way there is nothing to build on.\n return;\n }\n this.pd = window.devicePixelRatio;\n canvas.width = canvas.clientWidth * this.pd;\n canvas.height = canvas.clientHeight * this.pd;\n this.surface?.ref.delete();\n this.surface = null;\n if (canvas.width === 0 || canvas.height === 0) {\n // The canvas hasn't been laid out yet (or is hidden). The view's\n // ResizeObserver calls us again as soon as it has a size.\n return;\n }\n // Reuse the existing WebGL context and GrDirectContext: only the surface\n // needs to be recreated when the canvas is resized.\n const surface = CanvasKit.MakeOnScreenGLSurface(\n this.grContext,\n canvas.width,\n canvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(frame: WebFrame) {\n if (!this.surface || this.isContextLost()) {\n return false;\n }\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(this.pd, this.pd);\n for (const picture of frame) {\n canvas.drawPicture(picture);\n }\n canvas.restore();\n this.surface.ref.flush();\n return true;\n }\n\n dispose(): void {\n const { canvas } = this;\n canvas.removeEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.removeEventListener(\"webglcontextrestored\", this.onContextRestored);\n if (this.restoreRequest !== null) {\n clearTimeout(this.restoreRequest);\n this.restoreRequest = null;\n }\n this.restoreWanted = false;\n this.release();\n // Free the drawing buffer, which CanvasKit requests with depth and stencil\n // attachments (about 8 bytes per pixel): a canvas that stays in the\n // document without a renderer, hidden in an Activity say, would otherwise\n // keep a full-size buffer around. The next renderer's onResize() sizes it\n // again.\n canvas.width = 0;\n canvas.height = 0;\n const entry = canvasWebGL.get(canvas);\n if (!entry) {\n return;\n }\n entry.owner = null;\n // Whether the element is going away is only known once the commit is\n // over: on a real unmount React runs this cleanup *before* removing the\n // node from the document, while StrictMode's double-invoke and an\n // Activity hide keep the node in place (and the former builds the next\n // renderer on it right away). Losing the context of a detached element\n // matters: it would otherwise stay alive until the element is garbage\n // collected, and browsers cap the number of live contexts per page\n // (16 in Chrome, which then evicts the oldest one, visible or not).\n queueMicrotask(() => {\n if (\n entry.owner === null &&\n !canvas.isConnected &&\n !entry.gl.isContextLost()\n ) {\n entry.loseContext?.loseContext();\n }\n });\n }\n}\n\ninterface TempRenderResult {\n surface: JsiSkSurface;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext;\n contextHandle: WebGLContextHandle;\n}\n\nexport class StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderFrameToSurface(frame: WebFrame): TempRenderResult | null {\n this.pd = window.devicePixelRatio;\n if (this.canvas.clientWidth === 0 || this.canvas.clientHeight === 0) {\n return null;\n }\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 let grContext: GrDirectContext | null = null;\n let contextHandle: WebGLContextHandle = 0;\n\n try {\n contextHandle = CanvasKit.GetWebGLContext(tempCanvas);\n if (!contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n grContext = CanvasKit.MakeWebGLContext(contextHandle);\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n const webglSurface = CanvasKit.MakeOnScreenGLSurface(\n grContext,\n tempCanvas.width,\n tempCanvas.height,\n CanvasKit.ColorSpace.SRGB\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 for (const picture of frame) {\n skiaCanvas.drawPicture(picture);\n }\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas, grContext, contextHandle };\n } catch (error) {\n this.cleanupRenderResult({\n surface,\n tempCanvas,\n grContext,\n contextHandle,\n });\n return null;\n }\n }\n\n private cleanupRenderResult(result: {\n surface: JsiSkSurface | null;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext | null;\n contextHandle: WebGLContextHandle;\n }): void {\n result.surface?.ref.delete();\n if (result.grContext) {\n result.grContext.releaseResourcesAndAbandonContext();\n result.grContext.delete();\n }\n result.tempCanvas\n .getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (result.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the OffscreenCanvas forever.\n CanvasKit.deleteContext(result.contextHandle);\n // Clear CanvasKit's current-context globals (see WebGLRenderer.dispose).\n CanvasKit.MakeWebGLContext(result.contextHandle);\n }\n }\n\n draw(frame: WebFrame) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return false;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n this.cleanupRenderResult(renderResult);\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.cleanupRenderResult(renderResult);\n return true;\n }\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return null;\n }\n\n try {\n this.cachedImage = renderResult.surface.makeImageSnapshot(\n dp2Pixel(this.pd, rect)\n );\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n this.cleanupRenderResult(renderResult);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\n// Mirrors the event react-native-web synthesizes for onLayout.\nexport const makeLayoutEvent = (\n x: number,\n y: number,\n width: number,\n height: number\n): LayoutChangeEvent => ({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x, y, width, height } },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n currentTarget: 0,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n target: 0,\n bubbles: false,\n cancelable: false,\n defaultPrevented: false,\n eventPhase: 0,\n isDefaultPrevented() {\n throw new Error(\"Method not supported on web.\");\n },\n isPropagationStopped() {\n throw new Error(\"Method not supported on web.\");\n },\n persist() {\n throw new Error(\"Method not supported on web.\");\n },\n preventDefault() {\n throw new Error(\"Method not supported on web.\");\n },\n stopPropagation() {\n throw new Error(\"Method not supported on web.\");\n },\n isTrusted: true,\n type: \"\",\n});\n\nexport interface WebRendererHost {\n /**\n * Paints the view's current content, if any, on a renderer that just got\n * (or got back) a surface: after a resize, a density change or a restored\n * context.\n */\n paint: (renderer: Renderer) => void;\n onLayout?: (event: LayoutChangeEvent) => void;\n}\n\n/**\n * Owns a renderer for the given <canvas> element for as long as the view is\n * mounted, and keeps its surface in step with the element's size and the\n * display's pixel density.\n *\n * The rendering lifecycle deliberately does not depend on layout events:\n * - The renderer is created synchronously on mount (the canvas element is\n * guaranteed to exist in useLayoutEffect; a zero size at that point is\n * fine, the surface is created once the canvas is measurable).\n * - A ResizeObserver on the canvas itself recreates the surface and repaints\n * synchronously (its callbacks run after layout, before paint), and is\n * also the source of the user-facing onLayout event.\n * - The renderer belongs to the layout effect, the WebGL context to the\n * <canvas> element, whose lifetime is longer; see WebGLRenderer for how\n * the two are reconciled.\n */\nexport const useSkiaWebRenderer = (\n canvasRef: RefObject<HTMLCanvasElement | null>,\n isStatic: boolean,\n host: WebRendererHost\n): RefObject<Renderer | null> => {\n const rendererRef = useRef<Renderer | null>(null);\n const hostRef = useRef(host);\n useLayoutEffect(() => {\n hostRef.current = host;\n }, [host]);\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer: Renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas, () => hostRef.current.paint(renderer));\n rendererRef.current = renderer;\n\n const paint = () => hostRef.current.paint(renderer);\n\n // The renderer constructor already sized the surface from the current\n // layout, so the observer's initial delivery only repaints if the size\n // changed in between.\n let lastWidth = canvas.clientWidth;\n let lastHeight = canvas.clientHeight;\n let lastPixelDensity = window.devicePixelRatio;\n const resizeIfNeeded = () => {\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n const pixelDensity = window.devicePixelRatio;\n if (\n width === lastWidth &&\n height === lastHeight &&\n pixelDensity === lastPixelDensity\n ) {\n return;\n }\n lastWidth = width;\n lastHeight = height;\n lastPixelDensity = pixelDensity;\n renderer.onResize();\n paint();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = hostRef.current.onLayout;\n if (layoutHandler) {\n const { left, top, width, height } = entries[0].contentRect;\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () => layoutHandler(makeLayoutEvent(left, top, width, height)),\n 0\n );\n }\n });\n observer.observe(canvas);\n\n // A pixel-density change with no CSS size change (browser zoom, moving\n // the window to another display) doesn't trigger the ResizeObserver:\n // watch it via matchMedia, re-arming the query for each new density.\n // This degrades gracefully where unsupported: without matchMedia or\n // MediaQueryList.addEventListener (older Safari), or where the query\n // never matches because the resolution feature is unknown (Safari < 16),\n // density-only changes simply don't repaint — everything else still does.\n let media: MediaQueryList | null = null;\n const onPixelDensityChange = () => {\n resizeIfNeeded();\n watchPixelDensity();\n };\n const watchPixelDensity = () => {\n media?.removeEventListener(\"change\", onPixelDensityChange);\n media = null;\n if (typeof window.matchMedia === \"function\") {\n const query = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n if (typeof query.addEventListener === \"function\") {\n media = query;\n media.addEventListener(\"change\", onPixelDensityChange);\n }\n }\n };\n watchPixelDensity();\n\n // Paint any content that was dispatched before the renderer existed.\n paint();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [canvasRef, isStatic]);\n\n return rendererRef;\n};\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAD,OAAA;AAAwD,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAA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,cAAAG,MAAA,eAALA,MAAA,CAAOtE,mBAAmB,CAAC,QAAQ,EAAEoE,oBAAoB,CAAC;MAC1DD,KAAK,GAAG,IAAI;MACZ,IAAI,OAAOnF,MAAM,CAACuF,UAAU,KAAK,UAAU,EAAE;QAC3C,MAAMC,KAAK,GAAGxF,MAAM,CAACuF,UAAU,CAC7B,gBAAgBvF,MAAM,CAACC,gBAAgB,OACzC,CAAC;QACD,IAAI,OAAOuF,KAAK,CAAC5H,gBAAgB,KAAK,UAAU,EAAE;UAChDuH,KAAK,GAAGK,KAAK;UACbL,KAAK,CAACvH,gBAAgB,CAAC,QAAQ,EAAEwH,oBAAoB,CAAC;QACxD;MACF;IACF,CAAC;IACDC,iBAAiB,CAAC,CAAC;;IAEnB;IACAjB,KAAK,CAAC,CAAC;IAEP,OAAO,MAAM;MAAA,IAAAqB,OAAA;MACXf,QAAQ,CAACgB,UAAU,CAAC,CAAC;MACrB,CAAAD,OAAA,GAAAN,KAAK,cAAAM,OAAA,eAALA,OAAA,CAAOzE,mBAAmB,CAAC,QAAQ,EAAEoE,oBAAoB,CAAC;MAC1DtB,WAAW,CAACI,OAAO,GAAG,IAAI;MAC1BC,QAAQ,CAACpD,OAAO,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAAC4C,SAAS,EAAEC,QAAQ,CAAC,CAAC;EAEzB,OAAOE,WAAW;AACpB,CAAC;AAACzC,OAAA,CAAAqC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AndroidCanvasProps, AndroidSurfaceType } from "./types";
|
|
2
|
+
/** The native props the `android` prop of a view resolves to. */
|
|
3
|
+
export declare const androidNativeProps: (android?: AndroidCanvasProps) => {
|
|
4
|
+
androidSurfaceType: AndroidSurfaceType | "auto";
|
|
5
|
+
androidZOrderOnTop: boolean;
|
|
6
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.androidNativeProps = void 0;
|
|
7
|
+
// Anything else reaching the native component would hit the generated
|
|
8
|
+
// string-enum parser, which aborts on unknown values.
|
|
9
|
+
const resolveSurfaceType = surfaceType => surfaceType === "SurfaceView" || surfaceType === "TextureView" ? surfaceType : "auto";
|
|
10
|
+
|
|
11
|
+
/** The native props the `android` prop of a view resolves to. */
|
|
12
|
+
const androidNativeProps = android => ({
|
|
13
|
+
androidSurfaceType: resolveSurfaceType(android === null || android === void 0 ? void 0 : android.surfaceType),
|
|
14
|
+
androidZOrderOnTop: !!(android !== null && android !== void 0 && android.zOrderOnTop)
|
|
15
|
+
});
|
|
16
|
+
exports.androidNativeProps = androidNativeProps;
|
|
17
|
+
//# sourceMappingURL=android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["resolveSurfaceType","surfaceType","androidNativeProps","android","androidSurfaceType","androidZOrderOnTop","zOrderOnTop","exports"],"sources":["android.ts"],"sourcesContent":["import type { AndroidCanvasProps, AndroidSurfaceType } from \"./types\";\n\n// Anything else reaching the native component would hit the generated\n// string-enum parser, which aborts on unknown values.\nconst resolveSurfaceType = (\n surfaceType: AndroidSurfaceType | undefined\n): \"auto\" | AndroidSurfaceType =>\n surfaceType === \"SurfaceView\" || surfaceType === \"TextureView\"\n ? surfaceType\n : \"auto\";\n\n/** The native props the `android` prop of a view resolves to. */\nexport const androidNativeProps = (android?: AndroidCanvasProps) => ({\n androidSurfaceType: resolveSurfaceType(android?.surfaceType),\n androidZOrderOnTop: !!android?.zOrderOnTop,\n});\n"],"mappings":";;;;;;AAEA;AACA;AACA,MAAMA,kBAAkB,GACtBC,WAA2C,IAE3CA,WAAW,KAAK,aAAa,IAAIA,WAAW,KAAK,aAAa,GAC1DA,WAAW,GACX,MAAM;;AAEZ;AACO,MAAMC,kBAAkB,GAAIC,OAA4B,KAAM;EACnEC,kBAAkB,EAAEJ,kBAAkB,CAACG,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEF,WAAW,CAAC;EAC5DI,kBAAkB,EAAE,CAAC,EAACF,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEG,WAAW;AAC5C,CAAC,CAAC;AAACC,OAAA,CAAAL,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ViewProps } from "react-native";
|
|
2
2
|
import type { SharedValue } from "react-native-reanimated";
|
|
3
3
|
import type { SkGraphiteContext, SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
|
|
4
|
-
export type NativeSkiaViewProps = ViewProps & {
|
|
5
|
-
debug?: boolean;
|
|
6
|
-
opaque?: boolean;
|
|
7
|
-
};
|
|
8
4
|
export type AndroidSurfaceType = "SurfaceView" | "TextureView";
|
|
9
5
|
export interface AndroidCanvasProps {
|
|
10
6
|
/**
|
|
@@ -35,17 +31,13 @@ export interface ISkiaViewApi {
|
|
|
35
31
|
makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
|
|
36
32
|
size: (nativeId: number) => SkSize;
|
|
37
33
|
/**
|
|
38
|
-
* The recording side of a
|
|
39
|
-
*
|
|
34
|
+
* The recording side of a view: its native id, the layout size in points,
|
|
35
|
+
* and the props its surface format follows from.
|
|
40
36
|
*/
|
|
41
37
|
makeGraphiteContext: (nativeId: number, width: number, height: number, opaque: boolean, highBitDepth: boolean) => SkGraphiteContext;
|
|
42
38
|
}
|
|
39
|
+
/** The props every Skia view takes, whichever way it is drawn. */
|
|
43
40
|
export interface SkiaBaseViewProps extends ViewProps {
|
|
44
|
-
/**
|
|
45
|
-
* When set to true the view will display information about the
|
|
46
|
-
* average time it takes to render.
|
|
47
|
-
*/
|
|
48
|
-
debug?: boolean;
|
|
49
41
|
/**
|
|
50
42
|
* Declares that the canvas covers every pixel of its bounds. On Android an
|
|
51
43
|
* opaque canvas is backed by a `SurfaceView` by default, the cheapest path
|
|
@@ -64,6 +56,5 @@ export interface SkiaBaseViewProps extends ViewProps {
|
|
|
64
56
|
}
|
|
65
57
|
export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
|
|
66
58
|
picture?: SkPicture;
|
|
67
|
-
androidWarmup?: boolean;
|
|
68
59
|
}
|
|
69
60
|
export type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\n\nexport type
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\n\nexport type AndroidSurfaceType = \"SurfaceView\" | \"TextureView\";\n\nexport interface AndroidCanvasProps {\n /**\n * Backing view. Defaults to `SurfaceView` when the canvas is `opaque` and to\n * `TextureView` otherwise; both composite correctly in React Native stacking\n * order without further flags.\n */\n surfaceType?: AndroidSurfaceType;\n /**\n * SurfaceView only: composite above every React Native view in the window,\n * ignoring `zIndex`. Ignored for TextureView. Defaults to false.\n */\n zOrderOnTop?: boolean;\n}\n\nexport interface ISkiaViewApi {\n web?: boolean;\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n /**\n * Reads the shared values into the recording held for the view and\n * schedules a redraw. Native only; called from a worklet on every frame.\n * Until the view registers, the recording is queued for it and kept\n * current all the same. Ignored when the recording `recorderId` is neither\n * held by the view nor queued for it.\n */\n applyUpdates: (\n nativeId: number,\n recorderId: number,\n values: SharedValue<unknown>[]\n ) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n size: (nativeId: number) => SkSize;\n /**\n * The recording side of a view: its native id, the layout size in points,\n * and the props its surface format follows from.\n */\n makeGraphiteContext: (\n nativeId: number,\n width: number,\n height: number,\n opaque: boolean,\n highBitDepth: boolean\n ) => SkGraphiteContext;\n}\n\n/** The props every Skia view takes, whichever way it is drawn. */\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * Declares that the canvas covers every pixel of its bounds. On Android an\n * opaque canvas is backed by a `SurfaceView` by default, the cheapest path\n * (see `android.surfaceType`). Defaults to false.\n */\n opaque?: boolean;\n\n /**\n * Renders into a surface with more than 8 bits per channel (16-bit float on\n * iOS, 10-bit on Android) to avoid banding in subtle gradients. On Android\n * the extra precision survives composition only when combined with `opaque`.\n */\n highBitDepth?: boolean;\n\n /** Android-only rendering options. Ignored on iOS and web. */\n android?: AndroidCanvasProps;\n\n // On web, only 16 WebGL contextes are allowed. If the drawing is non-animated, set\n // __destroyWebGLContextAfterRender to true to release the context after each draw.\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { isRNModule, unwrapModule } from "../skia/types";
|
|
3
|
-
// Layout is observed by the views themselves (see
|
|
3
|
+
// Layout is observed by the views themselves (see SkiaView.web.tsx):
|
|
4
4
|
// this shim only reproduces react-native-web's default View styling.
|
|
5
5
|
const View = ({
|
|
6
6
|
children,
|