@shopify/react-native-skia 2.11.2 → 2.12.0
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 +117 -0
- package/android/CMakeLists.txt +1 -2
- package/cpp/api/JsiSkSVGFactory.h +4 -0
- package/cpp/jsi/JSICache.cpp +99 -0
- package/cpp/jsi/JSICache.h +90 -0
- package/cpp/jsi/NativeObject.h +30 -97
- package/cpp/jsi/ViewProperty.h +0 -24
- package/cpp/rnskia/RNDawnContext.h +2 -1
- package/cpp/rnskia/RNDawnWindowContext.h +22 -0
- package/cpp/rnskia/RNSkManager.cpp +0 -11
- package/cpp/skia/include/core/RasterContext.h +25 -0
- package/cpp/skia/include/core/SkCanvas.h +0 -1
- package/cpp/skia/include/core/SkContext.h +62 -0
- package/cpp/skia/include/core/SkContextOptions.h +15 -0
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPicture.h +36 -18
- package/cpp/skia/include/core/SkRecorder.h +8 -0
- package/cpp/skia/include/core/SkSerialProcs.h +2 -6
- package/cpp/skia/include/effects/SkImageFilters.h +15 -2
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +73 -47
- package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +7 -4
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +12 -0
- package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +11 -0
- package/cpp/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h +11 -0
- package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +13 -0
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +6 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +5 -4
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +9 -1
- package/cpp/skia/include/gpu/graphite/Recorder.h +0 -2
- package/cpp/skia/include/gpu/graphite/Recording.h +3 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +8 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +11 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +11 -0
- package/cpp/skia/include/private/SkLog.h +1 -19
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +2 -1
- package/cpp/skia/include/utils/SkLogHandler.h +53 -0
- package/cpp/skia/include/utils/SkNWayCanvas.h +1 -0
- package/cpp/skia/modules/skcms/src/Transform_inl.h +9 -10
- package/cpp/skia/modules/skcms/src/skcms_internals.h +8 -3
- package/cpp/skia/modules/skottie/include/SkottieProperty.h +2 -0
- package/cpp/skia/modules/skottie/include/TextShaper.h +1 -0
- package/cpp/skia/modules/skshaper/include/SkShaper.h +23 -1
- package/include/ReactNativeSkia.h +6 -0
- package/lib/commonjs/skia/web/JsiSkCanvas.js +4 -4
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +6 -3
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js +2 -2
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextStyle.js +5 -5
- package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js +8 -8
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +2 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +228 -43
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +4 -4
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +6 -3
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.js +2 -2
- package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextStyle.js +5 -5
- package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkottieAnimation.js +8 -8
- package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +2 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +228 -43
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/typescript/react-native.config.d.ts +3 -0
- package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/package.json +12 -9
- package/react-native.config.js +5 -0
- package/src/skia/web/JsiSkCanvas.ts +11 -6
- package/src/skia/web/JsiSkImage.ts +6 -3
- package/src/skia/web/JsiSkPathBuilder.ts +2 -2
- package/src/skia/web/JsiSkTextStyle.ts +20 -15
- package/src/skia/web/JsiSkottieAnimation.ts +8 -8
- package/src/sksg/Recorder/commands/Drawing.ts +2 -1
- package/src/views/SkiaPictureView.web.tsx +228 -43
- package/cpp/jsi/RuntimeAwareCache.cpp +0 -8
- package/cpp/jsi/RuntimeAwareCache.h +0 -146
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +0 -72
- package/cpp/jsi/RuntimeLifecycleMonitor.h +0 -32
|
@@ -23,31 +23,189 @@ const dp2Pixel = (pd, rect) => {
|
|
|
23
23
|
height: rect.height * pd
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
// A <canvas> element owns at most one WebGL context for its whole lifetime.
|
|
28
|
+
// A renderer, on the other hand, lives as long as the layout effect that
|
|
29
|
+
// creates it, which is shorter: React re-runs layout effects on a *preserved*
|
|
30
|
+
// host node under StrictMode's DEV double-invoke and when an Activity/offscreen
|
|
31
|
+
// subtree is hidden and revealed (#3976). What belongs to the element rather
|
|
32
|
+
// than to a renderer is tracked here, per element:
|
|
33
|
+
// - the context, so that a new renderer can tell whether the element already
|
|
34
|
+
// has one (and whether it is lost) without calling getContext() itself,
|
|
35
|
+
// which on a fresh element would create a context with the wrong attributes
|
|
36
|
+
// (CanvasKit.GetWebGLContext requests its own);
|
|
37
|
+
// - the WEBGL_lose_context extension, captured while the context is healthy:
|
|
38
|
+
// getExtension() returns null on a lost context, and this object is the only
|
|
39
|
+
// way to lose a context on purpose or to ask the browser to restore one;
|
|
40
|
+
// - whether the browser has announced the loss of the context yet: a lost
|
|
41
|
+
// context can only be restored once its webglcontextlost event has been
|
|
42
|
+
// dispatched, and that event is asynchronous;
|
|
43
|
+
// - the renderer currently attached to the element, if any.
|
|
44
|
+
|
|
45
|
+
const canvasWebGL = new WeakMap();
|
|
46
|
+
|
|
47
|
+
// Unregisters a context from CanvasKit's registry, which otherwise retains the
|
|
48
|
+
// canvas element (and its detached DOM tree) forever (#3924).
|
|
49
|
+
const deleteContextHandle = handle => {
|
|
50
|
+
CanvasKit.deleteContext(handle);
|
|
51
|
+
// Making the now-deleted handle current clears CanvasKit's current-context
|
|
52
|
+
// globals (GLctx/Module.ctx), which would otherwise keep referencing the
|
|
53
|
+
// context (and the canvas) until another surface becomes current. With a
|
|
54
|
+
// deleted handle this is a no-op that returns null without creating
|
|
55
|
+
// anything.
|
|
56
|
+
CanvasKit.MakeWebGLContext(handle);
|
|
57
|
+
};
|
|
26
58
|
class WebGLRenderer {
|
|
27
|
-
constructor(canvas
|
|
59
|
+
constructor(canvas,
|
|
60
|
+
// Called when the renderer becomes able to paint again and the current
|
|
61
|
+
// picture should be drawn.
|
|
62
|
+
requestRedraw) {
|
|
28
63
|
this.canvas = canvas;
|
|
64
|
+
this.requestRedraw = requestRedraw;
|
|
29
65
|
_defineProperty(this, "surface", null);
|
|
30
66
|
_defineProperty(this, "grContext", null);
|
|
31
67
|
_defineProperty(this, "contextHandle", 0);
|
|
32
68
|
_defineProperty(this, "pd", 1);
|
|
33
|
-
|
|
34
|
-
|
|
69
|
+
// Set while the renderer is waiting for a lost context to be restored.
|
|
70
|
+
_defineProperty(this, "restoreWanted", false);
|
|
71
|
+
_defineProperty(this, "restoreRequest", null);
|
|
72
|
+
_defineProperty(this, "onContextLost", () => {
|
|
73
|
+
// The browser already dropped every GL object; drop our references to
|
|
74
|
+
// them. Restoration is left to the browser (it restores an evicted
|
|
75
|
+
// context as soon as a slot frees up), except when this renderer was
|
|
76
|
+
// built on an already-lost context and is waiting to paint for the first
|
|
77
|
+
// time: chasing an eviction from here would evict the next-oldest context
|
|
78
|
+
// in turn, and with more live canvases than the browser allows the
|
|
79
|
+
// canvases would endlessly evict each other.
|
|
80
|
+
this.release();
|
|
81
|
+
if (this.restoreWanted) {
|
|
82
|
+
// The permission granted by preventDefault() is only recorded by the
|
|
83
|
+
// browser once the event dispatch is over: a restoreContext() call
|
|
84
|
+
// from inside the handler is refused, so ask from a later task.
|
|
85
|
+
this.restoreRequest = setTimeout(() => {
|
|
86
|
+
var _canvasWebGL$get;
|
|
87
|
+
this.restoreRequest = null;
|
|
88
|
+
(_canvasWebGL$get = canvasWebGL.get(this.canvas)) === null || _canvasWebGL$get === void 0 || (_canvasWebGL$get = _canvasWebGL$get.loseContext) === null || _canvasWebGL$get === void 0 || _canvasWebGL$get.restoreContext();
|
|
89
|
+
}, 0);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
_defineProperty(this, "onContextRestored", () => {
|
|
93
|
+
this.acquire();
|
|
94
|
+
this.requestRedraw();
|
|
95
|
+
});
|
|
96
|
+
const entry = canvasWebGL.get(canvas);
|
|
97
|
+
if (entry) {
|
|
98
|
+
entry.owner = this;
|
|
99
|
+
}
|
|
100
|
+
canvas.addEventListener("webglcontextlost", this.onContextLost);
|
|
101
|
+
canvas.addEventListener("webglcontextrestored", this.onContextRestored);
|
|
102
|
+
this.acquire();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Builds the GrDirectContext and the surface on the element's WebGL
|
|
106
|
+
// context, creating the context first if the element has none.
|
|
107
|
+
acquire() {
|
|
108
|
+
const {
|
|
109
|
+
canvas
|
|
110
|
+
} = this;
|
|
111
|
+
const known = canvasWebGL.get(canvas);
|
|
112
|
+
if (known !== null && known !== void 0 && known.gl.isContextLost()) {
|
|
113
|
+
// Nothing can be built on a lost context: CanvasKit.GetWebGLContext
|
|
114
|
+
// happily registers it, and MakeWebGLContext then faults inside wasm
|
|
115
|
+
// (#3976). Ask the browser for it back and finish in onContextRestored;
|
|
116
|
+
// if the loss hasn't been announced yet, onContextLost asks.
|
|
117
|
+
this.restoreWanted = true;
|
|
118
|
+
if (known.lossAnnounced) {
|
|
119
|
+
var _known$loseContext;
|
|
120
|
+
(_known$loseContext = known.loseContext) === null || _known$loseContext === void 0 || _known$loseContext.restoreContext();
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const handle = CanvasKit.GetWebGLContext(canvas);
|
|
125
|
+
if (!handle) {
|
|
35
126
|
throw new Error("Could not create a WebGL context");
|
|
36
127
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
128
|
+
const entry = known !== null && known !== void 0 ? known : this.trackContext();
|
|
129
|
+
let grContext = null;
|
|
130
|
+
try {
|
|
131
|
+
grContext = CanvasKit.MakeWebGLContext(handle);
|
|
132
|
+
} finally {
|
|
133
|
+
if (!grContext) {
|
|
134
|
+
// Whether it returned null or threw, don't leave the registry
|
|
135
|
+
// holding on to the canvas.
|
|
136
|
+
deleteContextHandle(handle);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (!grContext) {
|
|
41
140
|
throw new Error("Could not create a graphics context");
|
|
42
141
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
142
|
+
this.restoreWanted = false;
|
|
143
|
+
this.contextHandle = handle;
|
|
144
|
+
this.grContext = grContext;
|
|
145
|
+
if (entry) {
|
|
146
|
+
entry.gl.drawingBufferColorSpace = "display-p3";
|
|
46
147
|
}
|
|
47
148
|
this.onResize();
|
|
48
149
|
}
|
|
150
|
+
|
|
151
|
+
// CanvasKit just created the element's context; asking for it again hands
|
|
152
|
+
// back the same object (the attributes are only honored the first time).
|
|
153
|
+
trackContext() {
|
|
154
|
+
var _canvas$getContext;
|
|
155
|
+
const {
|
|
156
|
+
canvas
|
|
157
|
+
} = this;
|
|
158
|
+
const gl = (_canvas$getContext = canvas.getContext("webgl2")) !== null && _canvas$getContext !== void 0 ? _canvas$getContext : canvas.getContext("webgl");
|
|
159
|
+
if (!gl) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const entry = {
|
|
163
|
+
gl,
|
|
164
|
+
loseContext: gl.getExtension("WEBGL_lose_context"),
|
|
165
|
+
lossAnnounced: false,
|
|
166
|
+
owner: this
|
|
167
|
+
};
|
|
168
|
+
canvasWebGL.set(canvas, entry);
|
|
169
|
+
// Browsers restore a lost context (evicted as the oldest one when the
|
|
170
|
+
// page exceeds the active-context limit, or lost to a GPU reset) only if
|
|
171
|
+
// the page called preventDefault() on the webglcontextlost event. A
|
|
172
|
+
// renderer isn't necessarily attached when that happens (the canvas may
|
|
173
|
+
// be in a hidden Activity), so these listeners live as long as the
|
|
174
|
+
// element does. They are registered ahead of any renderer's, and the
|
|
175
|
+
// loss can't be announced before they exist since the event is
|
|
176
|
+
// asynchronous.
|
|
177
|
+
canvas.addEventListener("webglcontextlost", event => {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
entry.lossAnnounced = true;
|
|
180
|
+
});
|
|
181
|
+
canvas.addEventListener("webglcontextrestored", () => {
|
|
182
|
+
entry.lossAnnounced = false;
|
|
183
|
+
});
|
|
184
|
+
return entry;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Frees everything built on the context. The context itself belongs to the
|
|
188
|
+
// element, see dispose().
|
|
189
|
+
release() {
|
|
190
|
+
var _this$surface;
|
|
191
|
+
(_this$surface = this.surface) === null || _this$surface === void 0 || _this$surface.ref.delete();
|
|
192
|
+
this.surface = null;
|
|
193
|
+
if (this.grContext) {
|
|
194
|
+
this.grContext.releaseResourcesAndAbandonContext();
|
|
195
|
+
this.grContext.delete();
|
|
196
|
+
this.grContext = null;
|
|
197
|
+
}
|
|
198
|
+
if (this.contextHandle) {
|
|
199
|
+
deleteContextHandle(this.contextHandle);
|
|
200
|
+
this.contextHandle = 0;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
isContextLost() {
|
|
204
|
+
var _canvasWebGL$get$gl$i, _canvasWebGL$get2;
|
|
205
|
+
return (_canvasWebGL$get$gl$i = (_canvasWebGL$get2 = canvasWebGL.get(this.canvas)) === null || _canvasWebGL$get2 === void 0 ? void 0 : _canvasWebGL$get2.gl.isContextLost()) !== null && _canvasWebGL$get$gl$i !== void 0 ? _canvasWebGL$get$gl$i : false;
|
|
206
|
+
}
|
|
49
207
|
makeImageSnapshot(picture, rect) {
|
|
50
|
-
if (!this.surface) {
|
|
208
|
+
if (!this.surface || this.isContextLost()) {
|
|
51
209
|
return null;
|
|
52
210
|
}
|
|
53
211
|
const canvas = this.surface.getCanvas();
|
|
@@ -57,17 +215,20 @@ class WebGLRenderer {
|
|
|
57
215
|
return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));
|
|
58
216
|
}
|
|
59
217
|
onResize() {
|
|
60
|
-
var _this$
|
|
218
|
+
var _this$surface2;
|
|
61
219
|
const {
|
|
62
220
|
canvas
|
|
63
221
|
} = this;
|
|
64
|
-
if (!this.grContext) {
|
|
222
|
+
if (!this.grContext || this.isContextLost()) {
|
|
223
|
+
// Waiting for the context to be restored (the restore path resizes),
|
|
224
|
+
// or the loss hasn't been announced yet and onContextLost is about to
|
|
225
|
+
// release everything: either way there is nothing to build on.
|
|
65
226
|
return;
|
|
66
227
|
}
|
|
67
228
|
this.pd = window.devicePixelRatio;
|
|
68
229
|
canvas.width = canvas.clientWidth * this.pd;
|
|
69
230
|
canvas.height = canvas.clientHeight * this.pd;
|
|
70
|
-
(_this$
|
|
231
|
+
(_this$surface2 = this.surface) === null || _this$surface2 === void 0 || _this$surface2.ref.delete();
|
|
71
232
|
this.surface = null;
|
|
72
233
|
if (canvas.width === 0 || canvas.height === 0) {
|
|
73
234
|
// The canvas hasn't been laid out yet (or is hidden). The view's
|
|
@@ -83,38 +244,55 @@ class WebGLRenderer {
|
|
|
83
244
|
this.surface = new _JsiSkSurface.JsiSkSurface(CanvasKit, surface);
|
|
84
245
|
}
|
|
85
246
|
draw(picture) {
|
|
86
|
-
if (this.surface) {
|
|
87
|
-
|
|
88
|
-
canvas.clear(Float32Array.of(0, 0, 0, 0));
|
|
89
|
-
canvas.save();
|
|
90
|
-
canvas.scale(this.pd, this.pd);
|
|
91
|
-
canvas.drawPicture(picture);
|
|
92
|
-
canvas.restore();
|
|
93
|
-
this.surface.ref.flush();
|
|
247
|
+
if (!this.surface || this.isContextLost()) {
|
|
248
|
+
return;
|
|
94
249
|
}
|
|
250
|
+
const canvas = this.surface.getCanvas();
|
|
251
|
+
canvas.clear(Float32Array.of(0, 0, 0, 0));
|
|
252
|
+
canvas.save();
|
|
253
|
+
canvas.scale(this.pd, this.pd);
|
|
254
|
+
canvas.drawPicture(picture);
|
|
255
|
+
canvas.restore();
|
|
256
|
+
this.surface.ref.flush();
|
|
95
257
|
}
|
|
96
258
|
dispose() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.
|
|
259
|
+
const {
|
|
260
|
+
canvas
|
|
261
|
+
} = this;
|
|
262
|
+
canvas.removeEventListener("webglcontextlost", this.onContextLost);
|
|
263
|
+
canvas.removeEventListener("webglcontextrestored", this.onContextRestored);
|
|
264
|
+
if (this.restoreRequest !== null) {
|
|
265
|
+
clearTimeout(this.restoreRequest);
|
|
266
|
+
this.restoreRequest = null;
|
|
104
267
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
268
|
+
this.restoreWanted = false;
|
|
269
|
+
this.release();
|
|
270
|
+
// Free the drawing buffer, which CanvasKit requests with depth and stencil
|
|
271
|
+
// attachments (about 8 bytes per pixel): a canvas that stays in the
|
|
272
|
+
// document without a renderer, hidden in an Activity say, would otherwise
|
|
273
|
+
// keep a full-size buffer around. The next renderer's onResize() sizes it
|
|
274
|
+
// again.
|
|
275
|
+
canvas.width = 0;
|
|
276
|
+
canvas.height = 0;
|
|
277
|
+
const entry = canvasWebGL.get(canvas);
|
|
278
|
+
if (!entry) {
|
|
279
|
+
return;
|
|
117
280
|
}
|
|
281
|
+
entry.owner = null;
|
|
282
|
+
// Whether the element is going away is only known once the commit is
|
|
283
|
+
// over: on a real unmount React runs this cleanup *before* removing the
|
|
284
|
+
// node from the document, while StrictMode's double-invoke and an
|
|
285
|
+
// Activity hide keep the node in place (and the former builds the next
|
|
286
|
+
// renderer on it right away). Losing the context of a detached element
|
|
287
|
+
// matters: it would otherwise stay alive until the element is garbage
|
|
288
|
+
// collected, and browsers cap the number of live contexts per page
|
|
289
|
+
// (16 in Chrome, which then evicts the oldest one, visible or not).
|
|
290
|
+
queueMicrotask(() => {
|
|
291
|
+
if (entry.owner === null && !canvas.isConnected && !entry.gl.isContextLost()) {
|
|
292
|
+
var _entry$loseContext;
|
|
293
|
+
(_entry$loseContext = entry.loseContext) === null || _entry$loseContext === void 0 || _entry$loseContext.loseContext();
|
|
294
|
+
}
|
|
295
|
+
});
|
|
118
296
|
}
|
|
119
297
|
}
|
|
120
298
|
class StaticWebGLRenderer {
|
|
@@ -301,6 +479,9 @@ const SkiaPictureView = props => {
|
|
|
301
479
|
// - A ResizeObserver on the canvas itself recreates the surface and repaints
|
|
302
480
|
// synchronously (its callbacks run after layout, before paint), and is
|
|
303
481
|
// also the source of the user-facing onLayout event.
|
|
482
|
+
// - The renderer belongs to the layout effect, the WebGL context to the
|
|
483
|
+
// <canvas> element, whose lifetime is longer; see WebGLRenderer for how
|
|
484
|
+
// the two are reconciled.
|
|
304
485
|
const redrawPendingRef = (0, _react.useRef)(false);
|
|
305
486
|
const flushScheduledRef = (0, _react.useRef)(false);
|
|
306
487
|
const onLayoutRef = (0, _react.useRef)(onLayout);
|
|
@@ -375,7 +556,7 @@ const SkiaPictureView = props => {
|
|
|
375
556
|
if (!canvas) {
|
|
376
557
|
return undefined;
|
|
377
558
|
}
|
|
378
|
-
const renderer = isStatic ? new StaticWebGLRenderer(canvas) : new WebGLRenderer(canvas);
|
|
559
|
+
const renderer = isStatic ? new StaticWebGLRenderer(canvas) : new WebGLRenderer(canvas, redraw);
|
|
379
560
|
rendererRef.current = renderer;
|
|
380
561
|
const drawPicture = () => {
|
|
381
562
|
if (pictureRef.current) {
|
|
@@ -454,7 +635,7 @@ const SkiaPictureView = props => {
|
|
|
454
635
|
rendererRef.current = null;
|
|
455
636
|
renderer.dispose();
|
|
456
637
|
};
|
|
457
|
-
}, [isStatic]);
|
|
638
|
+
}, [isStatic, redraw]);
|
|
458
639
|
|
|
459
640
|
// No flush cancellation is needed on unmount: a microtask queued before
|
|
460
641
|
// unmount runs within the same task, and flushRedraw no-ops once the
|
|
@@ -501,6 +682,10 @@ const SkiaPictureView = props => {
|
|
|
501
682
|
...viewProps
|
|
502
683
|
} = props;
|
|
503
684
|
return /*#__PURE__*/_react.default.createElement(_Platform.Platform.View, viewProps, /*#__PURE__*/_react.default.createElement("canvas", {
|
|
685
|
+
// A canvas element is bound to one context kind for life (WebGL for
|
|
686
|
+
// the live renderer, 2D for the static one), so switching renderers
|
|
687
|
+
// needs a fresh element.
|
|
688
|
+
key: isStatic ? "static" : "webgl",
|
|
504
689
|
ref: canvasRef,
|
|
505
690
|
style: {
|
|
506
691
|
display: "block",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_JsiSkSurface","_Platform","_SkiaViewNativeId","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","dp2Pixel","pd","rect","undefined","x","y","width","height","WebGLRenderer","constructor","canvas","contextHandle","CanvasKit","GetWebGLContext","Error","grContext","MakeWebGLContext","deleteContext","ctx","getContext","drawingBufferColorSpace","onResize","makeImageSnapshot","picture","surface","getCanvas","clear","TRANSPARENT","draw","ref","flush","_this$surface","window","devicePixelRatio","clientWidth","clientHeight","delete","MakeOnScreenGLSurface","ColorSpace","SRGB","JsiSkSurface","Float32Array","of","save","scale","drawPicture","restore","dispose","_this$surface2","_this$canvas","releaseResourcesAndAbandonContext","getExtension","loseContext","StaticWebGLRenderer","cachedImage","renderPictureToSurface","tempCanvas","OffscreenCanvas","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","preventDefault","stopPropagation","isTrusted","type","SkiaPictureView","props","onLayout","canvasRef","useRef","rendererRef","pictureRef","redrawPendingRef","flushScheduledRef","onLayoutRef","useLayoutEffect","current","flushRedraw","useCallback","redraw","queueMicrotask","getSize","_canvasRef$current","_canvasRef$current2","setPicture","newPicture","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","pageX","scrollX","pageY","scrollY","measureInWindow","isStatic","__destroyWebGLContextAfterRender","renderer","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","contentRect","setTimeout","observe","media","onPixelDensityChange","watchPixelDensity","_media","removeEventListener","matchMedia","query","addEventListener","_media2","disconnect","useImperativeHandle","useEffect","_props$nativeID","nativeID","SkiaViewNativeId","api","global","SkiaViewApi","registerView","unregisterView","debug","_debug","_ref","_onLayout","_picture","_isStatic","viewProps","createElement","Platform","View","style","display","exports"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n} 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\";\nimport { Platform } from \"../Platform\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\ninterface Renderer {\n onResize(): void;\n draw(picture: SkPicture): void;\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\nclass WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n private grContext: GrDirectContext | null = null;\n private contextHandle: WebGLContextHandle = 0;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {\n this.contextHandle = CanvasKit.GetWebGLContext(canvas);\n if (!this.contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n this.grContext = CanvasKit.MakeWebGLContext(this.contextHandle);\n if (!this.grContext) {\n CanvasKit.deleteContext(this.contextHandle);\n this.contextHandle = 0;\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = canvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n this.onResize();\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.surface) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(picture);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas } = this;\n if (!this.grContext) {\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(picture: SkPicture) {\n if (this.surface) {\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(this.pd, this.pd);\n canvas.drawPicture(picture);\n canvas.restore();\n this.surface.ref.flush();\n }\n }\n\n dispose(): void {\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 this.canvas\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (this.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the canvas element (and its detached DOM tree) forever.\n CanvasKit.deleteContext(this.contextHandle);\n // Making the now-deleted handle current clears CanvasKit's\n // current-context globals (GLctx/Module.ctx), which would otherwise\n // keep referencing the context (and the canvas) until another surface\n // becomes current. With a deleted handle this is a no-op that returns\n // null without creating anything.\n CanvasKit.MakeWebGLContext(this.contextHandle);\n this.contextHandle = 0;\n }\n }\n}\n\ninterface TempRenderResult {\n surface: JsiSkSurface;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext;\n contextHandle: WebGLContextHandle;\n}\n\nclass 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 renderPictureToSurface(picture: SkPicture): 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 skiaCanvas.drawPicture(picture);\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(picture: SkPicture): void {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n 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 }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return null;\n }\n\n 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.\nconst 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 SkiaPictureViewHandle {\n setPicture(picture: SkPicture): void;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n ref?: React.Ref<SkiaPictureViewHandle>;\n}\n\nexport const SkiaPictureView = (props: SkiaPictureViewProps) => {\n const { ref, picture, onLayout } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const rendererRef = useRef<Renderer | null>(null);\n const pictureRef = useRef<SkPicture | null>(null);\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 // - Redraw requests coalesce into a single microtask. A microtask (not an\n // animation frame) so that a picture produced inside a rAF callback (the\n // Reanimated mapper) is drawn before the current frame paints: deferring\n // to the next rAF alternates between \"flush pending in this frame\" and\n // \"flush scheduled for the next frame\", drawing on every other frame\n // only and halving the effective frame rate. A picture dispatched before\n // the canvas has a size stays in pictureRef (drawing while unmeasured is\n // a no-op) and is painted by the resize path below once the canvas\n // becomes measurable, so it is never lost.\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 const redrawPendingRef = useRef(false);\n const flushScheduledRef = useRef(false);\n const onLayoutRef = useRef(onLayout);\n useLayoutEffect(() => {\n onLayoutRef.current = onLayout;\n }, [onLayout]);\n\n const flushRedraw = useCallback(() => {\n flushScheduledRef.current = false;\n if (redrawPendingRef.current && rendererRef.current && pictureRef.current) {\n redrawPendingRef.current = false;\n rendererRef.current.draw(pictureRef.current);\n }\n // If the renderer or picture isn't available yet, the request stays\n // pending and is flushed by whichever arrives last.\n }, []);\n\n const redraw = useCallback(() => {\n redrawPendingRef.current = true;\n if (!flushScheduledRef.current) {\n flushScheduledRef.current = true;\n queueMicrotask(flushRedraw);\n }\n }, [flushRedraw]);\n\n const getSize = useCallback(() => {\n return {\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n };\n }, []);\n\n const setPicture = useCallback(\n (newPicture: SkPicture) => {\n pictureRef.current = newPicture;\n redraw();\n },\n [redraw]\n );\n\n const makeImageSnapshot = useCallback((rect?: SkRect) => {\n if (rendererRef.current && pictureRef.current) {\n return rendererRef.current.makeImageSnapshot(pictureRef.current, rect);\n }\n return null;\n }, []);\n\n const measure = useCallback(\n (\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n const parentElement = canvasRef.current.offsetParent as HTMLElement;\n const parentRect = parentElement?.getBoundingClientRect() || {\n left: 0,\n top: 0,\n };\n\n // x, y are relative to the parent\n const x = rect.left - parentRect.left;\n const y = rect.top - parentRect.top;\n\n // pageX, pageY are absolute screen coordinates\n const pageX = rect.left + window.scrollX;\n const pageY = rect.top + window.scrollY;\n\n callback(x, y, rect.width, rect.height, pageX, pageY);\n }\n },\n []\n );\n\n const measureInWindow = useCallback(\n (\n callback: (x: number, y: number, width: number, height: number) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n\n // x, y are the absolute coordinates in the window\n const x = rect.left;\n const y = rect.top;\n\n callback(x, y, rect.width, rect.height);\n }\n },\n []\n );\n\n const isStatic = props.__destroyWebGLContextAfterRender === true;\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas);\n rendererRef.current = renderer;\n\n const drawPicture = () => {\n if (pictureRef.current) {\n redrawPendingRef.current = false;\n renderer.draw(pictureRef.current);\n }\n };\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 drawPicture();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = onLayoutRef.current;\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 picture that was dispatched before the renderer existed.\n drawPicture();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [isStatic]);\n\n // No flush cancellation is needed on unmount: a microtask queued before\n // unmount runs within the same task, and flushRedraw no-ops once the\n // layout-effect cleanup has nulled rendererRef.\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [setPicture, getSize, redraw, makeImageSnapshot, measure, measureInWindow]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n const api = global.SkiaViewApi as ISkiaViewApiWeb;\n api.registerView(nativeID, {\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n } as SkiaPictureViewHandle);\n return () => {\n api.unregisterView(nativeID);\n };\n }, [\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n props.nativeID,\n ]);\n\n useEffect(() => {\n if (picture) {\n setPicture(picture);\n }\n }, [setPicture, picture]);\n\n const {\n debug: _debug,\n ref: _ref,\n onLayout: _onLayout,\n picture: _picture,\n __destroyWebGLContextAfterRender: _isStatic,\n ...viewProps\n } = props;\n return (\n <Platform.View {...viewProps}>\n <canvas\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;AAWA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAIA,IAAAG,iBAAA,GAAAH,OAAA;AAAsD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,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,I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AAiB,EACjBwF,OAAO,EACPY,eAAe,EACfhC,KAAK,CAAC6D,QAAQ,CACf,CAAC;EAEF,IAAAF,gBAAS,EAAC,MAAM;IACd,IAAI9H,OAAO,EAAE;MACXqF,UAAU,CAACrF,OAAO,CAAC;IACrB;EACF,CAAC,EAAE,CAACqF,UAAU,EAAErF,OAAO,CAAC,CAAC;EAEzB,MAAM;IACJuI,KAAK,EAAEC,MAAM;IACblI,GAAG,EAAEmI,IAAI;IACTrE,QAAQ,EAAEsE,SAAS;IACnB1I,OAAO,EAAE2I,QAAQ;IACjBtC,gCAAgC,EAAEuC,SAAS;IAC3C,GAAGC;EACL,CAAC,GAAG1E,KAAK;EACT,oBACE/H,MAAA,CAAAgB,OAAA,CAAA0L,aAAA,CAACtM,SAAA,CAAAuM,QAAQ,CAACC,IAAI,EAAKH,SAAS,eAC1BzM,MAAA,CAAAgB,OAAA,CAAA0L,aAAA;IACExI,GAAG,EAAE+D,SAAU;IACf4E,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAEnK,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC;AAACmK,OAAA,CAAAjF,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_JsiSkSurface","_Platform","_SkiaViewNativeId","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","dp2Pixel","pd","rect","undefined","x","y","width","height","canvasWebGL","deleteContextHandle","handle","CanvasKit","deleteContext","MakeWebGLContext","WebGLRenderer","constructor","canvas","requestRedraw","release","restoreWanted","restoreRequest","setTimeout","_canvasWebGL$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","event","preventDefault","_this$surface","surface","ref","delete","releaseResourcesAndAbandonContext","_canvasWebGL$get$gl$i","_canvasWebGL$get2","makeImageSnapshot","picture","getCanvas","clear","TRANSPARENT","draw","flush","_this$surface2","window","devicePixelRatio","clientWidth","clientHeight","MakeOnScreenGLSurface","ColorSpace","SRGB","JsiSkSurface","Float32Array","of","save","scale","drawPicture","restore","dispose","removeEventListener","clearTimeout","queueMicrotask","isConnected","_entry$loseContext","StaticWebGLRenderer","cachedImage","renderPictureToSurface","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","SkiaPictureView","props","onLayout","canvasRef","useRef","rendererRef","pictureRef","redrawPendingRef","flushScheduledRef","onLayoutRef","useLayoutEffect","current","flushRedraw","useCallback","redraw","getSize","_canvasRef$current","_canvasRef$current2","setPicture","newPicture","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","pageX","scrollX","pageY","scrollY","measureInWindow","isStatic","__destroyWebGLContextAfterRender","renderer","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","contentRect","observe","media","onPixelDensityChange","watchPixelDensity","_media","matchMedia","query","_media2","disconnect","useImperativeHandle","useEffect","_props$nativeID","nativeID","SkiaViewNativeId","api","global","SkiaViewApi","registerView","unregisterView","debug","_debug","_ref","_onLayout","_picture","_isStatic","viewProps","createElement","Platform","View","key","style","display","exports"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n} 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\";\nimport { Platform } from \"../Platform\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\ninterface Renderer {\n onResize(): void;\n draw(picture: SkPicture): void;\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\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\nclass 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 // picture 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(picture: SkPicture, 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(picture);\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(picture: SkPicture) {\n if (!this.surface || this.isContextLost()) {\n return;\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 canvas.drawPicture(picture);\n canvas.restore();\n this.surface.ref.flush();\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\nclass 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 renderPictureToSurface(picture: SkPicture): 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 skiaCanvas.drawPicture(picture);\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(picture: SkPicture): void {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n 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 }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return null;\n }\n\n 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.\nconst 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 SkiaPictureViewHandle {\n setPicture(picture: SkPicture): void;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n ref?: React.Ref<SkiaPictureViewHandle>;\n}\n\nexport const SkiaPictureView = (props: SkiaPictureViewProps) => {\n const { ref, picture, onLayout } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const rendererRef = useRef<Renderer | null>(null);\n const pictureRef = useRef<SkPicture | null>(null);\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 // - Redraw requests coalesce into a single microtask. A microtask (not an\n // animation frame) so that a picture produced inside a rAF callback (the\n // Reanimated mapper) is drawn before the current frame paints: deferring\n // to the next rAF alternates between \"flush pending in this frame\" and\n // \"flush scheduled for the next frame\", drawing on every other frame\n // only and halving the effective frame rate. A picture dispatched before\n // the canvas has a size stays in pictureRef (drawing while unmeasured is\n // a no-op) and is painted by the resize path below once the canvas\n // becomes measurable, so it is never lost.\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 const redrawPendingRef = useRef(false);\n const flushScheduledRef = useRef(false);\n const onLayoutRef = useRef(onLayout);\n useLayoutEffect(() => {\n onLayoutRef.current = onLayout;\n }, [onLayout]);\n\n const flushRedraw = useCallback(() => {\n flushScheduledRef.current = false;\n if (redrawPendingRef.current && rendererRef.current && pictureRef.current) {\n redrawPendingRef.current = false;\n rendererRef.current.draw(pictureRef.current);\n }\n // If the renderer or picture isn't available yet, the request stays\n // pending and is flushed by whichever arrives last.\n }, []);\n\n const redraw = useCallback(() => {\n redrawPendingRef.current = true;\n if (!flushScheduledRef.current) {\n flushScheduledRef.current = true;\n queueMicrotask(flushRedraw);\n }\n }, [flushRedraw]);\n\n const getSize = useCallback(() => {\n return {\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n };\n }, []);\n\n const setPicture = useCallback(\n (newPicture: SkPicture) => {\n pictureRef.current = newPicture;\n redraw();\n },\n [redraw]\n );\n\n const makeImageSnapshot = useCallback((rect?: SkRect) => {\n if (rendererRef.current && pictureRef.current) {\n return rendererRef.current.makeImageSnapshot(pictureRef.current, rect);\n }\n return null;\n }, []);\n\n const measure = useCallback(\n (\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n const parentElement = canvasRef.current.offsetParent as HTMLElement;\n const parentRect = parentElement?.getBoundingClientRect() || {\n left: 0,\n top: 0,\n };\n\n // x, y are relative to the parent\n const x = rect.left - parentRect.left;\n const y = rect.top - parentRect.top;\n\n // pageX, pageY are absolute screen coordinates\n const pageX = rect.left + window.scrollX;\n const pageY = rect.top + window.scrollY;\n\n callback(x, y, rect.width, rect.height, pageX, pageY);\n }\n },\n []\n );\n\n const measureInWindow = useCallback(\n (\n callback: (x: number, y: number, width: number, height: number) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n\n // x, y are the absolute coordinates in the window\n const x = rect.left;\n const y = rect.top;\n\n callback(x, y, rect.width, rect.height);\n }\n },\n []\n );\n\n const isStatic = props.__destroyWebGLContextAfterRender === true;\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas, redraw);\n rendererRef.current = renderer;\n\n const drawPicture = () => {\n if (pictureRef.current) {\n redrawPendingRef.current = false;\n renderer.draw(pictureRef.current);\n }\n };\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 drawPicture();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = onLayoutRef.current;\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 picture that was dispatched before the renderer existed.\n drawPicture();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [isStatic, redraw]);\n\n // No flush cancellation is needed on unmount: a microtask queued before\n // unmount runs within the same task, and flushRedraw no-ops once the\n // layout-effect cleanup has nulled rendererRef.\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [setPicture, getSize, redraw, makeImageSnapshot, measure, measureInWindow]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n const api = global.SkiaViewApi as ISkiaViewApiWeb;\n api.registerView(nativeID, {\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n } as SkiaPictureViewHandle);\n return () => {\n api.unregisterView(nativeID);\n };\n }, [\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n props.nativeID,\n ]);\n\n useEffect(() => {\n if (picture) {\n setPicture(picture);\n }\n }, [setPicture, picture]);\n\n const {\n debug: _debug,\n ref: _ref,\n onLayout: _onLayout,\n picture: _picture,\n __destroyWebGLContextAfterRender: _isStatic,\n ...viewProps\n } = props;\n return (\n <Platform.View {...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;AAWA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAIA,IAAAG,iBAAA,GAAAH,OAAA;AAAsD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OA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AAO,EAAE;MACXiF,UAAU,CAACjF,OAAO,CAAC;IACrB;EACF,CAAC,EAAE,CAACiF,UAAU,EAAEjF,OAAO,CAAC,CAAC;EAEzB,MAAM;IACJgI,KAAK,EAAEC,MAAM;IACbvI,GAAG,EAAEwI,IAAI;IACTjE,QAAQ,EAAEkE,SAAS;IACnBnI,OAAO,EAAEoI,QAAQ;IACjBnC,gCAAgC,EAAEoC,SAAS;IAC3C,GAAGC;EACL,CAAC,GAAGtE,KAAK;EACT,oBACE7J,MAAA,CAAAgB,OAAA,CAAAoN,aAAA,CAAChO,SAAA,CAAAiO,QAAQ,CAACC,IAAI,EAAKH,SAAS,eAC1BnO,MAAA,CAAAgB,OAAA,CAAAoN,aAAA;IACE;IACA;IACA;IACAG,GAAG,EAAE1C,QAAQ,GAAG,QAAQ,GAAG,OAAQ;IACnCtG,GAAG,EAAEwE,SAAU;IACfyE,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAE9L,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC;AAAC8L,OAAA,CAAA9E,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -57,7 +57,7 @@ export class JsiSkCanvas extends HostObject {
|
|
|
57
57
|
this.ref.drawPatch(cubics.map(({
|
|
58
58
|
x,
|
|
59
59
|
y
|
|
60
|
-
}) => [x, y]).flat(), colors, texs ? texs.flatMap(p => Array.from(JsiSkPoint.fromValue(p))) : texs, mode ? getEnum(this.CanvasKit, "BlendMode", mode) : null, paint ? JsiSkPaint.fromValue(paint) : undefined);
|
|
60
|
+
}) => [x, y]).flat(), colors, texs ? texs.flatMap(p => Array.from(JsiSkPoint.fromValue(p))) : texs, mode !== undefined && mode !== null ? getEnum(this.CanvasKit, "BlendMode", mode) : null, paint ? JsiSkPaint.fromValue(paint) : undefined);
|
|
61
61
|
}
|
|
62
62
|
restoreToCount(saveCount) {
|
|
63
63
|
this.ref.restoreToCount(saveCount);
|
|
@@ -123,7 +123,7 @@ export class JsiSkCanvas extends HostObject {
|
|
|
123
123
|
this.ref.translate(dx, dy);
|
|
124
124
|
}
|
|
125
125
|
drawColor(color, blendMode) {
|
|
126
|
-
this.ref.drawColor(color, blendMode ? getEnum(this.CanvasKit, "BlendMode", blendMode) : undefined);
|
|
126
|
+
this.ref.drawColor(color, blendMode !== undefined ? getEnum(this.CanvasKit, "BlendMode", blendMode) : undefined);
|
|
127
127
|
}
|
|
128
128
|
clear(color) {
|
|
129
129
|
this.ref.clear(color);
|
|
@@ -165,10 +165,10 @@ export class JsiSkCanvas extends HostObject {
|
|
|
165
165
|
} else if (sampling) {
|
|
166
166
|
ckSampling = {
|
|
167
167
|
filter: getEnum(this.CanvasKit, "FilterMode", sampling.filter),
|
|
168
|
-
mipmap: sampling.mipmap ? getEnum(this.CanvasKit, "MipmapMode", sampling.mipmap) : this.CanvasKit.MipmapMode.None
|
|
168
|
+
mipmap: sampling.mipmap !== undefined ? getEnum(this.CanvasKit, "MipmapMode", sampling.mipmap) : this.CanvasKit.MipmapMode.None
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
this.ref.drawAtlas(JsiSkImage.fromValue(atlas), src, dst, JsiSkPaint.fromValue(paint), blendMode ? getEnum(this.CanvasKit, "BlendMode", blendMode) : this.CanvasKit.BlendMode.DstOver, cls, ckSampling);
|
|
171
|
+
this.ref.drawAtlas(JsiSkImage.fromValue(atlas), src, dst, JsiSkPaint.fromValue(paint), blendMode !== undefined ? getEnum(this.CanvasKit, "BlendMode", blendMode) : this.CanvasKit.BlendMode.DstOver, cls, ckSampling);
|
|
172
172
|
}
|
|
173
173
|
readPixels(srcX, srcY, imageInfo) {
|
|
174
174
|
const pxInfo = {
|