@shopify/react-native-skia 2.11.1 → 2.11.2-next.1
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/cpp/api/JsiSkFont.h +3 -2
- package/cpp/api/recorder/Paint.h +6 -2
- package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
- package/cpp/dawn/include/dawn/dawn_proc_table.h +330 -0
- package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/include/dawn/dawn_version.h +41 -0
- package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
- package/cpp/dawn/include/dawn/native/D3D12Backend.h +103 -0
- package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/DawnNative.h +368 -0
- package/cpp/dawn/include/dawn/native/MetalBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
- package/cpp/dawn/include/dawn/native/VulkanBackend.h +183 -0
- package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
- package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/include/dawn/platform/DawnPlatform.h +207 -0
- package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
- package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
- package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2856 -0
- package/cpp/dawn/include/tint/tint.h +91 -0
- package/cpp/dawn/include/webgpu/webgpu.h +5029 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +10353 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +162 -0
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
- package/cpp/jsi/NativeObject.h +50 -32
- package/cpp/jsi/RuntimeAwareCache.cpp +1 -0
- package/cpp/jsi/RuntimeAwareCache.h +29 -0
- package/cpp/rnskia/RNSkManager.cpp +5 -0
- package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
- package/cpp/skia/src/gpu/graphite/ResourceTypes.h +360 -0
- package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
- package/lib/commonjs/dom/nodes/datatypes/Rect.js +5 -1
- package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/commonjs/external/reanimated/useVideo.js +8 -2
- package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
- package/lib/commonjs/skia/types/JsiInstance.d.ts +1 -0
- package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +10 -5
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +19 -14
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Rect.js +5 -1
- package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/module/external/reanimated/useVideo.js +8 -2
- package/lib/module/external/reanimated/useVideo.js.map +1 -1
- package/lib/module/skia/types/JsiInstance.d.ts +1 -0
- package/lib/module/skia/types/JsiInstance.js.map +1 -1
- package/lib/module/sksg/Recorder/DrawingContext.js +10 -5
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +19 -14
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/src/skia/types/JsiInstance.d.ts +1 -0
- package/libs/.graphite +1 -0
- package/package.json +6 -6
- package/src/dom/nodes/datatypes/Rect.ts +6 -1
- package/src/external/reanimated/useVideo.ts +7 -2
- package/src/skia/types/JsiInstance.ts +2 -0
- package/src/sksg/Recorder/DrawingContext.ts +10 -5
- package/src/views/SkiaPictureView.web.tsx +17 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_FrameScope","require","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","createFrameScope","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","length","push","Paint","reset","savePaint","nextPaint","assign","getCurrentPaint","pushPaint","paint","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","exports"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nimport { createFrameScope } from \"./FrameScope\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // Everything the renderer creates through frameSkia is frame-scoped and\n // deleted by dispose() once the frame has been recorded. The paint pool is\n // recording-scoped and deliberately allocated with the raw Skia instance.\n const { Skia: frameSkia, track, dispose } = createFrameScope(Skia);\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n if (paintPool.length === 0) {\n paintPool.push(Skia.Paint());\n } else {\n paintPool[0].reset();\n }\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n // Pushes an externally owned paint (the `paint` prop) onto the stack. It must\n // push an opacity alongside it: restorePaint() pops both, so pushing only the
|
|
1
|
+
{"version":3,"names":["_FrameScope","require","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","createFrameScope","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","length","push","Paint","reset","setAntiAlias","savePaint","nextPaint","assign","getCurrentPaint","pushPaint","paint","copy","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","exports"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nimport { createFrameScope } from \"./FrameScope\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // Everything the renderer creates through frameSkia is frame-scoped and\n // deleted by dispose() once the frame has been recorded. The paint pool is\n // recording-scoped and deliberately allocated with the raw Skia instance.\n const { Skia: frameSkia, track, dispose } = createFrameScope(Skia);\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n if (paintPool.length === 0) {\n paintPool.push(Skia.Paint());\n } else {\n // reset() produces an anti-alias false paint, unlike the Skia.Paint()\n // factory: restore the default so reused pools render like the first frame.\n paintPool[0].reset();\n paintPool[0].setAntiAlias(true);\n }\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n // Pushes an externally owned paint (the `paint` prop) onto the stack. It\n // pushes a frame-scoped copy, like the C++ DrawingCtx: materializePaint()\n // mutates the top of the stack, and those mutations must not leak into the\n // user-owned paint. It must also push an opacity alongside it: restorePaint()\n // pops both, so pushing only the paint would underflow the opacity stack and\n // leak the enclosing group's opacity onto everything drawn afterwards.\n const pushPaint = (paint: SkPaint) => {\n paints.push(track(paint.copy()));\n opacities.push(opacities[opacities.length - 1]);\n };\n\n const getOpacity = () => {\n return opacities[opacities.length - 1];\n };\n\n const setOpacity = (newOpacity: number) => {\n opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n opacities.pop();\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia: frameSkia,\n canvas,\n track,\n dispose,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n pushPaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n getOpacity,\n setOpacity,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":";;;;;;AAUA,IAAAA,WAAA,GAAAC,OAAA;AAEO,MAAMC,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA;EACA;EACA,MAAM;IAAEF,IAAI,EAAEG,SAAS;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAG,IAAAC,4BAAgB,EAACN,IAAI,CAAC;;EAElE;EACA,MAAMO,MAAiB,GAAG,EAAE;EAC5B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,OAAmB,GAAG,EAAE;EAC9B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,WAA2B,GAAG,EAAE;EACtC,MAAMC,iBAA4B,GAAG,EAAE;EACvC,MAAMC,SAAmB,GAAG,EAAE;EAE9B,IAAIC,cAAc,GAAG,CAAC;;EAEtB;EACA,IAAIb,SAAS,CAACc,MAAM,KAAK,CAA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ACF,CAAC;AACH,CAAC;AAAC2B,OAAA,CAAAxD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -289,21 +289,26 @@ const SkiaPictureView = props => {
|
|
|
289
289
|
// - The renderer is created synchronously on mount (the canvas element is
|
|
290
290
|
// guaranteed to exist in useLayoutEffect; a zero size at that point is
|
|
291
291
|
// fine, the surface is created once the canvas is measurable).
|
|
292
|
-
// - Redraw requests coalesce into a single
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
292
|
+
// - Redraw requests coalesce into a single microtask. A microtask (not an
|
|
293
|
+
// animation frame) so that a picture produced inside a rAF callback (the
|
|
294
|
+
// Reanimated mapper) is drawn before the current frame paints: deferring
|
|
295
|
+
// to the next rAF alternates between "flush pending in this frame" and
|
|
296
|
+
// "flush scheduled for the next frame", drawing on every other frame
|
|
297
|
+
// only and halving the effective frame rate. A picture dispatched before
|
|
298
|
+
// the canvas has a size stays in pictureRef (drawing while unmeasured is
|
|
299
|
+
// a no-op) and is painted by the resize path below once the canvas
|
|
300
|
+
// becomes measurable, so it is never lost.
|
|
296
301
|
// - A ResizeObserver on the canvas itself recreates the surface and repaints
|
|
297
302
|
// synchronously (its callbacks run after layout, before paint), and is
|
|
298
303
|
// also the source of the user-facing onLayout event.
|
|
299
304
|
const redrawPendingRef = (0, _react.useRef)(false);
|
|
300
|
-
const
|
|
305
|
+
const flushScheduledRef = (0, _react.useRef)(false);
|
|
301
306
|
const onLayoutRef = (0, _react.useRef)(onLayout);
|
|
302
307
|
(0, _react.useLayoutEffect)(() => {
|
|
303
308
|
onLayoutRef.current = onLayout;
|
|
304
309
|
}, [onLayout]);
|
|
305
310
|
const flushRedraw = (0, _react.useCallback)(() => {
|
|
306
|
-
|
|
311
|
+
flushScheduledRef.current = false;
|
|
307
312
|
if (redrawPendingRef.current && rendererRef.current && pictureRef.current) {
|
|
308
313
|
redrawPendingRef.current = false;
|
|
309
314
|
rendererRef.current.draw(pictureRef.current);
|
|
@@ -313,8 +318,9 @@ const SkiaPictureView = props => {
|
|
|
313
318
|
}, []);
|
|
314
319
|
const redraw = (0, _react.useCallback)(() => {
|
|
315
320
|
redrawPendingRef.current = true;
|
|
316
|
-
if (
|
|
317
|
-
|
|
321
|
+
if (!flushScheduledRef.current) {
|
|
322
|
+
flushScheduledRef.current = true;
|
|
323
|
+
queueMicrotask(flushRedraw);
|
|
318
324
|
}
|
|
319
325
|
}, [flushRedraw]);
|
|
320
326
|
const getSize = (0, _react.useCallback)(() => {
|
|
@@ -449,12 +455,11 @@ const SkiaPictureView = props => {
|
|
|
449
455
|
renderer.dispose();
|
|
450
456
|
};
|
|
451
457
|
}, [isStatic]);
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}, []);
|
|
458
|
+
|
|
459
|
+
// No flush cancellation is needed on unmount: a microtask queued before
|
|
460
|
+
// unmount runs within the same task, and flushRedraw no-ops once the
|
|
461
|
+
// layout-effect cleanup has nulled rendererRef.
|
|
462
|
+
|
|
458
463
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
459
464
|
setPicture,
|
|
460
465
|
getSize,
|
|
@@ -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","frameRef","onLayoutRef","useLayoutEffect","current","flushRedraw","useCallback","redraw","requestAnimationFrame","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","useEffect","cancelAnimationFrame","useImperativeHandle","_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 animation frame. A picture\n // dispatched before the canvas has a size stays in pictureRef (drawing\n // while unmeasured is a no-op) and is painted by the resize path below\n // once the canvas 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 frameRef = useRef(0);\n const onLayoutRef = useRef(onLayout);\n useLayoutEffect(() => {\n onLayoutRef.current = onLayout;\n }, [onLayout]);\n\n const flushRedraw = useCallback(() => {\n frameRef.current = 0;\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 (frameRef.current === 0) {\n frameRef.current = requestAnimationFrame(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 useEffect(() => {\n return () => {\n cancelAnimationFrame(frameRef.current);\n frameRef.current = 0;\n };\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [setPicture, getSize, redraw, makeImageSnapshot, measure, measureInWindow]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n 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,CA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MAAEC,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC;AAACoK,OAAA,CAAAlF,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","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,IAAAL,CAAA,CA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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":[]}
|
|
@@ -4,7 +4,11 @@ import { processRadius } from "./Radius";
|
|
|
4
4
|
export const isEdge = (pos, b) => {
|
|
5
5
|
"worklet";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const right = b.x + b.width;
|
|
8
|
+
const bottom = b.y + b.height;
|
|
9
|
+
const withinX = pos.x >= b.x && pos.x <= right;
|
|
10
|
+
const withinY = pos.y >= b.y && pos.y <= bottom;
|
|
11
|
+
return withinY && (pos.x === b.x || pos.x === right) || withinX && (pos.y === b.y || pos.y === bottom);
|
|
8
12
|
};
|
|
9
13
|
|
|
10
14
|
// We have an issue to check property existence on JSI backed instances
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["processRadius","isEdge","pos","b","
|
|
1
|
+
{"version":3,"names":["processRadius","isEdge","pos","b","right","x","width","bottom","y","height","withinX","withinY","isRRectCtor","def","rect","undefined","isRectCtor","processRect","Skia","_def$x","_def$y","XYWHRect","processRRect","_def$r","_def$x2","_def$y2","r","RRectXY","inflate","box","dx","dy","tx","ty","rx","ry","deflate"],"sources":["Rect.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Skia, SkRect, SkRRect, Vector } from \"../../../skia/types\";\nimport type { RectCtor, RectDef, RRectCtor, RRectDef } from \"../../types\";\n\nimport { processRadius } from \"./Radius\";\n\nexport const isEdge = (pos: Vector, b: SkRect) => {\n \"worklet\";\n const right = b.x + b.width;\n const bottom = b.y + b.height;\n const withinX = pos.x >= b.x && pos.x <= right;\n const withinY = pos.y >= b.y && pos.y <= bottom;\n return (\n (withinY && (pos.x === b.x || pos.x === right)) ||\n (withinX && (pos.y === b.y || pos.y === bottom))\n );\n};\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor => {\n \"worklet\";\n return (def as any).rect === undefined;\n};\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor => {\n \"worklet\";\n return (def as any).rect === undefined;\n};\n\nexport const processRect = (Skia: Skia, def: RectDef) => {\n \"worklet\";\n if (isRectCtor(def)) {\n return Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (Skia: Skia, def: RRectDef) => {\n \"worklet\";\n if (isRRectCtor(def)) {\n const r = processRadius(Skia, def.r ?? 0);\n return Skia.RRectXY(\n Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height),\n r.x,\n r.y\n );\n } else {\n return def.rect;\n }\n};\n\nexport const inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => {\n \"worklet\";\n return Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n};\n\nexport const deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => {\n \"worklet\";\n return inflate(Skia, box, -dx, -dy, tx, ty);\n};\n"],"mappings":"AAAA;;AAIA,SAASA,aAAa,QAAQ,UAAU;AAExC,OAAO,MAAMC,MAAM,GAAGA,CAACC,GAAW,EAAEC,CAAS,KAAK;EAChD,SAAS;;EACT,MAAMC,KAAK,GAAGD,CAAC,CAACE,CAAC,GAAGF,CAAC,CAACG,KAAK;EAC3B,MAAMC,MAAM,GAAGJ,CAAC,CAACK,CAAC,GAAGL,CAAC,CAACM,MAAM;EAC7B,MAAMC,OAAO,GAAGR,GAAG,CAACG,CAAC,IAAIF,CAAC,CAACE,CAAC,IAAIH,GAAG,CAACG,CAAC,IAAID,KAAK;EAC9C,MAAMO,OAAO,GAAGT,GAAG,CAACM,CAAC,IAAIL,CAAC,CAACK,CAAC,IAAIN,GAAG,CAACM,CAAC,IAAID,MAAM;EAC/C,OACGI,OAAO,KAAKT,GAAG,CAACG,CAAC,KAAKF,CAAC,CAACE,CAAC,IAAIH,GAAG,CAACG,CAAC,KAAKD,KAAK,CAAC,IAC7CM,OAAO,KAAKR,GAAG,CAACM,CAAC,KAAKL,CAAC,CAACK,CAAC,IAAIN,GAAG,CAACM,CAAC,KAAKD,MAAM,CAAE;AAEpD,CAAC;;AAED;AACA,MAAMK,WAAW,GAAIC,GAAa,IAAuB;EACvD,SAAS;;EACT,OAAQA,GAAG,CAASC,IAAI,KAAKC,SAAS;AACxC,CAAC;AACD;AACA,MAAMC,UAAU,GAAIH,GAAY,IAAsB;EACpD,SAAS;;EACT,OAAQA,GAAG,CAASC,IAAI,KAAKC,SAAS;AACxC,CAAC;AAED,OAAO,MAAME,WAAW,GAAGA,CAACC,IAAU,EAAEL,GAAY,KAAK;EAC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EACT,OAAOf,IAAI,CAACS,OAAO,CACjBT,IAAI,CAACG,QAAQ,CACXQ,GAAG,CAACf,IAAI,CAACT,CAAC,GAAGyB,EAAE,GAAGE,EAAE,EACpBH,GAAG,CAACf,IAAI,CAACN,CAAC,GAAGuB,EAAE,GAAGE,EAAE,EACpBJ,GAAG,CAACf,IAAI,CAACR,KAAK,GAAG,CAAC,GAAGwB,EAAE,EACvBD,GAAG,CAACf,IAAI,CAACL,MAAM,GAAG,CAAC,GAAGsB,EACxB,CAAC,EACDF,GAAG,CAACK,EAAE,GAAGJ,EAAE,EACXD,GAAG,CAACM,EAAE,GAAGJ,EACX,CAAC;AACH,CAAC;AAED,OAAO,MAAMK,OAAO,GAAGA,CACrBlB,IAAU,EACVW,GAAY,EACZC,EAAU,EACVC,EAAU,EACVC,EAAE,GAAG,CAAC,EACNC,EAAE,GAAG,CAAC,KACH;EACH,SAAS;;EACT,OAAOL,OAAO,CAACV,IAAI,EAAEW,GAAG,EAAE,CAACC,EAAE,EAAE,CAACC,EAAE,EAAEC,EAAE,EAAEC,EAAE,CAAC;AAC7C,CAAC","ignoreList":[]}
|
|
@@ -9,8 +9,12 @@ const copyFrameOnAndroid = currentFrame => {
|
|
|
9
9
|
if (Platform.OS === "android") {
|
|
10
10
|
const tex = currentFrame.value;
|
|
11
11
|
if (tex) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const copy = tex.makeNonTextureImage();
|
|
13
|
+
if (copy) {
|
|
14
|
+
currentFrame.value = copy;
|
|
15
|
+
tex.dispose();
|
|
16
|
+
}
|
|
17
|
+
// If copy fails, keep the original frame rather than showing black
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
};
|
|
@@ -19,6 +23,8 @@ const setFrame = (video, currentFrame) => {
|
|
|
19
23
|
|
|
20
24
|
const img = video.nextImage();
|
|
21
25
|
if (img) {
|
|
26
|
+
var _currentFrame$value;
|
|
27
|
+
(_currentFrame$value = currentFrame.value) === null || _currentFrame$value === void 0 || _currentFrame$value.dispose();
|
|
22
28
|
currentFrame.value = img;
|
|
23
29
|
copyFrameOnAndroid(currentFrame);
|
|
24
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","Platform","Rea","useVideoLoading","copyFrameOnAndroid","currentFrame","OS","tex","value","dispose","setFrame","video","img","nextImage","defaultOptions","looping","paused","seek","volume","useOption","defaultValue","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$volume","isPaused","currentTime","duration","_video$duration","framerate","_video$framerate","size","_video$size","width","height","rotation","_video$rotation","useAnimatedReaction","pause","play","setVolume","setLooping","useFrameCallback","_frameInfo","runOnUI"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype MaybeAnimated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: MaybeAnimated<boolean>;\n paused: MaybeAnimated<boolean>;\n seek: MaybeAnimated<number | null>;\n volume: MaybeAnimated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","Platform","Rea","useVideoLoading","copyFrameOnAndroid","currentFrame","OS","tex","value","copy","makeNonTextureImage","dispose","setFrame","video","img","nextImage","_currentFrame$value","defaultOptions","looping","paused","seek","volume","useOption","defaultValue","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$volume","isPaused","currentTime","duration","_video$duration","framerate","_video$framerate","size","_video$size","width","height","rotation","_video$rotation","useAnimatedReaction","pause","play","setVolume","setLooping","useFrameCallback","_frameInfo","runOnUI"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype MaybeAnimated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: MaybeAnimated<boolean>;\n paused: MaybeAnimated<boolean>;\n seek: MaybeAnimated<number | null>;\n volume: MaybeAnimated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n const copy = tex.makeNonTextureImage();\n if (copy) {\n currentFrame.value = copy;\n tex.dispose();\n }\n // If copy fails, keep the original frame rather than showing black\n }\n }\n};\n\nconst setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n currentFrame.value?.dispose();\n currentFrame.value = img;\n copyFrameOnAndroid(currentFrame);\n }\n};\n\nconst defaultOptions = {\n looping: true,\n paused: false,\n seek: null,\n volume: 0,\n};\n\nconst useOption = <T>(value: MaybeAnimated<T>) => {\n \"worklet\";\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value)\n ? (value as SharedValue<T>)\n : (defaultValue as SharedValue<T>);\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useVideoLoading(source);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const volume = useOption(userOptions?.volume ?? defaultOptions.volume);\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(\n () => (Platform.OS === \"web\" ? -1 : (video?.framerate() ?? 0)),\n [video]\n );\n const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);\n const rotation = useMemo(() => video?.rotation() ?? 0, [video]);\n\n // Handle pause/play state changes\n Rea.useAnimatedReaction(\n () => isPaused.value,\n (paused) => {\n if (paused) {\n video?.pause();\n } else {\n video?.play();\n }\n }\n );\n\n // Handle seek\n Rea.useAnimatedReaction(\n () => seek.value,\n (value) => {\n if (value !== null) {\n video?.seek(value);\n seek.value = null;\n }\n }\n );\n\n // Handle volume changes\n Rea.useAnimatedReaction(\n () => volume.value,\n (value) => {\n video?.setVolume(value);\n }\n );\n\n // Handle looping changes\n Rea.useAnimatedReaction(\n () => looping.value,\n (value) => {\n video?.setLooping(value);\n }\n );\n\n // Frame callback - simplified since native handles frame timing\n Rea.useFrameCallback((_frameInfo: FrameInfo) => {\n \"worklet\";\n if (!video) {\n return;\n }\n // Update current time from native player\n currentTime.value = video.currentTime();\n // Get the latest frame (native handles timing via CADisplayLink/etc)\n setFrame(video, currentFrame);\n });\n\n // Apply initial state when video becomes available\n useEffect(() => {\n if (video) {\n video.setLooping(looping.value);\n video.setVolume(volume.value);\n if (isPaused.value) {\n video.pause();\n } else {\n video.play();\n }\n }\n return () => {\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video, isPaused, looping, volume]);\n\n return {\n currentFrame,\n currentTime,\n duration,\n framerate,\n rotation,\n size,\n };\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAG1C,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,OAAOC,GAAG,MAAM,mBAAmB;AACnC,SAASC,eAAe,Q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IACXC,QAAQ;IACRE,SAAS;IACTM,QAAQ;IACRJ;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["JsiInstance.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":[],"sources":["JsiInstance.ts"],"sourcesContent":["/// <reference lib=\"esnext.disposable\" preserve=\"true\" />\n\nexport interface SkJSIInstance<T extends string> extends Disposable {\n __typename__: T;\n dispose(): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -25,7 +25,10 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
25
25
|
if (paintPool.length === 0) {
|
|
26
26
|
paintPool.push(Skia.Paint());
|
|
27
27
|
} else {
|
|
28
|
+
// reset() produces an anti-alias false paint, unlike the Skia.Paint()
|
|
29
|
+
// factory: restore the default so reused pools render like the first frame.
|
|
28
30
|
paintPool[0].reset();
|
|
31
|
+
paintPool[0].setAntiAlias(true);
|
|
29
32
|
}
|
|
30
33
|
paints.push(paintPool[0]);
|
|
31
34
|
opacities.push(1);
|
|
@@ -43,12 +46,14 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
43
46
|
nextPaintIndex++;
|
|
44
47
|
};
|
|
45
48
|
|
|
46
|
-
// Pushes an externally owned paint (the `paint` prop) onto the stack. It
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// opacity
|
|
49
|
+
// Pushes an externally owned paint (the `paint` prop) onto the stack. It
|
|
50
|
+
// pushes a frame-scoped copy, like the C++ DrawingCtx: materializePaint()
|
|
51
|
+
// mutates the top of the stack, and those mutations must not leak into the
|
|
52
|
+
// user-owned paint. It must also push an opacity alongside it: restorePaint()
|
|
53
|
+
// pops both, so pushing only the paint would underflow the opacity stack and
|
|
54
|
+
// leak the enclosing group's opacity onto everything drawn afterwards.
|
|
50
55
|
const pushPaint = paint => {
|
|
51
|
-
paints.push(paint);
|
|
56
|
+
paints.push(track(paint.copy()));
|
|
52
57
|
opacities.push(opacities[opacities.length - 1]);
|
|
53
58
|
};
|
|
54
59
|
const getOpacity = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFrameScope","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","length","push","Paint","reset","savePaint","nextPaint","assign","getCurrentPaint","pushPaint","paint","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nimport { createFrameScope } from \"./FrameScope\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // Everything the renderer creates through frameSkia is frame-scoped and\n // deleted by dispose() once the frame has been recorded. The paint pool is\n // recording-scoped and deliberately allocated with the raw Skia instance.\n const { Skia: frameSkia, track, dispose } = createFrameScope(Skia);\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n if (paintPool.length === 0) {\n paintPool.push(Skia.Paint());\n } else {\n paintPool[0].reset();\n }\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n // Pushes an externally owned paint (the `paint` prop) onto the stack. It must\n // push an opacity alongside it: restorePaint() pops both, so pushing only the
|
|
1
|
+
{"version":3,"names":["createFrameScope","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","length","push","Paint","reset","setAntiAlias","savePaint","nextPaint","assign","getCurrentPaint","pushPaint","paint","copy","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nimport { createFrameScope } from \"./FrameScope\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // Everything the renderer creates through frameSkia is frame-scoped and\n // deleted by dispose() once the frame has been recorded. The paint pool is\n // recording-scoped and deliberately allocated with the raw Skia instance.\n const { Skia: frameSkia, track, dispose } = createFrameScope(Skia);\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n if (paintPool.length === 0) {\n paintPool.push(Skia.Paint());\n } else {\n // reset() produces an anti-alias false paint, unlike the Skia.Paint()\n // factory: restore the default so reused pools render like the first frame.\n paintPool[0].reset();\n paintPool[0].setAntiAlias(true);\n }\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n // Pushes an externally owned paint (the `paint` prop) onto the stack. It\n // pushes a frame-scoped copy, like the C++ DrawingCtx: materializePaint()\n // mutates the top of the stack, and those mutations must not leak into the\n // user-owned paint. It must also push an opacity alongside it: restorePaint()\n // pops both, so pushing only the paint would underflow the opacity stack and\n // leak the enclosing group's opacity onto everything drawn afterwards.\n const pushPaint = (paint: SkPaint) => {\n paints.push(track(paint.copy()));\n opacities.push(opacities[opacities.length - 1]);\n };\n\n const getOpacity = () => {\n return opacities[opacities.length - 1];\n };\n\n const setOpacity = (newOpacity: number) => {\n opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n opacities.pop();\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia: frameSkia,\n canvas,\n track,\n dispose,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n pushPaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n getOpacity,\n setOpacity,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":"AAUA,SAASA,gBAAgB,QAAQ,cAAc;AAE/C,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA;EACA;EACA,MAAM;IAAEF,IAAI,EAAEG,SAAS;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGP,gBAAgB,CAACE,IAAI,CAAC;;EAElE;EACA,MAAMM,MAAiB,GAAG,EAAE;EAC5B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,OAAmB,GAAG,EAAE;EAC9B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,WAA2B,GAAG,EAAE;EACtC,MAAMC,iBAA4B,GAAG,EAAE;EACvC,MAAMC,SAAmB,GAAG,EAAE;EAE9B,IAAIC,cAAc,GAAG,CAA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ACH4B,YAAY;IACZC,gBAAgB;IAChBjB,UAAU;IACVC;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -283,21 +283,26 @@ export const SkiaPictureView = props => {
|
|
|
283
283
|
// - The renderer is created synchronously on mount (the canvas element is
|
|
284
284
|
// guaranteed to exist in useLayoutEffect; a zero size at that point is
|
|
285
285
|
// fine, the surface is created once the canvas is measurable).
|
|
286
|
-
// - Redraw requests coalesce into a single
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
//
|
|
286
|
+
// - Redraw requests coalesce into a single microtask. A microtask (not an
|
|
287
|
+
// animation frame) so that a picture produced inside a rAF callback (the
|
|
288
|
+
// Reanimated mapper) is drawn before the current frame paints: deferring
|
|
289
|
+
// to the next rAF alternates between "flush pending in this frame" and
|
|
290
|
+
// "flush scheduled for the next frame", drawing on every other frame
|
|
291
|
+
// only and halving the effective frame rate. A picture dispatched before
|
|
292
|
+
// the canvas has a size stays in pictureRef (drawing while unmeasured is
|
|
293
|
+
// a no-op) and is painted by the resize path below once the canvas
|
|
294
|
+
// becomes measurable, so it is never lost.
|
|
290
295
|
// - A ResizeObserver on the canvas itself recreates the surface and repaints
|
|
291
296
|
// synchronously (its callbacks run after layout, before paint), and is
|
|
292
297
|
// also the source of the user-facing onLayout event.
|
|
293
298
|
const redrawPendingRef = useRef(false);
|
|
294
|
-
const
|
|
299
|
+
const flushScheduledRef = useRef(false);
|
|
295
300
|
const onLayoutRef = useRef(onLayout);
|
|
296
301
|
useLayoutEffect(() => {
|
|
297
302
|
onLayoutRef.current = onLayout;
|
|
298
303
|
}, [onLayout]);
|
|
299
304
|
const flushRedraw = useCallback(() => {
|
|
300
|
-
|
|
305
|
+
flushScheduledRef.current = false;
|
|
301
306
|
if (redrawPendingRef.current && rendererRef.current && pictureRef.current) {
|
|
302
307
|
redrawPendingRef.current = false;
|
|
303
308
|
rendererRef.current.draw(pictureRef.current);
|
|
@@ -307,8 +312,9 @@ export const SkiaPictureView = props => {
|
|
|
307
312
|
}, []);
|
|
308
313
|
const redraw = useCallback(() => {
|
|
309
314
|
redrawPendingRef.current = true;
|
|
310
|
-
if (
|
|
311
|
-
|
|
315
|
+
if (!flushScheduledRef.current) {
|
|
316
|
+
flushScheduledRef.current = true;
|
|
317
|
+
queueMicrotask(flushRedraw);
|
|
312
318
|
}
|
|
313
319
|
}, [flushRedraw]);
|
|
314
320
|
const getSize = useCallback(() => {
|
|
@@ -443,12 +449,11 @@ export const SkiaPictureView = props => {
|
|
|
443
449
|
renderer.dispose();
|
|
444
450
|
};
|
|
445
451
|
}, [isStatic]);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}, []);
|
|
452
|
+
|
|
453
|
+
// No flush cancellation is needed on unmount: a microtask queued before
|
|
454
|
+
// unmount runs within the same task, and flushRedraw no-ops once the
|
|
455
|
+
// layout-effect cleanup has nulled rendererRef.
|
|
456
|
+
|
|
452
457
|
useImperativeHandle(ref, () => ({
|
|
453
458
|
setPicture,
|
|
454
459
|
getSize,
|