@shopify/react-native-skia 2.11.1 → 2.11.2
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/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/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/package.json +1 -1
- 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":["React","useRef","useEffect","useCallback","useImperativeHandle","useLayoutEffect","JsiSkSurface","Platform","SkiaViewNativeId","dp2Pixel","pd","rect","undefined","x","y","width","height","WebGLRenderer","constructor","canvas","_defineProperty","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","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","rendererRef","pictureRef","redrawPendingRef","frameRef","onLayoutRef","current","flushRedraw","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","cancelAnimationFrame","_props$nativeID","nativeID","api","global","SkiaViewApi","registerView","unregisterView","debug","_debug","_ref","_onLayout","_picture","_isStatic","viewProps","createElement","View","style","display"],"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":";;;AAAA;AACA,OAAOA,KAAK,IACVC,MAAM,EACNC,SAAS,EACTC,WAAW,EACXC,mBAAmB,EACnBC,eAAe,QACV,OAAO;AAKd,SAASC,YAAY,QAAQ,0BAA0B;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Q,IAAAD,eAAA,GAAGxD,KAAK,CAACyD,QAAQ,cAAAD,eAAA,cAAAA,eAAA,GAAI,GAAGnJ,gBAAgB,CAACmG,OAAO,EAAE,EAAE;IAClE,MAAMkD,GAAG,GAAGC,MAAM,CAACC,WAA8B;IACjDF,GAAG,CAACG,YAAY,CAACJ,QAAQ,EAAE;MACzB1C,UAAU;MACVH,OAAO;MACPF,MAAM;MACN7E,iBAAiB;MACjBoF,OAAO;MACPY;IACF,CAA0B,CAAC;IAC3B,OAAO,MAAM;MACX6B,GAAG,CAACI,cAAc,CAACL,QAAQ,CAAC;IAC9B,CAAC;EACH,CAAC,EAAE,CACD1C,UAAU,EACVH,OAAO,EACPF,MAAM,EACN7E,iBAAiB,EACjBoF,OAAO,EACPY,eAAe,EACf7B,KAAK,CAACyD,QAAQ,CACf,CAAC;EAEF1J,SAAS,CAAC,MAAM;IACd,IAAI+B,OAAO,EAAE;MACXiF,UAAU,CAACjF,OAAO,CAAC;IACrB;EACF,CAAC,EAAE,CAACiF,UAAU,EAAEjF,OAAO,CAAC,CAAC;EAEzB,MAAM;IACJiI,KAAK,EAAEC,MAAM;IACb5H,GAAG,EAAE6H,IAAI;IACThE,QAAQ,EAAEiE,SAAS;IACnBpI,OAAO,EAAEqI,QAAQ;IACjBpC,gCAAgC,EAAEqC,SAAS;IAC3C,GAAGC;EACL,CAAC,GAAGrE,KAAK;EACT,oBACEnG,KAAA,CAAAyK,aAAA,CAAClK,QAAQ,CAACmK,IAAI,EAAKF,SAAS,eAC1BxK,KAAA,CAAAyK,aAAA;IACElI,GAAG,EAAE8D,SAAU;IACfsE,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAE7J,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useRef","useEffect","useCallback","useImperativeHandle","useLayoutEffect","JsiSkSurface","Platform","SkiaViewNativeId","dp2Pixel","pd","rect","undefined","x","y","width","height","WebGLRenderer","constructor","canvas","_defineProperty","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","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","rendererRef","pictureRef","redrawPendingRef","flushScheduledRef","onLayoutRef","current","flushRedraw","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","_props$nativeID","nativeID","api","global","SkiaViewApi","registerView","unregisterView","debug","_debug","_ref","_onLayout","_picture","_isStatic","viewProps","createElement","View","style","display"],"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":";;;AAAA;AACA,OAAOA,KAAK,IACVC,MAAM,EACNC,SAAS,EACTC,WAAW,EACXC,mBAAmB,EACnBC,eAAe,QACV,OAAO;AAKd,SAASC,YAAY,QAAQ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AAE,EAAE;IAClE,MAAMiD,GAAG,GAAGC,MAAM,CAACC,WAA8B;IACjDF,GAAG,CAACG,YAAY,CAACJ,QAAQ,EAAE;MACzBzC,UAAU;MACVH,OAAO;MACPF,MAAM;MACN7E,iBAAiB;MACjBoF,OAAO;MACPY;IACF,CAA0B,CAAC;IAC3B,OAAO,MAAM;MACX4B,GAAG,CAACI,cAAc,CAACL,QAAQ,CAAC;IAC9B,CAAC;EACH,CAAC,EAAE,CACDzC,UAAU,EACVH,OAAO,EACPF,MAAM,EACN7E,iBAAiB,EACjBoF,OAAO,EACPY,eAAe,EACf7B,KAAK,CAACwD,QAAQ,CACf,CAAC;EAEFzJ,SAAS,CAAC,MAAM;IACd,IAAI+B,OAAO,EAAE;MACXiF,UAAU,CAACjF,OAAO,CAAC;IACrB;EACF,CAAC,EAAE,CAACiF,UAAU,EAAEjF,OAAO,CAAC,CAAC;EAEzB,MAAM;IACJgI,KAAK,EAAEC,MAAM;IACb3H,GAAG,EAAE4H,IAAI;IACT/D,QAAQ,EAAEgE,SAAS;IACnBnI,OAAO,EAAEoI,QAAQ;IACjBnC,gCAAgC,EAAEoC,SAAS;IAC3C,GAAGC;EACL,CAAC,GAAGpE,KAAK;EACT,oBACEnG,KAAA,CAAAwK,aAAA,CAACjK,QAAQ,CAACkK,IAAI,EAAKF,SAAS,eAC1BvK,KAAA,CAAAwK,aAAA;IACEjI,GAAG,EAAE8D,SAAU;IACfqE,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAE5J,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"setup-skia-web": "scripts/setup-canvaskit.js"
|
|
9
9
|
},
|
|
10
10
|
"title": "React Native Skia",
|
|
11
|
-
"version": "2.11.
|
|
11
|
+
"version": "2.11.2",
|
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
|
13
13
|
"main": "lib/module/index.js",
|
|
14
14
|
"react-native": "src/index.ts",
|
|
@@ -6,8 +6,13 @@ import { processRadius } from "./Radius";
|
|
|
6
6
|
|
|
7
7
|
export const isEdge = (pos: Vector, b: SkRect) => {
|
|
8
8
|
"worklet";
|
|
9
|
+
const right = b.x + b.width;
|
|
10
|
+
const bottom = b.y + b.height;
|
|
11
|
+
const withinX = pos.x >= b.x && pos.x <= right;
|
|
12
|
+
const withinY = pos.y >= b.y && pos.y <= bottom;
|
|
9
13
|
return (
|
|
10
|
-
pos.x === b.x || pos.
|
|
14
|
+
(withinY && (pos.x === b.x || pos.x === right)) ||
|
|
15
|
+
(withinX && (pos.y === b.y || pos.y === bottom))
|
|
11
16
|
);
|
|
12
17
|
};
|
|
13
18
|
|
|
@@ -22,8 +22,12 @@ const copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {
|
|
|
22
22
|
if (Platform.OS === "android") {
|
|
23
23
|
const tex = currentFrame.value;
|
|
24
24
|
if (tex) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const copy = tex.makeNonTextureImage();
|
|
26
|
+
if (copy) {
|
|
27
|
+
currentFrame.value = copy;
|
|
28
|
+
tex.dispose();
|
|
29
|
+
}
|
|
30
|
+
// If copy fails, keep the original frame rather than showing black
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
};
|
|
@@ -32,6 +36,7 @@ const setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {
|
|
|
32
36
|
"worklet";
|
|
33
37
|
const img = video.nextImage();
|
|
34
38
|
if (img) {
|
|
39
|
+
currentFrame.value?.dispose();
|
|
35
40
|
currentFrame.value = img;
|
|
36
41
|
copyFrameOnAndroid(currentFrame);
|
|
37
42
|
}
|
|
@@ -37,7 +37,10 @@ export const createDrawingContext = (
|
|
|
37
37
|
if (paintPool.length === 0) {
|
|
38
38
|
paintPool.push(Skia.Paint());
|
|
39
39
|
} else {
|
|
40
|
+
// reset() produces an anti-alias false paint, unlike the Skia.Paint()
|
|
41
|
+
// factory: restore the default so reused pools render like the first frame.
|
|
40
42
|
paintPool[0].reset();
|
|
43
|
+
paintPool[0].setAntiAlias(true);
|
|
41
44
|
}
|
|
42
45
|
paints.push(paintPool[0]);
|
|
43
46
|
opacities.push(1);
|
|
@@ -56,12 +59,14 @@ export const createDrawingContext = (
|
|
|
56
59
|
nextPaintIndex++;
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
// Pushes an externally owned paint (the `paint` prop) onto the stack. It
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
// opacity
|
|
62
|
+
// Pushes an externally owned paint (the `paint` prop) onto the stack. It
|
|
63
|
+
// pushes a frame-scoped copy, like the C++ DrawingCtx: materializePaint()
|
|
64
|
+
// mutates the top of the stack, and those mutations must not leak into the
|
|
65
|
+
// user-owned paint. It must also push an opacity alongside it: restorePaint()
|
|
66
|
+
// pops both, so pushing only the paint would underflow the opacity stack and
|
|
67
|
+
// leak the enclosing group's opacity onto everything drawn afterwards.
|
|
63
68
|
const pushPaint = (paint: SkPaint) => {
|
|
64
|
-
paints.push(paint);
|
|
69
|
+
paints.push(track(paint.copy()));
|
|
65
70
|
opacities.push(opacities[opacities.length - 1]);
|
|
66
71
|
};
|
|
67
72
|
|
|
@@ -370,22 +370,27 @@ export const SkiaPictureView = (props: SkiaPictureViewProps) => {
|
|
|
370
370
|
// - The renderer is created synchronously on mount (the canvas element is
|
|
371
371
|
// guaranteed to exist in useLayoutEffect; a zero size at that point is
|
|
372
372
|
// fine, the surface is created once the canvas is measurable).
|
|
373
|
-
// - Redraw requests coalesce into a single
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
//
|
|
373
|
+
// - Redraw requests coalesce into a single microtask. A microtask (not an
|
|
374
|
+
// animation frame) so that a picture produced inside a rAF callback (the
|
|
375
|
+
// Reanimated mapper) is drawn before the current frame paints: deferring
|
|
376
|
+
// to the next rAF alternates between "flush pending in this frame" and
|
|
377
|
+
// "flush scheduled for the next frame", drawing on every other frame
|
|
378
|
+
// only and halving the effective frame rate. A picture dispatched before
|
|
379
|
+
// the canvas has a size stays in pictureRef (drawing while unmeasured is
|
|
380
|
+
// a no-op) and is painted by the resize path below once the canvas
|
|
381
|
+
// becomes measurable, so it is never lost.
|
|
377
382
|
// - A ResizeObserver on the canvas itself recreates the surface and repaints
|
|
378
383
|
// synchronously (its callbacks run after layout, before paint), and is
|
|
379
384
|
// also the source of the user-facing onLayout event.
|
|
380
385
|
const redrawPendingRef = useRef(false);
|
|
381
|
-
const
|
|
386
|
+
const flushScheduledRef = useRef(false);
|
|
382
387
|
const onLayoutRef = useRef(onLayout);
|
|
383
388
|
useLayoutEffect(() => {
|
|
384
389
|
onLayoutRef.current = onLayout;
|
|
385
390
|
}, [onLayout]);
|
|
386
391
|
|
|
387
392
|
const flushRedraw = useCallback(() => {
|
|
388
|
-
|
|
393
|
+
flushScheduledRef.current = false;
|
|
389
394
|
if (redrawPendingRef.current && rendererRef.current && pictureRef.current) {
|
|
390
395
|
redrawPendingRef.current = false;
|
|
391
396
|
rendererRef.current.draw(pictureRef.current);
|
|
@@ -396,8 +401,9 @@ export const SkiaPictureView = (props: SkiaPictureViewProps) => {
|
|
|
396
401
|
|
|
397
402
|
const redraw = useCallback(() => {
|
|
398
403
|
redrawPendingRef.current = true;
|
|
399
|
-
if (
|
|
400
|
-
|
|
404
|
+
if (!flushScheduledRef.current) {
|
|
405
|
+
flushScheduledRef.current = true;
|
|
406
|
+
queueMicrotask(flushRedraw);
|
|
401
407
|
}
|
|
402
408
|
}, [flushRedraw]);
|
|
403
409
|
|
|
@@ -568,12 +574,9 @@ export const SkiaPictureView = (props: SkiaPictureViewProps) => {
|
|
|
568
574
|
};
|
|
569
575
|
}, [isStatic]);
|
|
570
576
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
frameRef.current = 0;
|
|
575
|
-
};
|
|
576
|
-
}, []);
|
|
577
|
+
// No flush cancellation is needed on unmount: a microtask queued before
|
|
578
|
+
// unmount runs within the same task, and flushRedraw no-ops once the
|
|
579
|
+
// layout-effect cleanup has nulled rendererRef.
|
|
577
580
|
|
|
578
581
|
useImperativeHandle(
|
|
579
582
|
ref,
|