@shopify/react-native-skia 0.1.154 → 0.1.156
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/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
package/cpp/api/JsiSkColor.h
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <algorithm>
|
|
3
4
|
#include <memory>
|
|
4
5
|
#include <utility>
|
|
5
6
|
|
|
@@ -17,67 +18,68 @@
|
|
|
17
18
|
|
|
18
19
|
namespace RNSkia {
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
namespace jsi = facebook::jsi;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
class JsiSkColor : public RNJsi::JsiHostObject {
|
|
24
|
+
public:
|
|
25
|
+
JsiSkColor() : JsiHostObject() {}
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
~JsiSkColor() {}
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
static jsi::Object toValue(jsi::Runtime &runtime, SkColor color) {
|
|
30
|
+
auto result = runtime.global()
|
|
31
|
+
.getPropertyAsFunction(runtime, "Float32Array")
|
|
32
|
+
.callAsConstructor(runtime, 4)
|
|
33
|
+
.getObject(runtime);
|
|
34
|
+
jsi::ArrayBuffer buffer =
|
|
35
|
+
result
|
|
36
|
+
.getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
|
|
37
|
+
.asObject(runtime)
|
|
38
|
+
.getArrayBuffer(runtime);
|
|
39
|
+
auto bfrPtr = reinterpret_cast<float *>(buffer.data(runtime));
|
|
40
|
+
auto color4f = SkColor4f::FromColor(color).array();
|
|
41
|
+
std::copy(color4f.begin(), color4f.end(), bfrPtr);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
28
44
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static SkColor fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
46
|
-
const auto& object = obj.asObject(runtime);
|
|
47
|
-
jsi::ArrayBuffer buffer = object
|
|
48
|
-
.getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
|
|
49
|
-
.asObject(runtime)
|
|
50
|
-
.getArrayBuffer(runtime);
|
|
51
|
-
auto bfrPtr = reinterpret_cast<float *>(buffer.data(runtime));
|
|
52
|
-
if (bfrPtr[0] > 1 || bfrPtr[1] > 1 || bfrPtr[2] > 1 || bfrPtr[3] > 1) {
|
|
53
|
-
return SK_ColorBLACK;
|
|
54
|
-
}
|
|
55
|
-
return SkColorSetARGB(bfrPtr[3] * 255, bfrPtr[0] * 255, bfrPtr[1] * 255, bfrPtr[2] * 255);
|
|
56
|
-
}
|
|
45
|
+
static SkColor fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
46
|
+
const auto &object = obj.asObject(runtime);
|
|
47
|
+
jsi::ArrayBuffer buffer =
|
|
48
|
+
object
|
|
49
|
+
.getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
|
|
50
|
+
.asObject(runtime)
|
|
51
|
+
.getArrayBuffer(runtime);
|
|
52
|
+
auto bfrPtr = reinterpret_cast<float *>(buffer.data(runtime));
|
|
53
|
+
if (bfrPtr[0] > 1 || bfrPtr[1] > 1 || bfrPtr[2] > 1 || bfrPtr[3] > 1) {
|
|
54
|
+
return SK_ColorBLACK;
|
|
55
|
+
}
|
|
56
|
+
return SkColorSetARGB(bfrPtr[3] * 255, bfrPtr[0] * 255, bfrPtr[1] * 255,
|
|
57
|
+
bfrPtr[2] * 255);
|
|
58
|
+
}
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return JsiSkColor::toValue(runtime, SK_ColorBLACK);
|
|
74
|
-
}
|
|
75
|
-
return JsiSkColor::toValue(runtime, SkColorSetARGB(color.a * 255, color.r, color.g, color.b));
|
|
76
|
-
} else if (arguments[0].isObject()) {
|
|
77
|
-
return arguments[0].getObject(runtime);
|
|
78
|
-
}
|
|
79
|
-
return jsi::Value::undefined();
|
|
80
|
-
};
|
|
60
|
+
/**
|
|
61
|
+
* Creates the function for construction a new instance of the SkColor
|
|
62
|
+
* wrapper
|
|
63
|
+
* @return A function for creating a new host object wrapper for the SkColor
|
|
64
|
+
* class
|
|
65
|
+
*/
|
|
66
|
+
static const jsi::HostFunctionType createCtor() {
|
|
67
|
+
return JSI_HOST_FUNCTION_LAMBDA {
|
|
68
|
+
if (arguments[0].isNumber()) {
|
|
69
|
+
return JsiSkColor::toValue(runtime, arguments[0].getNumber());
|
|
70
|
+
} else if (arguments[0].isString()) {
|
|
71
|
+
auto text = arguments[0].asString(runtime).utf8(runtime);
|
|
72
|
+
auto color = CSSColorParser::parse(text);
|
|
73
|
+
if (color.a == -1.0f) {
|
|
74
|
+
return JsiSkColor::toValue(runtime, SK_ColorBLACK);
|
|
81
75
|
}
|
|
76
|
+
return JsiSkColor::toValue(
|
|
77
|
+
runtime, SkColorSetARGB(color.a * 255, color.r, color.g, color.b));
|
|
78
|
+
} else if (arguments[0].isObject()) {
|
|
79
|
+
return arguments[0].getObject(runtime);
|
|
80
|
+
}
|
|
81
|
+
return jsi::Value::undefined();
|
|
82
82
|
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
83
85
|
} // namespace RNSkia
|
|
@@ -14,20 +14,22 @@
|
|
|
14
14
|
|
|
15
15
|
namespace RNSkia {
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
namespace jsi = facebook::jsi;
|
|
18
18
|
|
|
19
19
|
class JsiSkColorFilter : public JsiSkWrappingSkPtrHostObject<SkColorFilter> {
|
|
20
20
|
public:
|
|
21
21
|
JsiSkColorFilter(std::shared_ptr<RNSkPlatformContext> context,
|
|
22
22
|
sk_sp<SkColorFilter> colorFilter)
|
|
23
|
-
: JsiSkWrappingSkPtrHostObject<SkColorFilter>(std::move(context),
|
|
23
|
+
: JsiSkWrappingSkPtrHostObject<SkColorFilter>(std::move(context),
|
|
24
|
+
std::move(colorFilter)) {}
|
|
24
25
|
|
|
25
26
|
// TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
|
|
26
27
|
JSI_PROPERTY_GET(__typename__) {
|
|
27
28
|
return jsi::String::createFromUtf8(runtime, "ColorFilter");
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkColorFilter,
|
|
31
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkColorFilter,
|
|
32
|
+
__typename__))
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
Returns the underlying object from a host object of this type
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include "JsiSkColor.h"
|
|
3
4
|
#include "JsiSkColorFilter.h"
|
|
4
5
|
#include "JsiSkHostObjects.h"
|
|
5
|
-
#include "JsiSkColor.h"
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
|
+
#include <memory>
|
|
7
8
|
#include <utility>
|
|
8
9
|
|
|
9
10
|
#pragma clang diagnostic push
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
|
|
17
18
|
namespace RNSkia {
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
namespace jsi = facebook::jsi;
|
|
20
21
|
|
|
21
22
|
class JsiSkColorFilterFactory : public JsiSkHostObject {
|
|
22
23
|
public:
|
|
@@ -49,7 +50,8 @@ public:
|
|
|
49
50
|
// Return the newly constructed object
|
|
50
51
|
return jsi::Object::createFromHostObject(
|
|
51
52
|
runtime, std::make_shared<JsiSkColorFilter>(
|
|
52
|
-
getContext(), SkColorFilters::Compose(std::move(outer),
|
|
53
|
+
getContext(), SkColorFilters::Compose(std::move(outer),
|
|
54
|
+
std::move(inner))));
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
JSI_HOST_FUNCTION(MakeLerp) {
|
|
@@ -59,15 +61,16 @@ public:
|
|
|
59
61
|
// Return the newly constructed object
|
|
60
62
|
return jsi::Object::createFromHostObject(
|
|
61
63
|
runtime, std::make_shared<JsiSkColorFilter>(
|
|
62
|
-
getContext(),
|
|
64
|
+
getContext(),
|
|
65
|
+
SkColorFilters::Lerp(t, std::move(dst), std::move(src))));
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
JSI_HOST_FUNCTION(MakeSRGBToLinearGamma) {
|
|
69
|
+
// Return the newly constructed object
|
|
70
|
+
return jsi::Object::createFromHostObject(
|
|
71
|
+
runtime, std::make_shared<JsiSkColorFilter>(
|
|
72
|
+
getContext(), SkColorFilters::SRGBToLinearGamma()));
|
|
73
|
+
}
|
|
71
74
|
|
|
72
75
|
JSI_HOST_FUNCTION(MakeLinearToSRGBGamma) {
|
|
73
76
|
// Return the newly constructed object
|
|
@@ -79,21 +82,20 @@ public:
|
|
|
79
82
|
JSI_HOST_FUNCTION(MakeLumaColorFilter) {
|
|
80
83
|
// Return the newly constructed object
|
|
81
84
|
return jsi::Object::createFromHostObject(
|
|
82
|
-
runtime, std::make_shared<JsiSkColorFilter>(
|
|
83
|
-
|
|
85
|
+
runtime, std::make_shared<JsiSkColorFilter>(getContext(),
|
|
86
|
+
SkLumaColorFilter::Make()));
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
JSI_EXPORT_FUNCTIONS(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
)
|
|
90
|
+
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeMatrix),
|
|
91
|
+
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeBlend),
|
|
92
|
+
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeCompose),
|
|
93
|
+
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLerp),
|
|
94
|
+
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeSRGBToLinearGamma),
|
|
95
|
+
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLinearToSRGBGamma),
|
|
96
|
+
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLumaColorFilter))
|
|
95
97
|
|
|
96
|
-
JsiSkColorFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
98
|
+
explicit JsiSkColorFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
97
99
|
: JsiSkHostObject(std::move(context)) {}
|
|
98
100
|
};
|
|
99
101
|
} // namespace RNSkia
|
|
@@ -12,91 +12,80 @@
|
|
|
12
12
|
|
|
13
13
|
#include <SkContourMeasure.h>
|
|
14
14
|
|
|
15
|
-
#
|
|
15
|
+
#include "JsiSkPath.h"
|
|
16
16
|
|
|
17
|
+
#pragma clang diagnostic pop
|
|
17
18
|
|
|
18
|
-
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
|
-
|
|
91
|
-
/**
|
|
92
|
-
Returns the underlying object from a host object of this type
|
|
93
|
-
*/
|
|
94
|
-
static sk_sp<SkContourMeasure> fromValue(jsi::Runtime &runtime,
|
|
95
|
-
const jsi::Value &obj)
|
|
96
|
-
{
|
|
97
|
-
return obj.asObject(runtime)
|
|
98
|
-
.asHostObject<JsiSkContourMeasure>(runtime)
|
|
99
|
-
->getObject();
|
|
100
|
-
}
|
|
101
|
-
};
|
|
19
|
+
namespace RNSkia {
|
|
20
|
+
|
|
21
|
+
namespace jsi = facebook::jsi;
|
|
22
|
+
|
|
23
|
+
class JsiSkContourMeasure
|
|
24
|
+
: public JsiSkWrappingSkPtrHostObject<SkContourMeasure> {
|
|
25
|
+
public:
|
|
26
|
+
JsiSkContourMeasure(std::shared_ptr<RNSkPlatformContext> context,
|
|
27
|
+
const sk_sp<SkContourMeasure> contourMeasure)
|
|
28
|
+
: JsiSkWrappingSkPtrHostObject(std::move(context),
|
|
29
|
+
std::move(contourMeasure)) {
|
|
30
|
+
if (contourMeasure == nullptr) {
|
|
31
|
+
throw jsi::JSError(*context->getJsRuntime(), "Contour measure is null");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
JSI_HOST_FUNCTION(getPosTan) {
|
|
36
|
+
auto dist = arguments[0].asNumber();
|
|
37
|
+
SkPoint position;
|
|
38
|
+
SkPoint tangent;
|
|
39
|
+
auto result = getObject()->getPosTan(dist, &position, &tangent);
|
|
40
|
+
if (!result) {
|
|
41
|
+
throw jsi::JSError(runtime, "getSegment() failed");
|
|
42
|
+
}
|
|
43
|
+
auto posTan = jsi::Object(runtime);
|
|
44
|
+
posTan.setProperty(runtime, "px", position.x());
|
|
45
|
+
posTan.setProperty(runtime, "py", position.y());
|
|
46
|
+
posTan.setProperty(runtime, "tx", tangent.x());
|
|
47
|
+
posTan.setProperty(runtime, "ty", tangent.y());
|
|
48
|
+
return posTan;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
JSI_HOST_FUNCTION(length) {
|
|
52
|
+
return jsi::Value(SkScalarToDouble(getObject()->length()));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
JSI_HOST_FUNCTION(isClosed) { return jsi::Value(getObject()->isClosed()); }
|
|
56
|
+
|
|
57
|
+
JSI_HOST_FUNCTION(getSegment) {
|
|
58
|
+
auto start = arguments[0].asNumber();
|
|
59
|
+
auto end = arguments[1].asNumber();
|
|
60
|
+
auto startWithMoveTo = arguments[2].getBool();
|
|
61
|
+
SkPath path;
|
|
62
|
+
auto result = getObject()->getSegment(start, end, &path, startWithMoveTo);
|
|
63
|
+
if (!result) {
|
|
64
|
+
throw jsi::JSError(runtime, "getSegment() failed");
|
|
65
|
+
}
|
|
66
|
+
return JsiSkPath::toValue(runtime, getContext(), std::move(path));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
JSI_PROPERTY_GET(__typename__) {
|
|
70
|
+
return jsi::String::createFromUtf8(runtime, "ContourMeasure");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkContourMeasure,
|
|
74
|
+
__typename__))
|
|
75
|
+
|
|
76
|
+
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkContourMeasure, getPosTan),
|
|
77
|
+
JSI_EXPORT_FUNC(JsiSkContourMeasure, length),
|
|
78
|
+
JSI_EXPORT_FUNC(JsiSkContourMeasure, isClosed),
|
|
79
|
+
JSI_EXPORT_FUNC(JsiSkContourMeasure, getSegment))
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
Returns the underlying object from a host object of this type
|
|
83
|
+
*/
|
|
84
|
+
static sk_sp<SkContourMeasure> fromValue(jsi::Runtime &runtime,
|
|
85
|
+
const jsi::Value &obj) {
|
|
86
|
+
return obj.asObject(runtime)
|
|
87
|
+
.asHostObject<JsiSkContourMeasure>(runtime)
|
|
88
|
+
->getObject();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
102
91
|
} // namespace RNSkia
|
|
@@ -3,88 +3,81 @@
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
#include <utility>
|
|
5
5
|
|
|
6
|
-
#include "JsiSkHostObjects.h"
|
|
7
6
|
#include "JsiSkContourMeasure.h"
|
|
7
|
+
#include "JsiSkHostObjects.h"
|
|
8
8
|
|
|
9
9
|
#pragma clang diagnostic push
|
|
10
10
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
11
11
|
|
|
12
12
|
#include <SkContourMeasure.h>
|
|
13
13
|
|
|
14
|
+
#include "JsiSkPath.h"
|
|
15
|
+
|
|
14
16
|
#pragma clang diagnostic pop
|
|
15
17
|
|
|
16
|
-
namespace RNSkia
|
|
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
|
-
|
|
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
|
-
return jsi::Object::createFromHostObject(
|
|
82
|
-
runtime, std::make_shared<JsiSkContourMeasureIter>(
|
|
83
|
-
std::move(context),
|
|
84
|
-
*path,
|
|
85
|
-
forceClosed,
|
|
86
|
-
resScale));
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
};
|
|
18
|
+
namespace RNSkia {
|
|
19
|
+
|
|
20
|
+
namespace jsi = facebook::jsi;
|
|
21
|
+
|
|
22
|
+
class JsiSkContourMeasureIter
|
|
23
|
+
: public JsiSkWrappingSharedPtrHostObject<SkContourMeasureIter> {
|
|
24
|
+
public:
|
|
25
|
+
JsiSkContourMeasureIter(std::shared_ptr<RNSkPlatformContext> context,
|
|
26
|
+
const SkPath &path, bool forceClosed,
|
|
27
|
+
SkScalar resScale = 1)
|
|
28
|
+
: JsiSkWrappingSharedPtrHostObject<SkContourMeasureIter>(
|
|
29
|
+
std::move(context), std::make_shared<SkContourMeasureIter>(
|
|
30
|
+
path, forceClosed, resScale)) {}
|
|
31
|
+
|
|
32
|
+
// TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
|
|
33
|
+
JSI_PROPERTY_GET(__typename__) {
|
|
34
|
+
return jsi::String::createFromUtf8(runtime, "ContourMeasureIter");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkContourMeasureIter,
|
|
38
|
+
__typename__), )
|
|
39
|
+
|
|
40
|
+
JSI_HOST_FUNCTION(next) {
|
|
41
|
+
auto next = getObject()->next();
|
|
42
|
+
if (next == nullptr) {
|
|
43
|
+
return jsi::Value::undefined();
|
|
44
|
+
}
|
|
45
|
+
auto nextObject =
|
|
46
|
+
std::make_shared<JsiSkContourMeasure>(getContext(), std::move(next));
|
|
47
|
+
|
|
48
|
+
return jsi::Object::createFromHostObject(runtime, std::move(nextObject));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkContourMeasureIter, next))
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
Returns the underlying object from a host object of this type
|
|
55
|
+
*/
|
|
56
|
+
static std::shared_ptr<SkContourMeasureIter>
|
|
57
|
+
fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
58
|
+
return obj.asObject(runtime)
|
|
59
|
+
.asHostObject<JsiSkContourMeasureIter>(runtime)
|
|
60
|
+
->getObject();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Creates the function for construction a new instance of the
|
|
65
|
+
* SkContourMeasureIter wrapper
|
|
66
|
+
* @param context platform context
|
|
67
|
+
* @return A function for creating a new host object wrapper for the
|
|
68
|
+
* SkContourMeasureIter class
|
|
69
|
+
*/
|
|
70
|
+
static const jsi::HostFunctionType
|
|
71
|
+
createCtor(std::shared_ptr<RNSkPlatformContext> context) {
|
|
72
|
+
return JSI_HOST_FUNCTION_LAMBDA {
|
|
73
|
+
auto path = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
74
|
+
auto forceClosed = arguments[1].getBool();
|
|
75
|
+
auto resScale = arguments[2].asNumber();
|
|
76
|
+
// Return the newly constructed object
|
|
77
|
+
return jsi::Object::createFromHostObject(
|
|
78
|
+
runtime, std::make_shared<JsiSkContourMeasureIter>(
|
|
79
|
+
std::move(context), *path, forceClosed, resScale));
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
90
83
|
} // namespace RNSkia
|
package/cpp/api/JsiSkData.h
CHANGED
|
@@ -15,32 +15,26 @@
|
|
|
15
15
|
|
|
16
16
|
#pragma clang diagnostic pop
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
namespace RNSkia {
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class JsiSkData : public JsiSkWrappingSkPtrHostObject<SkData> {
|
|
24
|
-
public:
|
|
25
|
-
JsiSkData(std::shared_ptr<RNSkPlatformContext> context,
|
|
26
|
-
sk_sp<SkData> asset)
|
|
27
|
-
: JsiSkWrappingSkPtrHostObject(std::move(context), std::move(asset)){}
|
|
20
|
+
namespace jsi = facebook::jsi;
|
|
28
21
|
|
|
22
|
+
class JsiSkData : public JsiSkWrappingSkPtrHostObject<SkData> {
|
|
23
|
+
public:
|
|
24
|
+
JsiSkData(std::shared_ptr<RNSkPlatformContext> context, sk_sp<SkData> asset)
|
|
25
|
+
: JsiSkWrappingSkPtrHostObject(std::move(context), std::move(asset)) {}
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
JSI_PROPERTY_GET(__typename__) {
|
|
28
|
+
return jsi::String::createFromUtf8(runtime, "Data");
|
|
29
|
+
}
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkData, __typename__))
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
->getObject();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
33
|
+
/**
|
|
34
|
+
Returns the underlying object from a host object of this type
|
|
35
|
+
*/
|
|
36
|
+
static sk_sp<SkData> fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
37
|
+
return obj.asObject(runtime).asHostObject<JsiSkData>(runtime)->getObject();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
46
40
|
} // namespace RNSkia
|