react-native-skia 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Package.swift +14 -13
- package/README.md +19 -2
- package/android/CMakeLists.txt +13 -42
- package/android/build.gradle +54 -63
- package/android/cpp/jni/JniLoad.cpp +2 -4
- package/android/cpp/jni/include/JniSkiaView.h +123 -0
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp} +45 -100
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h} +24 -22
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -83
- package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -8
- package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +1 -2
- package/android/src/main/java/com/reactnative/skia/SkiaSurfaceView.java +1 -3
- package/android/src/main/java/com/reactnative/skia/SkiaTextureView.java +1 -17
- package/android/src/main/java/com/reactnative/skia/{SkiaBaseView.java → SkiaView.java} +78 -16
- package/android/src/main/java/com/reactnative/skia/SkiaViewManager.java +85 -0
- package/apple/MetalLayerColorSpace.mm +10 -12
- package/apple/RNSkApplePlatformContext.h +12 -14
- package/apple/RNSkApplePlatformContext.mm +19 -112
- package/apple/RNSkMetalCanvasProvider.h +14 -19
- package/apple/RNSkMetalCanvasProvider.mm +39 -70
- package/apple/RNSkiaModule.mm +10 -0
- package/apple/SkiaView.h +20 -0
- package/apple/SkiaView.mm +210 -0
- package/cpp/api/JsiSkApi.h +2 -13
- package/cpp/api/JsiSkCanvas.h +4 -18
- package/cpp/api/JsiSkGraphiteContext.h +1 -5
- package/cpp/api/JsiSkGraphiteRecording.h +1 -5
- package/cpp/api/JsiSkImage.h +7 -41
- package/cpp/api/JsiSkImageFactory.h +0 -14
- package/cpp/api/JsiSkSurface.h +2 -16
- package/cpp/api/JsiSkSurfaceFactory.h +0 -8
- package/cpp/rnskia/RNDawnContext.h +3 -2
- package/cpp/rnskia/RNDawnInterop.cpp +0 -4
- package/cpp/rnskia/RNDawnUtils.h +12 -1
- package/cpp/rnskia/RNDawnWindowContext.cpp +12 -1
- package/cpp/rnskia/RNDawnWindowContext.h +19 -7
- package/cpp/rnskia/RNMetalLayerColorSpace.h +4 -2
- package/cpp/rnskia/RNSkCanvasProvider.h +231 -0
- package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
- package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
- package/cpp/rnskia/RNSkGraphiteTarget.h +396 -0
- package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
- package/cpp/rnskia/RNSkPlatformContext.h +17 -15
- package/cpp/rnskia/RNSkView.h +362 -246
- package/jestSetup.js +1 -3
- package/lib/commonjs/Platform/Platform.web.js +1 -1
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/index.d.ts +1 -3
- package/lib/commonjs/index.js +3 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +15 -12
- package/lib/commonjs/renderer/Canvas.js +25 -21
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
- package/lib/commonjs/skia/types/Graphite.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +1 -2
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
- package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
- package/lib/commonjs/views/SkiaPictureView.js +12 -10
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
- package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
- package/lib/commonjs/views/SkiaView.web.js.map +1 -0
- package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
- package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
- package/lib/commonjs/views/android.d.ts +6 -0
- package/lib/commonjs/views/android.js +17 -0
- package/lib/commonjs/views/android.js.map +1 -0
- package/lib/commonjs/views/types.d.ts +3 -12
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +1 -1
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.js +1 -1
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/index.d.ts +1 -3
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock/index.js +0 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +15 -12
- package/lib/module/renderer/Canvas.js +25 -20
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/Graphite.d.ts +3 -3
- package/lib/module/skia/types/Graphite.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +1 -2
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/module/specs/NativeSkiaModule.web.js +5 -9
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/module/views/SkiaGraphiteView.js +23 -12
- package/lib/module/views/SkiaGraphiteView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.d.ts +4 -1
- package/lib/module/views/SkiaPictureView.js +12 -10
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.web.d.ts +12 -0
- package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
- package/lib/module/views/SkiaView.web.js.map +1 -0
- package/lib/module/views/SkiaWebRenderer.js +1 -1
- package/lib/module/views/SkiaWebRenderer.js.map +1 -1
- package/lib/module/views/android.d.ts +6 -0
- package/lib/module/views/android.js +10 -0
- package/lib/module/views/android.js.map +1 -0
- package/lib/module/views/types.d.ts +3 -12
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -3
- package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
- package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
- package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
- package/lib/typescript/src/views/android.d.ts +6 -0
- package/lib/typescript/src/views/types.d.ts +3 -12
- package/package.json +5 -13
- package/react-native-skia.podspec +34 -58
- package/src/Platform/Platform.web.tsx +1 -1
- package/src/external/reanimated/interpolators.ts +1 -1
- package/src/index.ts +1 -3
- package/src/mock/index.ts +0 -1
- package/src/renderer/Canvas.tsx +24 -28
- package/src/skia/types/Graphite.ts +3 -3
- package/src/skia/types/Image/ImageFactory.ts +2 -2
- package/src/skia/types/Skia.ts +1 -2
- package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
- package/src/specs/NativeSkiaModule.web.ts +9 -21
- package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
- package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
- package/src/views/SkiaGraphiteView.tsx +27 -16
- package/src/views/SkiaPictureView.tsx +11 -10
- package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
- package/src/views/SkiaWebRenderer.ts +1 -1
- package/src/views/android.ts +16 -0
- package/src/views/types.ts +3 -14
- package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
- package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
- package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
- package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
- package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
- package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
- package/android/cpp/rnskia-android/gl/Context.h +0 -80
- package/android/cpp/rnskia-android/gl/Display.h +0 -123
- package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
- package/android/cpp/rnskia-android/gl/Error.h +0 -8
- package/android/cpp/rnskia-android/gl/Surface.h +0 -43
- package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
- package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
- package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
- package/apple/MetalContext.h +0 -116
- package/apple/MetalContext.mm +0 -38
- package/apple/MetalWindowContext.h +0 -42
- package/apple/MetalWindowContext.mm +0 -95
- package/apple/RNSkAppleView.h +0 -49
- package/apple/RNSkAppleView.mm +0 -35
- package/apple/SkiaCVPixelBufferUtils.h +0 -122
- package/apple/SkiaCVPixelBufferUtils.mm +0 -535
- package/apple/SkiaGraphiteView.h +0 -26
- package/apple/SkiaGraphiteView.mm +0 -180
- package/apple/SkiaPictureView.h +0 -7
- package/apple/SkiaPictureView.mm +0 -70
- package/apple/SkiaUIView.h +0 -31
- package/apple/SkiaUIView.mm +0 -164
- package/cpp/rnskia/RNSkGraphiteView.h +0 -708
- package/cpp/rnskia/RNSkPictureView.cpp +0 -69
- package/cpp/rnskia/RNSkPictureView.h +0 -211
- package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
- package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
- package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
- package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
- package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
- package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
- package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/module/renderer/DefaultCanvas.js +0 -34
- package/lib/module/renderer/DefaultCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/module/renderer/GraphiteCanvas.js +0 -57
- package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
- package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/module/views/SkiaPictureView.web.js +0 -156
- package/lib/module/views/SkiaPictureView.web.js.map +0 -1
- package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
- package/libs/.graphite +0 -1
- package/src/renderer/DefaultCanvas.tsx +0 -41
- package/src/renderer/GraphiteCanvas.tsx +0 -61
- package/src/renderer/GraphiteCanvas.web.tsx +0 -3
- package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
- package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
- package/src/views/SkiaPictureView.web.tsx +0 -224
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useLayoutEffect","useRef","JsiSkSurface","dp2Pixel","pd","rect","undefined","x","y","width","height","canvasWebGL","WeakMap","deleteContextHandle","handle","CanvasKit","deleteContext","MakeWebGLContext","WebGLRenderer","constructor","canvas","requestRedraw","_defineProperty","release","restoreWanted","restoreRequest","setTimeout","_canvasWebGL$get","get","loseContext","restoreContext","acquire","entry","owner","addEventListener","onContextLost","onContextRestored","known","gl","isContextLost","lossAnnounced","_known$loseContext","GetWebGLContext","Error","trackContext","grContext","contextHandle","drawingBufferColorSpace","onResize","_canvas$getContext","getContext","getExtension","set","event","preventDefault","_this$surface","surface","ref","delete","releaseResourcesAndAbandonContext","_canvasWebGL$get$gl$i","_canvasWebGL$get2","makeImageSnapshot","frame","getCanvas","clear","TRANSPARENT","draw","flush","_this$surface2","window","devicePixelRatio","clientWidth","clientHeight","MakeOnScreenGLSurface","ColorSpace","SRGB","Float32Array","of","save","scale","picture","drawPicture","restore","dispose","removeEventListener","clearTimeout","queueMicrotask","isConnected","_entry$loseContext","StaticWebGLRenderer","cachedImage","renderFrameToSurface","tempCanvas","OffscreenCanvas","ctx","webglSurface","skiaCanvas","error","cleanupRenderResult","result","_result$surface","_result$tempCanvas$ge","renderResult","ctx2d","drawImage","console","_this$cachedImage","makeLayoutEvent","timeStamp","Date","now","nativeEvent","layout","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","isPropagationStopped","persist","stopPropagation","isTrusted","type","useSkiaWebRenderer","canvasRef","isStatic","host","rendererRef","hostRef","current","renderer","paint","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","onLayout","left","top","contentRect","observe","media","onPixelDensityChange","watchPixelDensity","_media","matchMedia","query","_media2","disconnect"],"sources":["SkiaWebRenderer.ts"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport type { RefObject } from \"react\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport type { GrDirectContext, WebGLContextHandle } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\n// The WebGL renderers behind the web views (SkiaPictureView, SkiaGraphiteView):\n// a <canvas> element, its WebGL context and the CanvasKit surface built on\n// it, with the context-loss handling and the \"destroy the context after each\n// draw\" mode that keeps a page under the browser's live-context limit.\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\n/**\n * What a view paints: pictures in points, replayed in order onto a cleared\n * surface.\n */\nexport type WebFrame = SkPicture[];\n\nexport interface Renderer {\n onResize(): void;\n /**\n * Paints the frame. Returns false when there is nothing to paint on yet\n * (the canvas is unmeasured, the context is lost): the caller keeps the\n * frame for the next opportunity.\n */\n draw(frame: WebFrame): boolean;\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\n// A <canvas> element owns at most one WebGL context for its whole lifetime.\n// A renderer, on the other hand, lives as long as the layout effect that\n// creates it, which is shorter: React re-runs layout effects on a *preserved*\n// host node under StrictMode's DEV double-invoke and when an Activity/offscreen\n// subtree is hidden and revealed (#3976). What belongs to the element rather\n// than to a renderer is tracked here, per element:\n// - the context, so that a new renderer can tell whether the element already\n// has one (and whether it is lost) without calling getContext() itself,\n// which on a fresh element would create a context with the wrong attributes\n// (CanvasKit.GetWebGLContext requests its own);\n// - the WEBGL_lose_context extension, captured while the context is healthy:\n// getExtension() returns null on a lost context, and this object is the only\n// way to lose a context on purpose or to ask the browser to restore one;\n// - whether the browser has announced the loss of the context yet: a lost\n// context can only be restored once its webglcontextlost event has been\n// dispatched, and that event is asynchronous;\n// - the renderer currently attached to the element, if any.\ninterface CanvasWebGL {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n // The WEBGL_lose_context extension.\n loseContext: { loseContext(): void; restoreContext(): void } | null;\n lossAnnounced: boolean;\n owner: WebGLRenderer | null;\n}\nconst canvasWebGL = new WeakMap<HTMLCanvasElement, CanvasWebGL>();\n\n// Unregisters a context from CanvasKit's registry, which otherwise retains the\n// canvas element (and its detached DOM tree) forever (#3924).\nconst deleteContextHandle = (handle: WebGLContextHandle) => {\n CanvasKit.deleteContext(handle);\n // Making the now-deleted handle current clears CanvasKit's current-context\n // globals (GLctx/Module.ctx), which would otherwise keep referencing the\n // context (and the canvas) until another surface becomes current. With a\n // deleted handle this is a no-op that returns null without creating\n // anything.\n CanvasKit.MakeWebGLContext(handle);\n};\n\nexport class WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n private grContext: GrDirectContext | null = null;\n private contextHandle: WebGLContextHandle = 0;\n private pd = 1;\n // Set while the renderer is waiting for a lost context to be restored.\n private restoreWanted = false;\n private restoreRequest: ReturnType<typeof setTimeout> | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n // Called when the renderer becomes able to paint again and the current\n // frame should be drawn.\n private requestRedraw: () => void\n ) {\n const entry = canvasWebGL.get(canvas);\n if (entry) {\n entry.owner = this;\n }\n canvas.addEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.addEventListener(\"webglcontextrestored\", this.onContextRestored);\n this.acquire();\n }\n\n // Builds the GrDirectContext and the surface on the element's WebGL\n // context, creating the context first if the element has none.\n private acquire() {\n const { canvas } = this;\n const known = canvasWebGL.get(canvas);\n if (known?.gl.isContextLost()) {\n // Nothing can be built on a lost context: CanvasKit.GetWebGLContext\n // happily registers it, and MakeWebGLContext then faults inside wasm\n // (#3976). Ask the browser for it back and finish in onContextRestored;\n // if the loss hasn't been announced yet, onContextLost asks.\n this.restoreWanted = true;\n if (known.lossAnnounced) {\n known.loseContext?.restoreContext();\n }\n return;\n }\n const handle = CanvasKit.GetWebGLContext(canvas);\n if (!handle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n const entry = known ?? this.trackContext();\n let grContext: GrDirectContext | null = null;\n try {\n grContext = CanvasKit.MakeWebGLContext(handle);\n } finally {\n if (!grContext) {\n // Whether it returned null or threw, don't leave the registry\n // holding on to the canvas.\n deleteContextHandle(handle);\n }\n }\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n this.restoreWanted = false;\n this.contextHandle = handle;\n this.grContext = grContext;\n if (entry) {\n entry.gl.drawingBufferColorSpace = \"display-p3\";\n }\n this.onResize();\n }\n\n // CanvasKit just created the element's context; asking for it again hands\n // back the same object (the attributes are only honored the first time).\n private trackContext(): CanvasWebGL | null {\n const { canvas } = this;\n const gl = canvas.getContext(\"webgl2\") ?? canvas.getContext(\"webgl\");\n if (!gl) {\n return null;\n }\n const entry: CanvasWebGL = {\n gl,\n loseContext: gl.getExtension(\"WEBGL_lose_context\"),\n lossAnnounced: false,\n owner: this,\n };\n canvasWebGL.set(canvas, entry);\n // Browsers restore a lost context (evicted as the oldest one when the\n // page exceeds the active-context limit, or lost to a GPU reset) only if\n // the page called preventDefault() on the webglcontextlost event. A\n // renderer isn't necessarily attached when that happens (the canvas may\n // be in a hidden Activity), so these listeners live as long as the\n // element does. They are registered ahead of any renderer's, and the\n // loss can't be announced before they exist since the event is\n // asynchronous.\n canvas.addEventListener(\"webglcontextlost\", (event) => {\n event.preventDefault();\n entry.lossAnnounced = true;\n });\n canvas.addEventListener(\"webglcontextrestored\", () => {\n entry.lossAnnounced = false;\n });\n return entry;\n }\n\n // Frees everything built on the context. The context itself belongs to the\n // element, see dispose().\n private release() {\n this.surface?.ref.delete();\n this.surface = null;\n if (this.grContext) {\n this.grContext.releaseResourcesAndAbandonContext();\n this.grContext.delete();\n this.grContext = null;\n }\n if (this.contextHandle) {\n deleteContextHandle(this.contextHandle);\n this.contextHandle = 0;\n }\n }\n\n private isContextLost() {\n return canvasWebGL.get(this.canvas)?.gl.isContextLost() ?? false;\n }\n\n private onContextLost = () => {\n // The browser already dropped every GL object; drop our references to\n // them. Restoration is left to the browser (it restores an evicted\n // context as soon as a slot frees up), except when this renderer was\n // built on an already-lost context and is waiting to paint for the first\n // time: chasing an eviction from here would evict the next-oldest context\n // in turn, and with more live canvases than the browser allows the\n // canvases would endlessly evict each other.\n this.release();\n if (this.restoreWanted) {\n // The permission granted by preventDefault() is only recorded by the\n // browser once the event dispatch is over: a restoreContext() call\n // from inside the handler is refused, so ask from a later task.\n this.restoreRequest = setTimeout(() => {\n this.restoreRequest = null;\n canvasWebGL.get(this.canvas)?.loseContext?.restoreContext();\n }, 0);\n }\n };\n\n private onContextRestored = () => {\n this.acquire();\n this.requestRedraw();\n };\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.surface || this.isContextLost()) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(frame);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas } = this;\n if (!this.grContext || this.isContextLost()) {\n // Waiting for the context to be restored (the restore path resizes),\n // or the loss hasn't been announced yet and onContextLost is about to\n // release everything: either way there is nothing to build on.\n return;\n }\n this.pd = window.devicePixelRatio;\n canvas.width = canvas.clientWidth * this.pd;\n canvas.height = canvas.clientHeight * this.pd;\n this.surface?.ref.delete();\n this.surface = null;\n if (canvas.width === 0 || canvas.height === 0) {\n // The canvas hasn't been laid out yet (or is hidden). The view's\n // ResizeObserver calls us again as soon as it has a size.\n return;\n }\n // Reuse the existing WebGL context and GrDirectContext: only the surface\n // needs to be recreated when the canvas is resized.\n const surface = CanvasKit.MakeOnScreenGLSurface(\n this.grContext,\n canvas.width,\n canvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(frame: WebFrame) {\n if (!this.surface || this.isContextLost()) {\n return false;\n }\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(this.pd, this.pd);\n for (const picture of frame) {\n canvas.drawPicture(picture);\n }\n canvas.restore();\n this.surface.ref.flush();\n return true;\n }\n\n dispose(): void {\n const { canvas } = this;\n canvas.removeEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.removeEventListener(\"webglcontextrestored\", this.onContextRestored);\n if (this.restoreRequest !== null) {\n clearTimeout(this.restoreRequest);\n this.restoreRequest = null;\n }\n this.restoreWanted = false;\n this.release();\n // Free the drawing buffer, which CanvasKit requests with depth and stencil\n // attachments (about 8 bytes per pixel): a canvas that stays in the\n // document without a renderer, hidden in an Activity say, would otherwise\n // keep a full-size buffer around. The next renderer's onResize() sizes it\n // again.\n canvas.width = 0;\n canvas.height = 0;\n const entry = canvasWebGL.get(canvas);\n if (!entry) {\n return;\n }\n entry.owner = null;\n // Whether the element is going away is only known once the commit is\n // over: on a real unmount React runs this cleanup *before* removing the\n // node from the document, while StrictMode's double-invoke and an\n // Activity hide keep the node in place (and the former builds the next\n // renderer on it right away). Losing the context of a detached element\n // matters: it would otherwise stay alive until the element is garbage\n // collected, and browsers cap the number of live contexts per page\n // (16 in Chrome, which then evicts the oldest one, visible or not).\n queueMicrotask(() => {\n if (\n entry.owner === null &&\n !canvas.isConnected &&\n !entry.gl.isContextLost()\n ) {\n entry.loseContext?.loseContext();\n }\n });\n }\n}\n\ninterface TempRenderResult {\n surface: JsiSkSurface;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext;\n contextHandle: WebGLContextHandle;\n}\n\nexport class StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderFrameToSurface(frame: WebFrame): TempRenderResult | null {\n this.pd = window.devicePixelRatio;\n if (this.canvas.clientWidth === 0 || this.canvas.clientHeight === 0) {\n return null;\n }\n const tempCanvas = new OffscreenCanvas(\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n let surface: JsiSkSurface | null = null;\n let grContext: GrDirectContext | null = null;\n let contextHandle: WebGLContextHandle = 0;\n\n try {\n contextHandle = CanvasKit.GetWebGLContext(tempCanvas);\n if (!contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n grContext = CanvasKit.MakeWebGLContext(contextHandle);\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n const webglSurface = CanvasKit.MakeOnScreenGLSurface(\n grContext,\n tempCanvas.width,\n tempCanvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n\n if (!webglSurface) {\n throw new Error(\"Could not create WebGL surface\");\n }\n\n surface = new JsiSkSurface(CanvasKit, webglSurface);\n\n const skiaCanvas = surface.getCanvas();\n skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));\n skiaCanvas.save();\n skiaCanvas.scale(this.pd, this.pd);\n for (const picture of frame) {\n skiaCanvas.drawPicture(picture);\n }\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas, grContext, contextHandle };\n } catch (error) {\n this.cleanupRenderResult({\n surface,\n tempCanvas,\n grContext,\n contextHandle,\n });\n return null;\n }\n }\n\n private cleanupRenderResult(result: {\n surface: JsiSkSurface | null;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext | null;\n contextHandle: WebGLContextHandle;\n }): void {\n result.surface?.ref.delete();\n if (result.grContext) {\n result.grContext.releaseResourcesAndAbandonContext();\n result.grContext.delete();\n }\n result.tempCanvas\n .getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (result.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the OffscreenCanvas forever.\n CanvasKit.deleteContext(result.contextHandle);\n // Clear CanvasKit's current-context globals (see WebGLRenderer.dispose).\n CanvasKit.MakeWebGLContext(result.contextHandle);\n }\n }\n\n draw(frame: WebFrame) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return false;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n this.cleanupRenderResult(renderResult);\n throw new Error(\"Could not get 2D context\");\n }\n\n // Set canvas dimensions to match pixel density\n this.canvas.width = this.canvas.clientWidth * this.pd;\n this.canvas.height = this.canvas.clientHeight * this.pd;\n\n // Draw the tempCanvas scaled down to the display size\n ctx2d.drawImage(\n tempCanvas,\n 0,\n 0,\n tempCanvas.width,\n tempCanvas.height,\n 0,\n 0,\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n this.cleanupRenderResult(renderResult);\n return true;\n }\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return null;\n }\n\n try {\n this.cachedImage = renderResult.surface.makeImageSnapshot(\n dp2Pixel(this.pd, rect)\n );\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n this.cleanupRenderResult(renderResult);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\n// Mirrors the event react-native-web synthesizes for onLayout.\nexport const makeLayoutEvent = (\n x: number,\n y: number,\n width: number,\n height: number\n): LayoutChangeEvent => ({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x, y, width, height } },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n currentTarget: 0,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n target: 0,\n bubbles: false,\n cancelable: false,\n defaultPrevented: false,\n eventPhase: 0,\n isDefaultPrevented() {\n throw new Error(\"Method not supported on web.\");\n },\n isPropagationStopped() {\n throw new Error(\"Method not supported on web.\");\n },\n persist() {\n throw new Error(\"Method not supported on web.\");\n },\n preventDefault() {\n throw new Error(\"Method not supported on web.\");\n },\n stopPropagation() {\n throw new Error(\"Method not supported on web.\");\n },\n isTrusted: true,\n type: \"\",\n});\n\nexport interface WebRendererHost {\n /**\n * Paints the view's current content, if any, on a renderer that just got\n * (or got back) a surface: after a resize, a density change or a restored\n * context.\n */\n paint: (renderer: Renderer) => void;\n onLayout?: (event: LayoutChangeEvent) => void;\n}\n\n/**\n * Owns a renderer for the given <canvas> element for as long as the view is\n * mounted, and keeps its surface in step with the element's size and the\n * display's pixel density.\n *\n * The rendering lifecycle deliberately does not depend on layout events:\n * - The renderer is created synchronously on mount (the canvas element is\n * guaranteed to exist in useLayoutEffect; a zero size at that point is\n * fine, the surface is created once the canvas is measurable).\n * - A ResizeObserver on the canvas itself recreates the surface and repaints\n * synchronously (its callbacks run after layout, before paint), and is\n * also the source of the user-facing onLayout event.\n * - The renderer belongs to the layout effect, the WebGL context to the\n * <canvas> element, whose lifetime is longer; see WebGLRenderer for how\n * the two are reconciled.\n */\nexport const useSkiaWebRenderer = (\n canvasRef: RefObject<HTMLCanvasElement | null>,\n isStatic: boolean,\n host: WebRendererHost\n): RefObject<Renderer | null> => {\n const rendererRef = useRef<Renderer | null>(null);\n const hostRef = useRef(host);\n useLayoutEffect(() => {\n hostRef.current = host;\n }, [host]);\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer: Renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas, () => hostRef.current.paint(renderer));\n rendererRef.current = renderer;\n\n const paint = () => hostRef.current.paint(renderer);\n\n // The renderer constructor already sized the surface from the current\n // layout, so the observer's initial delivery only repaints if the size\n // changed in between.\n let lastWidth = canvas.clientWidth;\n let lastHeight = canvas.clientHeight;\n let lastPixelDensity = window.devicePixelRatio;\n const resizeIfNeeded = () => {\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n const pixelDensity = window.devicePixelRatio;\n if (\n width === lastWidth &&\n height === lastHeight &&\n pixelDensity === lastPixelDensity\n ) {\n return;\n }\n lastWidth = width;\n lastHeight = height;\n lastPixelDensity = pixelDensity;\n renderer.onResize();\n paint();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = hostRef.current.onLayout;\n if (layoutHandler) {\n const { left, top, width, height } = entries[0].contentRect;\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () => layoutHandler(makeLayoutEvent(left, top, width, height)),\n 0\n );\n }\n });\n observer.observe(canvas);\n\n // A pixel-density change with no CSS size change (browser zoom, moving\n // the window to another display) doesn't trigger the ResizeObserver:\n // watch it via matchMedia, re-arming the query for each new density.\n // This degrades gracefully where unsupported: without matchMedia or\n // MediaQueryList.addEventListener (older Safari), or where the query\n // never matches because the resolution feature is unknown (Safari < 16),\n // density-only changes simply don't repaint — everything else still does.\n let media: MediaQueryList | null = null;\n const onPixelDensityChange = () => {\n resizeIfNeeded();\n watchPixelDensity();\n };\n const watchPixelDensity = () => {\n media?.removeEventListener(\"change\", onPixelDensityChange);\n media = null;\n if (typeof window.matchMedia === \"function\") {\n const query = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n if (typeof query.addEventListener === \"function\") {\n media = query;\n media.addEventListener(\"change\", onPixelDensityChange);\n }\n }\n };\n watchPixelDensity();\n\n // Paint any content that was dispatched before the renderer existed.\n paint();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [canvasRef, isStatic]);\n\n return rendererRef;\n};\n"],"mappings":";;;AAAA;;AAEA,SAASA,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAK/C,SAASC,YAAY,QAAQ,0BAA0B;;AAEvD;AACA;AACA;AACA;;AAEA,MAAMC,QAAQ,GAAGA,CAACC,EAAU,EAAEC,IAAa,KAAK;EAC9C,IAAI,CAACA,IAAI,EAAE;IACT,OAAOC,SAAS;EAClB;EACA,OAAO;IACLC,CAAC,EAAEF,IAAI,CAACE,CAAC,GAAGH,EAAE;IACdI,CAAC,EAAEH,IAAI,CAACG,CAAC,GAAGJ,EAAE;IACdK,KAAK,EAAEJ,IAAI,CAACI,KAAK,GAAGL,EAAE;IACtBM,MAAM,EAAEL,IAAI,CAACK,MAAM,GAAGN;EACxB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,MAAMO,WAAW,GAAG,IAAIC,OAAO,CAAiC,CAAC;;AAEjE;AACA;AACA,MAAMC,mBAAmB,GAAIC,MAA0B,IAAK;EAC1DC,SAAS,CAACC,aAAa,CAACF,MAAM,CAAC;EAC/B;EACA;EACA;EACA;EACA;EACAC,SAAS,CAACE,gBAAgB,CAACH,MAAM,CAAC;AACpC,CAAC;AAED,OAAO,MAAMI,aAAa,CAAqB;EAS7CC,WAAWA,CACDC,MAAyB;EACjC;EACA;EACQC,aAAyB,EACjC;IAAA,KAJQD,MAAyB,GAAzBA,MAAyB;IAAA,KAGzBC,aAAyB,GAAzBA,aAAyB;IAAAC,eAAA,kBAZI,IAAI;IAAAA,eAAA,oBACC,I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AC,CAAC;MAChBa,iBAAiB,CAAC,CAAC;IACrB,CAAC;IACD,MAAMA,iBAAiB,GAAGA,CAAA,KAAM;MAAA,IAAAC,MAAA;MAC9B,CAAAA,MAAA,GAAAH,KAAK,cAAAG,MAAA,eAALA,MAAA,CAAOnE,mBAAmB,CAAC,QAAQ,EAAEiE,oBAAoB,CAAC;MAC1DD,KAAK,GAAG,IAAI;MACZ,IAAI,OAAO/E,MAAM,CAACmF,UAAU,KAAK,UAAU,EAAE;QAC3C,MAAMC,KAAK,GAAGpF,MAAM,CAACmF,UAAU,CAC7B,gBAAgBnF,MAAM,CAACC,gBAAgB,OACzC,CAAC;QACD,IAAI,OAAOmF,KAAK,CAACxH,gBAAgB,KAAK,UAAU,EAAE;UAChDmH,KAAK,GAAGK,KAAK;UACbL,KAAK,CAACnH,gBAAgB,CAAC,QAAQ,EAAEoH,oBAAoB,CAAC;QACxD;MACF;IACF,CAAC;IACDC,iBAAiB,CAAC,CAAC;;IAEnB;IACAjB,KAAK,CAAC,CAAC;IAEP,OAAO,MAAM;MAAA,IAAAqB,OAAA;MACXf,QAAQ,CAACgB,UAAU,CAAC,CAAC;MACrB,CAAAD,OAAA,GAAAN,KAAK,cAAAM,OAAA,eAALA,OAAA,CAAOtE,mBAAmB,CAAC,QAAQ,EAAEiE,oBAAoB,CAAC;MAC1DpB,WAAW,CAACE,OAAO,GAAG,IAAI;MAC1BC,QAAQ,CAACjD,OAAO,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAAC2C,SAAS,EAAEC,QAAQ,CAAC,CAAC;EAEzB,OAAOE,WAAW;AACpB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","useRef","JsiSkSurface","dp2Pixel","pd","rect","undefined","x","y","width","height","canvasWebGL","WeakMap","deleteContextHandle","handle","CanvasKit","deleteContext","MakeWebGLContext","WebGLRenderer","constructor","canvas","requestRedraw","_defineProperty","release","restoreWanted","restoreRequest","setTimeout","_canvasWebGL$get","get","loseContext","restoreContext","acquire","entry","owner","addEventListener","onContextLost","onContextRestored","known","gl","isContextLost","lossAnnounced","_known$loseContext","GetWebGLContext","Error","trackContext","grContext","contextHandle","drawingBufferColorSpace","onResize","_canvas$getContext","getContext","getExtension","set","event","preventDefault","_this$surface","surface","ref","delete","releaseResourcesAndAbandonContext","_canvasWebGL$get$gl$i","_canvasWebGL$get2","makeImageSnapshot","frame","getCanvas","clear","TRANSPARENT","draw","flush","_this$surface2","window","devicePixelRatio","clientWidth","clientHeight","MakeOnScreenGLSurface","ColorSpace","SRGB","Float32Array","of","save","scale","picture","drawPicture","restore","dispose","removeEventListener","clearTimeout","queueMicrotask","isConnected","_entry$loseContext","StaticWebGLRenderer","cachedImage","renderFrameToSurface","tempCanvas","OffscreenCanvas","ctx","webglSurface","skiaCanvas","error","cleanupRenderResult","result","_result$surface","_result$tempCanvas$ge","renderResult","ctx2d","drawImage","console","_this$cachedImage","makeLayoutEvent","timeStamp","Date","now","nativeEvent","layout","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","isPropagationStopped","persist","stopPropagation","isTrusted","type","useSkiaWebRenderer","canvasRef","isStatic","host","rendererRef","hostRef","current","renderer","paint","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","onLayout","left","top","contentRect","observe","media","onPixelDensityChange","watchPixelDensity","_media","matchMedia","query","_media2","disconnect"],"sources":["SkiaWebRenderer.ts"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport type { RefObject } from \"react\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport type { GrDirectContext, WebGLContextHandle } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\n// The WebGL renderers behind the web view (SkiaView.web):\n// a <canvas> element, its WebGL context and the CanvasKit surface built on\n// it, with the context-loss handling and the \"destroy the context after each\n// draw\" mode that keeps a page under the browser's live-context limit.\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\n/**\n * What a view paints: pictures in points, replayed in order onto a cleared\n * surface.\n */\nexport type WebFrame = SkPicture[];\n\nexport interface Renderer {\n onResize(): void;\n /**\n * Paints the frame. Returns false when there is nothing to paint on yet\n * (the canvas is unmeasured, the context is lost): the caller keeps the\n * frame for the next opportunity.\n */\n draw(frame: WebFrame): boolean;\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\n// A <canvas> element owns at most one WebGL context for its whole lifetime.\n// A renderer, on the other hand, lives as long as the layout effect that\n// creates it, which is shorter: React re-runs layout effects on a *preserved*\n// host node under StrictMode's DEV double-invoke and when an Activity/offscreen\n// subtree is hidden and revealed (#3976). What belongs to the element rather\n// than to a renderer is tracked here, per element:\n// - the context, so that a new renderer can tell whether the element already\n// has one (and whether it is lost) without calling getContext() itself,\n// which on a fresh element would create a context with the wrong attributes\n// (CanvasKit.GetWebGLContext requests its own);\n// - the WEBGL_lose_context extension, captured while the context is healthy:\n// getExtension() returns null on a lost context, and this object is the only\n// way to lose a context on purpose or to ask the browser to restore one;\n// - whether the browser has announced the loss of the context yet: a lost\n// context can only be restored once its webglcontextlost event has been\n// dispatched, and that event is asynchronous;\n// - the renderer currently attached to the element, if any.\ninterface CanvasWebGL {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n // The WEBGL_lose_context extension.\n loseContext: { loseContext(): void; restoreContext(): void } | null;\n lossAnnounced: boolean;\n owner: WebGLRenderer | null;\n}\nconst canvasWebGL = new WeakMap<HTMLCanvasElement, CanvasWebGL>();\n\n// Unregisters a context from CanvasKit's registry, which otherwise retains the\n// canvas element (and its detached DOM tree) forever (#3924).\nconst deleteContextHandle = (handle: WebGLContextHandle) => {\n CanvasKit.deleteContext(handle);\n // Making the now-deleted handle current clears CanvasKit's current-context\n // globals (GLctx/Module.ctx), which would otherwise keep referencing the\n // context (and the canvas) until another surface becomes current. With a\n // deleted handle this is a no-op that returns null without creating\n // anything.\n CanvasKit.MakeWebGLContext(handle);\n};\n\nexport class WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n private grContext: GrDirectContext | null = null;\n private contextHandle: WebGLContextHandle = 0;\n private pd = 1;\n // Set while the renderer is waiting for a lost context to be restored.\n private restoreWanted = false;\n private restoreRequest: ReturnType<typeof setTimeout> | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n // Called when the renderer becomes able to paint again and the current\n // frame should be drawn.\n private requestRedraw: () => void\n ) {\n const entry = canvasWebGL.get(canvas);\n if (entry) {\n entry.owner = this;\n }\n canvas.addEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.addEventListener(\"webglcontextrestored\", this.onContextRestored);\n this.acquire();\n }\n\n // Builds the GrDirectContext and the surface on the element's WebGL\n // context, creating the context first if the element has none.\n private acquire() {\n const { canvas } = this;\n const known = canvasWebGL.get(canvas);\n if (known?.gl.isContextLost()) {\n // Nothing can be built on a lost context: CanvasKit.GetWebGLContext\n // happily registers it, and MakeWebGLContext then faults inside wasm\n // (#3976). Ask the browser for it back and finish in onContextRestored;\n // if the loss hasn't been announced yet, onContextLost asks.\n this.restoreWanted = true;\n if (known.lossAnnounced) {\n known.loseContext?.restoreContext();\n }\n return;\n }\n const handle = CanvasKit.GetWebGLContext(canvas);\n if (!handle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n const entry = known ?? this.trackContext();\n let grContext: GrDirectContext | null = null;\n try {\n grContext = CanvasKit.MakeWebGLContext(handle);\n } finally {\n if (!grContext) {\n // Whether it returned null or threw, don't leave the registry\n // holding on to the canvas.\n deleteContextHandle(handle);\n }\n }\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n this.restoreWanted = false;\n this.contextHandle = handle;\n this.grContext = grContext;\n if (entry) {\n entry.gl.drawingBufferColorSpace = \"display-p3\";\n }\n this.onResize();\n }\n\n // CanvasKit just created the element's context; asking for it again hands\n // back the same object (the attributes are only honored the first time).\n private trackContext(): CanvasWebGL | null {\n const { canvas } = this;\n const gl = canvas.getContext(\"webgl2\") ?? canvas.getContext(\"webgl\");\n if (!gl) {\n return null;\n }\n const entry: CanvasWebGL = {\n gl,\n loseContext: gl.getExtension(\"WEBGL_lose_context\"),\n lossAnnounced: false,\n owner: this,\n };\n canvasWebGL.set(canvas, entry);\n // Browsers restore a lost context (evicted as the oldest one when the\n // page exceeds the active-context limit, or lost to a GPU reset) only if\n // the page called preventDefault() on the webglcontextlost event. A\n // renderer isn't necessarily attached when that happens (the canvas may\n // be in a hidden Activity), so these listeners live as long as the\n // element does. They are registered ahead of any renderer's, and the\n // loss can't be announced before they exist since the event is\n // asynchronous.\n canvas.addEventListener(\"webglcontextlost\", (event) => {\n event.preventDefault();\n entry.lossAnnounced = true;\n });\n canvas.addEventListener(\"webglcontextrestored\", () => {\n entry.lossAnnounced = false;\n });\n return entry;\n }\n\n // Frees everything built on the context. The context itself belongs to the\n // element, see dispose().\n private release() {\n this.surface?.ref.delete();\n this.surface = null;\n if (this.grContext) {\n this.grContext.releaseResourcesAndAbandonContext();\n this.grContext.delete();\n this.grContext = null;\n }\n if (this.contextHandle) {\n deleteContextHandle(this.contextHandle);\n this.contextHandle = 0;\n }\n }\n\n private isContextLost() {\n return canvasWebGL.get(this.canvas)?.gl.isContextLost() ?? false;\n }\n\n private onContextLost = () => {\n // The browser already dropped every GL object; drop our references to\n // them. Restoration is left to the browser (it restores an evicted\n // context as soon as a slot frees up), except when this renderer was\n // built on an already-lost context and is waiting to paint for the first\n // time: chasing an eviction from here would evict the next-oldest context\n // in turn, and with more live canvases than the browser allows the\n // canvases would endlessly evict each other.\n this.release();\n if (this.restoreWanted) {\n // The permission granted by preventDefault() is only recorded by the\n // browser once the event dispatch is over: a restoreContext() call\n // from inside the handler is refused, so ask from a later task.\n this.restoreRequest = setTimeout(() => {\n this.restoreRequest = null;\n canvasWebGL.get(this.canvas)?.loseContext?.restoreContext();\n }, 0);\n }\n };\n\n private onContextRestored = () => {\n this.acquire();\n this.requestRedraw();\n };\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.surface || this.isContextLost()) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(frame);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas } = this;\n if (!this.grContext || this.isContextLost()) {\n // Waiting for the context to be restored (the restore path resizes),\n // or the loss hasn't been announced yet and onContextLost is about to\n // release everything: either way there is nothing to build on.\n return;\n }\n this.pd = window.devicePixelRatio;\n canvas.width = canvas.clientWidth * this.pd;\n canvas.height = canvas.clientHeight * this.pd;\n this.surface?.ref.delete();\n this.surface = null;\n if (canvas.width === 0 || canvas.height === 0) {\n // The canvas hasn't been laid out yet (or is hidden). The view's\n // ResizeObserver calls us again as soon as it has a size.\n return;\n }\n // Reuse the existing WebGL context and GrDirectContext: only the surface\n // needs to be recreated when the canvas is resized.\n const surface = CanvasKit.MakeOnScreenGLSurface(\n this.grContext,\n canvas.width,\n canvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(frame: WebFrame) {\n if (!this.surface || this.isContextLost()) {\n return false;\n }\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(this.pd, this.pd);\n for (const picture of frame) {\n canvas.drawPicture(picture);\n }\n canvas.restore();\n this.surface.ref.flush();\n return true;\n }\n\n dispose(): void {\n const { canvas } = this;\n canvas.removeEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.removeEventListener(\"webglcontextrestored\", this.onContextRestored);\n if (this.restoreRequest !== null) {\n clearTimeout(this.restoreRequest);\n this.restoreRequest = null;\n }\n this.restoreWanted = false;\n this.release();\n // Free the drawing buffer, which CanvasKit requests with depth and stencil\n // attachments (about 8 bytes per pixel): a canvas that stays in the\n // document without a renderer, hidden in an Activity say, would otherwise\n // keep a full-size buffer around. The next renderer's onResize() sizes it\n // again.\n canvas.width = 0;\n canvas.height = 0;\n const entry = canvasWebGL.get(canvas);\n if (!entry) {\n return;\n }\n entry.owner = null;\n // Whether the element is going away is only known once the commit is\n // over: on a real unmount React runs this cleanup *before* removing the\n // node from the document, while StrictMode's double-invoke and an\n // Activity hide keep the node in place (and the former builds the next\n // renderer on it right away). Losing the context of a detached element\n // matters: it would otherwise stay alive until the element is garbage\n // collected, and browsers cap the number of live contexts per page\n // (16 in Chrome, which then evicts the oldest one, visible or not).\n queueMicrotask(() => {\n if (\n entry.owner === null &&\n !canvas.isConnected &&\n !entry.gl.isContextLost()\n ) {\n entry.loseContext?.loseContext();\n }\n });\n }\n}\n\ninterface TempRenderResult {\n surface: JsiSkSurface;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext;\n contextHandle: WebGLContextHandle;\n}\n\nexport class StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderFrameToSurface(frame: WebFrame): TempRenderResult | null {\n this.pd = window.devicePixelRatio;\n if (this.canvas.clientWidth === 0 || this.canvas.clientHeight === 0) {\n return null;\n }\n const tempCanvas = new OffscreenCanvas(\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n let surface: JsiSkSurface | null = null;\n let grContext: GrDirectContext | null = null;\n let contextHandle: WebGLContextHandle = 0;\n\n try {\n contextHandle = CanvasKit.GetWebGLContext(tempCanvas);\n if (!contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n grContext = CanvasKit.MakeWebGLContext(contextHandle);\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n const webglSurface = CanvasKit.MakeOnScreenGLSurface(\n grContext,\n tempCanvas.width,\n tempCanvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n\n if (!webglSurface) {\n throw new Error(\"Could not create WebGL surface\");\n }\n\n surface = new JsiSkSurface(CanvasKit, webglSurface);\n\n const skiaCanvas = surface.getCanvas();\n skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));\n skiaCanvas.save();\n skiaCanvas.scale(this.pd, this.pd);\n for (const picture of frame) {\n skiaCanvas.drawPicture(picture);\n }\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas, grContext, contextHandle };\n } catch (error) {\n this.cleanupRenderResult({\n surface,\n tempCanvas,\n grContext,\n contextHandle,\n });\n return null;\n }\n }\n\n private cleanupRenderResult(result: {\n surface: JsiSkSurface | null;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext | null;\n contextHandle: WebGLContextHandle;\n }): void {\n result.surface?.ref.delete();\n if (result.grContext) {\n result.grContext.releaseResourcesAndAbandonContext();\n result.grContext.delete();\n }\n result.tempCanvas\n .getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (result.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the OffscreenCanvas forever.\n CanvasKit.deleteContext(result.contextHandle);\n // Clear CanvasKit's current-context globals (see WebGLRenderer.dispose).\n CanvasKit.MakeWebGLContext(result.contextHandle);\n }\n }\n\n draw(frame: WebFrame) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return false;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n this.cleanupRenderResult(renderResult);\n throw new Error(\"Could not get 2D context\");\n }\n\n // Set canvas dimensions to match pixel density\n this.canvas.width = this.canvas.clientWidth * this.pd;\n this.canvas.height = this.canvas.clientHeight * this.pd;\n\n // Draw the tempCanvas scaled down to the display size\n ctx2d.drawImage(\n tempCanvas,\n 0,\n 0,\n tempCanvas.width,\n tempCanvas.height,\n 0,\n 0,\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n this.cleanupRenderResult(renderResult);\n return true;\n }\n\n makeImageSnapshot(frame: WebFrame, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderFrameToSurface(frame);\n if (!renderResult) {\n return null;\n }\n\n try {\n this.cachedImage = renderResult.surface.makeImageSnapshot(\n dp2Pixel(this.pd, rect)\n );\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n this.cleanupRenderResult(renderResult);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\n// Mirrors the event react-native-web synthesizes for onLayout.\nexport const makeLayoutEvent = (\n x: number,\n y: number,\n width: number,\n height: number\n): LayoutChangeEvent => ({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x, y, width, height } },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n currentTarget: 0,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n target: 0,\n bubbles: false,\n cancelable: false,\n defaultPrevented: false,\n eventPhase: 0,\n isDefaultPrevented() {\n throw new Error(\"Method not supported on web.\");\n },\n isPropagationStopped() {\n throw new Error(\"Method not supported on web.\");\n },\n persist() {\n throw new Error(\"Method not supported on web.\");\n },\n preventDefault() {\n throw new Error(\"Method not supported on web.\");\n },\n stopPropagation() {\n throw new Error(\"Method not supported on web.\");\n },\n isTrusted: true,\n type: \"\",\n});\n\nexport interface WebRendererHost {\n /**\n * Paints the view's current content, if any, on a renderer that just got\n * (or got back) a surface: after a resize, a density change or a restored\n * context.\n */\n paint: (renderer: Renderer) => void;\n onLayout?: (event: LayoutChangeEvent) => void;\n}\n\n/**\n * Owns a renderer for the given <canvas> element for as long as the view is\n * mounted, and keeps its surface in step with the element's size and the\n * display's pixel density.\n *\n * The rendering lifecycle deliberately does not depend on layout events:\n * - The renderer is created synchronously on mount (the canvas element is\n * guaranteed to exist in useLayoutEffect; a zero size at that point is\n * fine, the surface is created once the canvas is measurable).\n * - A ResizeObserver on the canvas itself recreates the surface and repaints\n * synchronously (its callbacks run after layout, before paint), and is\n * also the source of the user-facing onLayout event.\n * - The renderer belongs to the layout effect, the WebGL context to the\n * <canvas> element, whose lifetime is longer; see WebGLRenderer for how\n * the two are reconciled.\n */\nexport const useSkiaWebRenderer = (\n canvasRef: RefObject<HTMLCanvasElement | null>,\n isStatic: boolean,\n host: WebRendererHost\n): RefObject<Renderer | null> => {\n const rendererRef = useRef<Renderer | null>(null);\n const hostRef = useRef(host);\n useLayoutEffect(() => {\n hostRef.current = host;\n }, [host]);\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer: Renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas, () => hostRef.current.paint(renderer));\n rendererRef.current = renderer;\n\n const paint = () => hostRef.current.paint(renderer);\n\n // The renderer constructor already sized the surface from the current\n // layout, so the observer's initial delivery only repaints if the size\n // changed in between.\n let lastWidth = canvas.clientWidth;\n let lastHeight = canvas.clientHeight;\n let lastPixelDensity = window.devicePixelRatio;\n const resizeIfNeeded = () => {\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n const pixelDensity = window.devicePixelRatio;\n if (\n width === lastWidth &&\n height === lastHeight &&\n pixelDensity === lastPixelDensity\n ) {\n return;\n }\n lastWidth = width;\n lastHeight = height;\n lastPixelDensity = pixelDensity;\n renderer.onResize();\n paint();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = hostRef.current.onLayout;\n if (layoutHandler) {\n const { left, top, width, height } = entries[0].contentRect;\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () => layoutHandler(makeLayoutEvent(left, top, width, height)),\n 0\n );\n }\n });\n observer.observe(canvas);\n\n // A pixel-density change with no CSS size change (browser zoom, moving\n // the window to another display) doesn't trigger the ResizeObserver:\n // watch it via matchMedia, re-arming the query for each new density.\n // This degrades gracefully where unsupported: without matchMedia or\n // MediaQueryList.addEventListener (older Safari), or where the query\n // never matches because the resolution feature is unknown (Safari < 16),\n // density-only changes simply don't repaint — everything else still does.\n let media: MediaQueryList | null = null;\n const onPixelDensityChange = () => {\n resizeIfNeeded();\n watchPixelDensity();\n };\n const watchPixelDensity = () => {\n media?.removeEventListener(\"change\", onPixelDensityChange);\n media = null;\n if (typeof window.matchMedia === \"function\") {\n const query = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n if (typeof query.addEventListener === \"function\") {\n media = query;\n media.addEventListener(\"change\", onPixelDensityChange);\n }\n }\n };\n watchPixelDensity();\n\n // Paint any content that was dispatched before the renderer existed.\n paint();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [canvasRef, isStatic]);\n\n return rendererRef;\n};\n"],"mappings":";;;AAAA;;AAEA,SAASA,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAK/C,SAASC,YAAY,QAAQ,0BAA0B;;AAEvD;AACA;AACA;AACA;;AAEA,MAAMC,QAAQ,GAAGA,CAACC,EAAU,EAAEC,IAAa,KAAK;EAC9C,IAAI,CAACA,IAAI,EAAE;IACT,OAAOC,SAAS;EAClB;EACA,OAAO;IACLC,CAAC,EAAEF,IAAI,CAACE,CAAC,GAAGH,EAAE;IACdI,CAAC,EAAEH,IAAI,CAACG,CAAC,GAAGJ,EAAE;IACdK,KAAK,EAAEJ,IAAI,CAACI,KAAK,GAAGL,EAAE;IACtBM,MAAM,EAAEL,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;IAEP,OAAO,MAAM;MAAA,IAAAqB,OAAA;MACXf,QAAQ,CAACgB,UAAU,CAAC,CAAC;MACrB,CAAAD,OAAA,GAAAN,KAAK,cAAAM,OAAA,eAALA,OAAA,CAAOtE,mBAAmB,CAAC,QAAQ,EAAEiE,oBAAoB,CAAC;MAC1DpB,WAAW,CAACE,OAAO,GAAG,IAAI;MAC1BC,QAAQ,CAACjD,OAAO,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAAC2C,SAAS,EAAEC,QAAQ,CAAC,CAAC;EAEzB,OAAOE,WAAW;AACpB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AndroidCanvasProps, AndroidSurfaceType } from "./types";
|
|
2
|
+
/** The native props the `android` prop of a view resolves to. */
|
|
3
|
+
export declare const androidNativeProps: (android?: AndroidCanvasProps) => {
|
|
4
|
+
androidSurfaceType: AndroidSurfaceType | "auto";
|
|
5
|
+
androidZOrderOnTop: boolean;
|
|
6
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Anything else reaching the native component would hit the generated
|
|
2
|
+
// string-enum parser, which aborts on unknown values.
|
|
3
|
+
const resolveSurfaceType = surfaceType => surfaceType === "SurfaceView" || surfaceType === "TextureView" ? surfaceType : "auto";
|
|
4
|
+
|
|
5
|
+
/** The native props the `android` prop of a view resolves to. */
|
|
6
|
+
export const androidNativeProps = android => ({
|
|
7
|
+
androidSurfaceType: resolveSurfaceType(android === null || android === void 0 ? void 0 : android.surfaceType),
|
|
8
|
+
androidZOrderOnTop: !!(android !== null && android !== void 0 && android.zOrderOnTop)
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["resolveSurfaceType","surfaceType","androidNativeProps","android","androidSurfaceType","androidZOrderOnTop","zOrderOnTop"],"sources":["android.ts"],"sourcesContent":["import type { AndroidCanvasProps, AndroidSurfaceType } from \"./types\";\n\n// Anything else reaching the native component would hit the generated\n// string-enum parser, which aborts on unknown values.\nconst resolveSurfaceType = (\n surfaceType: AndroidSurfaceType | undefined\n): \"auto\" | AndroidSurfaceType =>\n surfaceType === \"SurfaceView\" || surfaceType === \"TextureView\"\n ? surfaceType\n : \"auto\";\n\n/** The native props the `android` prop of a view resolves to. */\nexport const androidNativeProps = (android?: AndroidCanvasProps) => ({\n androidSurfaceType: resolveSurfaceType(android?.surfaceType),\n androidZOrderOnTop: !!android?.zOrderOnTop,\n});\n"],"mappings":"AAEA;AACA;AACA,MAAMA,kBAAkB,GACtBC,WAA2C,IAE3CA,WAAW,KAAK,aAAa,IAAIA,WAAW,KAAK,aAAa,GAC1DA,WAAW,GACX,MAAM;;AAEZ;AACA,OAAO,MAAMC,kBAAkB,GAAIC,OAA4B,KAAM;EACnEC,kBAAkB,EAAEJ,kBAAkB,CAACG,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEF,WAAW,CAAC;EAC5DI,kBAAkB,EAAE,CAAC,EAACF,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEG,WAAW;AAC5C,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ViewProps } from "react-native";
|
|
2
2
|
import type { SharedValue } from "react-native-reanimated";
|
|
3
3
|
import type { SkGraphiteContext, SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
|
|
4
|
-
export type NativeSkiaViewProps = ViewProps & {
|
|
5
|
-
debug?: boolean;
|
|
6
|
-
opaque?: boolean;
|
|
7
|
-
};
|
|
8
4
|
export type AndroidSurfaceType = "SurfaceView" | "TextureView";
|
|
9
5
|
export interface AndroidCanvasProps {
|
|
10
6
|
/**
|
|
@@ -35,17 +31,13 @@ export interface ISkiaViewApi {
|
|
|
35
31
|
makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
|
|
36
32
|
size: (nativeId: number) => SkSize;
|
|
37
33
|
/**
|
|
38
|
-
* The recording side of a
|
|
39
|
-
*
|
|
34
|
+
* The recording side of a view: its native id, the layout size in points,
|
|
35
|
+
* and the props its surface format follows from.
|
|
40
36
|
*/
|
|
41
37
|
makeGraphiteContext: (nativeId: number, width: number, height: number, opaque: boolean, highBitDepth: boolean) => SkGraphiteContext;
|
|
42
38
|
}
|
|
39
|
+
/** The props every Skia view takes, whichever way it is drawn. */
|
|
43
40
|
export interface SkiaBaseViewProps extends ViewProps {
|
|
44
|
-
/**
|
|
45
|
-
* When set to true the view will display information about the
|
|
46
|
-
* average time it takes to render.
|
|
47
|
-
*/
|
|
48
|
-
debug?: boolean;
|
|
49
41
|
/**
|
|
50
42
|
* Declares that the canvas covers every pixel of its bounds. On Android an
|
|
51
43
|
* opaque canvas is backed by a `SurfaceView` by default, the cheapest path
|
|
@@ -64,6 +56,5 @@ export interface SkiaBaseViewProps extends ViewProps {
|
|
|
64
56
|
}
|
|
65
57
|
export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
|
|
66
58
|
picture?: SkPicture;
|
|
67
|
-
androidWarmup?: boolean;
|
|
68
59
|
}
|
|
69
60
|
export type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\n\nexport type
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\n\nexport type AndroidSurfaceType = \"SurfaceView\" | \"TextureView\";\n\nexport interface AndroidCanvasProps {\n /**\n * Backing view. Defaults to `SurfaceView` when the canvas is `opaque` and to\n * `TextureView` otherwise; both composite correctly in React Native stacking\n * order without further flags.\n */\n surfaceType?: AndroidSurfaceType;\n /**\n * SurfaceView only: composite above every React Native view in the window,\n * ignoring `zIndex`. Ignored for TextureView. Defaults to false.\n */\n zOrderOnTop?: boolean;\n}\n\nexport interface ISkiaViewApi {\n web?: boolean;\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n /**\n * Reads the shared values into the recording held for the view and\n * schedules a redraw. Native only; called from a worklet on every frame.\n * Until the view registers, the recording is queued for it and kept\n * current all the same. Ignored when the recording `recorderId` is neither\n * held by the view nor queued for it.\n */\n applyUpdates: (\n nativeId: number,\n recorderId: number,\n values: SharedValue<unknown>[]\n ) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n size: (nativeId: number) => SkSize;\n /**\n * The recording side of a view: its native id, the layout size in points,\n * and the props its surface format follows from.\n */\n makeGraphiteContext: (\n nativeId: number,\n width: number,\n height: number,\n opaque: boolean,\n highBitDepth: boolean\n ) => SkGraphiteContext;\n}\n\n/** The props every Skia view takes, whichever way it is drawn. */\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * Declares that the canvas covers every pixel of its bounds. On Android an\n * opaque canvas is backed by a `SurfaceView` by default, the cheapest path\n * (see `android.surfaceType`). Defaults to false.\n */\n opaque?: boolean;\n\n /**\n * Renders into a surface with more than 8 bits per channel (16-bit float on\n * iOS, 10-bit on Android) to avoid banding in subtle gradients. On Android\n * the extra precision survives composition only when combined with `opaque`.\n */\n highBitDepth?: boolean;\n\n /** Android-only rendering options. Ignored on iOS and web. */\n android?: AndroidCanvasProps;\n\n // On web, only 16 WebGL contextes are allowed. If the drawing is non-animated, set\n // __destroyWebGLContextAfterRender to true to release the context after each draw.\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import "./skia/NativeSetup";
|
|
2
2
|
export { JsiSkImage } from "./skia/web/JsiSkImage";
|
|
3
3
|
export * from "./renderer";
|
|
4
|
-
export { useCanvasRef, useCanvasSize } from "./renderer/Canvas";
|
|
4
|
+
export { Canvas, useCanvasRef, useCanvasSize } from "./renderer/Canvas";
|
|
5
5
|
export type { CanvasProps, CanvasRef } from "./renderer/Canvas";
|
|
6
|
-
export { GraphiteCanvas } from "./renderer/GraphiteCanvas";
|
|
7
|
-
export { Canvas } from "./renderer/DefaultCanvas";
|
|
8
6
|
export * from "./renderer/Offscreen";
|
|
9
7
|
export * from "./views";
|
|
10
8
|
export * from "./skia";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FC, RefObject } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type { MeasureInWindowOnSuccessCallback, MeasureOnSuccessCallback,
|
|
3
|
+
import type { MeasureInWindowOnSuccessCallback, MeasureOnSuccessCallback, ViewProps } from "react-native";
|
|
4
4
|
import type { SharedValue } from "react-native-reanimated";
|
|
5
5
|
import type { AndroidCanvasProps } from "../views/types";
|
|
6
6
|
import type { SkImage, SkRect, SkSize } from "../skia/types";
|
|
@@ -18,7 +18,6 @@ export declare const useCanvasSize: (userRef?: RefObject<CanvasRef | null>) => {
|
|
|
18
18
|
size: SkSize;
|
|
19
19
|
};
|
|
20
20
|
export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
|
|
21
|
-
debug?: boolean;
|
|
22
21
|
/** @deprecated Not supported on native. Use `onSize` or `useCanvasSize()` instead. */
|
|
23
22
|
onLayout?: ViewProps["onLayout"];
|
|
24
23
|
/**
|
|
@@ -29,7 +28,6 @@ export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
|
|
|
29
28
|
*/
|
|
30
29
|
opaque?: boolean;
|
|
31
30
|
onSize?: SharedValue<SkSize>;
|
|
32
|
-
colorSpace?: "p3" | "srgb";
|
|
33
31
|
/**
|
|
34
32
|
* Renders into a surface with more than 8 bits per channel (16-bit float on
|
|
35
33
|
* iOS, 10-bit on Android) to avoid banding in subtle gradients. Colors are
|
|
@@ -42,16 +40,21 @@ export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
|
|
|
42
40
|
/** Android-only rendering options. Ignored on iOS and web. */
|
|
43
41
|
android?: AndroidCanvasProps;
|
|
44
42
|
ref?: React.Ref<CanvasRef>;
|
|
45
|
-
androidWarmup?: boolean;
|
|
46
43
|
__destroyWebGLContextAfterRender?: boolean;
|
|
47
44
|
}
|
|
48
45
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
46
|
+
* The declarative canvas. Its children are rendered by Skia's own React
|
|
47
|
+
* renderer; the frames are produced off the JS thread:
|
|
48
|
+
*
|
|
49
|
+
* - the JS thread records the scene graph into a native recorder once per
|
|
50
|
+
* React commit and hands it to the view;
|
|
51
|
+
* - the Reanimated UI runtime only reads the shared values into it (the one
|
|
52
|
+
* step that needs a JS runtime), it never replays anything;
|
|
53
|
+
* - a dedicated native thread pool replays the recorder into a Graphite
|
|
54
|
+
* recording whenever the content changed, at most once per presented frame;
|
|
55
|
+
* - the view presents the recording on the next vsync.
|
|
56
|
+
*
|
|
57
|
+
* On the web the scene is drawn into a picture on the JS thread and painted
|
|
58
|
+
* on a WebGL canvas.
|
|
52
59
|
*/
|
|
53
|
-
export declare const
|
|
54
|
-
nativeId: number;
|
|
55
|
-
viewRef: RefObject<View | null>;
|
|
56
|
-
};
|
|
57
|
-
export declare const Canvas: ({ debug, opaque, children, onSize, colorSpace, highBitDepth, androidWarmup, android, ref, onLayout, ...viewProps }: CanvasProps) => React.JSX.Element;
|
|
60
|
+
export declare const Canvas: ({ opaque, children, onSize, highBitDepth, android, ref, onLayout, ...viewProps }: CanvasProps) => React.JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { SkCanvas } from "./Canvas";
|
|
2
2
|
import type { SkJSIInstance } from "./JsiInstance";
|
|
3
3
|
/**
|
|
4
|
-
* A frame recorded for a
|
|
5
|
-
*
|
|
4
|
+
* A frame recorded for a view. Immutable once finished: submit it to the view
|
|
5
|
+
* as many times as needed, from any runtime.
|
|
6
6
|
*/
|
|
7
7
|
export type SkGraphiteRecording = SkJSIInstance<"GraphiteRecording">;
|
|
8
8
|
/**
|
|
9
|
-
* The recording side of a
|
|
9
|
+
* The recording side of a view, obtained from the ref of a SkiaGraphiteView.
|
|
10
10
|
*
|
|
11
11
|
* Frames are recorded on the calling thread and presented by the view on its
|
|
12
12
|
* display link, so the context can be captured into a worklet and used from
|
|
@@ -89,7 +89,7 @@ export interface ImageFactory {
|
|
|
89
89
|
* while the image is in use: destroy() releases the underlying GPU
|
|
90
90
|
* resource regardless of reference counts.
|
|
91
91
|
*
|
|
92
|
-
*
|
|
92
|
+
* Native only.
|
|
93
93
|
*
|
|
94
94
|
* @param pointer - The WGPUTexture pointer (texture.nativePointer)
|
|
95
95
|
* @returns An SkImage wrapping the texture, or throws if the texture is invalid
|
|
@@ -101,7 +101,7 @@ export interface ImageFactory {
|
|
|
101
101
|
* returned pointer carries one reference and must be adopted exactly once
|
|
102
102
|
* with react-native-webgpu's adoptTexture(), which owns it from then on.
|
|
103
103
|
*
|
|
104
|
-
*
|
|
104
|
+
* Native only.
|
|
105
105
|
*
|
|
106
106
|
* @param image - An SkImage to convert to a texture
|
|
107
107
|
* @returns A WGPUTexture pointer for adoptTexture(), or throws on failure
|
|
@@ -83,8 +83,7 @@ export interface Skia {
|
|
|
83
83
|
/**
|
|
84
84
|
* Raw WGPUDevice pointer of Skia's Graphite device, as a BigInt. Pass it to
|
|
85
85
|
* react-native-webgpu's importDevice() to get a GPUDevice sharing Skia's
|
|
86
|
-
* device (zero-copy interop).
|
|
87
|
-
* otherwise.
|
|
86
|
+
* device (zero-copy interop). Native only.
|
|
88
87
|
*/
|
|
89
88
|
getNativeDevice(): bigint;
|
|
90
89
|
}
|
|
@@ -33,7 +33,7 @@ export interface SurfaceFactory {
|
|
|
33
33
|
* surface exists. Calling destroy() on the GPUTexture still invalidates
|
|
34
34
|
* the surface.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
36
|
+
* Native only.
|
|
37
37
|
*
|
|
38
38
|
* @param pointer - The WGPUTexture pointer (texture.nativePointer)
|
|
39
39
|
* @returns An SkSurface rendering into the texture, or throws if the texture is invalid
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { SkGraphiteContext, SkImage, SkPicture, SkRect } from "../skia/types";
|
|
2
2
|
import type { ISkiaViewApi } from "../views/types";
|
|
3
|
-
/** What
|
|
3
|
+
/** What the web view registers under its native id. */
|
|
4
4
|
export interface SkiaWebViewHandle {
|
|
5
|
+
/** Shows a picture: the frame of a <Canvas> or a <SkiaPictureView>. */
|
|
6
|
+
setPicture(picture: SkPicture): void;
|
|
7
|
+
/** The recording side of the view, see SkiaGraphiteView. */
|
|
8
|
+
getContext(): SkGraphiteContext;
|
|
5
9
|
getSize(): {
|
|
6
10
|
width: number;
|
|
7
11
|
height: number;
|
|
@@ -11,9 +15,6 @@ export interface SkiaWebViewHandle {
|
|
|
11
15
|
measure(callback: (x: number, y: number, width: number, height: number, pageX: number, pageY: number) => void): void;
|
|
12
16
|
measureInWindow(callback: (x: number, y: number, width: number, height: number) => void): void;
|
|
13
17
|
}
|
|
14
|
-
export interface SkiaGraphiteViewHandle extends SkiaWebViewHandle {
|
|
15
|
-
getContext(): SkGraphiteContext;
|
|
16
|
-
}
|
|
17
18
|
export type ISkiaViewApiWeb = ISkiaViewApi & {
|
|
18
19
|
views: Record<string, SkiaWebViewHandle>;
|
|
19
20
|
deferedPictures: Record<string, SkPicture>;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { type ViewProps } from "react-native";
|
|
2
2
|
import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
|
|
3
3
|
export interface NativeProps extends ViewProps {
|
|
4
|
-
debug?: boolean;
|
|
5
4
|
opaque?: boolean;
|
|
6
|
-
colorSpace?: string;
|
|
7
5
|
highBitDepth?: boolean;
|
|
8
|
-
androidWarmup?: boolean;
|
|
9
6
|
androidSurfaceType?: WithDefault<"auto" | "SurfaceView" | "TextureView", "auto">;
|
|
10
7
|
androidZOrderOnTop?: WithDefault<boolean, false>;
|
|
11
8
|
pointerEvents?: WithDefault<"auto" | "none" | "box-none" | "box-only", "auto">;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ViewProps } from "react-native";
|
|
2
|
+
export interface NativeProps extends ViewProps {
|
|
3
|
+
opaque?: boolean;
|
|
4
|
+
highBitDepth?: boolean;
|
|
5
|
+
nativeID: string;
|
|
6
|
+
androidSurfaceType?: "auto" | "SurfaceView" | "TextureView";
|
|
7
|
+
androidZOrderOnTop?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const SkiaViewNativeComponent: ({ nativeID, onLayout, opaque: _opaque, highBitDepth: _highBitDepth, androidSurfaceType: _androidSurfaceType, androidZOrderOnTop: _androidZOrderOnTop, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("../views/SkiaView.web").SkiaViewProps>;
|
|
10
|
+
export default SkiaViewNativeComponent;
|
|
@@ -13,8 +13,7 @@ export interface SkiaGraphiteViewProps extends SkiaGraphiteViewNativeProps {
|
|
|
13
13
|
ref?: React.Ref<SkiaGraphiteViewRef>;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* A view
|
|
17
|
-
*
|
|
18
|
-
* nothing. See {@link SkGraphiteContext}.
|
|
16
|
+
* A view whose frames are recorded from JavaScript, on any runtime, through
|
|
17
|
+
* the context of its ref. See {@link SkGraphiteContext}.
|
|
19
18
|
*/
|
|
20
|
-
export declare const SkiaGraphiteView: ({
|
|
19
|
+
export declare const SkiaGraphiteView: ({ opaque, highBitDepth, android, ref, ...viewProps }: SkiaGraphiteViewProps) => React.JSX.Element;
|
|
@@ -3,8 +3,11 @@ import type { SkRect } from "../skia/types";
|
|
|
3
3
|
import type { SkiaPictureViewNativeProps } from "./types";
|
|
4
4
|
interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
|
|
5
5
|
mode?: "default" | "continuous";
|
|
6
|
-
androidWarmup?: boolean;
|
|
7
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* A view showing a picture. The picture is handed to the native view, which
|
|
9
|
+
* records it once (and again on every redraw) for its surface.
|
|
10
|
+
*/
|
|
8
11
|
export declare class SkiaPictureView extends React.Component<SkiaPictureViewProps> {
|
|
9
12
|
private requestId;
|
|
10
13
|
constructor(props: SkiaPictureViewProps);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ViewProps } from "react-native";
|
|
3
|
+
import type { SkiaWebViewHandle } from "../specs/NativeSkiaModule.web";
|
|
4
|
+
export interface SkiaViewHandle extends SkiaWebViewHandle {
|
|
5
|
+
/** The canvas element, for Reanimated's measure(). */
|
|
6
|
+
readonly canvasRef: () => HTMLCanvasElement | null;
|
|
7
|
+
}
|
|
8
|
+
export interface SkiaViewProps extends ViewProps {
|
|
9
|
+
ref?: React.Ref<SkiaViewHandle>;
|
|
10
|
+
__destroyWebGLContextAfterRender?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const SkiaView: (props: SkiaViewProps) => React.JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AndroidCanvasProps, AndroidSurfaceType } from "./types";
|
|
2
|
+
/** The native props the `android` prop of a view resolves to. */
|
|
3
|
+
export declare const androidNativeProps: (android?: AndroidCanvasProps) => {
|
|
4
|
+
androidSurfaceType: AndroidSurfaceType | "auto";
|
|
5
|
+
androidZOrderOnTop: boolean;
|
|
6
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ViewProps } from "react-native";
|
|
2
2
|
import type { SharedValue } from "react-native-reanimated";
|
|
3
3
|
import type { SkGraphiteContext, SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
|
|
4
|
-
export type NativeSkiaViewProps = ViewProps & {
|
|
5
|
-
debug?: boolean;
|
|
6
|
-
opaque?: boolean;
|
|
7
|
-
};
|
|
8
4
|
export type AndroidSurfaceType = "SurfaceView" | "TextureView";
|
|
9
5
|
export interface AndroidCanvasProps {
|
|
10
6
|
/**
|
|
@@ -35,17 +31,13 @@ export interface ISkiaViewApi {
|
|
|
35
31
|
makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
|
|
36
32
|
size: (nativeId: number) => SkSize;
|
|
37
33
|
/**
|
|
38
|
-
* The recording side of a
|
|
39
|
-
*
|
|
34
|
+
* The recording side of a view: its native id, the layout size in points,
|
|
35
|
+
* and the props its surface format follows from.
|
|
40
36
|
*/
|
|
41
37
|
makeGraphiteContext: (nativeId: number, width: number, height: number, opaque: boolean, highBitDepth: boolean) => SkGraphiteContext;
|
|
42
38
|
}
|
|
39
|
+
/** The props every Skia view takes, whichever way it is drawn. */
|
|
43
40
|
export interface SkiaBaseViewProps extends ViewProps {
|
|
44
|
-
/**
|
|
45
|
-
* When set to true the view will display information about the
|
|
46
|
-
* average time it takes to render.
|
|
47
|
-
*/
|
|
48
|
-
debug?: boolean;
|
|
49
41
|
/**
|
|
50
42
|
* Declares that the canvas covers every pixel of its bounds. On Android an
|
|
51
43
|
* opaque canvas is backed by a `SurfaceView` by default, the cheapest path
|
|
@@ -64,6 +56,5 @@ export interface SkiaBaseViewProps extends ViewProps {
|
|
|
64
56
|
}
|
|
65
57
|
export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
|
|
66
58
|
picture?: SkPicture;
|
|
67
|
-
androidWarmup?: boolean;
|
|
68
59
|
}
|
|
69
60
|
export type SkiaGraphiteViewNativeProps = SkiaBaseViewProps;
|
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": "3.0.
|
|
11
|
+
"version": "3.0.3",
|
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
|
13
13
|
"main": "lib/module/index.js",
|
|
14
14
|
"react-native": "src/index.ts",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"Package.swift",
|
|
36
36
|
"include/**",
|
|
37
37
|
"react-native.config.js",
|
|
38
|
-
"dist/**"
|
|
39
|
-
"libs/.graphite"
|
|
38
|
+
"dist/**"
|
|
40
39
|
],
|
|
41
40
|
"scripts": {
|
|
42
41
|
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache --fix",
|
|
@@ -48,8 +47,6 @@
|
|
|
48
47
|
"clean-skia": "yarn rimraf ./libs && yarn rimraf ../../externals/skia/out",
|
|
49
48
|
"build-skia": "tsx ./scripts/build-skia.ts",
|
|
50
49
|
"copy-skia-headers": "tsx ./scripts/copy-skia-headers.ts",
|
|
51
|
-
"install-skia": "tsx ./scripts/install-skia.ts",
|
|
52
|
-
"install-skia-graphite": "tsx ./scripts/install-skia-graphite.ts",
|
|
53
50
|
"clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
|
|
54
51
|
"clang-format-ios": "find apple/ -iname '*.h' -o -iname '*.mm' -o -iname '*.cpp' | xargs clang-format -i",
|
|
55
52
|
"clang-format-android": "find android/cpp/ -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' | xargs clang-format -i",
|
|
@@ -130,6 +127,7 @@
|
|
|
130
127
|
"react-native": "0.83.1",
|
|
131
128
|
"react-native-builder-bob": "0.18.2",
|
|
132
129
|
"react-native-reanimated": "4.3.1",
|
|
130
|
+
"react-native-skia-graphite-headers": "154.0.1",
|
|
133
131
|
"react-native-worklets": "0.8.3",
|
|
134
132
|
"rimraf": "3.0.2",
|
|
135
133
|
"semantic-release": "^24.1.0",
|
|
@@ -147,11 +145,6 @@
|
|
|
147
145
|
"react-native-skia-graphite-apple-macos": "154.0.1",
|
|
148
146
|
"react-reconciler": "0.31.0"
|
|
149
147
|
},
|
|
150
|
-
"graphiteDependencies": {
|
|
151
|
-
"react-native-skia-graphite-android": "154.0.1",
|
|
152
|
-
"react-native-skia-graphite-apple-ios": "154.0.1",
|
|
153
|
-
"react-native-skia-graphite-apple-macos": "154.0.1"
|
|
154
|
-
},
|
|
155
148
|
"eslintIgnore": [
|
|
156
149
|
"node_modules/",
|
|
157
150
|
"lib/"
|
|
@@ -165,8 +158,7 @@
|
|
|
165
158
|
},
|
|
166
159
|
"ios": {
|
|
167
160
|
"componentProvider": {
|
|
168
|
-
"
|
|
169
|
-
"SkiaGraphiteView": "SkiaGraphiteView"
|
|
161
|
+
"SkiaView": "SkiaView"
|
|
170
162
|
}
|
|
171
163
|
}
|
|
172
164
|
},
|
|
@@ -189,4 +181,4 @@
|
|
|
189
181
|
]
|
|
190
182
|
]
|
|
191
183
|
}
|
|
192
|
-
}
|
|
184
|
+
}
|