@shopify/react-native-skia 0.1.155 → 0.1.157
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/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/Canvas.js +1 -1
- package/lib/commonjs/renderer/Canvas.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/HostConfig.js +10 -1
- package/lib/commonjs/renderer/HostConfig.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/animation/spring/runSpring.js +1 -1
- package/lib/module/animation/spring/runSpring.js.map +1 -1
- package/lib/module/animation/spring/useSpring.js +1 -1
- package/lib/module/animation/spring/useSpring.js.map +1 -1
- package/lib/module/animation/timing/createTiming.js +6 -2
- package/lib/module/animation/timing/createTiming.js.map +1 -1
- package/lib/module/animation/timing/functions/getResolvedParams.js +10 -6
- package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -1
- package/lib/module/animation/timing/useTiming.js +3 -1
- package/lib/module/animation/timing/useTiming.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +6 -1
- 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/datatypes/Gradient.js +2 -2
- package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +4 -2
- package/lib/module/dom/nodes/paint/Shaders.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/mock/index.js +10 -6
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +1 -1
- package/lib/module/renderer/Canvas.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/HostConfig.js +9 -1
- package/lib/module/renderer/HostConfig.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/skia/core/Vector.js +1 -1
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/lib/module/skia/web/Host.js +1 -1
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/values/web/RNSkAnimation.js +2 -2
- package/lib/module/values/web/RNSkAnimation.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +3 -1
- package/lib/module/views/SkiaBaseWebView.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/module/views/useTouchHandler.js +6 -6
- package/lib/module/views/useTouchHandler.js.map +1 -1
- package/lib/module/web/WithSkiaWeb.js +1 -1
- package/lib/module/web/WithSkiaWeb.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 +14 -6
- package/src/dom/nodes/JsiSkDOM.ts +5 -0
- package/src/dom/nodes/LayerNode.ts +35 -0
- package/src/dom/types/NodeType.ts +1 -0
- package/src/dom/types/SkDOM.ts +1 -0
- package/src/renderer/Canvas.tsx +11 -1
- package/src/renderer/HostComponents.ts +3 -0
- package/src/renderer/HostConfig.ts +8 -1
- 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
@@ -12,18 +12,18 @@
|
|
12
12
|
#pragma clang diagnostic push
|
13
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
14
14
|
|
15
|
+
#include "include/effects/Sk1DPathEffect.h"
|
16
|
+
#include "include/effects/Sk2DPathEffect.h"
|
15
17
|
#include <SkCornerPathEffect.h>
|
16
18
|
#include <SkDashPathEffect.h>
|
17
19
|
#include <SkDiscretePathEffect.h>
|
18
20
|
#include <SkPathEffect.h>
|
19
|
-
#include "include/effects/Sk1DPathEffect.h"
|
20
|
-
#include "include/effects/Sk2DPathEffect.h"
|
21
21
|
|
22
22
|
#pragma clang diagnostic pop
|
23
23
|
|
24
24
|
namespace RNSkia {
|
25
25
|
|
26
|
-
|
26
|
+
namespace jsi = facebook::jsi;
|
27
27
|
|
28
28
|
class JsiSkPathEffectFactory : public JsiSkHostObject {
|
29
29
|
public:
|
@@ -36,14 +36,17 @@ public:
|
|
36
36
|
|
37
37
|
JSI_HOST_FUNCTION(MakeDash) {
|
38
38
|
auto jsiIntervals = arguments[0].asObject(runtime).asArray(runtime);
|
39
|
-
auto size = (
|
39
|
+
auto size = static_cast<int>(jsiIntervals.size(runtime));
|
40
40
|
std::vector<SkScalar> intervals;
|
41
41
|
intervals.reserve(size);
|
42
42
|
for (int i = 0; i < size; i++) {
|
43
43
|
SkScalar interval = jsiIntervals.getValueAtIndex(runtime, i).asNumber();
|
44
44
|
intervals.push_back(interval);
|
45
45
|
}
|
46
|
-
int phase =
|
46
|
+
int phase =
|
47
|
+
count >= 2 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
48
|
+
? arguments[1].asNumber()
|
49
|
+
: 0;
|
47
50
|
return jsi::Object::createFromHostObject(
|
48
51
|
runtime, std::make_shared<JsiSkPathEffect>(
|
49
52
|
getContext(),
|
@@ -65,8 +68,9 @@ public:
|
|
65
68
|
auto inner = JsiSkPathEffect::fromValue(runtime, arguments[1]);
|
66
69
|
|
67
70
|
return jsi::Object::createFromHostObject(
|
68
|
-
|
69
|
-
|
71
|
+
runtime, std::make_shared<JsiSkPathEffect>(
|
72
|
+
getContext(), SkPathEffect::MakeCompose(
|
73
|
+
std::move(outer), std::move(inner))));
|
70
74
|
}
|
71
75
|
|
72
76
|
JSI_HOST_FUNCTION(MakeSum) {
|
@@ -74,26 +78,29 @@ public:
|
|
74
78
|
auto inner = JsiSkPathEffect::fromValue(runtime, arguments[1]);
|
75
79
|
|
76
80
|
return jsi::Object::createFromHostObject(
|
77
|
-
|
78
|
-
|
81
|
+
runtime, std::make_shared<JsiSkPathEffect>(
|
82
|
+
getContext(), SkPathEffect::MakeSum(std::move(outer),
|
83
|
+
std::move(inner))));
|
79
84
|
}
|
80
85
|
|
81
86
|
JSI_HOST_FUNCTION(MakePath1D) {
|
82
87
|
auto path = JsiSkPath::fromValue(runtime, arguments[0]);
|
83
88
|
auto advance = arguments[1].asNumber();
|
84
89
|
auto phase = arguments[2].asNumber();
|
85
|
-
auto style =
|
90
|
+
auto style =
|
91
|
+
static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
|
86
92
|
return jsi::Object::createFromHostObject(
|
87
|
-
|
88
|
-
|
93
|
+
runtime, std::make_shared<JsiSkPathEffect>(
|
94
|
+
getContext(),
|
95
|
+
SkPath1DPathEffect::Make(*path, advance, phase, style)));
|
89
96
|
}
|
90
97
|
|
91
98
|
JSI_HOST_FUNCTION(MakePath2D) {
|
92
99
|
auto matrix = JsiSkMatrix::fromValue(runtime, arguments[0]);
|
93
100
|
auto path = JsiSkPath::fromValue(runtime, arguments[1]);
|
94
101
|
return jsi::Object::createFromHostObject(
|
95
|
-
|
96
|
-
|
102
|
+
runtime, std::make_shared<JsiSkPathEffect>(
|
103
|
+
getContext(), SkPath2DPathEffect::Make(*matrix, *path)));
|
97
104
|
}
|
98
105
|
|
99
106
|
JSI_HOST_FUNCTION(MakeLine2D) {
|
@@ -101,22 +108,20 @@ public:
|
|
101
108
|
auto matrix = JsiSkMatrix::fromValue(runtime, arguments[1]);
|
102
109
|
|
103
110
|
return jsi::Object::createFromHostObject(
|
104
|
-
|
105
|
-
|
111
|
+
runtime, std::make_shared<JsiSkPathEffect>(
|
112
|
+
getContext(), SkLine2DPathEffect::Make(width, *matrix)));
|
106
113
|
}
|
107
114
|
|
108
|
-
JSI_EXPORT_FUNCTIONS(
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
JsiSkPathEffectFactory(std::shared_ptr<RNSkPlatformContext> context)
|
115
|
+
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeCorner),
|
116
|
+
JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeDash),
|
117
|
+
JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeDiscrete),
|
118
|
+
JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeCompose),
|
119
|
+
JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeSum),
|
120
|
+
JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeLine2D),
|
121
|
+
JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakePath1D),
|
122
|
+
JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakePath2D), )
|
123
|
+
|
124
|
+
explicit JsiSkPathEffectFactory(std::shared_ptr<RNSkPlatformContext> context)
|
120
125
|
: JsiSkHostObject(std::move(context)) {}
|
121
126
|
};
|
122
127
|
|
@@ -11,15 +11,15 @@
|
|
11
11
|
#pragma clang diagnostic push
|
12
12
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
13
13
|
|
14
|
+
#include <RNSkLog.h>
|
14
15
|
#include <SkPath.h>
|
15
16
|
#include <SkPathOps.h>
|
16
|
-
#include <RNSkLog.h>
|
17
17
|
|
18
18
|
#pragma clang diagnostic pop
|
19
19
|
|
20
20
|
namespace RNSkia {
|
21
21
|
|
22
|
-
|
22
|
+
namespace jsi = facebook::jsi;
|
23
23
|
|
24
24
|
class JsiSkPathFactory : public JsiSkHostObject {
|
25
25
|
|
@@ -67,84 +67,85 @@ public:
|
|
67
67
|
auto cmds = arguments[0].asObject(runtime).asArray(runtime);
|
68
68
|
auto cmdCount = cmds.size(runtime);
|
69
69
|
for (int i = 0; i < cmdCount; i++) {
|
70
|
-
auto cmd =
|
70
|
+
auto cmd =
|
71
|
+
cmds.getValueAtIndex(runtime, i).asObject(runtime).asArray(runtime);
|
71
72
|
if (cmd.size(runtime) < 1) {
|
72
73
|
RNSkLogger::logToConsole("Invalid command found (got an empty array)");
|
73
74
|
return jsi::Value::null();
|
74
75
|
}
|
75
76
|
auto verb = static_cast<int>(cmd.getValueAtIndex(runtime, 0).asNumber());
|
76
77
|
switch (verb) {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
82
|
-
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
83
|
-
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
84
|
-
path.moveTo(x, y);
|
85
|
-
break;
|
86
|
-
}
|
87
|
-
case LINE: {
|
88
|
-
if (cmd.size(runtime) < 3) {
|
89
|
-
RNSkLogger::logToConsole("Invalid line command found");
|
90
|
-
return jsi::Value::null();
|
91
|
-
}
|
92
|
-
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
93
|
-
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
94
|
-
path.lineTo(x, y);
|
95
|
-
break;
|
96
|
-
}
|
97
|
-
case QUAD: {
|
98
|
-
if (cmd.size(runtime) < 5) {
|
99
|
-
RNSkLogger::logToConsole("Invalid line command found");
|
100
|
-
return jsi::Value::null();
|
101
|
-
}
|
102
|
-
auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
|
103
|
-
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
104
|
-
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
105
|
-
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
106
|
-
path.quadTo(x1, y1, x2, y2);
|
107
|
-
break;
|
78
|
+
case MOVE: {
|
79
|
+
if (cmd.size(runtime) < 3) {
|
80
|
+
RNSkLogger::logToConsole("Invalid move command found");
|
81
|
+
return jsi::Value::null();
|
108
82
|
}
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
|
119
|
-
path.conicTo(x1, y1, x2, y2, w);
|
120
|
-
break;
|
83
|
+
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
84
|
+
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
85
|
+
path.moveTo(x, y);
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
case LINE: {
|
89
|
+
if (cmd.size(runtime) < 3) {
|
90
|
+
RNSkLogger::logToConsole("Invalid line command found");
|
91
|
+
return jsi::Value::null();
|
121
92
|
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
|
132
|
-
auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
|
133
|
-
path.cubicTo(x1, y1, x2, y2, x3, y3);
|
134
|
-
break;
|
93
|
+
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
94
|
+
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
95
|
+
path.lineTo(x, y);
|
96
|
+
break;
|
97
|
+
}
|
98
|
+
case QUAD: {
|
99
|
+
if (cmd.size(runtime) < 5) {
|
100
|
+
RNSkLogger::logToConsole("Invalid line command found");
|
101
|
+
return jsi::Value::null();
|
135
102
|
}
|
136
|
-
|
137
|
-
|
138
|
-
|
103
|
+
auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
|
104
|
+
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
105
|
+
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
106
|
+
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
107
|
+
path.quadTo(x1, y1, x2, y2);
|
108
|
+
break;
|
109
|
+
}
|
110
|
+
case CONIC: {
|
111
|
+
if (cmd.size(runtime) < 6) {
|
112
|
+
RNSkLogger::logToConsole("Invalid line command found");
|
113
|
+
return jsi::Value::null();
|
139
114
|
}
|
140
|
-
|
141
|
-
|
115
|
+
auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
|
116
|
+
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
117
|
+
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
118
|
+
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
119
|
+
auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
|
120
|
+
path.conicTo(x1, y1, x2, y2, w);
|
121
|
+
break;
|
122
|
+
}
|
123
|
+
case CUBIC: {
|
124
|
+
if (cmd.size(runtime) < 7) {
|
125
|
+
RNSkLogger::logToConsole("Invalid line command found");
|
142
126
|
return jsi::Value::null();
|
143
127
|
}
|
128
|
+
auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
|
129
|
+
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
130
|
+
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
131
|
+
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
132
|
+
auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
|
133
|
+
auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
|
134
|
+
path.cubicTo(x1, y1, x2, y2, x3, y3);
|
135
|
+
break;
|
136
|
+
}
|
137
|
+
case CLOSE: {
|
138
|
+
path.close();
|
139
|
+
break;
|
140
|
+
}
|
141
|
+
default: {
|
142
|
+
RNSkLogger::logToConsole("Found an unknown command");
|
143
|
+
return jsi::Value::null();
|
144
|
+
}
|
144
145
|
}
|
145
146
|
}
|
146
147
|
return jsi::Object::createFromHostObject(
|
147
|
-
|
148
|
+
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
|
148
149
|
}
|
149
150
|
|
150
151
|
JSI_HOST_FUNCTION(MakeFromText) {
|
@@ -156,7 +157,7 @@ public:
|
|
156
157
|
SkTextUtils::GetPath(text.c_str(), strlen(text.c_str()),
|
157
158
|
SkTextEncoding::kUTF8, x, y, *font, &path);
|
158
159
|
return jsi::Object::createFromHostObject(
|
159
|
-
|
160
|
+
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
|
160
161
|
}
|
161
162
|
|
162
163
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathFactory, Make),
|
@@ -165,7 +166,7 @@ public:
|
|
165
166
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromCmds),
|
166
167
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromText))
|
167
168
|
|
168
|
-
|
169
|
+
explicit JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
|
169
170
|
: JsiSkHostObject(std::move(context)) {}
|
170
171
|
};
|
171
172
|
|
package/cpp/api/JsiSkPicture.h
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
2
1
|
#pragma once
|
3
2
|
|
3
|
+
#include <memory>
|
4
|
+
|
4
5
|
#include "JsiSkHostObjects.h"
|
5
6
|
#include <JsiSkData.h>
|
6
7
|
#include <JsiSkShader.h>
|
@@ -14,13 +15,13 @@
|
|
14
15
|
|
15
16
|
namespace RNSkia {
|
16
17
|
|
17
|
-
|
18
|
+
namespace jsi = facebook::jsi;
|
18
19
|
|
19
20
|
class JsiSkPicture : public JsiSkWrappingSkPtrHostObject<SkPicture> {
|
20
21
|
public:
|
21
|
-
|
22
|
-
|
23
|
-
: JsiSkWrappingSkPtrHostObject<SkPicture>(context, picture) {}
|
22
|
+
JsiSkPicture(std::shared_ptr<RNSkPlatformContext> context,
|
23
|
+
const sk_sp<SkPicture> picture)
|
24
|
+
: JsiSkWrappingSkPtrHostObject<SkPicture>(context, picture) {}
|
24
25
|
|
25
26
|
JSI_PROPERTY_GET(__typename__) {
|
26
27
|
return jsi::String::createFromUtf8(runtime, "Picture");
|
@@ -32,34 +33,39 @@ public:
|
|
32
33
|
auto tmx = (SkTileMode)arguments[0].asNumber();
|
33
34
|
auto tmy = (SkTileMode)arguments[1].asNumber();
|
34
35
|
auto fm = (SkFilterMode)arguments[2].asNumber();
|
35
|
-
auto m = count > 3 && !arguments[3].isUndefined()
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
auto m = count > 3 && !arguments[3].isUndefined()
|
37
|
+
? JsiSkMatrix::fromValue(runtime, arguments[3]).get()
|
38
|
+
: nullptr;
|
39
|
+
|
40
|
+
auto tr = count > 4 && !arguments[4].isUndefined()
|
41
|
+
? JsiSkRect::fromValue(runtime, arguments[4]).get()
|
42
|
+
: nullptr;
|
43
|
+
|
41
44
|
// Create shader
|
42
45
|
auto shader = getObject()->makeShader(tmx, tmy, fm, m, tr);
|
43
46
|
return jsi::Object::createFromHostObject(
|
44
47
|
runtime, std::make_shared<JsiSkShader>(getContext(), shader));
|
45
48
|
}
|
46
|
-
|
49
|
+
|
47
50
|
JSI_HOST_FUNCTION(serialize) {
|
48
51
|
auto data = getObject()->serialize();
|
49
|
-
auto arrayCtor =
|
52
|
+
auto arrayCtor =
|
53
|
+
runtime.global().getPropertyAsFunction(runtime, "Uint8Array");
|
50
54
|
size_t size = data->size();
|
51
55
|
|
52
|
-
jsi::Object array =
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
jsi::Object array =
|
57
|
+
arrayCtor.callAsConstructor(runtime, static_cast<double>(size))
|
58
|
+
.getObject(runtime);
|
59
|
+
jsi::ArrayBuffer buffer =
|
60
|
+
array.getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
|
61
|
+
.asObject(runtime)
|
62
|
+
.getArrayBuffer(runtime);
|
57
63
|
|
58
64
|
auto bfrPtr = reinterpret_cast<uint8_t *>(buffer.data(runtime));
|
59
65
|
memcpy(bfrPtr, data->bytes(), size);
|
60
|
-
return array;
|
66
|
+
return array;
|
61
67
|
}
|
62
|
-
|
68
|
+
|
63
69
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPicture, makeShader),
|
64
70
|
JSI_EXPORT_FUNC(JsiSkPicture, serialize))
|
65
71
|
|
@@ -67,11 +73,11 @@ public:
|
|
67
73
|
Returns the underlying object from a host object of this type
|
68
74
|
*/
|
69
75
|
static sk_sp<SkPicture> fromValue(jsi::Runtime &runtime,
|
70
|
-
|
76
|
+
const jsi::Value &obj) {
|
71
77
|
return obj.asObject(runtime)
|
72
78
|
.asHostObject<JsiSkPicture>(runtime)
|
73
79
|
.get()
|
74
80
|
->getObject();
|
75
|
-
}
|
81
|
+
}
|
76
82
|
};
|
77
83
|
} // namespace RNSkia
|
@@ -1,41 +1,42 @@
|
|
1
|
-
|
2
1
|
#pragma once
|
3
2
|
|
3
|
+
#include <memory>
|
4
|
+
|
4
5
|
#include "JsiSkColorFilter.h"
|
5
|
-
#include "JsiSkHostObjects.h"
|
6
6
|
#include "JsiSkData.h"
|
7
|
+
#include "JsiSkHostObjects.h"
|
7
8
|
#include "JsiSkPicture.h"
|
8
9
|
|
9
10
|
#pragma clang diagnostic push
|
10
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
11
12
|
|
12
|
-
#include <SkPicture.h>
|
13
13
|
#include <SkData.h>
|
14
|
+
#include <SkPicture.h>
|
14
15
|
|
15
16
|
#pragma clang diagnostic pop
|
16
17
|
|
17
18
|
namespace RNSkia {
|
18
19
|
|
19
|
-
|
20
|
+
namespace jsi = facebook::jsi;
|
20
21
|
|
21
22
|
class JsiSkPictureFactory : public JsiSkHostObject {
|
22
23
|
public:
|
23
24
|
JSI_HOST_FUNCTION(MakePicture) {
|
24
|
-
if(!arguments[0].isObject()) {
|
25
|
+
if (!arguments[0].isObject()) {
|
25
26
|
throw jsi::JSError(runtime, "Expected arraybuffer as first parameter");
|
26
27
|
}
|
27
28
|
auto array = arguments[0].asObject(runtime);
|
28
|
-
jsi::ArrayBuffer buffer =
|
29
|
-
|
29
|
+
jsi::ArrayBuffer buffer =
|
30
|
+
array.getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
|
30
31
|
.asObject(runtime)
|
31
32
|
.getArrayBuffer(runtime);
|
32
33
|
|
33
|
-
sk_sp<SkData> data =
|
34
|
+
sk_sp<SkData> data =
|
35
|
+
SkData::MakeWithCopy(buffer.data(runtime), buffer.size(runtime));
|
34
36
|
auto picture = SkPicture::MakeFromData(data.get());
|
35
|
-
if(picture != nullptr) {
|
37
|
+
if (picture != nullptr) {
|
36
38
|
return jsi::Object::createFromHostObject(
|
37
|
-
runtime,
|
38
|
-
std::make_shared<JsiSkPicture>(getContext(), picture));
|
39
|
+
runtime, std::make_shared<JsiSkPicture>(getContext(), picture));
|
39
40
|
} else {
|
40
41
|
return jsi::Value::undefined();
|
41
42
|
}
|
@@ -43,7 +44,7 @@ public:
|
|
43
44
|
|
44
45
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPictureFactory, MakePicture))
|
45
46
|
|
46
|
-
JsiSkPictureFactory(std::shared_ptr<RNSkPlatformContext> context)
|
47
|
+
explicit JsiSkPictureFactory(std::shared_ptr<RNSkPlatformContext> context)
|
47
48
|
: JsiSkHostObject(context) {}
|
48
49
|
};
|
49
50
|
|
@@ -1,53 +1,55 @@
|
|
1
|
-
|
2
1
|
#pragma once
|
3
2
|
|
3
|
+
#include <memory>
|
4
|
+
|
5
|
+
#include "JsiSkCanvas.h"
|
4
6
|
#include "JsiSkHostObjects.h"
|
5
|
-
#include "JsiSkRect.h"
|
6
7
|
#include "JsiSkPicture.h"
|
7
|
-
#include "
|
8
|
+
#include "JsiSkRect.h"
|
8
9
|
|
9
10
|
#pragma clang diagnostic push
|
10
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
11
12
|
|
12
|
-
#include <SkPictureRecorder.h>
|
13
13
|
#include <SkBBHFactory.h>
|
14
|
+
#include <SkPictureRecorder.h>
|
14
15
|
|
15
16
|
#pragma clang diagnostic pop
|
16
17
|
|
17
18
|
namespace RNSkia {
|
18
19
|
|
19
|
-
|
20
|
+
namespace jsi = facebook::jsi;
|
20
21
|
|
21
|
-
class JsiSkPictureRecorder
|
22
|
+
class JsiSkPictureRecorder
|
23
|
+
: public JsiSkWrappingSharedPtrHostObject<SkPictureRecorder> {
|
22
24
|
public:
|
23
|
-
|
24
|
-
JsiSkPictureRecorder(std::shared_ptr<RNSkPlatformContext> context)
|
25
|
+
explicit JsiSkPictureRecorder(std::shared_ptr<RNSkPlatformContext> context)
|
25
26
|
: JsiSkWrappingSharedPtrHostObject<SkPictureRecorder>(
|
26
|
-
context, std::make_shared<SkPictureRecorder>()){}
|
27
|
+
context, std::make_shared<SkPictureRecorder>()) {}
|
27
28
|
|
28
29
|
JSI_HOST_FUNCTION(beginRecording) {
|
29
30
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
30
31
|
SkRTreeFactory factory;
|
31
32
|
auto canvas = getObject()->beginRecording(*rect, &factory);
|
32
33
|
return jsi::Object::createFromHostObject(
|
33
|
-
|
34
|
+
runtime, std::make_shared<JsiSkCanvas>(getContext(), canvas));
|
34
35
|
}
|
35
|
-
|
36
|
+
|
36
37
|
JSI_HOST_FUNCTION(finishRecordingAsPicture) {
|
37
38
|
auto picture = getObject()->finishRecordingAsPicture();
|
38
39
|
return jsi::Object::createFromHostObject(
|
39
|
-
|
40
|
+
runtime, std::make_shared<JsiSkPicture>(getContext(), picture));
|
40
41
|
}
|
41
|
-
|
42
|
+
|
42
43
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPictureRecorder, beginRecording),
|
43
|
-
JSI_EXPORT_FUNC(JsiSkPictureRecorder,
|
44
|
-
|
44
|
+
JSI_EXPORT_FUNC(JsiSkPictureRecorder,
|
45
|
+
finishRecordingAsPicture))
|
46
|
+
|
45
47
|
static const jsi::HostFunctionType
|
46
48
|
createCtor(std::shared_ptr<RNSkPlatformContext> context) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
return JSI_HOST_FUNCTION_LAMBDA {
|
50
|
+
return jsi::Object::createFromHostObject(
|
51
|
+
runtime, std::make_shared<JsiSkPictureRecorder>(context));
|
52
|
+
};
|
51
53
|
}
|
52
54
|
};
|
53
55
|
} // namespace RNSkia
|
package/cpp/api/JsiSkPoint.h
CHANGED
@@ -16,11 +16,10 @@
|
|
16
16
|
|
17
17
|
namespace RNSkia {
|
18
18
|
|
19
|
-
|
19
|
+
namespace jsi = facebook::jsi;
|
20
20
|
|
21
21
|
class JsiSkPoint : public JsiSkWrappingSharedPtrHostObject<SkPoint> {
|
22
22
|
public:
|
23
|
-
|
24
23
|
JSI_PROPERTY_GET(x) { return static_cast<double>(getObject()->x()); }
|
25
24
|
|
26
25
|
JSI_PROPERTY_GET(y) { return static_cast<double>(getObject()->y()); }
|
@@ -30,18 +29,16 @@ public:
|
|
30
29
|
|
31
30
|
JsiSkPoint(std::shared_ptr<RNSkPlatformContext> context, const SkPoint &point)
|
32
31
|
: JsiSkWrappingSharedPtrHostObject<SkPoint>(
|
33
|
-
std::move(context), std::make_shared<SkPoint>(point)){}
|
32
|
+
std::move(context), std::make_shared<SkPoint>(point)) {}
|
34
33
|
|
35
34
|
/**
|
36
35
|
Returns the underlying object from a host object of this type
|
37
36
|
*/
|
38
37
|
static std::shared_ptr<SkPoint> fromValue(jsi::Runtime &runtime,
|
39
38
|
const jsi::Value &obj) {
|
40
|
-
const auto&
|
39
|
+
const auto &object = obj.asObject(runtime);
|
41
40
|
if (object.isHostObject(runtime)) {
|
42
|
-
return object
|
43
|
-
.asHostObject<JsiSkPoint>(runtime)
|
44
|
-
->getObject();
|
41
|
+
return object.asHostObject<JsiSkPoint>(runtime)->getObject();
|
45
42
|
} else {
|
46
43
|
auto x = object.getProperty(runtime, "x").asNumber();
|
47
44
|
auto y = object.getProperty(runtime, "y").asNumber();
|
@@ -74,7 +71,8 @@ public:
|
|
74
71
|
|
75
72
|
// Return the newly constructed object
|
76
73
|
return jsi::Object::createFromHostObject(
|
77
|
-
runtime,
|
74
|
+
runtime,
|
75
|
+
std::make_shared<JsiSkPoint>(std::move(context), std::move(point)));
|
78
76
|
};
|
79
77
|
}
|
80
78
|
};
|
package/cpp/api/JsiSkRRect.h
CHANGED
@@ -12,11 +12,13 @@
|
|
12
12
|
|
13
13
|
#include <SkRRect.h>
|
14
14
|
|
15
|
+
#include "JsiSkRect.h"
|
16
|
+
|
15
17
|
#pragma clang diagnostic pop
|
16
18
|
|
17
19
|
namespace RNSkia {
|
18
20
|
|
19
|
-
|
21
|
+
namespace jsi = facebook::jsi;
|
20
22
|
|
21
23
|
class JsiSkRRect : public JsiSkWrappingSharedPtrHostObject<SkRRect> {
|
22
24
|
public:
|
@@ -38,7 +40,7 @@ public:
|
|
38
40
|
|
39
41
|
JsiSkRRect(std::shared_ptr<RNSkPlatformContext> context, const SkRRect &rect)
|
40
42
|
: JsiSkWrappingSharedPtrHostObject<SkRRect>(
|
41
|
-
std::move(context), std::make_shared<SkRRect>(rect)){}
|
43
|
+
std::move(context), std::make_shared<SkRRect>(rect)) {}
|
42
44
|
|
43
45
|
/**
|
44
46
|
Returns the underlying object from a host object of this type
|
@@ -46,13 +48,14 @@ public:
|
|
46
48
|
static std::shared_ptr<SkRRect> fromValue(jsi::Runtime &runtime,
|
47
49
|
const jsi::Value &obj) {
|
48
50
|
|
49
|
-
const auto&
|
51
|
+
const auto &object = obj.asObject(runtime);
|
50
52
|
if (object.isHostObject(runtime)) {
|
51
53
|
return obj.asObject(runtime)
|
52
|
-
|
53
|
-
|
54
|
+
.asHostObject<JsiSkRRect>(runtime)
|
55
|
+
->getObject();
|
54
56
|
} else {
|
55
|
-
auto rect =
|
57
|
+
auto rect =
|
58
|
+
JsiSkRect::fromValue(runtime, object.getProperty(runtime, "rect"));
|
56
59
|
auto rx = object.getProperty(runtime, "rx").asNumber();
|
57
60
|
auto ry = object.getProperty(runtime, "ry").asNumber();
|
58
61
|
return std::make_shared<SkRRect>(SkRRect::MakeRectXY(*rect, rx, ry));
|
@@ -86,7 +89,8 @@ public:
|
|
86
89
|
auto rrect = SkRRect::MakeRectXY(*rect, rx, ry);
|
87
90
|
// Return the newly constructed object
|
88
91
|
return jsi::Object::createFromHostObject(
|
89
|
-
runtime,
|
92
|
+
runtime,
|
93
|
+
std::make_shared<JsiSkRRect>(std::move(context), std::move(rrect)));
|
90
94
|
};
|
91
95
|
}
|
92
96
|
};
|