@shopify/react-native-skia 0.1.154 → 0.1.156
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/jni/JniLoad.cpp +5 -5
- package/android/cpp/jni/JniPlatformContext.cpp +107 -119
- package/android/cpp/jni/JniSkiaManager.cpp +18 -20
- package/android/cpp/jni/include/JniPlatformContext.h +41 -45
- package/android/cpp/jni/include/JniSkiaBaseView.h +52 -55
- package/android/cpp/jni/include/JniSkiaDrawView.h +72 -77
- package/android/cpp/jni/include/JniSkiaManager.h +51 -53
- package/android/cpp/jni/include/JniSkiaPictureView.h +74 -78
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +36 -45
- package/android/cpp/rnskia-android/RNSkAndroidView.h +87 -92
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +62 -65
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +20 -17
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +257 -313
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +107 -110
- package/cpp/api/JsiSkApi.h +66 -62
- package/cpp/api/JsiSkCanvas.h +38 -30
- package/cpp/api/JsiSkColor.h +58 -56
- package/cpp/api/JsiSkColorFilter.h +5 -3
- package/cpp/api/JsiSkColorFilterFactory.h +23 -21
- package/cpp/api/JsiSkContourMeasure.h +74 -85
- package/cpp/api/JsiSkContourMeasureIter.h +68 -75
- package/cpp/api/JsiSkData.h +16 -22
- package/cpp/api/JsiSkDataFactory.h +86 -79
- package/cpp/api/JsiSkFont.h +286 -311
- package/cpp/api/JsiSkHostObjects.h +15 -16
- package/cpp/api/JsiSkImage.h +107 -103
- package/cpp/api/JsiSkImageFactory.h +34 -36
- package/cpp/api/JsiSkImageFilter.h +5 -3
- package/cpp/api/JsiSkImageFilterFactory.h +71 -68
- package/cpp/api/JsiSkImageInfo.h +41 -38
- package/cpp/api/JsiSkMaskFilter.h +5 -3
- package/cpp/api/JsiSkMaskFilterFactory.h +2 -3
- package/cpp/api/JsiSkMatrix.h +26 -36
- package/cpp/api/JsiSkPaint.h +20 -13
- package/cpp/api/JsiSkPath.h +70 -85
- package/cpp/api/JsiSkPathEffect.h +5 -3
- package/cpp/api/JsiSkPathEffectFactory.h +33 -28
- package/cpp/api/JsiSkPathFactory.h +68 -67
- package/cpp/api/JsiSkPicture.h +28 -22
- package/cpp/api/JsiSkPictureFactory.h +13 -12
- package/cpp/api/JsiSkPictureRecorder.h +21 -19
- package/cpp/api/JsiSkPoint.h +6 -8
- package/cpp/api/JsiSkRRect.h +11 -7
- package/cpp/api/JsiSkRSXform.h +82 -85
- package/cpp/api/JsiSkRect.h +9 -9
- package/cpp/api/JsiSkRuntimeEffect.h +182 -186
- package/cpp/api/JsiSkRuntimeEffectFactory.h +10 -11
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +64 -61
- package/cpp/api/JsiSkSVG.h +4 -5
- package/cpp/api/JsiSkSVGFactory.h +28 -27
- package/cpp/api/JsiSkShader.h +3 -2
- package/cpp/api/JsiSkShaderFactory.h +37 -25
- package/cpp/api/JsiSkSurface.h +44 -40
- package/cpp/api/JsiSkSurfaceFactory.h +22 -22
- package/cpp/api/JsiSkTextBlob.h +28 -31
- package/cpp/api/JsiSkTextBlobFactory.h +88 -87
- package/cpp/api/JsiSkTypeface.h +6 -5
- package/cpp/api/JsiSkTypefaceFactory.h +22 -21
- package/cpp/api/JsiSkVertices.h +137 -124
- package/cpp/api/third_party/CSSColorParser.cpp +161 -174
- package/cpp/api/third_party/CSSColorParser.h +172 -96
- package/cpp/jsi/JsiHostObject.cpp +11 -9
- package/cpp/jsi/JsiHostObject.h +31 -24
- package/cpp/jsi/JsiSimpleValueWrapper.h +74 -83
- package/cpp/jsi/JsiValueWrapper.h +52 -54
- package/cpp/rnskia/RNSkAnimation.h +26 -29
- package/cpp/rnskia/RNSkDispatchQueue.cpp +50 -61
- package/cpp/rnskia/RNSkDispatchQueue.h +3 -1
- package/cpp/rnskia/RNSkInfoParameter.h +12 -12
- package/cpp/rnskia/RNSkJsView.cpp +82 -81
- package/cpp/rnskia/RNSkJsView.h +45 -41
- package/cpp/rnskia/RNSkJsiViewApi.h +99 -89
- package/cpp/rnskia/RNSkManager.cpp +8 -7
- package/cpp/rnskia/RNSkManager.h +8 -6
- package/cpp/rnskia/RNSkPictureView.h +44 -37
- package/cpp/rnskia/RNSkPlatformContext.h +39 -28
- package/cpp/rnskia/RNSkValueApi.h +33 -34
- package/cpp/rnskia/RNSkView.h +108 -93
- package/cpp/rnskia/values/RNSkClockValue.h +63 -64
- package/cpp/rnskia/values/RNSkComputedValue.h +32 -30
- package/cpp/rnskia/values/RNSkReadonlyValue.h +60 -59
- package/cpp/rnskia/values/RNSkValue.h +38 -40
- package/cpp/utils/RNSkLog.h +9 -7
- package/cpp/utils/RNSkMeasureTime.h +7 -7
- package/cpp/utils/RNSkTimingInfo.h +27 -24
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +8 -9
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +24 -23
- package/ios/RNSkia-iOS/RNSkiOSView.h +16 -13
- package/ios/RNSkia-iOS/SkiaUIView.h +9 -8
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +6 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/dom/nodes/LayerNode.js +43 -0
- package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -0
- package/lib/commonjs/dom/nodes/RenderNode.js +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/types/NodeType.js +1 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.js +3 -0
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +19 -4
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +6 -1
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.js +3 -2
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.js +6 -3
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +5 -0
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/LayerNode.js +32 -0
- package/lib/module/dom/nodes/LayerNode.js.map +1 -0
- package/lib/module/dom/nodes/RenderNode.js +1 -1
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/types/NodeType.js +1 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/renderer/HostComponents.js +3 -0
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/components/Group.js +16 -3
- package/lib/module/renderer/components/Group.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +7 -1
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/views/SkiaPictureView.js +2 -2
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.js +4 -2
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
- package/lib/typescript/src/dom/nodes/LayerNode.d.ts +8 -0
- package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
- package/lib/typescript/src/dom/types/SkDOM.d.ts +1 -0
- package/lib/typescript/src/renderer/HostComponents.d.ts +2 -1
- package/lib/typescript/src/renderer/components/Group.d.ts +5 -1
- package/lib/typescript/src/views/SkiaView.d.ts +3 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +42 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libsksg.xcframework/Info.plist +42 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +3 -1
- package/src/dom/nodes/JsiSkDOM.ts +5 -0
- package/src/dom/nodes/LayerNode.ts +35 -0
- package/src/dom/nodes/RenderNode.ts +4 -3
- package/src/dom/types/NodeType.ts +1 -0
- package/src/dom/types/SkDOM.ts +1 -0
- package/src/renderer/HostComponents.ts +3 -0
- package/src/renderer/components/Group.tsx +16 -3
- package/src/renderer/components/Paint.tsx +7 -1
- package/src/views/SkiaPictureView.tsx +2 -3
- package/src/views/SkiaView.tsx +2 -2
@@ -1,95 +1,90 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
3
|
#include <memory>
|
4
|
+
#include <string>
|
4
5
|
|
5
6
|
#include <fbjni/fbjni.h>
|
6
7
|
#include <jni.h>
|
7
8
|
#include <jsi/jsi.h>
|
8
9
|
|
9
|
-
#include <RNSkJsView.h>
|
10
|
-
#include <RNSkAndroidView.h>
|
11
10
|
#include <JniSkiaBaseView.h>
|
12
11
|
#include <JniSkiaManager.h>
|
12
|
+
#include <RNSkAndroidView.h>
|
13
|
+
#include <RNSkJsView.h>
|
13
14
|
|
14
15
|
#include <android/native_window.h>
|
15
16
|
#include <android/native_window_jni.h>
|
16
17
|
#include <fbjni/detail/Hybrid.h>
|
17
18
|
|
18
19
|
namespace RNSkia {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
std::make_shared<RNSkAndroidView<RNSkia::RNSkJsView>>(
|
89
|
-
skiaManager->cthis()->getPlatformContext())) {
|
90
|
-
}
|
91
|
-
|
92
|
-
jni::global_ref<javaobject> javaPart_;
|
93
|
-
};
|
20
|
+
namespace jsi = facebook::jsi;
|
21
|
+
namespace jni = facebook::jni;
|
22
|
+
|
23
|
+
class JniSkiaDrawView : public jni::HybridClass<JniSkiaDrawView>,
|
24
|
+
public JniSkiaBaseView {
|
25
|
+
public:
|
26
|
+
static auto constexpr kJavaDescriptor =
|
27
|
+
"Lcom/shopify/reactnative/skia/SkiaDrawView;";
|
28
|
+
|
29
|
+
static jni::local_ref<jhybriddata>
|
30
|
+
initHybrid(jni::alias_ref<jhybridobject> jThis,
|
31
|
+
jni::alias_ref<JniSkiaManager::javaobject> skiaManager) {
|
32
|
+
return makeCxxInstance(jThis, skiaManager);
|
33
|
+
}
|
34
|
+
|
35
|
+
static void registerNatives() {
|
36
|
+
registerHybrid(
|
37
|
+
{makeNativeMethod("initHybrid", JniSkiaDrawView::initHybrid),
|
38
|
+
makeNativeMethod("surfaceAvailable",
|
39
|
+
JniSkiaDrawView::surfaceAvailable),
|
40
|
+
makeNativeMethod("surfaceDestroyed",
|
41
|
+
JniSkiaDrawView::surfaceDestroyed),
|
42
|
+
makeNativeMethod("surfaceSizeChanged",
|
43
|
+
JniSkiaDrawView::surfaceSizeChanged),
|
44
|
+
makeNativeMethod("setMode", JniSkiaDrawView::setMode),
|
45
|
+
makeNativeMethod("setDebugMode", JniSkiaDrawView::setDebugMode),
|
46
|
+
makeNativeMethod("updateTouchPoints",
|
47
|
+
JniSkiaDrawView::updateTouchPoints),
|
48
|
+
makeNativeMethod("registerView", JniSkiaDrawView::registerView),
|
49
|
+
makeNativeMethod("unregisterView", JniSkiaDrawView::unregisterView)});
|
50
|
+
}
|
51
|
+
|
52
|
+
protected:
|
53
|
+
void updateTouchPoints(jni::JArrayDouble touches) override {
|
54
|
+
JniSkiaBaseView::updateTouchPoints(touches);
|
55
|
+
}
|
56
|
+
|
57
|
+
void surfaceAvailable(jobject surface, int width, int height) override {
|
58
|
+
JniSkiaBaseView::surfaceAvailable(surface, width, height);
|
59
|
+
}
|
60
|
+
|
61
|
+
void surfaceSizeChanged(int width, int height) override {
|
62
|
+
JniSkiaBaseView::surfaceSizeChanged(width, height);
|
63
|
+
}
|
64
|
+
|
65
|
+
void surfaceDestroyed() override { JniSkiaBaseView::surfaceDestroyed(); }
|
66
|
+
|
67
|
+
void setMode(std::string mode) override { JniSkiaBaseView::setMode(mode); }
|
68
|
+
|
69
|
+
void setDebugMode(bool show) override { JniSkiaBaseView::setDebugMode(show); }
|
70
|
+
|
71
|
+
void registerView(int nativeId) override {
|
72
|
+
JniSkiaBaseView::registerView(nativeId);
|
73
|
+
}
|
74
|
+
|
75
|
+
void unregisterView() override { JniSkiaBaseView::unregisterView(); }
|
76
|
+
|
77
|
+
private:
|
78
|
+
friend HybridBase;
|
79
|
+
|
80
|
+
explicit JniSkiaDrawView(
|
81
|
+
jni::alias_ref<jhybridobject> jThis,
|
82
|
+
jni::alias_ref<JniSkiaManager::javaobject> skiaManager)
|
83
|
+
: JniSkiaBaseView(skiaManager,
|
84
|
+
std::make_shared<RNSkAndroidView<RNSkia::RNSkJsView>>(
|
85
|
+
skiaManager->cthis()->getPlatformContext())) {}
|
86
|
+
|
87
|
+
jni::global_ref<javaobject> javaPart_;
|
88
|
+
};
|
94
89
|
|
95
90
|
} // namespace RNSkia
|
@@ -8,14 +8,14 @@
|
|
8
8
|
|
9
9
|
#include <JniPlatformContext.h>
|
10
10
|
#include <RNSkAndroidPlatformContext.h>
|
11
|
-
#include <RNSkManager.h>
|
12
11
|
#include <RNSkLog.h>
|
12
|
+
#include <RNSkManager.h>
|
13
13
|
|
14
14
|
namespace RNSkia {
|
15
15
|
|
16
16
|
class RNSkManager;
|
17
17
|
|
18
|
-
|
18
|
+
namespace jsi = facebook::jsi;
|
19
19
|
|
20
20
|
using JSCallInvokerHolder =
|
21
21
|
jni::alias_ref<facebook::react::CallInvokerHolder::javaobject>;
|
@@ -23,57 +23,55 @@ using JSCallInvokerHolder =
|
|
23
23
|
using JavaPlatformContext = jni::alias_ref<JniPlatformContext::javaobject>;
|
24
24
|
|
25
25
|
class JniSkiaManager : public jni::HybridClass<JniSkiaManager> {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
void initializeRuntime();
|
26
|
+
public:
|
27
|
+
static auto constexpr kJavaDescriptor =
|
28
|
+
"Lcom/shopify/reactnative/skia/SkiaManager;";
|
29
|
+
static auto constexpr TAG = "ReactNativeSkia";
|
30
|
+
|
31
|
+
static jni::local_ref<jni::HybridClass<JniSkiaManager>::jhybriddata>
|
32
|
+
initHybrid(jni::alias_ref<jhybridobject> jThis, jlong jsContext,
|
33
|
+
JSCallInvokerHolder jsCallInvokerHolder,
|
34
|
+
JavaPlatformContext platformContext);
|
35
|
+
|
36
|
+
static void registerNatives();
|
37
|
+
|
38
|
+
JniSkiaManager() {}
|
39
|
+
~JniSkiaManager() { RNSkLogger::logToConsole("JniSkiaManager dtor"); }
|
40
|
+
|
41
|
+
explicit JniSkiaManager(
|
42
|
+
jni::alias_ref<JniSkiaManager::jhybridobject> jThis,
|
43
|
+
jsi::Runtime *runtime,
|
44
|
+
std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker,
|
45
|
+
JniPlatformContext *platformContext)
|
46
|
+
: _javaPart(jni::make_global(jThis)), _jsRuntime(runtime),
|
47
|
+
_jsCallInvoker(jsCallInvoker),
|
48
|
+
_context(std::make_shared<RNSkAndroidPlatformContext>(
|
49
|
+
platformContext, runtime, jsCallInvoker)) {}
|
50
|
+
|
51
|
+
std::shared_ptr<RNSkAndroidPlatformContext> getPlatformContext() {
|
52
|
+
return _context;
|
53
|
+
}
|
54
|
+
std::shared_ptr<RNSkManager> getSkiaManager() { return _skManager; }
|
55
|
+
|
56
|
+
void invalidate() {
|
57
|
+
_context->stopDrawLoop();
|
58
|
+
_context->notifyDrawLoop(true);
|
59
|
+
_skManager = nullptr;
|
60
|
+
_context = nullptr;
|
61
|
+
}
|
62
|
+
|
63
|
+
private:
|
64
|
+
friend HybridBase;
|
65
|
+
|
66
|
+
std::shared_ptr<RNSkManager> _skManager;
|
67
|
+
|
68
|
+
jni::global_ref<JniSkiaManager::javaobject> _javaPart;
|
69
|
+
|
70
|
+
jsi::Runtime *_jsRuntime;
|
71
|
+
std::shared_ptr<facebook::react::CallInvoker> _jsCallInvoker;
|
72
|
+
std::shared_ptr<RNSkAndroidPlatformContext> _context;
|
73
|
+
|
74
|
+
void initializeRuntime();
|
77
75
|
};
|
78
76
|
|
79
77
|
} // namespace RNSkia
|
@@ -1,96 +1,92 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
3
|
#include <memory>
|
4
|
+
#include <string>
|
4
5
|
|
5
6
|
#include <fbjni/fbjni.h>
|
6
7
|
#include <jni.h>
|
7
8
|
#include <jsi/jsi.h>
|
8
9
|
|
9
|
-
#include <RNSkPictureView.h>
|
10
|
-
#include <RNSkAndroidView.h>
|
11
10
|
#include <JniSkiaBaseView.h>
|
12
11
|
#include <JniSkiaManager.h>
|
12
|
+
#include <RNSkAndroidView.h>
|
13
|
+
#include <RNSkPictureView.h>
|
13
14
|
|
14
15
|
#include <android/native_window.h>
|
15
16
|
#include <android/native_window_jni.h>
|
16
17
|
#include <fbjni/detail/Hybrid.h>
|
17
18
|
|
18
19
|
namespace RNSkia {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
skiaManager->cthis()->getPlatformContext())) {
|
91
|
-
}
|
92
|
-
|
93
|
-
jni::global_ref<javaobject> javaPart_;
|
94
|
-
};
|
20
|
+
namespace jsi = facebook::jsi;
|
21
|
+
namespace jni = facebook::jni;
|
22
|
+
|
23
|
+
class JniSkiaPictureView : public jni::HybridClass<JniSkiaPictureView>,
|
24
|
+
public JniSkiaBaseView {
|
25
|
+
public:
|
26
|
+
static auto constexpr kJavaDescriptor =
|
27
|
+
"Lcom/shopify/reactnative/skia/SkiaPictureView;";
|
28
|
+
|
29
|
+
static jni::local_ref<jhybriddata>
|
30
|
+
initHybrid(jni::alias_ref<jhybridobject> jThis,
|
31
|
+
jni::alias_ref<JniSkiaManager::javaobject> skiaManager) {
|
32
|
+
return makeCxxInstance(jThis, skiaManager);
|
33
|
+
}
|
34
|
+
|
35
|
+
static void registerNatives() {
|
36
|
+
registerHybrid(
|
37
|
+
{makeNativeMethod("initHybrid", JniSkiaPictureView::initHybrid),
|
38
|
+
makeNativeMethod("surfaceAvailable",
|
39
|
+
JniSkiaPictureView::surfaceAvailable),
|
40
|
+
makeNativeMethod("surfaceDestroyed",
|
41
|
+
JniSkiaPictureView::surfaceDestroyed),
|
42
|
+
makeNativeMethod("surfaceSizeChanged",
|
43
|
+
JniSkiaPictureView::surfaceSizeChanged),
|
44
|
+
makeNativeMethod("setMode", JniSkiaPictureView::setMode),
|
45
|
+
makeNativeMethod("setDebugMode", JniSkiaPictureView::setDebugMode),
|
46
|
+
makeNativeMethod("updateTouchPoints",
|
47
|
+
JniSkiaPictureView::updateTouchPoints),
|
48
|
+
makeNativeMethod("registerView", JniSkiaPictureView::registerView),
|
49
|
+
makeNativeMethod("unregisterView",
|
50
|
+
JniSkiaPictureView::unregisterView)});
|
51
|
+
}
|
52
|
+
|
53
|
+
protected:
|
54
|
+
void updateTouchPoints(jni::JArrayDouble touches) override {
|
55
|
+
JniSkiaBaseView::updateTouchPoints(touches);
|
56
|
+
}
|
57
|
+
|
58
|
+
void surfaceAvailable(jobject surface, int width, int height) override {
|
59
|
+
JniSkiaBaseView::surfaceAvailable(surface, width, height);
|
60
|
+
}
|
61
|
+
|
62
|
+
void surfaceSizeChanged(int width, int height) override {
|
63
|
+
JniSkiaBaseView::surfaceSizeChanged(width, height);
|
64
|
+
}
|
65
|
+
|
66
|
+
void surfaceDestroyed() override { JniSkiaBaseView::surfaceDestroyed(); }
|
67
|
+
|
68
|
+
void setMode(std::string mode) override { JniSkiaBaseView::setMode(mode); }
|
69
|
+
|
70
|
+
void setDebugMode(bool show) override { JniSkiaBaseView::setDebugMode(show); }
|
71
|
+
|
72
|
+
void registerView(int nativeId) override {
|
73
|
+
JniSkiaBaseView::registerView(nativeId);
|
74
|
+
}
|
75
|
+
|
76
|
+
void unregisterView() override { JniSkiaBaseView::unregisterView(); }
|
77
|
+
|
78
|
+
private:
|
79
|
+
friend HybridBase;
|
80
|
+
|
81
|
+
explicit JniSkiaPictureView(
|
82
|
+
jni::alias_ref<jhybridobject> jThis,
|
83
|
+
jni::alias_ref<JniSkiaManager::javaobject> skiaManager)
|
84
|
+
: JniSkiaBaseView(
|
85
|
+
skiaManager,
|
86
|
+
std::make_shared<RNSkAndroidView<RNSkia::RNSkPictureView>>(
|
87
|
+
skiaManager->cthis()->getPlatformContext())) {}
|
88
|
+
|
89
|
+
jni::global_ref<javaobject> javaPart_;
|
90
|
+
};
|
95
91
|
|
96
92
|
} // namespace RNSkia
|
@@ -1,54 +1,45 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#include <exception>
|
3
4
|
#include <functional>
|
4
|
-
#include <string>
|
5
5
|
#include <memory>
|
6
|
-
#include <
|
6
|
+
#include <string>
|
7
7
|
|
8
8
|
#include <JniPlatformContext.h>
|
9
9
|
#include <RNSkPlatformContext.h>
|
10
10
|
|
11
11
|
namespace RNSkia {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
|
48
|
-
private:
|
49
|
-
|
50
|
-
JniPlatformContext* _jniPlatformContext;
|
51
|
-
};
|
52
|
-
|
53
|
-
}
|
54
|
-
|
12
|
+
namespace jsi = facebook::jsi;
|
13
|
+
|
14
|
+
class RNSkAndroidPlatformContext : public RNSkPlatformContext {
|
15
|
+
public:
|
16
|
+
RNSkAndroidPlatformContext(
|
17
|
+
JniPlatformContext *jniPlatformContext, jsi::Runtime *runtime,
|
18
|
+
std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker)
|
19
|
+
: RNSkPlatformContext(runtime, jsCallInvoker,
|
20
|
+
jniPlatformContext->getPixelDensity()),
|
21
|
+
_jniPlatformContext(jniPlatformContext) {
|
22
|
+
// Hook onto the notify draw loop callback in the platform context
|
23
|
+
jniPlatformContext->setOnNotifyDrawLoop(
|
24
|
+
[this]() { notifyDrawLoop(false); });
|
25
|
+
}
|
26
|
+
|
27
|
+
void performStreamOperation(
|
28
|
+
const std::string &sourceUri,
|
29
|
+
const std::function<void(std::unique_ptr<SkStreamAsset>)> &op) override {
|
30
|
+
_jniPlatformContext->performStreamOperation(sourceUri, op);
|
31
|
+
}
|
32
|
+
|
33
|
+
void raiseError(const std::exception &err) override {
|
34
|
+
_jniPlatformContext->raiseError(err);
|
35
|
+
}
|
36
|
+
|
37
|
+
void startDrawLoop() override { _jniPlatformContext->startDrawLoop(); }
|
38
|
+
|
39
|
+
void stopDrawLoop() override { _jniPlatformContext->stopDrawLoop(); }
|
40
|
+
|
41
|
+
private:
|
42
|
+
JniPlatformContext *_jniPlatformContext;
|
43
|
+
};
|
44
|
+
|
45
|
+
} // namespace RNSkia
|