@shopify/react-native-skia 0.1.155 → 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/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/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/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
package/cpp/api/JsiSkImageInfo.h
CHANGED
@@ -16,42 +16,45 @@
|
|
16
16
|
|
17
17
|
namespace RNSkia {
|
18
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
19
|
+
namespace jsi = facebook::jsi;
|
20
|
+
|
21
|
+
class JsiSkImageInfo : public JsiSkWrappingSharedPtrHostObject<SkImageInfo> {
|
22
|
+
public:
|
23
|
+
JsiSkImageInfo(std::shared_ptr<RNSkPlatformContext> context,
|
24
|
+
const SkImageInfo &imageInfo)
|
25
|
+
: JsiSkWrappingSharedPtrHostObject<SkImageInfo>(
|
26
|
+
std::move(context), std::make_shared<SkImageInfo>(imageInfo)) {}
|
27
|
+
|
28
|
+
/**
|
29
|
+
Returns the underlying object from a host object of this type
|
30
|
+
*/
|
31
|
+
static std::shared_ptr<SkImageInfo> fromValue(jsi::Runtime &runtime,
|
32
|
+
const jsi::Value &obj) {
|
33
|
+
const auto &object = obj.asObject(runtime);
|
34
|
+
if (object.isHostObject(runtime)) {
|
35
|
+
return object.asHostObject<JsiSkImageInfo>(runtime)->getObject();
|
36
|
+
} else {
|
37
|
+
auto width = object.getProperty(runtime, "width").asNumber();
|
38
|
+
auto height = object.getProperty(runtime, "height").asNumber();
|
39
|
+
auto colorType = static_cast<SkColorType>(
|
40
|
+
object.getProperty(runtime, "colorType").asNumber());
|
41
|
+
auto alphaType = static_cast<SkAlphaType>(
|
42
|
+
object.getProperty(runtime, "alphaType").asNumber());
|
43
|
+
// TODO: color space not supported yet
|
44
|
+
return std::make_shared<SkImageInfo>(
|
45
|
+
SkImageInfo::Make(width, height, colorType, alphaType));
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
Returns the jsi object from a host object of this type
|
51
|
+
*/
|
52
|
+
static jsi::Value toValue(jsi::Runtime &runtime,
|
53
|
+
std::shared_ptr<RNSkPlatformContext> context,
|
54
|
+
const SkImageInfo &imageInfo) {
|
55
|
+
return jsi::Object::createFromHostObject(
|
56
|
+
runtime,
|
57
|
+
std::make_shared<JsiSkImageInfo>(std::move(context), imageInfo));
|
58
|
+
}
|
59
|
+
};
|
57
60
|
} // namespace RNSkia
|
@@ -16,20 +16,22 @@
|
|
16
16
|
|
17
17
|
namespace RNSkia {
|
18
18
|
|
19
|
-
|
19
|
+
namespace jsi = facebook::jsi;
|
20
20
|
|
21
21
|
class JsiSkMaskFilter : public JsiSkWrappingSkPtrHostObject<SkMaskFilter> {
|
22
22
|
public:
|
23
23
|
JsiSkMaskFilter(std::shared_ptr<RNSkPlatformContext> context,
|
24
24
|
sk_sp<SkMaskFilter> maskFilter)
|
25
|
-
: JsiSkWrappingSkPtrHostObject<SkMaskFilter>(std::move(context),
|
25
|
+
: JsiSkWrappingSkPtrHostObject<SkMaskFilter>(std::move(context),
|
26
|
+
std::move(maskFilter)) {}
|
26
27
|
|
27
28
|
// TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
|
28
29
|
JSI_PROPERTY_GET(__typename__) {
|
29
30
|
return jsi::String::createFromUtf8(runtime, "MaskFilter");
|
30
31
|
}
|
31
32
|
|
32
|
-
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkMaskFilter,
|
33
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkMaskFilter,
|
34
|
+
__typename__))
|
33
35
|
|
34
36
|
/**
|
35
37
|
Returns the underlying object from a host object of this type
|
@@ -15,10 +15,9 @@
|
|
15
15
|
|
16
16
|
#pragma clang diagnostic pop
|
17
17
|
|
18
|
-
|
19
18
|
namespace RNSkia {
|
20
19
|
|
21
|
-
|
20
|
+
namespace jsi = facebook::jsi;
|
22
21
|
|
23
22
|
class JsiSkMaskFilterFactory : public JsiSkHostObject {
|
24
23
|
public:
|
@@ -35,7 +34,7 @@ public:
|
|
35
34
|
|
36
35
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMaskFilterFactory, MakeBlur))
|
37
36
|
|
38
|
-
JsiSkMaskFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
|
37
|
+
explicit JsiSkMaskFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
|
39
38
|
: JsiSkHostObject(std::move(context)) {}
|
40
39
|
};
|
41
40
|
|
package/cpp/api/JsiSkMatrix.h
CHANGED
@@ -16,35 +16,29 @@
|
|
16
16
|
|
17
17
|
namespace RNSkia {
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
namespace jsi = facebook::jsi;
|
21
20
|
|
22
21
|
class JsiSkMatrix : public JsiSkWrappingSharedPtrHostObject<SkMatrix> {
|
23
22
|
public:
|
24
|
-
|
25
23
|
JsiSkMatrix(std::shared_ptr<RNSkPlatformContext> context, SkMatrix m)
|
26
24
|
: JsiSkWrappingSharedPtrHostObject<SkMatrix>(
|
27
25
|
context, std::make_shared<SkMatrix>(std::move(m))) {}
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
skewY, scaleY, transY,
|
45
|
-
pers0, pers1, pers2
|
46
|
-
);
|
47
|
-
}
|
27
|
+
static SkMatrix getMatrix(jsi::Runtime &runtime, const jsi::Value &value) {
|
28
|
+
const auto &object = value.asObject(runtime);
|
29
|
+
const auto &array = object.asArray(runtime);
|
30
|
+
auto scaleX = array.getValueAtIndex(runtime, 0).asNumber();
|
31
|
+
auto skewX = array.getValueAtIndex(runtime, 1).asNumber();
|
32
|
+
auto transX = array.getValueAtIndex(runtime, 2).asNumber();
|
33
|
+
auto skewY = array.getValueAtIndex(runtime, 3).asNumber();
|
34
|
+
auto scaleY = array.getValueAtIndex(runtime, 4).asNumber();
|
35
|
+
auto transY = array.getValueAtIndex(runtime, 5).asNumber();
|
36
|
+
auto pers0 = array.getValueAtIndex(runtime, 6).asNumber();
|
37
|
+
auto pers1 = array.getValueAtIndex(runtime, 7).asNumber();
|
38
|
+
auto pers2 = array.getValueAtIndex(runtime, 8).asNumber();
|
39
|
+
return SkMatrix::MakeAll(scaleX, skewX, transX, skewY, scaleY, transY,
|
40
|
+
pers0, pers1, pers2);
|
41
|
+
}
|
48
42
|
|
49
43
|
JSI_PROPERTY_GET(__typename__) {
|
50
44
|
return jsi::String::createFromUtf8(runtime, "Matrix");
|
@@ -82,7 +76,7 @@ public:
|
|
82
76
|
getObject()->preRotate(SkRadiansToDegrees(a));
|
83
77
|
return jsi::Value::undefined();
|
84
78
|
}
|
85
|
-
|
79
|
+
|
86
80
|
JSI_HOST_FUNCTION(identity) {
|
87
81
|
getObject()->setIdentity();
|
88
82
|
return jsi::Value::undefined();
|
@@ -98,26 +92,22 @@ public:
|
|
98
92
|
|
99
93
|
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkMatrix, __typename__))
|
100
94
|
|
101
|
-
JSI_EXPORT_FUNCTIONS(
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
JSI_EXPORT_FUNC(JsiSkMatrix, get),
|
109
|
-
)
|
95
|
+
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMatrix, concat),
|
96
|
+
JSI_EXPORT_FUNC(JsiSkMatrix, translate),
|
97
|
+
JSI_EXPORT_FUNC(JsiSkMatrix, scale),
|
98
|
+
JSI_EXPORT_FUNC(JsiSkMatrix, skew),
|
99
|
+
JSI_EXPORT_FUNC(JsiSkMatrix, rotate),
|
100
|
+
JSI_EXPORT_FUNC(JsiSkMatrix, identity),
|
101
|
+
JSI_EXPORT_FUNC(JsiSkMatrix, get), )
|
110
102
|
|
111
103
|
/**
|
112
104
|
* Returns the underlying object from a host object of this type
|
113
105
|
*/
|
114
106
|
static std::shared_ptr<SkMatrix> fromValue(jsi::Runtime &runtime,
|
115
107
|
const jsi::Value &obj) {
|
116
|
-
const auto&
|
108
|
+
const auto &object = obj.asObject(runtime);
|
117
109
|
if (object.isHostObject(runtime)) {
|
118
|
-
return object
|
119
|
-
.asHostObject<JsiSkMatrix>(runtime)
|
120
|
-
->getObject();
|
110
|
+
return object.asHostObject<JsiSkMatrix>(runtime)->getObject();
|
121
111
|
} else {
|
122
112
|
return std::make_shared<SkMatrix>(JsiSkMatrix::getMatrix(runtime, obj));
|
123
113
|
}
|
package/cpp/api/JsiSkPaint.h
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
#include <jsi/jsi.h>
|
7
7
|
|
8
|
+
#include <JsiSkColor.h>
|
9
|
+
#include <JsiSkColorFilter.h>
|
8
10
|
#include <JsiSkHostObjects.h>
|
9
11
|
#include <JsiSkImageFilter.h>
|
10
12
|
#include <JsiSkMaskFilter.h>
|
11
|
-
#include <JsiSkColorFilter.h>
|
12
13
|
#include <JsiSkPathEffect.h>
|
13
14
|
#include <JsiSkShader.h>
|
14
|
-
#include <JsiSkColor.h>
|
15
15
|
|
16
16
|
#pragma clang diagnostic push
|
17
17
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
@@ -21,11 +21,10 @@
|
|
21
21
|
#pragma clang diagnostic pop
|
22
22
|
|
23
23
|
namespace RNSkia {
|
24
|
-
|
24
|
+
namespace jsi = facebook::jsi;
|
25
25
|
|
26
26
|
class JsiSkPaint : public JsiSkWrappingSharedPtrHostObject<SkPaint> {
|
27
27
|
public:
|
28
|
-
|
29
28
|
// TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
|
30
29
|
JSI_PROPERTY_GET(__typename__) {
|
31
30
|
return jsi::String::createFromUtf8(runtime, "Paint");
|
@@ -34,7 +33,7 @@ public:
|
|
34
33
|
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPaint, __typename__))
|
35
34
|
|
36
35
|
JSI_HOST_FUNCTION(copy) {
|
37
|
-
const auto*
|
36
|
+
const auto *paint = getObject().get();
|
38
37
|
return jsi::Object::createFromHostObject(
|
39
38
|
runtime, std::make_shared<JsiSkPaint>(getContext(), SkPaint(*paint)));
|
40
39
|
}
|
@@ -119,31 +118,41 @@ public:
|
|
119
118
|
}
|
120
119
|
|
121
120
|
JSI_HOST_FUNCTION(setMaskFilter) {
|
122
|
-
auto maskFilter = arguments[0].isNull() || arguments[0].isUndefined()
|
121
|
+
auto maskFilter = arguments[0].isNull() || arguments[0].isUndefined()
|
122
|
+
? nullptr
|
123
|
+
: JsiSkMaskFilter::fromValue(runtime, arguments[0]);
|
123
124
|
getObject()->setMaskFilter(std::move(maskFilter));
|
124
125
|
return jsi::Value::undefined();
|
125
126
|
}
|
126
127
|
|
127
128
|
JSI_HOST_FUNCTION(setImageFilter) {
|
128
|
-
auto imageFilter = arguments[0].isNull() || arguments[0].isUndefined()
|
129
|
+
auto imageFilter = arguments[0].isNull() || arguments[0].isUndefined()
|
130
|
+
? nullptr
|
131
|
+
: JsiSkImageFilter::fromValue(runtime, arguments[0]);
|
129
132
|
getObject()->setImageFilter(std::move(imageFilter));
|
130
133
|
return jsi::Value::undefined();
|
131
134
|
}
|
132
135
|
|
133
136
|
JSI_HOST_FUNCTION(setColorFilter) {
|
134
|
-
auto colorFilter = arguments[0].isNull() || arguments[0].isUndefined()
|
137
|
+
auto colorFilter = arguments[0].isNull() || arguments[0].isUndefined()
|
138
|
+
? nullptr
|
139
|
+
: JsiSkColorFilter::fromValue(runtime, arguments[0]);
|
135
140
|
getObject()->setColorFilter(std::move(colorFilter));
|
136
141
|
return jsi::Value::undefined();
|
137
142
|
}
|
138
143
|
|
139
144
|
JSI_HOST_FUNCTION(setShader) {
|
140
|
-
auto shader = arguments[0].isNull() || arguments[0].isUndefined()
|
145
|
+
auto shader = arguments[0].isNull() || arguments[0].isUndefined()
|
146
|
+
? nullptr
|
147
|
+
: JsiSkShader::fromValue(runtime, arguments[0]);
|
141
148
|
getObject()->setShader(std::move(shader));
|
142
149
|
return jsi::Value::undefined();
|
143
150
|
}
|
144
151
|
|
145
152
|
JSI_HOST_FUNCTION(setPathEffect) {
|
146
|
-
auto pathEffect = arguments[0].isNull() || arguments[0].isUndefined()
|
153
|
+
auto pathEffect = arguments[0].isNull() || arguments[0].isUndefined()
|
154
|
+
? nullptr
|
155
|
+
: JsiSkPathEffect::fromValue(runtime, arguments[0]);
|
147
156
|
getObject()->setPathEffect(std::move(pathEffect));
|
148
157
|
return jsi::Value::undefined();
|
149
158
|
}
|
@@ -179,9 +188,7 @@ Returns the underlying object from a host object of this type
|
|
179
188
|
*/
|
180
189
|
static std::shared_ptr<SkPaint> fromValue(jsi::Runtime &runtime,
|
181
190
|
const jsi::Value &obj) {
|
182
|
-
return obj.asObject(runtime)
|
183
|
-
.asHostObject<JsiSkPaint>(runtime)
|
184
|
-
->getObject();
|
191
|
+
return obj.asObject(runtime).asHostObject<JsiSkPaint>(runtime)->getObject();
|
185
192
|
}
|
186
193
|
|
187
194
|
/**
|
package/cpp/api/JsiSkPath.h
CHANGED
@@ -19,16 +19,18 @@
|
|
19
19
|
#include <SkPath.h>
|
20
20
|
#include <SkPathOps.h>
|
21
21
|
#include <SkPathTypes.h>
|
22
|
+
#include <SkString.h>
|
22
23
|
#include <SkStrokeRec.h>
|
23
24
|
#include <SkTextUtils.h>
|
24
25
|
#include <SkTrimPathEffect.h>
|
25
26
|
|
27
|
+
#include "JsiSkMatrix.h"
|
28
|
+
|
26
29
|
#pragma clang diagnostic pop
|
27
30
|
|
28
31
|
namespace RNSkia {
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
namespace jsi = facebook::jsi;
|
32
34
|
|
33
35
|
class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPath> {
|
34
36
|
|
@@ -68,7 +70,7 @@ public:
|
|
68
70
|
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
69
71
|
points.push_back(*point.get());
|
70
72
|
}
|
71
|
-
getObject()->addPoly(points.data(), (
|
73
|
+
getObject()->addPoly(points.data(), static_cast<int>(points.size()), close);
|
72
74
|
return thisValue.getObject(runtime);
|
73
75
|
}
|
74
76
|
|
@@ -313,8 +315,8 @@ public:
|
|
313
315
|
JSI_HOST_FUNCTION(makeAsWinding) {
|
314
316
|
SkPath out;
|
315
317
|
if (AsWinding(*getObject(), &out)) {
|
316
|
-
|
317
|
-
|
318
|
+
getObject()->swap(out);
|
319
|
+
return thisValue.getObject(runtime);
|
318
320
|
}
|
319
321
|
return jsi::Value::null();
|
320
322
|
}
|
@@ -442,7 +444,7 @@ public:
|
|
442
444
|
}
|
443
445
|
|
444
446
|
JSI_HOST_FUNCTION(copy) {
|
445
|
-
const auto*
|
447
|
+
const auto *path = getObject().get();
|
446
448
|
return jsi::Object::createFromHostObject(
|
447
449
|
runtime, std::make_shared<JsiSkPath>(getContext(), SkPath(*path)));
|
448
450
|
}
|
@@ -472,16 +474,17 @@ public:
|
|
472
474
|
return nullptr;
|
473
475
|
}
|
474
476
|
return jsi::Object::createFromHostObject(
|
475
|
-
|
477
|
+
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(result)));
|
476
478
|
}
|
477
479
|
|
478
480
|
JSI_HOST_FUNCTION(toCmds) {
|
479
481
|
auto path = *getObject();
|
480
482
|
auto cmds = jsi::Array(runtime, path.countVerbs());
|
481
483
|
auto it = SkPath::Iter(path, false);
|
482
|
-
// { "Move", "Line", "Quad", "Conic", "Cubic",
|
483
|
-
|
484
|
-
const int
|
484
|
+
// { "Move", "Line", "Quad", "Conic", "Cubic",
|
485
|
+
// "Close", "Done" };
|
486
|
+
const int pointCount[] = {1, 1, 2, 2, 3, 0, 0};
|
487
|
+
const int cmdCount[] = {3, 3, 5, 6, 7, 1, 0};
|
485
488
|
SkPoint points[4];
|
486
489
|
SkPath::Verb verb;
|
487
490
|
auto k = 0;
|
@@ -491,11 +494,14 @@ public:
|
|
491
494
|
auto j = 0;
|
492
495
|
cmd.setValueAtIndex(runtime, j++, jsi::Value(verbVal));
|
493
496
|
for (int i = 0; i < pointCount[verbVal]; ++i) {
|
494
|
-
cmd.setValueAtIndex(runtime, j++,
|
495
|
-
|
497
|
+
cmd.setValueAtIndex(runtime, j++,
|
498
|
+
jsi::Value(static_cast<double>(points[1 + i].fX)));
|
499
|
+
cmd.setValueAtIndex(runtime, j++,
|
500
|
+
jsi::Value(static_cast<double>(points[1 + i].fY)));
|
496
501
|
}
|
497
502
|
if (SkPath::kConic_Verb == verb) {
|
498
|
-
cmd.setValueAtIndex(runtime, j,
|
503
|
+
cmd.setValueAtIndex(runtime, j,
|
504
|
+
jsi::Value(static_cast<double>(it.conicWeight())));
|
499
505
|
}
|
500
506
|
cmds.setValueAtIndex(runtime, k++, cmd);
|
501
507
|
}
|
@@ -505,88 +511,67 @@ public:
|
|
505
511
|
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPath, __typename__))
|
506
512
|
|
507
513
|
JSI_EXPORT_FUNCTIONS(
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
JSI_EXPORT_FUNC(JsiSkPath, reset),
|
543
|
-
JSI_EXPORT_FUNC(JsiSkPath, rewind),
|
544
|
-
JSI_EXPORT_FUNC(JsiSkPath, quadTo),
|
545
|
-
JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
|
546
|
-
JSI_EXPORT_FUNC(JsiSkPath, addCircle),
|
547
|
-
JSI_EXPORT_FUNC(JsiSkPath, getLastPt),
|
548
|
-
JSI_EXPORT_FUNC(JsiSkPath, close),
|
549
|
-
JSI_EXPORT_FUNC(JsiSkPath, simplify),
|
550
|
-
JSI_EXPORT_FUNC(JsiSkPath, countPoints),
|
551
|
-
JSI_EXPORT_FUNC(JsiSkPath, copy),
|
552
|
-
JSI_EXPORT_FUNC(JsiSkPath, op),
|
553
|
-
JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
|
554
|
-
JSI_EXPORT_FUNC(JsiSkPath, interpolate),
|
555
|
-
JSI_EXPORT_FUNC(JsiSkPath, toCmds),
|
556
|
-
)
|
514
|
+
JSI_EXPORT_FUNC(JsiSkPath, addArc), JSI_EXPORT_FUNC(JsiSkPath, addOval),
|
515
|
+
JSI_EXPORT_FUNC(JsiSkPath, addPoly), JSI_EXPORT_FUNC(JsiSkPath, addRect),
|
516
|
+
JSI_EXPORT_FUNC(JsiSkPath, addRRect),
|
517
|
+
JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
|
518
|
+
JSI_EXPORT_FUNC(JsiSkPath, arcToRotated),
|
519
|
+
JSI_EXPORT_FUNC(JsiSkPath, rArcTo),
|
520
|
+
JSI_EXPORT_FUNC(JsiSkPath, arcToTangent),
|
521
|
+
JSI_EXPORT_FUNC(JsiSkPath, computeTightBounds),
|
522
|
+
JSI_EXPORT_FUNC(JsiSkPath, getBounds),
|
523
|
+
JSI_EXPORT_FUNC(JsiSkPath, conicTo), JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
|
524
|
+
JSI_EXPORT_FUNC(JsiSkPath, contains), JSI_EXPORT_FUNC(JsiSkPath, dash),
|
525
|
+
JSI_EXPORT_FUNC(JsiSkPath, equals),
|
526
|
+
JSI_EXPORT_FUNC(JsiSkPath, getFillType),
|
527
|
+
JSI_EXPORT_FUNC(JsiSkPath, setFillType),
|
528
|
+
JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
|
529
|
+
JSI_EXPORT_FUNC(JsiSkPath, isVolatile),
|
530
|
+
JSI_EXPORT_FUNC(JsiSkPath, transform), JSI_EXPORT_FUNC(JsiSkPath, stroke),
|
531
|
+
JSI_EXPORT_FUNC(JsiSkPath, trim), JSI_EXPORT_FUNC(JsiSkPath, getPoint),
|
532
|
+
JSI_EXPORT_FUNC(JsiSkPath, toSVGString),
|
533
|
+
JSI_EXPORT_FUNC(JsiSkPath, makeAsWinding),
|
534
|
+
JSI_EXPORT_FUNC(JsiSkPath, isEmpty), JSI_EXPORT_FUNC(JsiSkPath, offset),
|
535
|
+
JSI_EXPORT_FUNC(JsiSkPath, moveTo), JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
|
536
|
+
JSI_EXPORT_FUNC(JsiSkPath, lineTo), JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
|
537
|
+
JSI_EXPORT_FUNC(JsiSkPath, cubicTo), JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
|
538
|
+
JSI_EXPORT_FUNC(JsiSkPath, reset), JSI_EXPORT_FUNC(JsiSkPath, rewind),
|
539
|
+
JSI_EXPORT_FUNC(JsiSkPath, quadTo), JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
|
540
|
+
JSI_EXPORT_FUNC(JsiSkPath, addCircle),
|
541
|
+
JSI_EXPORT_FUNC(JsiSkPath, getLastPt), JSI_EXPORT_FUNC(JsiSkPath, close),
|
542
|
+
JSI_EXPORT_FUNC(JsiSkPath, simplify),
|
543
|
+
JSI_EXPORT_FUNC(JsiSkPath, countPoints), JSI_EXPORT_FUNC(JsiSkPath, copy),
|
544
|
+
JSI_EXPORT_FUNC(JsiSkPath, op),
|
545
|
+
JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
|
546
|
+
JSI_EXPORT_FUNC(JsiSkPath, interpolate),
|
547
|
+
JSI_EXPORT_FUNC(JsiSkPath, toCmds), )
|
557
548
|
|
558
549
|
JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, SkPath path)
|
559
550
|
: JsiSkWrappingSharedPtrHostObject<SkPath>(
|
560
|
-
std::move(context), std::make_shared<SkPath>(std::move(path))) {
|
561
|
-
}
|
551
|
+
std::move(context), std::make_shared<SkPath>(std::move(path))) {}
|
562
552
|
|
563
553
|
/**
|
564
554
|
Returns the underlying object from a host object of this type
|
565
555
|
*/
|
566
556
|
static std::shared_ptr<SkPath> fromValue(jsi::Runtime &runtime,
|
567
557
|
const jsi::Value &obj) {
|
568
|
-
return obj.asObject(runtime)
|
569
|
-
|
570
|
-
->getObject();
|
571
|
-
}
|
572
|
-
|
573
|
-
static jsi::Value toValue(jsi::Runtime &runtime,
|
574
|
-
std::shared_ptr<RNSkPlatformContext> context,
|
575
|
-
const SkPath &path) {
|
576
|
-
return jsi::Object::createFromHostObject(
|
577
|
-
runtime,
|
578
|
-
std::make_shared<JsiSkPath>(std::move(context), path)
|
579
|
-
);
|
580
|
-
}
|
558
|
+
return obj.asObject(runtime).asHostObject<JsiSkPath>(runtime)->getObject();
|
559
|
+
}
|
581
560
|
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
561
|
+
static jsi::Value toValue(jsi::Runtime &runtime,
|
562
|
+
std::shared_ptr<RNSkPlatformContext> context,
|
563
|
+
const SkPath &path) {
|
564
|
+
return jsi::Object::createFromHostObject(
|
565
|
+
runtime, std::make_shared<JsiSkPath>(std::move(context), path));
|
566
|
+
}
|
567
|
+
|
568
|
+
static jsi::Value toValue(jsi::Runtime &runtime,
|
569
|
+
std::shared_ptr<RNSkPlatformContext> context,
|
570
|
+
SkPath &&path) {
|
571
|
+
return jsi::Object::createFromHostObject(
|
572
|
+
runtime,
|
573
|
+
std::make_shared<JsiSkPath>(std::move(context), std::move(path)));
|
574
|
+
}
|
590
575
|
};
|
591
576
|
|
592
577
|
} // namespace RNSkia
|
@@ -16,20 +16,22 @@
|
|
16
16
|
|
17
17
|
namespace RNSkia {
|
18
18
|
|
19
|
-
|
19
|
+
namespace jsi = facebook::jsi;
|
20
20
|
|
21
21
|
class JsiSkPathEffect : public JsiSkWrappingSkPtrHostObject<SkPathEffect> {
|
22
22
|
public:
|
23
23
|
JsiSkPathEffect(std::shared_ptr<RNSkPlatformContext> context,
|
24
24
|
sk_sp<SkPathEffect> pathEffect)
|
25
|
-
: JsiSkWrappingSkPtrHostObject<SkPathEffect>(std::move(context),
|
25
|
+
: JsiSkWrappingSkPtrHostObject<SkPathEffect>(std::move(context),
|
26
|
+
std::move(pathEffect)) {}
|
26
27
|
|
27
28
|
// TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
|
28
29
|
JSI_PROPERTY_GET(__typename__) {
|
29
30
|
return jsi::String::createFromUtf8(runtime, "PathEffect");
|
30
31
|
}
|
31
32
|
|
32
|
-
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPathEffect,
|
33
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPathEffect,
|
34
|
+
__typename__))
|
33
35
|
|
34
36
|
/**
|
35
37
|
Returns the underlying object from a host object of this type
|