@shopify/react-native-skia 2.9.1 → 2.10.0
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/CMakeLists.txt +1 -5
- package/cpp/api/JsiNativeBuffer.h +15 -10
- package/cpp/api/JsiSkAnimatedImage.h +21 -19
- package/cpp/api/JsiSkAnimatedImageFactory.h +13 -14
- package/cpp/api/JsiSkApi.h +246 -92
- package/cpp/api/JsiSkCanvas.h +76 -58
- package/cpp/api/JsiSkColor.h +7 -5
- package/cpp/api/JsiSkColorFilter.h +15 -8
- package/cpp/api/JsiSkColorFilterFactory.h +45 -45
- package/cpp/api/JsiSkContourMeasure.h +24 -21
- package/cpp/api/JsiSkContourMeasureIter.h +18 -21
- package/cpp/api/JsiSkData.h +13 -7
- package/cpp/api/JsiSkDataFactory.h +22 -21
- package/cpp/api/JsiSkFont.h +56 -44
- package/cpp/api/JsiSkFontMgr.h +22 -13
- package/cpp/api/JsiSkFontMgrFactory.h +12 -10
- package/cpp/api/JsiSkFontStyle.h +14 -12
- package/cpp/api/JsiSkImage.h +45 -34
- package/cpp/api/JsiSkImageFactory.h +47 -52
- package/cpp/api/JsiSkImageFilter.h +21 -11
- package/cpp/api/JsiSkImageFilterFactory.h +96 -96
- package/cpp/api/JsiSkImageInfo.h +22 -19
- package/cpp/api/JsiSkMaskFilter.h +21 -11
- package/cpp/api/JsiSkMaskFilterFactory.h +16 -13
- package/cpp/api/JsiSkMatrix.h +31 -31
- package/cpp/api/JsiSkNativeObjects.h +419 -0
- package/cpp/api/JsiSkPaint.h +59 -39
- package/cpp/api/JsiSkParagraph.h +39 -32
- package/cpp/api/JsiSkParagraphBuilder.h +24 -21
- package/cpp/api/JsiSkParagraphBuilderFactory.h +13 -12
- package/cpp/api/JsiSkPath.h +95 -70
- package/cpp/api/JsiSkPathBuilder.h +83 -67
- package/cpp/api/JsiSkPathBuilderFactory.h +16 -17
- package/cpp/api/JsiSkPathEffect.h +21 -11
- package/cpp/api/JsiSkPathEffectFactory.h +33 -32
- package/cpp/api/JsiSkPathFactory.h +79 -103
- package/cpp/api/JsiSkPicture.h +24 -13
- package/cpp/api/JsiSkPictureFactory.h +21 -26
- package/cpp/api/JsiSkPictureRecorder.h +21 -22
- package/cpp/api/JsiSkPoint.h +19 -22
- package/cpp/api/JsiSkRRect.h +22 -29
- package/cpp/api/JsiSkRSXform.h +26 -30
- package/cpp/api/JsiSkRect.h +28 -30
- package/cpp/api/JsiSkRuntimeEffect.h +39 -30
- package/cpp/api/JsiSkRuntimeEffectFactory.h +12 -12
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +25 -18
- package/cpp/api/JsiSkSVG.h +13 -13
- package/cpp/api/JsiSkSVGFactory.h +17 -20
- package/cpp/api/JsiSkShader.h +15 -8
- package/cpp/api/JsiSkShaderFactory.h +41 -48
- package/cpp/api/JsiSkSkottie.h +49 -39
- package/cpp/api/JsiSkSurface.h +24 -24
- package/cpp/api/JsiSkSurfaceFactory.h +15 -16
- package/cpp/api/JsiSkTextBlob.h +15 -8
- package/cpp/api/JsiSkTextBlobFactory.h +25 -28
- package/cpp/api/JsiSkTypeface.h +19 -12
- package/cpp/api/JsiSkTypefaceFactory.h +12 -12
- package/cpp/api/JsiSkTypefaceFontProvider.h +30 -25
- package/cpp/api/JsiSkTypefaceFontProviderFactory.h +14 -12
- package/cpp/api/JsiSkVertices.h +21 -18
- package/cpp/api/JsiSkiaContext.h +17 -17
- package/cpp/api/JsiSkottieFactory.h +16 -17
- package/cpp/api/JsiVideo.h +27 -25
- package/cpp/api/recorder/Convertor.h +31 -61
- package/cpp/api/recorder/DataTypes.h +8 -16
- package/cpp/api/recorder/JsiRecorder.h +83 -55
- package/cpp/api/recorder/RNRecorder.h +1 -1
- package/cpp/jsi/BoxedNativeObject.h +146 -0
- package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
- package/cpp/{jsi2 → jsi}/NativeObject.h +120 -146
- package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
- package/cpp/jsi/RuntimeAwareCache.h +26 -8
- package/cpp/jsi/ViewProperty.h +5 -11
- package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
- package/cpp/rnskia/RNSkManager.cpp +23 -25
- package/cpp/rnskia/RNSkPictureView.h +1 -1
- package/cpp/rnwgpu/ArrayBuffer.h +5 -6
- package/cpp/rnwgpu/Canvas.h +4 -2
- package/cpp/rnwgpu/api/GPU.cpp +4 -4
- package/cpp/rnwgpu/api/GPU.h +1 -1
- package/cpp/rnwgpu/api/GPUAdapter.cpp +2 -3
- package/cpp/rnwgpu/api/GPUAdapter.h +4 -4
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +1 -1
- package/cpp/rnwgpu/api/GPUBindGroup.h +1 -1
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +1 -1
- package/cpp/rnwgpu/api/GPUBuffer.h +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.h +1 -1
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +1 -1
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +1 -1
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +1 -1
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPUComputePipeline.h +1 -1
- package/cpp/rnwgpu/api/GPUDevice.cpp +6 -7
- package/cpp/rnwgpu/api/GPUDevice.h +3 -3
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +1 -1
- package/cpp/rnwgpu/api/GPUError.h +1 -1
- package/cpp/rnwgpu/api/GPUExtent3D.h +1 -1
- package/cpp/rnwgpu/api/GPUExternalTexture.h +1 -1
- package/cpp/rnwgpu/api/GPUInternalError.h +1 -1
- package/cpp/rnwgpu/api/GPUOrigin2D.h +1 -1
- package/cpp/rnwgpu/api/GPUOrigin3D.h +1 -1
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +1 -1
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +1 -1
- package/cpp/rnwgpu/api/GPUQuerySet.h +1 -1
- package/cpp/rnwgpu/api/GPUQueue.h +1 -1
- package/cpp/rnwgpu/api/GPURenderBundle.h +1 -1
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPURenderPipeline.h +1 -1
- package/cpp/rnwgpu/api/GPUSampler.h +1 -1
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
- package/cpp/rnwgpu/api/GPUShaderModule.h +1 -1
- package/cpp/rnwgpu/api/GPUSharedFence.h +1 -1
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +1 -1
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +1 -1
- package/cpp/rnwgpu/api/GPUTexture.h +1 -1
- package/cpp/rnwgpu/api/GPUTextureView.h +1 -1
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +1 -1
- package/cpp/rnwgpu/api/GPUValidationError.h +1 -1
- package/cpp/rnwgpu/api/ImageBitmap.h +1 -1
- package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/Unions.h +1 -1
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +20 -21
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/skia/NativeSetup.js +4 -0
- package/lib/commonjs/skia/NativeSetup.js.map +1 -1
- package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
- package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
- package/lib/commonjs/sksg/Container.native.js +20 -1
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/module/external/reanimated/renderHelpers.js +29 -0
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/skia/NativeSetup.js +4 -0
- package/lib/module/skia/NativeSetup.js.map +1 -1
- package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
- package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
- package/lib/module/sksg/Container.native.js +21 -2
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/package.json +6 -2
- package/react-native-skia.podspec +1 -2
- package/src/external/reanimated/renderHelpers.ts +30 -0
- package/src/skia/NativeSetup.ts +5 -0
- package/src/skia/SkiaWorkletSerialization.ts +67 -0
- package/src/sksg/Container.native.ts +40 -2
- package/cpp/api/JsiSkHostObjects.h +0 -257
- package/cpp/jsi/JsiHostObject.cpp +0 -137
- package/cpp/jsi/JsiHostObject.h +0 -385
- /package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -0
- /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
- /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
package/cpp/api/JsiSkPoint.h
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
9
9
|
|
|
10
10
|
#pragma clang diagnostic push
|
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -18,22 +18,23 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkPoint
|
|
21
|
+
class JsiSkPoint
|
|
22
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkPoint, SkPoint> {
|
|
22
23
|
public:
|
|
24
|
+
static constexpr const char *CLASS_NAME = "Point";
|
|
25
|
+
|
|
23
26
|
JSI_PROPERTY_GET(x) { return static_cast<double>(getObject()->x()); }
|
|
24
27
|
|
|
25
28
|
JSI_PROPERTY_GET(y) { return static_cast<double>(getObject()->y()); }
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPoint, dispose))
|
|
30
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
31
|
+
installCommon(runtime, prototype);
|
|
32
|
+
installHostGetter(runtime, prototype, "x", &JsiSkPoint::get_x);
|
|
33
|
+
installHostGetter(runtime, prototype, "y", &JsiSkPoint::get_y);
|
|
34
|
+
}
|
|
34
35
|
|
|
35
36
|
JsiSkPoint(std::shared_ptr<RNSkPlatformContext> context, const SkPoint &point)
|
|
36
|
-
:
|
|
37
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkPoint, SkPoint>(
|
|
37
38
|
std::move(context), std::make_shared<SkPoint>(point)) {}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -42,8 +43,9 @@ public:
|
|
|
42
43
|
static std::shared_ptr<SkPoint> fromValue(jsi::Runtime &runtime,
|
|
43
44
|
const jsi::Value &obj) {
|
|
44
45
|
const auto &object = obj.asObject(runtime);
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
auto point = tryGetJsiObject<JsiSkPoint>(runtime, object);
|
|
47
|
+
if (point) {
|
|
48
|
+
return point->getObject();
|
|
47
49
|
} else {
|
|
48
50
|
auto x = object.getProperty(runtime, "x").asNumber();
|
|
49
51
|
auto y = object.getProperty(runtime, "y").asNumber();
|
|
@@ -57,17 +59,14 @@ public:
|
|
|
57
59
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
58
60
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
59
61
|
const SkPoint &point) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
context);
|
|
62
|
+
return makeJsiObject(
|
|
63
|
+
runtime, std::make_shared<JsiSkPoint>(std::move(context), point));
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
size_t getMemoryPressure()
|
|
66
|
+
size_t getMemoryPressure() override {
|
|
66
67
|
return std::max(sizeof(SkPoint), kMinMemoryPressure);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
std::string getObjectType() const override { return "JsiSkPoint"; }
|
|
70
|
-
|
|
71
70
|
/**
|
|
72
71
|
* Creates the function for construction a new instance of the SkPoint
|
|
73
72
|
* wrapper
|
|
@@ -82,10 +81,8 @@ public:
|
|
|
82
81
|
SkPoint::Make(arguments[0].asNumber(), arguments[1].asNumber());
|
|
83
82
|
|
|
84
83
|
// Return the newly constructed object
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, pointObj,
|
|
88
|
-
context);
|
|
84
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkPoint>(
|
|
85
|
+
std::move(context), std::move(point)));
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
88
|
};
|
package/cpp/api/JsiSkRRect.h
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#include <jsi/jsi.h>
|
|
8
8
|
|
|
9
|
-
#include "
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
|
|
11
11
|
#pragma clang diagnostic push
|
|
12
12
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -21,8 +21,11 @@ namespace RNSkia {
|
|
|
21
21
|
|
|
22
22
|
namespace jsi = facebook::jsi;
|
|
23
23
|
|
|
24
|
-
class JsiSkRRect
|
|
24
|
+
class JsiSkRRect
|
|
25
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkRRect, SkRRect> {
|
|
25
26
|
public:
|
|
27
|
+
static constexpr const char *CLASS_NAME = "RRect";
|
|
28
|
+
|
|
26
29
|
JSI_PROPERTY_GET(rx) {
|
|
27
30
|
return static_cast<double>(getObject()->getSimpleRadii().x());
|
|
28
31
|
}
|
|
@@ -30,23 +33,19 @@ public:
|
|
|
30
33
|
return static_cast<double>(getObject()->getSimpleRadii().y());
|
|
31
34
|
}
|
|
32
35
|
JSI_PROPERTY_GET(rect) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, rectObj,
|
|
36
|
-
getContext());
|
|
36
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkRect>(
|
|
37
|
+
getContext(), getObject()->getBounds()));
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkRRect, dispose))
|
|
40
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
41
|
+
installCommon(runtime, prototype);
|
|
42
|
+
installHostGetter(runtime, prototype, "rx", &JsiSkRRect::get_rx);
|
|
43
|
+
installHostGetter(runtime, prototype, "ry", &JsiSkRRect::get_ry);
|
|
44
|
+
installHostGetter(runtime, prototype, "rect", &JsiSkRRect::get_rect);
|
|
45
|
+
}
|
|
47
46
|
|
|
48
47
|
JsiSkRRect(std::shared_ptr<RNSkPlatformContext> context, const SkRRect &rect)
|
|
49
|
-
:
|
|
48
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkRRect, SkRRect>(
|
|
50
49
|
std::move(context), std::make_shared<SkRRect>(rect)) {}
|
|
51
50
|
|
|
52
51
|
/**
|
|
@@ -56,10 +55,9 @@ public:
|
|
|
56
55
|
const jsi::Value &obj) {
|
|
57
56
|
|
|
58
57
|
const auto &object = obj.asObject(runtime);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
->getObject();
|
|
58
|
+
auto rrect = tryGetJsiObject<JsiSkRRect>(runtime, object);
|
|
59
|
+
if (rrect) {
|
|
60
|
+
return rrect->getObject();
|
|
63
61
|
} else {
|
|
64
62
|
auto rect =
|
|
65
63
|
JsiSkRect::fromValue(runtime, object.getProperty(runtime, "rect"));
|
|
@@ -101,17 +99,14 @@ public:
|
|
|
101
99
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
102
100
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
103
101
|
const SkRRect &rect) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
context);
|
|
102
|
+
return makeJsiObject(
|
|
103
|
+
runtime, std::make_shared<JsiSkRRect>(std::move(context), rect));
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
size_t getMemoryPressure()
|
|
106
|
+
size_t getMemoryPressure() override {
|
|
110
107
|
return std::max(sizeof(SkRRect), kMinMemoryPressure);
|
|
111
108
|
}
|
|
112
109
|
|
|
113
|
-
std::string getObjectType() const override { return "JsiSkRRect"; }
|
|
114
|
-
|
|
115
110
|
/**
|
|
116
111
|
* Creates the function for construction a new instance of the SkRect
|
|
117
112
|
* wrapper
|
|
@@ -128,10 +123,8 @@ public:
|
|
|
128
123
|
auto ry = arguments[2].asNumber();
|
|
129
124
|
auto rrect = SkRRect::MakeRectXY(*rect, rx, ry);
|
|
130
125
|
// Return the newly constructed object
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, rrectObj,
|
|
134
|
-
context);
|
|
126
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkRRect>(
|
|
127
|
+
std::move(context), std::move(rrect)));
|
|
135
128
|
};
|
|
136
129
|
}
|
|
137
130
|
};
|
package/cpp/api/JsiSkRSXform.h
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
9
9
|
|
|
10
10
|
#pragma clang diagnostic push
|
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -18,15 +18,16 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkRSXform
|
|
21
|
+
class JsiSkRSXform
|
|
22
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkRSXform, SkRSXform> {
|
|
22
23
|
public:
|
|
24
|
+
static constexpr const char *CLASS_NAME = "RSXform";
|
|
25
|
+
|
|
23
26
|
JsiSkRSXform(std::shared_ptr<RNSkPlatformContext> context,
|
|
24
27
|
const SkRSXform &rsxform)
|
|
25
|
-
:
|
|
28
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkRSXform, SkRSXform>(
|
|
26
29
|
std::move(context), std::make_shared<SkRSXform>(rsxform)) {}
|
|
27
30
|
|
|
28
|
-
JSI_API_TYPENAME("RSXform");
|
|
29
|
-
|
|
30
31
|
JSI_PROPERTY_GET(scos) {
|
|
31
32
|
return jsi::Value(SkScalarToDouble(getObject()->fSCos));
|
|
32
33
|
}
|
|
@@ -52,14 +53,14 @@ public:
|
|
|
52
53
|
}
|
|
53
54
|
#pragma clang diagnostic pop
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
57
|
+
installCommon(runtime, prototype);
|
|
58
|
+
installHostGetter(runtime, prototype, "scos", &JsiSkRSXform::get_scos);
|
|
59
|
+
installHostGetter(runtime, prototype, "ssin", &JsiSkRSXform::get_ssin);
|
|
60
|
+
installHostGetter(runtime, prototype, "tx", &JsiSkRSXform::get_tx);
|
|
61
|
+
installHostGetter(runtime, prototype, "ty", &JsiSkRSXform::get_ty);
|
|
62
|
+
installHostMethod(runtime, prototype, "set", &JsiSkRSXform::set);
|
|
63
|
+
}
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
66
|
Returns the underlying object from a host object of this type
|
|
@@ -67,8 +68,9 @@ public:
|
|
|
67
68
|
static std::shared_ptr<SkRSXform> fromValue(jsi::Runtime &runtime,
|
|
68
69
|
const jsi::Value &obj) {
|
|
69
70
|
const auto &object = obj.asObject(runtime);
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
auto rsxform = tryGetJsiObject<JsiSkRSXform>(runtime, object);
|
|
72
|
+
if (rsxform) {
|
|
73
|
+
return rsxform->getObject();
|
|
72
74
|
} else {
|
|
73
75
|
auto scos = object.getProperty(runtime, "scos").asNumber();
|
|
74
76
|
auto ssin = object.getProperty(runtime, "ssin").asNumber();
|
|
@@ -84,10 +86,8 @@ public:
|
|
|
84
86
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
85
87
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
86
88
|
const SkRSXform &rsxform) {
|
|
87
|
-
|
|
88
|
-
std::make_shared<JsiSkRSXform>(std::move(context), rsxform);
|
|
89
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, rsxformObj,
|
|
90
|
-
context);
|
|
89
|
+
return makeJsiObject(
|
|
90
|
+
runtime, std::make_shared<JsiSkRSXform>(std::move(context), rsxform));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -105,18 +105,15 @@ public:
|
|
|
105
105
|
arguments[2].asNumber(), arguments[3].asNumber(),
|
|
106
106
|
arguments[4].asNumber(), arguments[5].asNumber());
|
|
107
107
|
// Return the newly constructed object
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
context);
|
|
108
|
+
return makeJsiObject(runtime,
|
|
109
|
+
std::make_shared<JsiSkRSXform>(std::move(context),
|
|
110
|
+
std::move(rsxform)));
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
|
-
size_t getMemoryPressure()
|
|
113
|
+
size_t getMemoryPressure() override {
|
|
115
114
|
return std::max(sizeof(SkRSXform), kMinMemoryPressure);
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
std::string getObjectType() const override { return "JsiSkRSXform"; }
|
|
119
|
-
|
|
120
117
|
/**
|
|
121
118
|
* Creates the function for construction a new instance of the SkRSXform
|
|
122
119
|
* wrapper
|
|
@@ -131,10 +128,9 @@ public:
|
|
|
131
128
|
SkRSXform::Make(arguments[0].asNumber(), arguments[1].asNumber(),
|
|
132
129
|
arguments[2].asNumber(), arguments[3].asNumber());
|
|
133
130
|
// Return the newly constructed object
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
context);
|
|
131
|
+
return makeJsiObject(runtime,
|
|
132
|
+
std::make_shared<JsiSkRSXform>(std::move(context),
|
|
133
|
+
std::move(rsxform)));
|
|
138
134
|
};
|
|
139
135
|
}
|
|
140
136
|
};
|
package/cpp/api/JsiSkRect.h
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
9
9
|
|
|
10
10
|
#pragma clang diagnostic push
|
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -18,8 +18,10 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkRect : public
|
|
21
|
+
class JsiSkRect : public JsiSkWrappingSharedPtrNativeObject<JsiSkRect, SkRect> {
|
|
22
22
|
public:
|
|
23
|
+
static constexpr const char *CLASS_NAME = "Rect";
|
|
24
|
+
|
|
23
25
|
JSI_PROPERTY_GET(x) { return static_cast<double>(getObject()->x()); }
|
|
24
26
|
JSI_PROPERTY_GET(y) { return static_cast<double>(getObject()->y()); }
|
|
25
27
|
JSI_PROPERTY_GET(width) { return static_cast<double>(getObject()->width()); }
|
|
@@ -33,14 +35,6 @@ public:
|
|
|
33
35
|
return static_cast<double>(getObject()->bottom());
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
JSI_API_TYPENAME("Rect");
|
|
37
|
-
|
|
38
|
-
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkRect, x),
|
|
39
|
-
JSI_EXPORT_PROP_GET(JsiSkRect, y),
|
|
40
|
-
JSI_EXPORT_PROP_GET(JsiSkRect, width),
|
|
41
|
-
JSI_EXPORT_PROP_GET(JsiSkRect, height),
|
|
42
|
-
JSI_EXPORT_PROP_GET(JsiSkRect, __typename__))
|
|
43
|
-
|
|
44
38
|
JSI_HOST_FUNCTION(setXYWH) {
|
|
45
39
|
getObject()->setXYWH(arguments[0].asNumber(), arguments[1].asNumber(),
|
|
46
40
|
arguments[2].asNumber(), arguments[3].asNumber());
|
|
@@ -53,15 +47,25 @@ public:
|
|
|
53
47
|
return jsi::Value::undefined();
|
|
54
48
|
}
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
51
|
+
installCommon(runtime, prototype);
|
|
52
|
+
installHostGetter(runtime, prototype, "x", &JsiSkRect::get_x);
|
|
53
|
+
installHostGetter(runtime, prototype, "y", &JsiSkRect::get_y);
|
|
54
|
+
installHostGetter(runtime, prototype, "width", &JsiSkRect::get_width);
|
|
55
|
+
installHostGetter(runtime, prototype, "height", &JsiSkRect::get_height);
|
|
56
|
+
installHostGetter(runtime, prototype, "left", &JsiSkRect::get_left);
|
|
57
|
+
installHostGetter(runtime, prototype, "top", &JsiSkRect::get_top);
|
|
58
|
+
installHostGetter(runtime, prototype, "right", &JsiSkRect::get_right);
|
|
59
|
+
installHostGetter(runtime, prototype, "bottom", &JsiSkRect::get_bottom);
|
|
60
|
+
installHostMethod(runtime, prototype, "setXYWH", &JsiSkRect::setXYWH);
|
|
61
|
+
installHostMethod(runtime, prototype, "setLTRB", &JsiSkRect::setLTRB);
|
|
62
|
+
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
Constructor
|
|
62
66
|
*/
|
|
63
67
|
JsiSkRect(std::shared_ptr<RNSkPlatformContext> context, const SkRect &rect)
|
|
64
|
-
:
|
|
68
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkRect, SkRect>(
|
|
65
69
|
std::move(context), std::make_shared<SkRect>(rect)) {}
|
|
66
70
|
|
|
67
71
|
/**
|
|
@@ -70,8 +74,9 @@ public:
|
|
|
70
74
|
static std::shared_ptr<SkRect> fromValue(jsi::Runtime &runtime,
|
|
71
75
|
const jsi::Value &obj) {
|
|
72
76
|
const auto &object = obj.asObject(runtime);
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
auto rect = tryGetJsiObject<JsiSkRect>(runtime, object);
|
|
78
|
+
if (rect) {
|
|
79
|
+
return rect->getObject();
|
|
75
80
|
} else {
|
|
76
81
|
auto x = object.getProperty(runtime, "x").asNumber();
|
|
77
82
|
auto y = object.getProperty(runtime, "y").asNumber();
|
|
@@ -87,25 +92,20 @@ public:
|
|
|
87
92
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
88
93
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
89
94
|
const SkRect &rect) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
context);
|
|
95
|
+
return makeJsiObject(runtime,
|
|
96
|
+
std::make_shared<JsiSkRect>(std::move(context), rect));
|
|
93
97
|
}
|
|
94
98
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
95
99
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
96
100
|
SkRect &&rect) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, rectObj,
|
|
100
|
-
context);
|
|
101
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkRect>(
|
|
102
|
+
std::move(context), std::move(rect)));
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
size_t getMemoryPressure()
|
|
105
|
+
size_t getMemoryPressure() override {
|
|
104
106
|
return std::max(sizeof(SkRect), kMinMemoryPressure);
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
std::string getObjectType() const override { return "JsiSkRect"; }
|
|
108
|
-
|
|
109
109
|
/**
|
|
110
110
|
* Creates the function for construction a new instance of the SkRect
|
|
111
111
|
* wrapper
|
|
@@ -122,10 +122,8 @@ public:
|
|
|
122
122
|
arguments[2].asNumber(), arguments[3].asNumber());
|
|
123
123
|
|
|
124
124
|
// Return the newly constructed object
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, rectObj,
|
|
128
|
-
context);
|
|
125
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkRect>(
|
|
126
|
+
std::move(context), std::move(rect)));
|
|
129
127
|
};
|
|
130
128
|
}
|
|
131
129
|
};
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
#include <utility>
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
|
-
#include "JsiSkHostObjects.h"
|
|
9
8
|
#include "JsiSkMatrix.h"
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
#include "JsiSkShader.h"
|
|
11
11
|
|
|
12
12
|
#include <jsi/jsi.h>
|
|
@@ -37,8 +37,11 @@ struct RuntimeEffectUniform {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
class JsiSkRuntimeEffect
|
|
40
|
-
: public
|
|
40
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkRuntimeEffect,
|
|
41
|
+
SkRuntimeEffect> {
|
|
41
42
|
public:
|
|
43
|
+
static constexpr const char *CLASS_NAME = "RuntimeEffect";
|
|
44
|
+
|
|
42
45
|
JSI_HOST_FUNCTION(makeShader) {
|
|
43
46
|
auto uniforms = castUniforms(runtime, arguments[0]);
|
|
44
47
|
|
|
@@ -51,10 +54,8 @@ public:
|
|
|
51
54
|
auto shader =
|
|
52
55
|
getObject()->makeShader(std::move(uniforms), nullptr, 0, matrix);
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shaderObj,
|
|
57
|
-
getContext());
|
|
57
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
58
|
+
getContext(), std::move(shader)));
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
JSI_HOST_FUNCTION(makeShaderWithChildren) {
|
|
@@ -66,9 +67,8 @@ public:
|
|
|
66
67
|
auto jsiChildCount = jsiChildren.size(runtime);
|
|
67
68
|
children.reserve(jsiChildCount);
|
|
68
69
|
for (int i = 0; i < jsiChildCount; i++) {
|
|
69
|
-
auto shader =
|
|
70
|
-
.
|
|
71
|
-
.asHostObject<JsiSkShader>(runtime)
|
|
70
|
+
auto shader = getJsiObject<JsiSkShader>(
|
|
71
|
+
runtime, jsiChildren.getValueAtIndex(runtime, i))
|
|
72
72
|
->getObject();
|
|
73
73
|
children.push_back(shader);
|
|
74
74
|
}
|
|
@@ -82,10 +82,8 @@ public:
|
|
|
82
82
|
auto shader = getObject()->makeShader(std::move(uniforms), children.data(),
|
|
83
83
|
children.size(), matrix);
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shaderObj,
|
|
88
|
-
getContext());
|
|
85
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
86
|
+
getContext(), std::move(shader)));
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
JSI_HOST_FUNCTION(getUniformCount) {
|
|
@@ -124,27 +122,38 @@ public:
|
|
|
124
122
|
return jsi::String::createFromAscii(runtime, getObject()->source());
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
126
|
+
installCommon(runtime, prototype);
|
|
127
|
+
installHostMethod(runtime, prototype, "makeShader",
|
|
128
|
+
&JsiSkRuntimeEffect::makeShader);
|
|
129
|
+
installHostMethod(runtime, prototype, "makeShaderWithChildren",
|
|
130
|
+
&JsiSkRuntimeEffect::makeShaderWithChildren);
|
|
131
|
+
installHostMethod(runtime, prototype, "getUniformCount",
|
|
132
|
+
&JsiSkRuntimeEffect::getUniformCount);
|
|
133
|
+
installHostMethod(runtime, prototype, "getUniformFloatCount",
|
|
134
|
+
&JsiSkRuntimeEffect::getUniformFloatCount);
|
|
135
|
+
installHostMethod(runtime, prototype, "getUniformName",
|
|
136
|
+
&JsiSkRuntimeEffect::getUniformName);
|
|
137
|
+
installHostMethod(runtime, prototype, "getUniform",
|
|
138
|
+
&JsiSkRuntimeEffect::getUniform);
|
|
139
|
+
installHostMethod(runtime, prototype, "source",
|
|
140
|
+
&JsiSkRuntimeEffect::source);
|
|
141
|
+
}
|
|
139
142
|
|
|
140
143
|
JsiSkRuntimeEffect(std::shared_ptr<RNSkPlatformContext> context,
|
|
141
144
|
sk_sp<SkRuntimeEffect> rt)
|
|
142
|
-
:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkRuntimeEffect, SkRuntimeEffect>(
|
|
146
|
+
std::move(context), std::move(rt)) {}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
Returns the underlying object from a host object of this type
|
|
150
|
+
*/
|
|
151
|
+
static sk_sp<SkRuntimeEffect> fromValue(jsi::Runtime &runtime,
|
|
152
|
+
const jsi::Value &obj) {
|
|
153
|
+
return getJsiObject<JsiSkRuntimeEffect>(runtime, obj)->getObject();
|
|
154
|
+
}
|
|
146
155
|
|
|
147
|
-
|
|
156
|
+
size_t getMemoryPressure() override { return 4096; }
|
|
148
157
|
|
|
149
158
|
static RuntimeEffectUniform fromUniform(const SkRuntimeEffect::Uniform &u) {
|
|
150
159
|
RuntimeEffectUniform su;
|
|
@@ -6,15 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
#include <jsi/jsi.h>
|
|
8
8
|
|
|
9
|
-
#include "
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
#include "JsiSkRuntimeEffect.h"
|
|
11
11
|
|
|
12
12
|
namespace RNSkia {
|
|
13
13
|
|
|
14
14
|
namespace jsi = facebook::jsi;
|
|
15
15
|
|
|
16
|
-
class JsiSkRuntimeEffectFactory
|
|
16
|
+
class JsiSkRuntimeEffectFactory
|
|
17
|
+
: public JsiSkNativeObject<JsiSkRuntimeEffectFactory> {
|
|
17
18
|
public:
|
|
19
|
+
static constexpr const char *CLASS_NAME = "RuntimeEffectFactory";
|
|
20
|
+
|
|
18
21
|
JSI_HOST_FUNCTION(Make) {
|
|
19
22
|
auto sksl = arguments[0].asString(runtime).utf8(runtime);
|
|
20
23
|
auto result = SkRuntimeEffect::MakeForShader(SkString(sksl));
|
|
@@ -26,23 +29,20 @@ public:
|
|
|
26
29
|
.c_str());
|
|
27
30
|
return jsi::Value::null();
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, runtimeEffect,
|
|
32
|
-
getContext());
|
|
32
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkRuntimeEffect>(
|
|
33
|
+
getContext(), std::move(effect)));
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
size_t getMemoryPressure()
|
|
36
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
39
|
+
installHostMethod(runtime, prototype, "Make",
|
|
40
|
+
&JsiSkRuntimeEffectFactory::Make);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkRuntimeEffectFactory, Make))
|
|
42
|
-
|
|
43
43
|
explicit JsiSkRuntimeEffectFactory(
|
|
44
44
|
std::shared_ptr<RNSkPlatformContext> context)
|
|
45
|
-
:
|
|
45
|
+
: JsiSkNativeObject<JsiSkRuntimeEffectFactory>(std::move(context)) {}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
} // namespace RNSkia
|