react-native-skia 3.0.0 → 3.0.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/Package.swift +14 -13
- package/android/CMakeLists.txt +13 -42
- package/android/build.gradle +55 -47
- 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 +0 -4
- package/apple/RNSkApplePlatformContext.h +0 -14
- package/apple/RNSkApplePlatformContext.mm +2 -112
- package/apple/RNSkMetalCanvasProvider.h +14 -19
- package/apple/RNSkMetalCanvasProvider.mm +35 -68
- 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 +6 -0
- package/cpp/rnskia/RNDawnInterop.cpp +0 -4
- package/cpp/rnskia/RNDawnUtils.h +0 -1
- package/cpp/rnskia/RNDawnWindowContext.cpp +10 -0
- package/cpp/rnskia/RNDawnWindowContext.h +4 -0
- package/cpp/rnskia/RNSkCanvasProvider.h +221 -0
- package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
- package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
- package/cpp/rnskia/RNSkGraphiteTarget.h +383 -0
- package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
- package/cpp/rnskia/RNSkPlatformContext.h +9 -15
- package/cpp/rnskia/RNSkView.h +340 -245
- 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/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 +24 -20
- 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/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 +24 -19
- 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 +8 -16
- package/react-native-skia.podspec +50 -57
- package/src/Platform/Platform.web.tsx +1 -1
- package/src/index.ts +1 -3
- package/src/mock/index.ts +0 -1
- package/src/renderer/Canvas.tsx +23 -27
- 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,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.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",
|
|
@@ -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",
|
|
@@ -142,16 +140,11 @@
|
|
|
142
140
|
},
|
|
143
141
|
"dependencies": {
|
|
144
142
|
"canvaskit-wasm": "0.41.0",
|
|
145
|
-
"react-native-skia-graphite-android": "154.0.
|
|
146
|
-
"react-native-skia-graphite-apple-ios": "154.0.
|
|
147
|
-
"react-native-skia-graphite-apple-macos": "154.0.
|
|
143
|
+
"react-native-skia-graphite-android": "154.0.1",
|
|
144
|
+
"react-native-skia-graphite-apple-ios": "154.0.1",
|
|
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.0",
|
|
152
|
-
"react-native-skia-graphite-apple-ios": "154.0.0",
|
|
153
|
-
"react-native-skia-graphite-apple-macos": "154.0.0"
|
|
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
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-native-skia.podspec
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
4
|
require "fileutils"
|
|
5
5
|
|
|
6
6
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
7
7
|
|
|
8
|
-
# Check if Graphite is enabled via marker file (created by install-skia-graphite)
|
|
9
|
-
use_graphite = File.exist?(File.join(__dir__, 'libs', '.graphite'))
|
|
10
|
-
puts "-- SK_GRAPHITE: #{use_graphite ? 'ON' : 'OFF'} (detected via libs/.graphite marker file)"
|
|
11
|
-
|
|
12
8
|
# Resolve a node package directory using Node's own module resolution
|
|
13
9
|
# (mirrors `require.resolve(pkg/package.json)`). Returns nil if it can't be found.
|
|
14
10
|
# Defined as a lambda (not a `def`) because CocoaPods evaluates the podspec inside
|
|
@@ -37,10 +33,25 @@ install_apple_skia_libs = lambda do |base_dir, packages|
|
|
|
37
33
|
src = File.join(pkg_dir, 'libs')
|
|
38
34
|
next unless Dir.exist?(src) && !Dir.glob(File.join(src, '*.xcframework')).empty?
|
|
39
35
|
|
|
36
|
+
# Graphite packages carry the Dawn release tag they ship (libs/.dawn-version),
|
|
37
|
+
# used below for the react-native-webgpu version check.
|
|
38
|
+
dawn_version = File.join(src, '.dawn-version')
|
|
39
|
+
if File.exist?(dawn_version)
|
|
40
|
+
FileUtils.mkdir_p(File.join(base_dir, 'libs'))
|
|
41
|
+
FileUtils.cp(dawn_version, File.join(base_dir, 'libs', '.dawn-version'))
|
|
42
|
+
end
|
|
43
|
+
|
|
40
44
|
version = JSON.parse(File.read(File.join(pkg_dir, 'package.json')))['version'].to_s
|
|
41
45
|
dest = File.join(base_dir, 'libs', platform)
|
|
42
46
|
marker = File.join(dest, '.version')
|
|
43
47
|
|
|
48
|
+
# Frameworks without a .version stamp were built locally (`yarn build-skia`):
|
|
49
|
+
# keep them instead of overwriting them with the npm package.
|
|
50
|
+
if !File.exist?(marker) && !Dir.glob(File.join(dest, '*.xcframework')).empty?
|
|
51
|
+
Pod::UI.puts "react-native-skia: using locally built #{platform} Skia frameworks"
|
|
52
|
+
next
|
|
53
|
+
end
|
|
54
|
+
|
|
44
55
|
# Already up to date: leave the files untouched so CocoaPods keeps its cache.
|
|
45
56
|
next if File.exist?(marker) && File.read(marker).strip == version
|
|
46
57
|
|
|
@@ -52,23 +63,15 @@ install_apple_skia_libs = lambda do |base_dir, packages|
|
|
|
52
63
|
end
|
|
53
64
|
end
|
|
54
65
|
|
|
55
|
-
# The
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{ 'ios' => 'react-native-skia-graphite-apple-ios',
|
|
62
|
-
'macos' => 'react-native-skia-graphite-apple-macos' } :
|
|
63
|
-
{ 'ios' => 'react-native-skia-apple-ios',
|
|
64
|
-
'macos' => 'react-native-skia-apple-macos',
|
|
65
|
-
'tvos' => 'react-native-skia-apple-tvos' }
|
|
66
|
+
# The Graphite binaries ship in the react-native-skia-graphite-apple-* npm
|
|
67
|
+
# packages (no tvOS), together with the shared Dawn (libwebgpu_dawn.xcframework).
|
|
68
|
+
apple_skia_packages = {
|
|
69
|
+
'ios' => 'react-native-skia-graphite-apple-ios',
|
|
70
|
+
'macos' => 'react-native-skia-graphite-apple-macos'
|
|
71
|
+
}
|
|
66
72
|
install_apple_skia_libs.call(__dir__, apple_skia_packages)
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
preprocessor_defs = use_graphite ?
|
|
70
|
-
'$(inherited) SK_GRAPHITE=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1' :
|
|
71
|
-
'$(inherited) SK_METAL=1 SK_GANESH=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1'
|
|
74
|
+
preprocessor_defs = '$(inherited) SK_GRAPHITE=1 SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API=1 SK_DISABLE_LEGACY_SHAPER_FACTORY=1'
|
|
72
75
|
|
|
73
76
|
# Define framework names
|
|
74
77
|
framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
|
|
@@ -81,14 +84,18 @@ framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
|
|
|
81
84
|
# vendoring the framework here as well would fail CocoaPods'
|
|
82
85
|
# duplicate-framework-name check, so Skia only vendors it when alone. The
|
|
83
86
|
# skia pod's dawn::native references resolve from webgpu's copy at app link.
|
|
87
|
+
# An app that installs react-native-webgpu but keeps it out of a platform's
|
|
88
|
+
# Pods (e.g. a macOS target that filters it out of autolinking) sets
|
|
89
|
+
# RNSKIA_VENDOR_DAWN=1 before `pod install` so Skia vendors Dawn itself there.
|
|
84
90
|
webgpu_pkg_dir = resolve_node_package.call('react-native-webgpu', __dir__)
|
|
85
|
-
has_webgpu_pkg = !webgpu_pkg_dir.nil?
|
|
86
|
-
if
|
|
91
|
+
has_webgpu_pkg = !webgpu_pkg_dir.nil? && ENV['RNSKIA_VENDOR_DAWN'] != '1'
|
|
92
|
+
if has_webgpu_pkg
|
|
87
93
|
Pod::UI.puts 'react-native-skia: react-native-webgpu detected, Dawn is provided by its libwebgpu_dawn'
|
|
88
94
|
|
|
89
95
|
# Both packages must link the exact same Dawn artifact. Compare the release
|
|
90
|
-
# tag
|
|
91
|
-
# the tag react-native-webgpu declares in
|
|
96
|
+
# tag the Skia binaries were packaged with (libs/.dawn-version, copied in from
|
|
97
|
+
# the binary package above) against the tag react-native-webgpu declares in
|
|
98
|
+
# its package.json `dawn` field.
|
|
92
99
|
dawn_marker = File.join(__dir__, 'libs', '.dawn-version')
|
|
93
100
|
if File.exist?(dawn_marker)
|
|
94
101
|
skia_dawn = File.read(dawn_marker).strip
|
|
@@ -110,10 +117,22 @@ if use_graphite && has_webgpu_pkg
|
|
|
110
117
|
Pod::UI.puts "react-native-skia: Dawn versions match (#{skia_dawn})"
|
|
111
118
|
end
|
|
112
119
|
end
|
|
113
|
-
|
|
120
|
+
unless has_webgpu_pkg
|
|
121
|
+
# CocoaPods silently skips missing vendored frameworks, which would surface
|
|
122
|
+
# later as undefined dawn::native symbols at link time. Fail early instead.
|
|
123
|
+
%w[ios macos].each do |platform|
|
|
124
|
+
platform_dir = File.join(__dir__, 'libs', platform)
|
|
125
|
+
# A missing libs/<platform> is reported by the prebuilt binaries check below.
|
|
126
|
+
next if !Dir.exist?(platform_dir) || Dir.exist?(File.join(platform_dir, 'libwebgpu_dawn.xcframework'))
|
|
127
|
+
raise "react-native-skia: libwebgpu_dawn.xcframework not found in libs/#{platform}. " \
|
|
128
|
+
"The installed #{apple_skia_packages[platform]} package does not ship the shared " \
|
|
129
|
+
"Dawn library this Graphite build links against. Upgrade it, then run `pod install` again."
|
|
130
|
+
end
|
|
131
|
+
framework_names += ['libwebgpu_dawn']
|
|
132
|
+
end
|
|
114
133
|
|
|
115
134
|
# Verify that the prebuilt binaries are available (copied in above from the npm
|
|
116
|
-
# packages, or
|
|
135
|
+
# packages, or built locally with `yarn build-skia`).
|
|
117
136
|
unless Dir.exist?(File.join(__dir__, 'libs', 'ios')) && Dir.exist?(File.join(__dir__, 'libs', 'macos'))
|
|
118
137
|
expected_packages = apple_skia_packages.values.join(', ')
|
|
119
138
|
Pod::UI.warn "#{'-' * 72}"
|
|
@@ -126,33 +145,26 @@ unless Dir.exist?(File.join(__dir__, 'libs', 'ios')) && Dir.exist?(File.join(__d
|
|
|
126
145
|
end
|
|
127
146
|
|
|
128
147
|
# Build platform-specific framework paths (relative to pod's libs directory)
|
|
129
|
-
# xcframeworks are copied into libs/ by install_apple_skia_libs above
|
|
130
|
-
# or downloaded by install-skia-graphite (Graphite build).
|
|
148
|
+
# xcframeworks are copied into libs/ by install_apple_skia_libs above.
|
|
131
149
|
ios_frameworks = framework_names.map { |f| "libs/ios/#{f}.xcframework" }
|
|
132
150
|
osx_frameworks = framework_names.map { |f| "libs/macos/#{f}.xcframework" }
|
|
133
|
-
# tvOS frameworks - check if libs/tvos/ exists (only populated for the default build)
|
|
134
|
-
tvos_frameworks = if use_graphite || !Dir.exist?(File.join(__dir__, 'libs', 'tvos'))
|
|
135
|
-
[]
|
|
136
|
-
else
|
|
137
|
-
framework_names.map { |f| "libs/tvos/#{f}.xcframework" }
|
|
138
|
-
end
|
|
139
151
|
|
|
140
152
|
Pod::Spec.new do |s|
|
|
141
153
|
s.name = "react-native-skia"
|
|
142
154
|
s.version = package["version"]
|
|
143
155
|
s.summary = package["description"]
|
|
144
156
|
s.description = <<-DESC
|
|
145
|
-
|
|
157
|
+
react-native-skia
|
|
146
158
|
DESC
|
|
147
|
-
s.homepage = "https://github.com/
|
|
159
|
+
s.homepage = "https://github.com/wcandillon/react-native-skia"
|
|
148
160
|
s.license = "MIT"
|
|
149
161
|
s.license = { :type => "MIT", :file => "LICENSE.md" }
|
|
150
162
|
s.authors = {
|
|
151
163
|
"Christian Falch" => "christian.falch@gmail.com",
|
|
152
164
|
"William Candillon" => "wcandillon@gmail.com"
|
|
153
165
|
}
|
|
154
|
-
s.platforms = { :ios => "14.0", :
|
|
155
|
-
s.source = { :git => "https://github.com/
|
|
166
|
+
s.platforms = { :ios => "14.0", :osx => "11" }
|
|
167
|
+
s.source = { :git => "https://github.com/wcandillon/react-native-skia.git", :tag => "#{s.version}" }
|
|
156
168
|
|
|
157
169
|
s.requires_arc = true
|
|
158
170
|
s.pod_target_xcconfig = {
|
|
@@ -168,11 +180,6 @@ Pod::Spec.new do |s|
|
|
|
168
180
|
s.ios.vendored_frameworks = ios_frameworks
|
|
169
181
|
s.osx.vendored_frameworks = osx_frameworks
|
|
170
182
|
|
|
171
|
-
# tvOS frameworks only available for non-Graphite builds
|
|
172
|
-
unless use_graphite
|
|
173
|
-
s.tvos.vendored_frameworks = tvos_frameworks
|
|
174
|
-
end
|
|
175
|
-
|
|
176
183
|
# Preserve the copied libs directory
|
|
177
184
|
s.preserve_paths = ["libs/**/*"]
|
|
178
185
|
|
|
@@ -182,20 +189,6 @@ Pod::Spec.new do |s|
|
|
|
182
189
|
"cpp/**/*.{h,cpp}"
|
|
183
190
|
]
|
|
184
191
|
|
|
185
|
-
graphite_exclusions = [
|
|
186
|
-
'cpp/rnskia/RNDawnContext.h',
|
|
187
|
-
'cpp/rnskia/RNDawnUtils.h',
|
|
188
|
-
'cpp/rnskia/RNMetalLayerColorSpace.h',
|
|
189
|
-
'cpp/rnskia/RNDawnWindowContext.h',
|
|
190
|
-
'cpp/rnskia/RNDawnWindowContext.cpp',
|
|
191
|
-
'cpp/rnskia/RNDawnInterop.cpp',
|
|
192
|
-
'cpp/rnskia/RNImageProvider.h',
|
|
193
|
-
'cpp/rnskia/RNSkGraphiteView.h',
|
|
194
|
-
'cpp/api/JsiSkGraphiteContext.h',
|
|
195
|
-
'cpp/api/JsiSkGraphiteRecording.h'
|
|
196
|
-
]
|
|
197
|
-
s.exclude_files = graphite_exclusions unless use_graphite
|
|
198
|
-
|
|
199
192
|
install_modules_dependencies(s)
|
|
200
193
|
s.dependency "React"
|
|
201
194
|
s.dependency "React-callinvoker"
|
|
@@ -7,7 +7,7 @@ import { isRNModule, unwrapModule } from "../skia/types";
|
|
|
7
7
|
|
|
8
8
|
import type { IPlatform } from "./IPlatform";
|
|
9
9
|
|
|
10
|
-
// Layout is observed by the views themselves (see
|
|
10
|
+
// Layout is observed by the views themselves (see SkiaView.web.tsx):
|
|
11
11
|
// this shim only reproduces react-native-web's default View styling.
|
|
12
12
|
const View = (({ children, style: rawStyle }: ViewProps) => {
|
|
13
13
|
const style = useMemo(() => (rawStyle ?? {}) as CSSProperties, [rawStyle]);
|
package/src/index.ts
CHANGED
|
@@ -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";
|
package/src/mock/index.ts
CHANGED
|
@@ -23,7 +23,6 @@ export const Mock = (CanvasKit: CanvasKit) => {
|
|
|
23
23
|
...require("../dom/types"),
|
|
24
24
|
...require("../dom/nodes"),
|
|
25
25
|
Canvas: require("react-native").View,
|
|
26
|
-
GraphiteCanvas: require("react-native").View,
|
|
27
26
|
getPreferredHighBitDepthCanvasFormat: () => "rgba16float",
|
|
28
27
|
SkiaPictureView: require("react-native").View,
|
|
29
28
|
SkiaGraphiteView: require("react-native").View,
|