@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
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <atomic>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <utility>
|
|
7
|
+
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
|
|
10
|
+
#include "jsi/NativeObject.h"
|
|
11
|
+
#include "rnskia/RNSkPlatformContext.h"
|
|
12
|
+
#include "utils/RNSkLog.h"
|
|
13
|
+
|
|
14
|
+
#define STR_CAT_NX(A, B) A##B
|
|
15
|
+
#define STR_CAT(A, B) STR_CAT_NX(A, B)
|
|
16
|
+
#define STR_GET get_
|
|
17
|
+
#define STR_SET set_
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new Host function declaration as a lambda with all deps passed
|
|
21
|
+
* with implicit lambda capture clause
|
|
22
|
+
*/
|
|
23
|
+
#define JSI_HOST_FUNCTION_LAMBDA \
|
|
24
|
+
[=](jsi::Runtime & runtime, const jsi::Value &thisValue, \
|
|
25
|
+
const jsi::Value *arguments, size_t count) -> jsi::Value
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new Host function declaration
|
|
29
|
+
*/
|
|
30
|
+
#define JSI_HOST_FUNCTION(NAME) \
|
|
31
|
+
jsi::Value NAME(jsi::Runtime &runtime, const jsi::Value &thisValue, \
|
|
32
|
+
const jsi::Value *arguments, size_t count)
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new property setter function declaration
|
|
36
|
+
*/
|
|
37
|
+
#define JSI_PROPERTY_SET(NAME) \
|
|
38
|
+
void STR_CAT(STR_SET, NAME)(jsi::Runtime & runtime, const jsi::Value &value)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new property getter function declaration
|
|
42
|
+
*/
|
|
43
|
+
#define JSI_PROPERTY_GET(NAME) \
|
|
44
|
+
jsi::Value STR_CAT(STR_GET, NAME)(jsi::Runtime & runtime)
|
|
45
|
+
|
|
46
|
+
namespace RNSkia {
|
|
47
|
+
|
|
48
|
+
namespace jsi = facebook::jsi;
|
|
49
|
+
|
|
50
|
+
// Minimum memory pressure reported for any native object — aliased from the
|
|
51
|
+
// NativeObject infrastructure so dispose() and create() agree on the floor.
|
|
52
|
+
static constexpr size_t kMinMemoryPressure = rnwgpu::kMinMemoryPressure;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates the JS object for a wrapper instance (a class based on the
|
|
56
|
+
* NativeObject pattern below).
|
|
57
|
+
*/
|
|
58
|
+
template <typename T>
|
|
59
|
+
jsi::Value makeJsiObject(jsi::Runtime &runtime, std::shared_ptr<T> instance) {
|
|
60
|
+
return T::create(runtime, std::move(instance));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns the wrapper instance backing the given JS object or nullptr if the
|
|
65
|
+
* object is not backed by the requested type.
|
|
66
|
+
*/
|
|
67
|
+
template <typename T>
|
|
68
|
+
std::shared_ptr<T> tryGetJsiObject(jsi::Runtime &runtime,
|
|
69
|
+
const jsi::Object &object) {
|
|
70
|
+
if (object.hasNativeState<T>(runtime)) {
|
|
71
|
+
return object.getNativeState<T>(runtime);
|
|
72
|
+
}
|
|
73
|
+
return nullptr;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
template <typename T>
|
|
77
|
+
std::shared_ptr<T> tryGetJsiObject(jsi::Runtime &runtime,
|
|
78
|
+
const jsi::Value &value) {
|
|
79
|
+
if (!value.isObject()) {
|
|
80
|
+
return nullptr;
|
|
81
|
+
}
|
|
82
|
+
auto object = value.asObject(runtime);
|
|
83
|
+
return tryGetJsiObject<T>(runtime, object);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns the wrapper instance backing the given JS value or throws a JS
|
|
88
|
+
* error if the value is not backed by the requested type.
|
|
89
|
+
*/
|
|
90
|
+
template <typename T>
|
|
91
|
+
std::shared_ptr<T> getJsiObject(jsi::Runtime &runtime,
|
|
92
|
+
const jsi::Value &value) {
|
|
93
|
+
auto result = tryGetJsiObject<T>(runtime, value);
|
|
94
|
+
if (result == nullptr) {
|
|
95
|
+
throw jsi::JSError(runtime, "Expected a Skia object of a different type.");
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Base class for Skia API objects implemented with the NativeObject /
|
|
102
|
+
* jsi::NativeState pattern (see jsi/NativeObject.h). Instead of a HostObject
|
|
103
|
+
* intercepting every property access, methods and properties live on a shared
|
|
104
|
+
* per-runtime prototype and the C++ instance is attached to plain JS objects
|
|
105
|
+
* as native state.
|
|
106
|
+
*
|
|
107
|
+
* Derived classes must provide:
|
|
108
|
+
* - `static constexpr const char *CLASS_NAME` — the public __typename__
|
|
109
|
+
* (e.g. "Rect"); also used as the boxing brand, so it must be unique.
|
|
110
|
+
* - `static void definePrototype(jsi::Runtime&, jsi::Object& prototype)` —
|
|
111
|
+
* installs methods/getters. The shared pieces (`__typename__`, `__box()`
|
|
112
|
+
* and the boxing reconstructor) are installed by
|
|
113
|
+
* NativeObject::installPrototype; wrapping classes additionally call
|
|
114
|
+
* `installCommon(runtime, proto)` to install dispose().
|
|
115
|
+
*
|
|
116
|
+
* The existing JSI_HOST_FUNCTION / JSI_PROPERTY_GET / JSI_PROPERTY_SET method
|
|
117
|
+
* bodies keep working unchanged; they are installed on the prototype with the
|
|
118
|
+
* installHostMethod / installHostGetter / installHostSetter helpers below,
|
|
119
|
+
* which resolve the C++ instance from `this` via native state.
|
|
120
|
+
*/
|
|
121
|
+
template <typename Derived>
|
|
122
|
+
class JsiSkNativeObject : public rnwgpu::NativeObject<Derived> {
|
|
123
|
+
public:
|
|
124
|
+
explicit JsiSkNativeObject(std::shared_ptr<RNSkPlatformContext> context)
|
|
125
|
+
: rnwgpu::NativeObject<Derived>(Derived::CLASS_NAME),
|
|
126
|
+
_context(std::move(context)) {}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Resolves the C++ instance backing `thisValue`. Throws a JSError if the
|
|
130
|
+
* value is not backed by this class.
|
|
131
|
+
*/
|
|
132
|
+
static std::shared_ptr<Derived> fromThis(jsi::Runtime &runtime,
|
|
133
|
+
const jsi::Value &thisValue) {
|
|
134
|
+
return rnwgpu::NativeObject<Derived>::fromValue(runtime, thisValue);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected:
|
|
138
|
+
std::shared_ptr<RNSkPlatformContext> getContext() { return _context; }
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
@Returns a reference to the argument at the given position in the arguments
|
|
142
|
+
array. Raises an error if the index is above the number of arguments.
|
|
143
|
+
*/
|
|
144
|
+
static const jsi::Value &getArgument(jsi::Runtime &runtime,
|
|
145
|
+
const jsi::Value *arguments,
|
|
146
|
+
size_t count, size_t index) {
|
|
147
|
+
if (index >= count) {
|
|
148
|
+
throw jsi::JSError(runtime, "Argument index out of bounds.");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return arguments[index];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
Returns argument as number or throws
|
|
156
|
+
*/
|
|
157
|
+
static double getArgumentAsNumber(jsi::Runtime &runtime,
|
|
158
|
+
const jsi::Value *arguments, size_t count,
|
|
159
|
+
size_t index) {
|
|
160
|
+
const jsi::Value &value = getArgument(runtime, arguments, count, index);
|
|
161
|
+
if (!value.isNumber()) {
|
|
162
|
+
throw jsi::JSError(runtime,
|
|
163
|
+
"Expected type number for parameter at index " +
|
|
164
|
+
std::to_string(index));
|
|
165
|
+
}
|
|
166
|
+
return value.asNumber();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
Returns argument as string or throws
|
|
171
|
+
*/
|
|
172
|
+
static jsi::String getArgumentAsString(jsi::Runtime &runtime,
|
|
173
|
+
const jsi::Value *arguments,
|
|
174
|
+
size_t count, size_t index) {
|
|
175
|
+
const jsi::Value &value = getArgument(runtime, arguments, count, index);
|
|
176
|
+
if (!value.isString()) {
|
|
177
|
+
throw jsi::JSError(runtime,
|
|
178
|
+
"Expected type string for parameter at index " +
|
|
179
|
+
std::to_string(index));
|
|
180
|
+
}
|
|
181
|
+
return value.asString(runtime);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
Returns argument as object or throws
|
|
186
|
+
*/
|
|
187
|
+
static jsi::Object getArgumentAsObject(jsi::Runtime &runtime,
|
|
188
|
+
const jsi::Value *arguments,
|
|
189
|
+
size_t count, size_t index) {
|
|
190
|
+
const jsi::Value &value = getArgument(runtime, arguments, count, index);
|
|
191
|
+
if (!value.isObject()) {
|
|
192
|
+
throw jsi::JSError(runtime,
|
|
193
|
+
"Expected type object for parameter at index " +
|
|
194
|
+
std::to_string(index));
|
|
195
|
+
}
|
|
196
|
+
return value.asObject(runtime);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
Returns argument as function or throws
|
|
201
|
+
*/
|
|
202
|
+
static jsi::Object getArgumentAsFunction(jsi::Runtime &runtime,
|
|
203
|
+
const jsi::Value *arguments,
|
|
204
|
+
size_t count, size_t index) {
|
|
205
|
+
auto value = getArgumentAsObject(runtime, arguments, count, index);
|
|
206
|
+
if (!value.isFunction(runtime)) {
|
|
207
|
+
throw jsi::JSError(runtime,
|
|
208
|
+
"Expected type function for parameter at index " +
|
|
209
|
+
std::to_string(index));
|
|
210
|
+
}
|
|
211
|
+
return value.asFunction(runtime);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
using HostMethod = jsi::Value (Derived::*)(jsi::Runtime &, const jsi::Value &,
|
|
215
|
+
const jsi::Value *, size_t);
|
|
216
|
+
using HostGetter = jsi::Value (Derived::*)(jsi::Runtime &);
|
|
217
|
+
using HostSetter = void (Derived::*)(jsi::Runtime &, const jsi::Value &);
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Installs a method with the classic host-function signature
|
|
221
|
+
* (JSI_HOST_FUNCTION) on the prototype.
|
|
222
|
+
*/
|
|
223
|
+
static void installHostMethod(jsi::Runtime &runtime, jsi::Object &prototype,
|
|
224
|
+
const char *name, HostMethod method) {
|
|
225
|
+
auto func = jsi::Function::createFromHostFunction(
|
|
226
|
+
runtime, jsi::PropNameID::forUtf8(runtime, name), 0,
|
|
227
|
+
[method](jsi::Runtime &rt, const jsi::Value &thisValue,
|
|
228
|
+
const jsi::Value *arguments, size_t count) -> jsi::Value {
|
|
229
|
+
auto native = fromThis(rt, thisValue);
|
|
230
|
+
return ((*native).*method)(rt, thisValue, arguments, count);
|
|
231
|
+
});
|
|
232
|
+
prototype.setProperty(runtime, name, func);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Installs a property getter with the classic JSI_PROPERTY_GET signature on
|
|
237
|
+
* the prototype.
|
|
238
|
+
*/
|
|
239
|
+
static void installHostGetter(jsi::Runtime &runtime, jsi::Object &prototype,
|
|
240
|
+
const char *name, HostGetter getter) {
|
|
241
|
+
auto getterFunc = jsi::Function::createFromHostFunction(
|
|
242
|
+
runtime, jsi::PropNameID::forUtf8(runtime, std::string("get_") + name),
|
|
243
|
+
0,
|
|
244
|
+
[getter](jsi::Runtime &rt, const jsi::Value &thisValue,
|
|
245
|
+
const jsi::Value *, size_t) -> jsi::Value {
|
|
246
|
+
auto native = fromThis(rt, thisValue);
|
|
247
|
+
return ((*native).*getter)(rt);
|
|
248
|
+
});
|
|
249
|
+
defineProperty(runtime, prototype, name, &getterFunc, nullptr);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Installs a property setter with the classic JSI_PROPERTY_SET signature on
|
|
254
|
+
* the prototype, preserving a previously installed getter.
|
|
255
|
+
*/
|
|
256
|
+
static void installHostSetter(jsi::Runtime &runtime, jsi::Object &prototype,
|
|
257
|
+
const char *name, HostSetter setter) {
|
|
258
|
+
auto setterFunc = jsi::Function::createFromHostFunction(
|
|
259
|
+
runtime, jsi::PropNameID::forUtf8(runtime, std::string("set_") + name),
|
|
260
|
+
1,
|
|
261
|
+
[setter](jsi::Runtime &rt, const jsi::Value &thisValue,
|
|
262
|
+
const jsi::Value *arguments, size_t count) -> jsi::Value {
|
|
263
|
+
if (count < 1) {
|
|
264
|
+
throw jsi::JSError(rt, "Setter requires a value argument");
|
|
265
|
+
}
|
|
266
|
+
auto native = fromThis(rt, thisValue);
|
|
267
|
+
((*native).*setter)(rt, arguments[0]);
|
|
268
|
+
return jsi::Value::undefined();
|
|
269
|
+
});
|
|
270
|
+
defineProperty(runtime, prototype, name, nullptr, &setterFunc);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Installs both getter and setter for a property on the prototype.
|
|
275
|
+
*/
|
|
276
|
+
static void installHostProperty(jsi::Runtime &runtime, jsi::Object &prototype,
|
|
277
|
+
const char *name, HostGetter getter,
|
|
278
|
+
HostSetter setter) {
|
|
279
|
+
installHostGetter(runtime, prototype, name, getter);
|
|
280
|
+
installHostSetter(runtime, prototype, name, setter);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private:
|
|
284
|
+
static void defineProperty(jsi::Runtime &runtime, jsi::Object &prototype,
|
|
285
|
+
const char *name, jsi::Function *getter,
|
|
286
|
+
jsi::Function *setter) {
|
|
287
|
+
auto objectCtor = runtime.global().getPropertyAsObject(runtime, "Object");
|
|
288
|
+
auto defineProp =
|
|
289
|
+
objectCtor.getPropertyAsFunction(runtime, "defineProperty");
|
|
290
|
+
auto getOwnPropertyDescriptor =
|
|
291
|
+
objectCtor.getPropertyAsFunction(runtime, "getOwnPropertyDescriptor");
|
|
292
|
+
auto existing = getOwnPropertyDescriptor.call(
|
|
293
|
+
runtime, prototype, jsi::String::createFromUtf8(runtime, name));
|
|
294
|
+
|
|
295
|
+
jsi::Object descriptor(runtime);
|
|
296
|
+
if (existing.isObject()) {
|
|
297
|
+
auto existingObj = existing.getObject(runtime);
|
|
298
|
+
if (existingObj.hasProperty(runtime, "get")) {
|
|
299
|
+
descriptor.setProperty(runtime, "get",
|
|
300
|
+
existingObj.getProperty(runtime, "get"));
|
|
301
|
+
}
|
|
302
|
+
if (existingObj.hasProperty(runtime, "set")) {
|
|
303
|
+
descriptor.setProperty(runtime, "set",
|
|
304
|
+
existingObj.getProperty(runtime, "set"));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (getter != nullptr) {
|
|
308
|
+
descriptor.setProperty(runtime, "get", *getter);
|
|
309
|
+
}
|
|
310
|
+
if (setter != nullptr) {
|
|
311
|
+
descriptor.setProperty(runtime, "set", *setter);
|
|
312
|
+
}
|
|
313
|
+
descriptor.setProperty(runtime, "enumerable", true);
|
|
314
|
+
descriptor.setProperty(runtime, "configurable", true);
|
|
315
|
+
defineProp.call(runtime, prototype,
|
|
316
|
+
jsi::String::createFromUtf8(runtime, name), descriptor);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
std::shared_ptr<RNSkPlatformContext> _context;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* NativeObject equivalent of JsiSkWrappingHostObject: wraps an inner object
|
|
324
|
+
* (a std::shared_ptr or sk_sp) and provides dispose() semantics.
|
|
325
|
+
*/
|
|
326
|
+
template <typename Derived, typename T>
|
|
327
|
+
class JsiSkWrappingNativeObject : public JsiSkNativeObject<Derived> {
|
|
328
|
+
public:
|
|
329
|
+
JsiSkWrappingNativeObject(std::shared_ptr<RNSkPlatformContext> context,
|
|
330
|
+
T object)
|
|
331
|
+
: JsiSkNativeObject<Derived>(std::move(context)),
|
|
332
|
+
_object(std::move(object)) {}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Returns the wrapped object. Throws if the object has been disposed.
|
|
336
|
+
*/
|
|
337
|
+
T getObject() { return validateObject(); }
|
|
338
|
+
const T getObject() const { return validateObject(); }
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Updates the inner object with a new version of the object.
|
|
342
|
+
*/
|
|
343
|
+
void setObject(T object) { _object = object; }
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Returns the wrapped object from a JS value backed by this class.
|
|
347
|
+
*/
|
|
348
|
+
static T objectFromValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
349
|
+
return JsiSkNativeObject<Derived>::fromThis(runtime, value)->getObject();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* dispose() releases the wrapped resources eagerly instead of waiting for
|
|
354
|
+
* garbage collection. Installed on the prototype via installCommon.
|
|
355
|
+
*/
|
|
356
|
+
JSI_HOST_FUNCTION(dispose) {
|
|
357
|
+
if (!isDisposed()) {
|
|
358
|
+
thisValue.asObject(runtime).setExternalMemoryPressure(runtime,
|
|
359
|
+
kMinMemoryPressure);
|
|
360
|
+
}
|
|
361
|
+
safeDispose();
|
|
362
|
+
return jsi::Value::undefined();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Installs dispose() on the prototype (the shared pieces — __typename__,
|
|
367
|
+
* __box() and the boxing reconstructor — are installed by
|
|
368
|
+
* NativeObject::installPrototype). Must be called from definePrototype().
|
|
369
|
+
*/
|
|
370
|
+
static void installCommon(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
371
|
+
JsiSkNativeObject<Derived>::installHostMethod(runtime, prototype, "dispose",
|
|
372
|
+
&Derived::dispose);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
protected:
|
|
376
|
+
/**
|
|
377
|
+
* Override to release additional resources. Called exactly once.
|
|
378
|
+
*/
|
|
379
|
+
virtual void releaseResources() { setObject(nullptr); }
|
|
380
|
+
|
|
381
|
+
bool isDisposed() const {
|
|
382
|
+
return _isDisposed.load(std::memory_order_acquire);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Returns the wrapped object without the disposed check — for destructors
|
|
387
|
+
* and releaseResources() implementations.
|
|
388
|
+
*/
|
|
389
|
+
T getObjectUnchecked() const { return _object; }
|
|
390
|
+
|
|
391
|
+
private:
|
|
392
|
+
T validateObject() const {
|
|
393
|
+
if (_isDisposed.load(std::memory_order_acquire)) {
|
|
394
|
+
throw std::runtime_error("Attempted to access a disposed object.");
|
|
395
|
+
}
|
|
396
|
+
return _object;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
void safeDispose() {
|
|
400
|
+
bool expected = false;
|
|
401
|
+
if (_isDisposed.compare_exchange_strong(expected, true,
|
|
402
|
+
std::memory_order_acq_rel)) {
|
|
403
|
+
releaseResources();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
T _object;
|
|
408
|
+
std::atomic<bool> _isDisposed = {false};
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
template <typename Derived, typename T>
|
|
412
|
+
using JsiSkWrappingSharedPtrNativeObject =
|
|
413
|
+
JsiSkWrappingNativeObject<Derived, std::shared_ptr<T>>;
|
|
414
|
+
|
|
415
|
+
template <typename Derived, typename T>
|
|
416
|
+
using JsiSkWrappingSkPtrNativeObject =
|
|
417
|
+
JsiSkWrappingNativeObject<Derived, sk_sp<T>>;
|
|
418
|
+
|
|
419
|
+
} // namespace RNSkia
|
package/cpp/api/JsiSkPaint.h
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
#include "CustomBlendModes.h"
|
|
9
9
|
#include "JsiSkColor.h"
|
|
10
10
|
#include "JsiSkColorFilter.h"
|
|
11
|
-
#include "JsiSkHostObjects.h"
|
|
12
11
|
#include "JsiSkImageFilter.h"
|
|
13
12
|
#include "JsiSkMaskFilter.h"
|
|
13
|
+
#include "JsiSkNativeObjects.h"
|
|
14
14
|
#include "JsiSkPathEffect.h"
|
|
15
15
|
#include "JsiSkShader.h"
|
|
16
16
|
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
namespace RNSkia {
|
|
25
25
|
namespace jsi = facebook::jsi;
|
|
26
26
|
|
|
27
|
-
class JsiSkPaint
|
|
27
|
+
class JsiSkPaint
|
|
28
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkPaint, SkPaint> {
|
|
28
29
|
public:
|
|
29
|
-
|
|
30
|
+
static constexpr const char *CLASS_NAME = "Paint";
|
|
30
31
|
|
|
31
32
|
JSI_HOST_FUNCTION(assign) {
|
|
32
33
|
SkPaint *paint = JsiSkPaint::fromValue(runtime, arguments[0]).get();
|
|
@@ -36,10 +37,8 @@ public:
|
|
|
36
37
|
|
|
37
38
|
JSI_HOST_FUNCTION(copy) {
|
|
38
39
|
const auto *paint = getObject().get();
|
|
39
|
-
|
|
40
|
-
std::make_shared<JsiSkPaint>(getContext(), SkPaint(*paint));
|
|
41
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
42
|
-
runtime, hostObjectInstance, getContext());
|
|
40
|
+
return makeJsiObject(
|
|
41
|
+
runtime, std::make_shared<JsiSkPaint>(getContext(), SkPaint(*paint)));
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
JSI_HOST_FUNCTION(reset) {
|
|
@@ -172,36 +171,60 @@ public:
|
|
|
172
171
|
return jsi::Value::undefined();
|
|
173
172
|
}
|
|
174
173
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
174
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
175
|
+
installCommon(runtime, prototype);
|
|
176
|
+
installHostMethod(runtime, prototype, "assign", &JsiSkPaint::assign);
|
|
177
|
+
installHostMethod(runtime, prototype, "copy", &JsiSkPaint::copy);
|
|
178
|
+
installHostMethod(runtime, prototype, "reset", &JsiSkPaint::reset);
|
|
179
|
+
installHostMethod(runtime, prototype, "getAlphaf", &JsiSkPaint::getAlphaf);
|
|
180
|
+
installHostMethod(runtime, prototype, "getColor", &JsiSkPaint::getColor);
|
|
181
|
+
installHostMethod(runtime, prototype, "getStrokeCap",
|
|
182
|
+
&JsiSkPaint::getStrokeCap);
|
|
183
|
+
installHostMethod(runtime, prototype, "getStrokeJoin",
|
|
184
|
+
&JsiSkPaint::getStrokeJoin);
|
|
185
|
+
installHostMethod(runtime, prototype, "getStrokeMiter",
|
|
186
|
+
&JsiSkPaint::getStrokeMiter);
|
|
187
|
+
installHostMethod(runtime, prototype, "getStrokeWidth",
|
|
188
|
+
&JsiSkPaint::getStrokeWidth);
|
|
189
|
+
installHostMethod(runtime, prototype, "setPathEffect",
|
|
190
|
+
&JsiSkPaint::setPathEffect);
|
|
191
|
+
installHostMethod(runtime, prototype, "setShader", &JsiSkPaint::setShader);
|
|
192
|
+
installHostMethod(runtime, prototype, "setColorFilter",
|
|
193
|
+
&JsiSkPaint::setColorFilter);
|
|
194
|
+
installHostMethod(runtime, prototype, "setImageFilter",
|
|
195
|
+
&JsiSkPaint::setImageFilter);
|
|
196
|
+
installHostMethod(runtime, prototype, "setMaskFilter",
|
|
197
|
+
&JsiSkPaint::setMaskFilter);
|
|
198
|
+
installHostMethod(runtime, prototype, "setBlendMode",
|
|
199
|
+
&JsiSkPaint::setBlendMode);
|
|
200
|
+
installHostMethod(runtime, prototype, "setStrokeMiter",
|
|
201
|
+
&JsiSkPaint::setStrokeMiter);
|
|
202
|
+
installHostMethod(runtime, prototype, "setStrokeJoin",
|
|
203
|
+
&JsiSkPaint::setStrokeJoin);
|
|
204
|
+
installHostMethod(runtime, prototype, "setStrokeCap",
|
|
205
|
+
&JsiSkPaint::setStrokeCap);
|
|
206
|
+
installHostMethod(runtime, prototype, "setAntiAlias",
|
|
207
|
+
&JsiSkPaint::setAntiAlias);
|
|
208
|
+
installHostMethod(runtime, prototype, "setDither", &JsiSkPaint::setDither);
|
|
209
|
+
installHostMethod(runtime, prototype, "setStrokeWidth",
|
|
210
|
+
&JsiSkPaint::setStrokeWidth);
|
|
211
|
+
installHostMethod(runtime, prototype, "setStyle", &JsiSkPaint::setStyle);
|
|
212
|
+
installHostMethod(runtime, prototype, "setColor", &JsiSkPaint::setColor);
|
|
213
|
+
installHostMethod(runtime, prototype, "setAlphaf", &JsiSkPaint::setAlphaf);
|
|
214
|
+
}
|
|
200
215
|
|
|
201
216
|
JsiSkPaint(std::shared_ptr<RNSkPlatformContext> context, SkPaint paint)
|
|
202
|
-
:
|
|
217
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkPaint, SkPaint>(
|
|
203
218
|
std::move(context), std::make_shared<SkPaint>(std::move(paint))) {}
|
|
204
219
|
|
|
220
|
+
/**
|
|
221
|
+
Returns the underlying object from a host object of this type
|
|
222
|
+
*/
|
|
223
|
+
static std::shared_ptr<SkPaint> fromValue(jsi::Runtime &runtime,
|
|
224
|
+
const jsi::Value &obj) {
|
|
225
|
+
return objectFromValue(runtime, obj);
|
|
226
|
+
}
|
|
227
|
+
|
|
205
228
|
/**
|
|
206
229
|
Copy from another paint
|
|
207
230
|
*/
|
|
@@ -209,12 +232,10 @@ public:
|
|
|
209
232
|
setObject(std::make_shared<SkPaint>(std::move(paint)));
|
|
210
233
|
}
|
|
211
234
|
|
|
212
|
-
size_t getMemoryPressure()
|
|
235
|
+
size_t getMemoryPressure() override {
|
|
213
236
|
return std::max(sizeof(SkPaint), kMinMemoryPressure);
|
|
214
237
|
}
|
|
215
238
|
|
|
216
|
-
std::string getObjectType() const override { return "JsiSkPaint"; }
|
|
217
|
-
|
|
218
239
|
/**
|
|
219
240
|
* Creates the function for construction a new instance of the SkPaint
|
|
220
241
|
* wrapper
|
|
@@ -228,9 +249,8 @@ public:
|
|
|
228
249
|
auto paint = SkPaint();
|
|
229
250
|
paint.setAntiAlias(true);
|
|
230
251
|
// Return the newly constructed object
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
runtime, hostObjectInstance, context);
|
|
252
|
+
return makeJsiObject(runtime,
|
|
253
|
+
std::make_shared<JsiSkPaint>(context, paint));
|
|
234
254
|
};
|
|
235
255
|
}
|
|
236
256
|
};
|