@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/JsiSkImageInfo.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,11 +18,14 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkImageInfo
|
|
21
|
+
class JsiSkImageInfo
|
|
22
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkImageInfo, SkImageInfo> {
|
|
22
23
|
public:
|
|
24
|
+
static constexpr const char *CLASS_NAME = "ImageInfo";
|
|
25
|
+
|
|
23
26
|
JsiSkImageInfo(std::shared_ptr<RNSkPlatformContext> context,
|
|
24
27
|
const SkImageInfo &imageInfo)
|
|
25
|
-
:
|
|
28
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkImageInfo, SkImageInfo>(
|
|
26
29
|
std::move(context), std::make_shared<SkImageInfo>(imageInfo)) {}
|
|
27
30
|
|
|
28
31
|
/**
|
|
@@ -31,8 +34,9 @@ public:
|
|
|
31
34
|
static std::shared_ptr<SkImageInfo> fromValue(jsi::Runtime &runtime,
|
|
32
35
|
const jsi::Value &obj) {
|
|
33
36
|
const auto &object = obj.asObject(runtime);
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
auto imageInfo = tryGetJsiObject<JsiSkImageInfo>(runtime, object);
|
|
38
|
+
if (imageInfo) {
|
|
39
|
+
return imageInfo->getObject();
|
|
36
40
|
} else {
|
|
37
41
|
auto width = object.getProperty(runtime, "width").asNumber();
|
|
38
42
|
auto height = object.getProperty(runtime, "height").asNumber();
|
|
@@ -52,10 +56,8 @@ public:
|
|
|
52
56
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
53
57
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
54
58
|
const SkImageInfo &imageInfo) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, imageInfoObj,
|
|
58
|
-
context);
|
|
59
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkImageInfo>(
|
|
60
|
+
std::move(context), imageInfo));
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
JSI_PROPERTY_GET(width) { return static_cast<double>(getObject()->width()); }
|
|
@@ -69,18 +71,19 @@ public:
|
|
|
69
71
|
return static_cast<double>(getObject()->alphaType());
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
size_t getMemoryPressure()
|
|
74
|
+
size_t getMemoryPressure() override {
|
|
73
75
|
return std::max(sizeof(SkImageInfo), kMinMemoryPressure);
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
79
|
+
installCommon(runtime, prototype);
|
|
80
|
+
installHostGetter(runtime, prototype, "width", &JsiSkImageInfo::get_width);
|
|
81
|
+
installHostGetter(runtime, prototype, "height",
|
|
82
|
+
&JsiSkImageInfo::get_height);
|
|
83
|
+
installHostGetter(runtime, prototype, "colorType",
|
|
84
|
+
&JsiSkImageInfo::get_colorType);
|
|
85
|
+
installHostGetter(runtime, prototype, "alphaType",
|
|
86
|
+
&JsiSkImageInfo::get_alphaType);
|
|
87
|
+
}
|
|
85
88
|
};
|
|
86
89
|
} // namespace RNSkia
|
|
@@ -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,19 +18,29 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkMaskFilter
|
|
21
|
+
class JsiSkMaskFilter
|
|
22
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkMaskFilter, SkMaskFilter> {
|
|
22
23
|
public:
|
|
24
|
+
static constexpr const char *CLASS_NAME = "MaskFilter";
|
|
25
|
+
|
|
23
26
|
JsiSkMaskFilter(std::shared_ptr<RNSkPlatformContext> context,
|
|
24
27
|
sk_sp<SkMaskFilter> maskFilter)
|
|
25
|
-
:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
size_t getMemoryPressure()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkMaskFilter, SkMaskFilter>(
|
|
29
|
+
std::move(context), std::move(maskFilter)) {}
|
|
30
|
+
|
|
31
|
+
size_t getMemoryPressure() override { return 2048; }
|
|
32
|
+
|
|
33
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
34
|
+
installCommon(runtime, prototype);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
Returns the underlying object from a host object of this type
|
|
39
|
+
*/
|
|
40
|
+
static sk_sp<SkMaskFilter> fromValue(jsi::Runtime &runtime,
|
|
41
|
+
const jsi::Value &obj) {
|
|
42
|
+
return objectFromValue(runtime, obj);
|
|
43
|
+
}
|
|
34
44
|
};
|
|
35
45
|
|
|
36
46
|
} // namespace RNSkia
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
8
|
#include "JsiSkColorFilter.h"
|
|
9
|
-
#include "
|
|
9
|
+
#include "JsiSkMaskFilter.h"
|
|
10
|
+
#include "JsiSkNativeObjects.h"
|
|
10
11
|
|
|
11
12
|
#pragma clang diagnostic push
|
|
12
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -19,29 +20,31 @@ namespace RNSkia {
|
|
|
19
20
|
|
|
20
21
|
namespace jsi = facebook::jsi;
|
|
21
22
|
|
|
22
|
-
class JsiSkMaskFilterFactory
|
|
23
|
+
class JsiSkMaskFilterFactory
|
|
24
|
+
: public JsiSkNativeObject<JsiSkMaskFilterFactory> {
|
|
23
25
|
public:
|
|
26
|
+
static constexpr const char *CLASS_NAME = "MaskFilterFactory";
|
|
27
|
+
|
|
24
28
|
JSI_HOST_FUNCTION(MakeBlur) {
|
|
25
29
|
int blurStyle = arguments[0].asNumber();
|
|
26
30
|
float sigma = arguments[1].asNumber();
|
|
27
31
|
bool respectCTM = arguments[2].getBool();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
return makeJsiObject(
|
|
33
|
+
runtime,
|
|
34
|
+
std::make_shared<JsiSkMaskFilter>(
|
|
35
|
+
getContext(),
|
|
36
|
+
SkMaskFilter::MakeBlur((SkBlurStyle)blurStyle, sigma, respectCTM)));
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
size_t getMemoryPressure()
|
|
39
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
42
|
+
installHostMethod(runtime, prototype, "MakeBlur",
|
|
43
|
+
&JsiSkMaskFilterFactory::MakeBlur);
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMaskFilterFactory, MakeBlur))
|
|
42
|
-
|
|
43
46
|
explicit JsiSkMaskFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
44
|
-
:
|
|
47
|
+
: JsiSkNativeObject<JsiSkMaskFilterFactory>(std::move(context)) {}
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
} // namespace RNSkia
|
package/cpp/api/JsiSkMatrix.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,10 +18,13 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkMatrix
|
|
21
|
+
class JsiSkMatrix
|
|
22
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkMatrix, SkMatrix> {
|
|
22
23
|
public:
|
|
24
|
+
static constexpr const char *CLASS_NAME = "Matrix";
|
|
25
|
+
|
|
23
26
|
JsiSkMatrix(std::shared_ptr<RNSkPlatformContext> context, SkMatrix m)
|
|
24
|
-
:
|
|
27
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkMatrix, SkMatrix>(
|
|
25
28
|
context, std::make_shared<SkMatrix>(std::move(m))) {}
|
|
26
29
|
|
|
27
30
|
static SkMatrix getMatrix(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
@@ -57,10 +60,9 @@ public:
|
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
JSI_HOST_FUNCTION(concat) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
getObject()->preConcat(*m3);
|
|
63
|
+
auto matrix = tryGetJsiObject<JsiSkMatrix>(runtime, arguments[0]);
|
|
64
|
+
if (matrix) {
|
|
65
|
+
getObject()->preConcat(*matrix->getObject());
|
|
64
66
|
} else {
|
|
65
67
|
auto m3 = JsiSkMatrix::getMatrix(runtime, arguments[0]);
|
|
66
68
|
getObject()->preConcat(m3);
|
|
@@ -138,40 +140,40 @@ public:
|
|
|
138
140
|
}
|
|
139
141
|
#pragma clang diagnostic pop
|
|
140
142
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
144
|
+
installCommon(runtime, prototype);
|
|
145
|
+
installHostMethod(runtime, prototype, "concat", &JsiSkMatrix::concat);
|
|
146
|
+
installHostMethod(runtime, prototype, "translate", &JsiSkMatrix::translate);
|
|
147
|
+
installHostMethod(runtime, prototype, "postTranslate",
|
|
148
|
+
&JsiSkMatrix::postTranslate);
|
|
149
|
+
installHostMethod(runtime, prototype, "scale", &JsiSkMatrix::scale);
|
|
150
|
+
installHostMethod(runtime, prototype, "postScale", &JsiSkMatrix::postScale);
|
|
151
|
+
installHostMethod(runtime, prototype, "skew", &JsiSkMatrix::skew);
|
|
152
|
+
installHostMethod(runtime, prototype, "postSkew", &JsiSkMatrix::postSkew);
|
|
153
|
+
installHostMethod(runtime, prototype, "rotate", &JsiSkMatrix::rotate);
|
|
154
|
+
installHostMethod(runtime, prototype, "postRotate",
|
|
155
|
+
&JsiSkMatrix::postRotate);
|
|
156
|
+
installHostMethod(runtime, prototype, "identity", &JsiSkMatrix::identity);
|
|
157
|
+
installHostMethod(runtime, prototype, "get", &JsiSkMatrix::get);
|
|
158
|
+
}
|
|
155
159
|
|
|
156
160
|
/**
|
|
157
161
|
* Returns the underlying object from a host object of this type
|
|
158
162
|
*/
|
|
159
163
|
static std::shared_ptr<SkMatrix> fromValue(jsi::Runtime &runtime,
|
|
160
164
|
const jsi::Value &obj) {
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
return
|
|
165
|
+
auto matrix = tryGetJsiObject<JsiSkMatrix>(runtime, obj);
|
|
166
|
+
if (matrix) {
|
|
167
|
+
return matrix->getObject();
|
|
164
168
|
} else {
|
|
165
169
|
return std::make_shared<SkMatrix>(JsiSkMatrix::getMatrix(runtime, obj));
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
size_t getMemoryPressure()
|
|
173
|
+
size_t getMemoryPressure() override {
|
|
170
174
|
return std::max(sizeof(SkMatrix), kMinMemoryPressure);
|
|
171
175
|
}
|
|
172
176
|
|
|
173
|
-
std::string getObjectType() const override { return "JsiSkMatrix"; }
|
|
174
|
-
|
|
175
177
|
static const jsi::HostFunctionType
|
|
176
178
|
createCtor(std::shared_ptr<RNSkPlatformContext> context) {
|
|
177
179
|
return JSI_HOST_FUNCTION_LAMBDA {
|
|
@@ -181,10 +183,8 @@ public:
|
|
|
181
183
|
} else {
|
|
182
184
|
matrix = SkMatrix::I();
|
|
183
185
|
}
|
|
184
|
-
|
|
185
|
-
std::make_shared<JsiSkMatrix>(context, std::move(matrix));
|
|
186
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
187
|
-
runtime, hostObjectInstance, context);
|
|
186
|
+
return makeJsiObject(
|
|
187
|
+
runtime, std::make_shared<JsiSkMatrix>(context, std::move(matrix)));
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
};
|