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
package/Package.swift
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// swift-tools-version: 6.0
|
|
2
2
|
//
|
|
3
|
-
// SwiftPM manifest for
|
|
3
|
+
// SwiftPM manifest for react-native-skia. iOS, Graphite.
|
|
4
4
|
// Additive: the CocoaPods podspec remains the supported default.
|
|
5
5
|
//
|
|
6
6
|
// React Native 0.87+ references a library that ships its own Package.swift
|
|
@@ -12,15 +12,17 @@ import Foundation
|
|
|
12
12
|
import PackageDescription
|
|
13
13
|
|
|
14
14
|
// Skia's xcframeworks are ~200MB and are not carried in this package. They come
|
|
15
|
-
// from the react-native-skia-apple-ios npm package, which
|
|
16
|
-
// depends on, so a checkout that has installed its
|
|
15
|
+
// from the react-native-skia-graphite-apple-ios npm package, which
|
|
16
|
+
// react-native-skia depends on, so a checkout that has installed its
|
|
17
|
+
// dependencies builds offline. The package also ships the shared Dawn
|
|
18
|
+
// (libwebgpu_dawn.xcframework) Graphite runs on.
|
|
17
19
|
// Xcode passes the symlink as the package directory, hence resolvingSymlinks.
|
|
18
20
|
let packageRoot = URL(fileURLWithPath: Context.packageDirectory)
|
|
19
21
|
.resolvingSymlinksInPath().path
|
|
20
22
|
|
|
21
23
|
let binariesPath = [
|
|
22
|
-
"../../react-native-skia-apple-ios", // consumer: sibling in node_modules
|
|
23
|
-
"../../node_modules/react-native-skia-apple-ios", // this monorepo
|
|
24
|
+
"../../react-native-skia-graphite-apple-ios", // consumer: sibling in node_modules
|
|
25
|
+
"../../node_modules/react-native-skia-graphite-apple-ios", // this monorepo
|
|
24
26
|
]
|
|
25
27
|
.map { "\(packageRoot)/\($0)" }
|
|
26
28
|
.first { FileManager.default.fileExists(atPath: "\($0)/Package.swift") }
|
|
@@ -31,7 +33,7 @@ guard let binariesPath else {
|
|
|
31
33
|
// unresolvable dependency path.
|
|
32
34
|
fatalError(
|
|
33
35
|
"""
|
|
34
|
-
react-native-skia-apple-ios was not found next to
|
|
36
|
+
react-native-skia-graphite-apple-ios was not found next to react-native-skia. \
|
|
35
37
|
It ships the prebuilt Skia binaries this package links against. Reinstall \
|
|
36
38
|
dependencies without --omit=optional, on macOS.
|
|
37
39
|
""")
|
|
@@ -57,15 +59,13 @@ let package = Package(
|
|
|
57
59
|
.product(name: "ReactNativeHeaders", package: "ReactNative"),
|
|
58
60
|
.product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
|
|
59
61
|
.product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
|
|
60
|
-
.product(
|
|
62
|
+
.product(
|
|
63
|
+
name: "react-native-skia-graphite-apple-ios",
|
|
64
|
+
package: "react-native-skia-graphite-apple-ios"),
|
|
61
65
|
],
|
|
62
66
|
// apple/ and cpp/ have no common ancestor below the package root, and
|
|
63
67
|
// .headerSearchPath cannot escape the target path.
|
|
64
68
|
path: ".",
|
|
65
|
-
exclude: [
|
|
66
|
-
"cpp/rnskia/RNDawnWindowContext.cpp", // Graphite only
|
|
67
|
-
"cpp/rnskia/RNDawnInterop.cpp", // Graphite only
|
|
68
|
-
],
|
|
69
69
|
// Explicit, so SwiftPM never walks node_modules, lib, android, or the
|
|
70
70
|
// headers-only cpp/skia — which carries x86 AVX skcms sources that
|
|
71
71
|
// cannot build for arm64.
|
|
@@ -83,6 +83,7 @@ let package = Package(
|
|
|
83
83
|
// Replaces the podspec's recursive cpp/** glob, which expands to 90.
|
|
84
84
|
.headerSearchPath("cpp"), // "api/…", "jsi/…", "utils/…"
|
|
85
85
|
.headerSearchPath("cpp/skia"), // "include/core/…", "modules/…", "src/…"
|
|
86
|
+
.headerSearchPath("cpp/dawn/include"), // "webgpu/…", "dawn/…"
|
|
86
87
|
.headerSearchPath("cpp/rnskia"), // apple/ uses bare "RNSkView.h"
|
|
87
88
|
.headerSearchPath("cpp/utils"), // apple/ uses bare "RNSkLog.h"
|
|
88
89
|
|
|
@@ -93,8 +94,8 @@ let package = Package(
|
|
|
93
94
|
.define("RCT_NEW_ARCH_ENABLED", to: "1"),
|
|
94
95
|
.define("RCT_REMOVE_LEGACY_ARCH", to: "1"),
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
.define("
|
|
97
|
+
// Skia's public headers only declare the Graphite API with SK_GRAPHITE.
|
|
98
|
+
.define("SK_GRAPHITE", to: "1"),
|
|
98
99
|
.define("SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API", to: "1"),
|
|
99
100
|
.define("SK_DISABLE_LEGACY_SHAPER_FACTORY", to: "1"),
|
|
100
101
|
|
package/android/CMakeLists.txt
CHANGED
|
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.4.1)
|
|
|
4
4
|
set (CMAKE_CXX_STANDARD 20)
|
|
5
5
|
|
|
6
6
|
# SKIA_LIBS_PATH is passed from Gradle (pointing at the prebuilt Skia binaries,
|
|
7
|
-
# read straight from the react-native-skia-android npm package, or libs/android for
|
|
7
|
+
# read straight from the react-native-skia-graphite-android npm package, or libs/android for local builds)
|
|
8
8
|
# Append the ABI to get the full path
|
|
9
9
|
set (SKIA_LIBS_PATH "${SKIA_LIBS_PATH}/${ANDROID_ABI}")
|
|
10
10
|
|
|
@@ -29,9 +29,10 @@ endif()
|
|
|
29
29
|
add_library(skia STATIC IMPORTED)
|
|
30
30
|
set_property(TARGET skia PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libskia.a")
|
|
31
31
|
|
|
32
|
-
# SK_GRAPHITE is passed from Gradle
|
|
33
32
|
message("-- SKIA_LIBS_PATH: ${SKIA_LIBS_PATH}")
|
|
34
|
-
|
|
33
|
+
|
|
34
|
+
# Skia's public headers only declare the Graphite API with SK_GRAPHITE set.
|
|
35
|
+
add_definitions(-DSK_GRAPHITE)
|
|
35
36
|
|
|
36
37
|
string(APPEND CMAKE_CXX_FLAGS " -DSK_BUILD_FOR_ANDROID -DSK_DISABLE_LEGACY_SHAPER_FACTORY -DSK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID")
|
|
37
38
|
|
|
@@ -51,21 +52,6 @@ message("-- ABI : " ${ANDROID_ABI})
|
|
|
51
52
|
|
|
52
53
|
link_directories(${SKIA_LIBS_PATH}/)
|
|
53
54
|
|
|
54
|
-
if(SK_GRAPHITE)
|
|
55
|
-
add_definitions(-DSK_GRAPHITE)
|
|
56
|
-
set(BACKEND_SOURCES
|
|
57
|
-
#TODO: is this source needed to be added?
|
|
58
|
-
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNDawnWindowContext.cpp"
|
|
59
|
-
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNDawnInterop.cpp"
|
|
60
|
-
)
|
|
61
|
-
else()
|
|
62
|
-
add_definitions(-DSK_GL -DSK_GANESH)
|
|
63
|
-
set(BACKEND_SOURCES
|
|
64
|
-
"${PROJECT_SOURCE_DIR}/cpp/rnskia-android/OpenGLWindowContext.cpp"
|
|
65
|
-
"${PROJECT_SOURCE_DIR}/cpp/rnskia-android/GrAHardwareBufferUtils.cpp"
|
|
66
|
-
)
|
|
67
|
-
endif()
|
|
68
|
-
|
|
69
55
|
add_library(
|
|
70
56
|
${PACKAGE_NAME}
|
|
71
57
|
SHARED
|
|
@@ -73,8 +59,7 @@ add_library(
|
|
|
73
59
|
"${PROJECT_SOURCE_DIR}/cpp/jni/JniSkiaManager.cpp"
|
|
74
60
|
|
|
75
61
|
"${PROJECT_SOURCE_DIR}/cpp/jni/JniPlatformContext.cpp"
|
|
76
|
-
"${PROJECT_SOURCE_DIR}/cpp/rnskia-android/
|
|
77
|
-
"${PROJECT_SOURCE_DIR}/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp"
|
|
62
|
+
"${PROJECT_SOURCE_DIR}/cpp/rnskia-android/RNSkAndroidCanvasProvider.cpp"
|
|
78
63
|
"${PROJECT_SOURCE_DIR}/cpp/rnskia-android/AHardwareBufferUtils.cpp"
|
|
79
64
|
"${PROJECT_SOURCE_DIR}/cpp/rnskia-android/RNSkAndroidVideo.cpp"
|
|
80
65
|
|
|
@@ -84,15 +69,15 @@ add_library(
|
|
|
84
69
|
"${PROJECT_SOURCE_DIR}/../cpp/jsi/ViewProperty.cpp"
|
|
85
70
|
|
|
86
71
|
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkManager.cpp"
|
|
87
|
-
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkPictureView.cpp"
|
|
88
72
|
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkGraphiteProducer.cpp"
|
|
73
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNDawnWindowContext.cpp"
|
|
74
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNDawnInterop.cpp"
|
|
89
75
|
|
|
90
76
|
"${PROJECT_SOURCE_DIR}/../cpp/api/third_party/CSSColorParser.cpp"
|
|
91
77
|
"${PROJECT_SOURCE_DIR}/../cpp/api/third_party/base64.cpp"
|
|
92
78
|
"${PROJECT_SOURCE_DIR}/../cpp/api/third_party/SkottieUtils.cpp"
|
|
93
79
|
|
|
94
80
|
"${PROJECT_SOURCE_DIR}/../cpp/api/JsiSkDispatcher.cpp"
|
|
95
|
-
${BACKEND_SOURCES}
|
|
96
81
|
)
|
|
97
82
|
|
|
98
83
|
|
|
@@ -155,12 +140,10 @@ set_property(TARGET pathops PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libpat
|
|
|
155
140
|
add_library(jsonreader STATIC IMPORTED)
|
|
156
141
|
set_property(TARGET jsonreader PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libjsonreader.a")
|
|
157
142
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
set_property(TARGET webgpu_dawn PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libwebgpu_dawn.so")
|
|
163
|
-
endif()
|
|
143
|
+
# Dawn is a shared library, the same artifact react-native-webgpu links, so
|
|
144
|
+
# an app that installs both packages loads exactly one Dawn copy.
|
|
145
|
+
add_library(webgpu_dawn SHARED IMPORTED)
|
|
146
|
+
set_property(TARGET webgpu_dawn PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libwebgpu_dawn.so")
|
|
164
147
|
|
|
165
148
|
find_library(
|
|
166
149
|
LOG_LIB
|
|
@@ -182,7 +165,7 @@ else()
|
|
|
182
165
|
endif()
|
|
183
166
|
|
|
184
167
|
# Link
|
|
185
|
-
|
|
168
|
+
target_link_libraries(${PACKAGE_NAME}
|
|
186
169
|
${LOG_LIB}
|
|
187
170
|
ReactAndroid::reactnative
|
|
188
171
|
fbjni::fbjni
|
|
@@ -196,23 +179,11 @@ set(COMMON_LIBS
|
|
|
196
179
|
${SKIA_SKSG_LIB}
|
|
197
180
|
${SKIA_JSONREADER_LIB}
|
|
198
181
|
${SKIA_LIB}
|
|
182
|
+
webgpu_dawn
|
|
199
183
|
-ljnigraphics
|
|
200
|
-
-lGLESv2
|
|
201
|
-
-lEGL
|
|
202
184
|
-landroid
|
|
203
185
|
)
|
|
204
186
|
|
|
205
|
-
if(SK_GRAPHITE)
|
|
206
|
-
target_link_libraries(${PACKAGE_NAME}
|
|
207
|
-
${COMMON_LIBS}
|
|
208
|
-
webgpu_dawn
|
|
209
|
-
)
|
|
210
|
-
else()
|
|
211
|
-
target_link_libraries(${PACKAGE_NAME}
|
|
212
|
-
${COMMON_LIBS}
|
|
213
|
-
)
|
|
214
|
-
endif()
|
|
215
|
-
|
|
216
187
|
# Enable Android 16kb native library alignment
|
|
217
188
|
if(CMAKE_ANDROID_NDK_VERSION VERSION_LESS "27")
|
|
218
189
|
target_link_options(${PACKAGE_NAME} PRIVATE "-Wl,-z,max-page-size=16384")
|
package/android/build.gradle
CHANGED
|
@@ -6,10 +6,12 @@ import java.nio.file.Paths
|
|
|
6
6
|
// https://github.com/facebookincubator/fbjni/blob/main/docs/android_setup.md
|
|
7
7
|
|
|
8
8
|
// These defaults should reflect the SDK versions used by
|
|
9
|
-
// the minimum React Native version supported (0.78)
|
|
9
|
+
// the minimum React Native version supported (0.78), except minSdk:
|
|
10
|
+
// the Graphite binaries are built for API level 26 (ndk_api in
|
|
11
|
+
// scripts/skia-configuration.ts).
|
|
10
12
|
def DEFAULT_COMPILE_SDK_VERSION = 35
|
|
11
13
|
def DEFAULT_BUILD_TOOLS_VERSION = '35.0.0'
|
|
12
|
-
def DEFAULT_MIN_SDK_VERSION =
|
|
14
|
+
def DEFAULT_MIN_SDK_VERSION = 26
|
|
13
15
|
def DEFAULT_TARGET_SDK_VERSION = 34
|
|
14
16
|
|
|
15
17
|
def safeExtGet(prop, fallback) {
|
|
@@ -58,54 +60,61 @@ static def resolveNodePackage(packageName, baseDir) {
|
|
|
58
60
|
return proc.text.trim()
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
// Graphite
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
63
|
+
// The Graphite binaries, including the shared Dawn (libwebgpu_dawn.so), live in
|
|
64
|
+
// the react-native-skia-graphite-android npm package. Binaries built locally
|
|
65
|
+
// with `yarn build-skia` land in libs/android and take precedence when present.
|
|
66
|
+
def localSkiaLibs = file("${projectDir}/../libs/android")
|
|
67
|
+
def skiaLibsPath = localSkiaLibs.exists()
|
|
68
|
+
? "${projectDir}/../libs/android"
|
|
69
|
+
: "${resolveNodePackage('react-native-skia-graphite-android', projectDir)}/libs"
|
|
70
|
+
|
|
71
|
+
// Fail early rather than with a ninja "missing and no known rule" error.
|
|
72
|
+
def missingDawn = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"].findAll {
|
|
73
|
+
!file("${skiaLibsPath}/${it}/libwebgpu_dawn.so").exists()
|
|
74
|
+
}
|
|
75
|
+
if (!missingDawn.isEmpty()) {
|
|
76
|
+
throw new GradleException(
|
|
77
|
+
"react-native-skia: libwebgpu_dawn.so not found in ${skiaLibsPath} " +
|
|
78
|
+
"for ${missingDawn.join(', ')}. The installed react-native-skia-graphite-android " +
|
|
79
|
+
"package does not ship the shared Dawn library this Graphite build links against. " +
|
|
80
|
+
"Upgrade it and rebuild.")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Both packages must link the exact same Dawn artifact: compare the Dawn
|
|
84
|
+
// release tag the Skia binaries were packaged with (libs/.dawn-version in the
|
|
85
|
+
// react-native-skia-graphite-android package, or next to a local build) with
|
|
86
|
+
// the tag react-native-webgpu declares in its package.json `dawn` field.
|
|
87
|
+
def dawnMarker = file("${skiaLibsPath}/.dawn-version")
|
|
88
|
+
if (!dawnMarker.exists()) {
|
|
89
|
+
dawnMarker = file("${projectDir}/../libs/.dawn-version")
|
|
90
|
+
}
|
|
91
|
+
def webgpuDir = null
|
|
92
|
+
try {
|
|
93
|
+
webgpuDir = resolveNodePackage('react-native-webgpu', projectDir)
|
|
94
|
+
} catch (Exception ignored) {
|
|
95
|
+
// react-native-webgpu not installed: nothing to check
|
|
96
|
+
}
|
|
97
|
+
if (dawnMarker.exists() && webgpuDir != null) {
|
|
98
|
+
def skiaDawn = dawnMarker.text.trim()
|
|
99
|
+
def webgpuJson = new groovy.json.JsonSlurper().parse(file("${webgpuDir}/package.json"))
|
|
100
|
+
if (webgpuJson.dawn == null) {
|
|
101
|
+
throw new GradleException(
|
|
102
|
+
"react-native-skia: the installed react-native-webgpu " +
|
|
103
|
+
"(${webgpuJson.version}) does not declare a `dawn` field in its " +
|
|
104
|
+
"package.json, so it predates shared-Dawn support and cannot be " +
|
|
105
|
+
"paired with this Graphite build (which links ${skiaDawn}). " +
|
|
106
|
+
"Upgrade react-native-webgpu.")
|
|
85
107
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"(${webgpuJson.version}) does not declare a `dawn` field in its " +
|
|
93
|
-
"package.json, so it predates shared-Dawn support and cannot be " +
|
|
94
|
-
"paired with this Graphite build (which links ${skiaDawn}). " +
|
|
95
|
-
"Upgrade react-native-webgpu.")
|
|
96
|
-
}
|
|
97
|
-
def webgpuDawn = "dawn-" + webgpuJson.dawn.toString().replace('/', '-')
|
|
98
|
-
if (skiaDawn != webgpuDawn) {
|
|
99
|
-
throw new GradleException(
|
|
100
|
-
"react-native-skia: Dawn version mismatch. This Graphite build links " +
|
|
101
|
-
"${skiaDawn} but react-native-webgpu links ${webgpuDawn}. " +
|
|
102
|
-
"Align the two packages so the app contains exactly one Dawn.")
|
|
103
|
-
}
|
|
104
|
-
logger.warn("react-native-skia: Dawn versions match (${skiaDawn})")
|
|
108
|
+
def webgpuDawn = "dawn-" + webgpuJson.dawn.toString().replace('/', '-')
|
|
109
|
+
if (skiaDawn != webgpuDawn) {
|
|
110
|
+
throw new GradleException(
|
|
111
|
+
"react-native-skia: Dawn version mismatch. This Graphite build links " +
|
|
112
|
+
"${skiaDawn} but react-native-webgpu links ${webgpuDawn}. " +
|
|
113
|
+
"Align the two packages so the app contains exactly one Dawn.")
|
|
105
114
|
}
|
|
115
|
+
logger.warn("react-native-skia: Dawn versions match (${skiaDawn})")
|
|
106
116
|
}
|
|
107
117
|
|
|
108
|
-
logger.warn("react-native-skia: SK_GRAPHITE: ${useGraphite}")
|
|
109
118
|
logger.warn("react-native-skia: Skia libs: ${skiaLibsPath}")
|
|
110
119
|
logger.warn("react-native-skia: node_modules/ found at: ${nodeModules}")
|
|
111
120
|
|
|
@@ -167,7 +176,6 @@ android {
|
|
|
167
176
|
"-DREACT_NATIVE_DIR=${defaultDir}",
|
|
168
177
|
"-DNODE_MODULES_DIR=${nodeModules}",
|
|
169
178
|
"-DSKIA_LIBS_PATH=${skiaLibsPath}",
|
|
170
|
-
"-DSK_GRAPHITE=${useGraphite ? 'ON' : 'OFF'}",
|
|
171
179
|
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
172
180
|
|
|
173
181
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
#include "JniPlatformContext.h"
|
|
2
2
|
#include "JniSkiaManager.h"
|
|
3
|
-
#include "
|
|
4
|
-
#include "JniSkiaPictureView.h"
|
|
3
|
+
#include "JniSkiaView.h"
|
|
5
4
|
#include <fbjni/fbjni.h>
|
|
6
5
|
#include <jni.h>
|
|
7
6
|
|
|
8
7
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
|
9
8
|
return facebook::jni::initialize(vm, [] {
|
|
10
9
|
RNSkia::JniSkiaManager::registerNatives();
|
|
11
|
-
RNSkia::
|
|
12
|
-
RNSkia::JniSkiaGraphiteView::registerNatives();
|
|
10
|
+
RNSkia::JniSkiaView::registerNatives();
|
|
13
11
|
RNSkia::JniPlatformContext::registerNatives();
|
|
14
12
|
});
|
|
15
13
|
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include <fbjni/fbjni.h>
|
|
6
|
+
#include <jni.h>
|
|
7
|
+
|
|
8
|
+
#include "JniSkiaManager.h"
|
|
9
|
+
#include "RNSkAndroidCanvasProvider.h"
|
|
10
|
+
#include "RNSkView.h"
|
|
11
|
+
|
|
12
|
+
namespace RNSkia {
|
|
13
|
+
namespace jni = facebook::jni;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The JNI side of SkiaView: owns the native view and the ANativeWindow
|
|
17
|
+
* provider it presents into, and relays the surface callbacks of the backing
|
|
18
|
+
* SurfaceView or TextureView.
|
|
19
|
+
*/
|
|
20
|
+
class JniSkiaView : public jni::HybridClass<JniSkiaView> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/reactnative/skia/SkiaView;";
|
|
23
|
+
|
|
24
|
+
static jni::local_ref<jhybriddata>
|
|
25
|
+
initHybrid(jni::alias_ref<jhybridobject> jThis,
|
|
26
|
+
jni::alias_ref<JniSkiaManager::javaobject> skiaManager) {
|
|
27
|
+
return makeCxxInstance(jThis, skiaManager);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static void registerNatives() {
|
|
31
|
+
registerHybrid(
|
|
32
|
+
{makeNativeMethod("initHybrid", JniSkiaView::initHybrid),
|
|
33
|
+
makeNativeMethod("surfaceAvailable", JniSkiaView::surfaceAvailable),
|
|
34
|
+
makeNativeMethod("surfaceDestroyed", JniSkiaView::surfaceDestroyed),
|
|
35
|
+
makeNativeMethod("surfaceSizeChanged",
|
|
36
|
+
JniSkiaView::surfaceSizeChanged),
|
|
37
|
+
makeNativeMethod("setLayoutSize", JniSkiaView::setLayoutSize),
|
|
38
|
+
makeNativeMethod("registerView", JniSkiaView::registerView),
|
|
39
|
+
makeNativeMethod("unregisterView", JniSkiaView::unregisterView),
|
|
40
|
+
makeNativeMethod("presentFrame", JniSkiaView::presentFrame)});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The manager is owned by the RNSkiaModule and is destroyed when the module
|
|
44
|
+
// is invalidated (reload). Fabric drops views on the UI thread while the
|
|
45
|
+
// module is invalidated on a background thread, so a view can outlive its
|
|
46
|
+
// manager: holding a weak reference makes a late unregister a no-op and a
|
|
47
|
+
// concurrent one keep the manager alive for the duration of the call.
|
|
48
|
+
std::shared_ptr<RNSkManager> getSkiaManager() { return _manager.lock(); }
|
|
49
|
+
|
|
50
|
+
protected:
|
|
51
|
+
void surfaceAvailable(jobject surface, int width, int height, bool isSurface,
|
|
52
|
+
bool highBitDepth) {
|
|
53
|
+
_provider->surfaceAvailable(surface, width, height, isSurface,
|
|
54
|
+
highBitDepth);
|
|
55
|
+
_view->redraw();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void surfaceSizeChanged(jobject surface, int width, int height,
|
|
59
|
+
bool isSurface, bool highBitDepth) {
|
|
60
|
+
_provider->surfaceSizeChanged(surface, width, height, isSurface,
|
|
61
|
+
highBitDepth);
|
|
62
|
+
// Paint the new size right away rather than on the next scheduled redraw.
|
|
63
|
+
_view->redraw();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void surfaceDestroyed() { _provider->surfaceDestroyed(); }
|
|
67
|
+
|
|
68
|
+
void setLayoutSize(int width, int height) {
|
|
69
|
+
_provider->setLayoutSize(width, height);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void registerView(int nativeId) {
|
|
73
|
+
auto manager = getSkiaManager();
|
|
74
|
+
if (manager == nullptr) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
manager->registerSkiaView(nativeId, _view);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void unregisterView() {
|
|
81
|
+
if (auto manager = getSkiaManager()) {
|
|
82
|
+
manager->setSkiaView(_view->getNativeId(), nullptr);
|
|
83
|
+
manager->unregisterSkiaView(_view->getNativeId());
|
|
84
|
+
}
|
|
85
|
+
// React drops the Java view here, but the native view behind it (and the
|
|
86
|
+
// content it owns) is only destroyed when the Java object is finalized.
|
|
87
|
+
// Release the content now so it does not wait for the garbage collector.
|
|
88
|
+
_view->releaseContent();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Choreographer tick: presents the queued recordings, returns whether more
|
|
92
|
+
// are already waiting.
|
|
93
|
+
bool presentFrame() { return _view->presentFrame(); }
|
|
94
|
+
|
|
95
|
+
private:
|
|
96
|
+
friend HybridBase;
|
|
97
|
+
|
|
98
|
+
explicit JniSkiaView(jni::alias_ref<jhybridobject> jThis,
|
|
99
|
+
jni::alias_ref<JniSkiaManager::javaobject> skiaManager)
|
|
100
|
+
: _manager(skiaManager->cthis()->getSkiaManager()) {
|
|
101
|
+
auto context = skiaManager->cthis()->getPlatformContext();
|
|
102
|
+
_provider = std::make_shared<RNSkAndroidCanvasProvider>(context);
|
|
103
|
+
_view = std::make_shared<RNSkView>(context, _provider);
|
|
104
|
+
// A submitted recording arms the Java view's frame callback. Weak: the
|
|
105
|
+
// Java view owns this object through its hybrid data.
|
|
106
|
+
jni::weak_ref<jhybridobject> weakJava = jni::make_weak(jThis);
|
|
107
|
+
_view->setFrameScheduler([weakJava]() {
|
|
108
|
+
auto javaPart = weakJava.lockLocal();
|
|
109
|
+
if (!javaPart) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
static const auto method =
|
|
113
|
+
javaPart->getClass()->getMethod<void()>("scheduleFrame");
|
|
114
|
+
method(javaPart);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
std::weak_ptr<RNSkManager> _manager;
|
|
119
|
+
std::shared_ptr<RNSkAndroidCanvasProvider> _provider;
|
|
120
|
+
std::shared_ptr<RNSkView> _view;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
} // namespace RNSkia
|