@shopify/react-native-skia 2.9.1-next.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/android/cpp/jni/JniWebGPUView.cpp +52 -7
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +3 -1
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +11 -5
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +10 -7
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +7 -2
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +1 -1
- package/apple/WebGPUMetalView.mm +49 -6
- 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/JsiSkParagraphStyle.h +20 -10
- 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/JsiSkStrutStyle.h +18 -8
- 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/JsiSkTextStyle.h +34 -24
- 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 +29 -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/SurfaceRegistry.h +469 -131
- package/cpp/rnwgpu/api/GPU.cpp +4 -4
- package/cpp/rnwgpu/api/GPU.h +1 -1
- package/cpp/rnwgpu/api/GPUAdapter.cpp +12 -6
- package/cpp/rnwgpu/api/GPUAdapter.h +5 -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.cpp +12 -2
- package/cpp/rnwgpu/api/GPUBuffer.h +4 -3
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +33 -19
- package/cpp/rnwgpu/api/GPUCanvasContext.h +4 -2
- 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 +38 -24
- package/cpp/rnwgpu/api/GPUDevice.h +12 -10
- 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.cpp +6 -2
- package/cpp/rnwgpu/api/GPUQueue.h +4 -4
- 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 +8 -3
- package/cpp/rnwgpu/api/GPUShaderModule.h +4 -4
- 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 +21 -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/cpp/rnwgpu/async/RuntimeContext.cpp +5 -0
- package/cpp/rnwgpu/async/RuntimeContext.h +15 -2
- 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/commonjs/views/WebGPUCanvas.d.ts +1 -0
- package/lib/commonjs/views/WebGPUCanvas.js +13 -0
- package/lib/commonjs/views/WebGPUCanvas.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/module/views/WebGPUCanvas.d.ts +1 -0
- package/lib/module/views/WebGPUCanvas.js +14 -1
- package/lib/module/views/WebGPUCanvas.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/lib/typescript/src/views/WebGPUCanvas.d.ts +1 -0
- package/package.json +12 -8
- 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/src/views/WebGPUCanvas.tsx +17 -1
- package/cpp/api/JsiSkHostObjects.h +0 -257
- package/cpp/dawn/include/dawn/dawn_proc.h +0 -53
- package/cpp/dawn/include/dawn/dawn_proc_table.h +0 -330
- package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +0 -47
- package/cpp/dawn/include/dawn/dawn_version.h +0 -41
- package/cpp/dawn/include/dawn/native/D3D11Backend.h +0 -65
- package/cpp/dawn/include/dawn/native/D3D12Backend.h +0 -86
- package/cpp/dawn/include/dawn/native/D3DBackend.h +0 -56
- package/cpp/dawn/include/dawn/native/DawnNative.h +0 -369
- package/cpp/dawn/include/dawn/native/MetalBackend.h +0 -56
- package/cpp/dawn/include/dawn/native/NullBackend.h +0 -39
- package/cpp/dawn/include/dawn/native/OpenGLBackend.h +0 -89
- package/cpp/dawn/include/dawn/native/VulkanBackend.h +0 -183
- package/cpp/dawn/include/dawn/native/WebGPUBackend.h +0 -49
- package/cpp/dawn/include/dawn/native/dawn_native_export.h +0 -49
- package/cpp/dawn/include/dawn/platform/DawnPlatform.h +0 -210
- package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +0 -49
- package/cpp/dawn/include/dawn/replay/Replay.h +0 -99
- package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +0 -49
- package/cpp/dawn/include/dawn/webgpu_cpp_print.h +0 -2844
- package/cpp/dawn/include/tint/tint.h +0 -90
- package/cpp/dawn/include/webgpu/webgpu.h +0 -4987
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +0 -10080
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +0 -57
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +0 -161
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +0 -88
- package/cpp/jsi/JsiHostObject.cpp +0 -137
- package/cpp/jsi/JsiHostObject.h +0 -385
- package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +0 -45
- package/cpp/skia/src/gpu/graphite/ResourceTypes.h +0 -360
- package/cpp/skia/src/gpu/graphite/TextureProxyView.h +0 -105
- package/libs/.graphite +0 -1
- /package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -0
- /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
- /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
|
@@ -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,14 +21,18 @@ namespace RNSkia {
|
|
|
21
21
|
namespace jsi = facebook::jsi;
|
|
22
22
|
|
|
23
23
|
class JsiSkRuntimeShaderBuilder
|
|
24
|
-
: public
|
|
24
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkRuntimeShaderBuilder,
|
|
25
|
+
SkRuntimeShaderBuilder> {
|
|
25
26
|
public:
|
|
27
|
+
static constexpr const char *CLASS_NAME = "RuntimeShaderBuilder";
|
|
28
|
+
|
|
26
29
|
/**
|
|
27
30
|
Constructor
|
|
28
31
|
*/
|
|
29
32
|
JsiSkRuntimeShaderBuilder(std::shared_ptr<RNSkPlatformContext> context,
|
|
30
33
|
const SkRuntimeShaderBuilder &rt)
|
|
31
|
-
:
|
|
34
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkRuntimeShaderBuilder,
|
|
35
|
+
SkRuntimeShaderBuilder>(
|
|
32
36
|
std::move(context), std::make_shared<SkRuntimeShaderBuilder>(rt)) {}
|
|
33
37
|
|
|
34
38
|
JSI_HOST_FUNCTION(setUniform) {
|
|
@@ -47,8 +51,19 @@ public:
|
|
|
47
51
|
return jsi::Value::undefined();
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
55
|
+
installCommon(runtime, prototype);
|
|
56
|
+
installHostMethod(runtime, prototype, "setUniform",
|
|
57
|
+
&JsiSkRuntimeShaderBuilder::setUniform);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
Returns the underlying object from a host object of this type
|
|
62
|
+
*/
|
|
63
|
+
static std::shared_ptr<SkRuntimeShaderBuilder>
|
|
64
|
+
fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
65
|
+
return getJsiObject<JsiSkRuntimeShaderBuilder>(runtime, obj)->getObject();
|
|
66
|
+
}
|
|
52
67
|
|
|
53
68
|
/**
|
|
54
69
|
Returns the jsi object from a host object of this type
|
|
@@ -56,20 +71,14 @@ public:
|
|
|
56
71
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
57
72
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
58
73
|
const SkRuntimeShaderBuilder &rt) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, builder,
|
|
62
|
-
context);
|
|
74
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkRuntimeShaderBuilder>(
|
|
75
|
+
std::move(context), rt));
|
|
63
76
|
}
|
|
64
77
|
|
|
65
|
-
size_t getMemoryPressure()
|
|
78
|
+
size_t getMemoryPressure() override {
|
|
66
79
|
return std::max(sizeof(SkRuntimeShaderBuilder), kMinMemoryPressure);
|
|
67
80
|
}
|
|
68
81
|
|
|
69
|
-
std::string getObjectType() const override {
|
|
70
|
-
return "JsiSkRuntimeShaderBuilder";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
82
|
/**
|
|
74
83
|
* Creates the function for construction a new instance of the SkRect
|
|
75
84
|
* wrapper
|
|
@@ -83,10 +92,8 @@ public:
|
|
|
83
92
|
auto rt = JsiSkRuntimeEffect::fromValue(runtime, arguments[0]);
|
|
84
93
|
auto rtb = SkRuntimeShaderBuilder(rt);
|
|
85
94
|
// Return the newly constructed object
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, builder,
|
|
89
|
-
context);
|
|
95
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkRuntimeShaderBuilder>(
|
|
96
|
+
std::move(context), std::move(rtb)));
|
|
90
97
|
};
|
|
91
98
|
}
|
|
92
99
|
};
|
package/cpp/api/JsiSkSVG.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,17 +18,17 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkSVG : public
|
|
21
|
+
class JsiSkSVG : public JsiSkWrappingSkPtrNativeObject<JsiSkSVG, SkSVGDOM> {
|
|
22
22
|
public:
|
|
23
|
+
static constexpr const char *CLASS_NAME = "SVG";
|
|
24
|
+
|
|
23
25
|
JsiSkSVG(std::shared_ptr<RNSkPlatformContext> context, sk_sp<SkSVGDOM> svgdom,
|
|
24
26
|
sk_sp<skresources::ResourceProvider> resourceProvider = nullptr)
|
|
25
|
-
:
|
|
26
|
-
|
|
27
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkSVG, SkSVGDOM>(std::move(context),
|
|
28
|
+
std::move(svgdom)) {}
|
|
27
29
|
|
|
28
30
|
~JsiSkSVG() = default;
|
|
29
31
|
|
|
30
|
-
EXPORT_JSI_API_TYPENAME(JsiSkSVG, SVG)
|
|
31
|
-
|
|
32
32
|
JSI_HOST_FUNCTION(width) {
|
|
33
33
|
return static_cast<double>(getObject()->containerSize().width());
|
|
34
34
|
}
|
|
@@ -37,19 +37,21 @@ public:
|
|
|
37
37
|
return static_cast<double>(getObject()->containerSize().height());
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
41
|
+
installCommon(runtime, prototype);
|
|
42
|
+
installHostMethod(runtime, prototype, "width", &JsiSkSVG::width);
|
|
43
|
+
installHostMethod(runtime, prototype, "height", &JsiSkSVG::height);
|
|
44
|
+
}
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
Returns the underlying object from a host object of this type
|
|
46
48
|
*/
|
|
47
49
|
static sk_sp<SkSVGDOM> fromValue(jsi::Runtime &runtime,
|
|
48
50
|
const jsi::Value &obj) {
|
|
49
|
-
return
|
|
51
|
+
return getJsiObject<JsiSkSVG>(runtime, obj)->getObject();
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
size_t getMemoryPressure()
|
|
54
|
+
size_t getMemoryPressure() override {
|
|
53
55
|
auto svgdom = getObject();
|
|
54
56
|
if (!svgdom) {
|
|
55
57
|
return 1024; // Base size if no SVG
|
|
@@ -72,8 +74,6 @@ public:
|
|
|
72
74
|
return (rasterBufferSize / 4) +
|
|
73
75
|
baseOverhead; // Quarter of full raster + overhead
|
|
74
76
|
}
|
|
75
|
-
|
|
76
|
-
std::string getObjectType() const override { return "JsiSkSVG"; }
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
} // namespace RNSkia
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#include <jsi/jsi.h>
|
|
8
8
|
|
|
9
9
|
#include "JsiSkData.h"
|
|
10
|
-
#include "
|
|
10
|
+
#include "JsiSkNativeObjects.h"
|
|
11
11
|
#include "JsiSkSVG.h"
|
|
12
12
|
#include "JsiSkTypeface.h"
|
|
13
13
|
|
|
@@ -55,8 +55,10 @@ private:
|
|
|
55
55
|
const skresources::ImageDecodeStrategy fStrategy;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
class JsiSkSVGFactory : public
|
|
58
|
+
class JsiSkSVGFactory : public JsiSkNativeObject<JsiSkSVGFactory> {
|
|
59
59
|
public:
|
|
60
|
+
static constexpr const char *CLASS_NAME = "SVGFactory";
|
|
61
|
+
|
|
60
62
|
// Helper function to parse asset map from JS object
|
|
61
63
|
static SVGAssetProvider::AssetMap parseAssetMap(jsi::Runtime &runtime,
|
|
62
64
|
const jsi::Value &jsValue) {
|
|
@@ -83,15 +85,9 @@ public:
|
|
|
83
85
|
continue;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
auto hostObject = jsObject.getHostObject(runtime);
|
|
90
|
-
auto skData = std::dynamic_pointer_cast<JsiSkData>(hostObject);
|
|
91
|
-
if (skData) {
|
|
92
|
-
assets[key] = skData->getObject();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
88
|
+
auto skData = tryGetJsiObject<JsiSkData>(runtime, jsValue);
|
|
89
|
+
if (skData) {
|
|
90
|
+
assets[key] = skData->getObject();
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
|
|
@@ -120,9 +116,8 @@ private:
|
|
|
120
116
|
builder.setResourceProvider(provider);
|
|
121
117
|
|
|
122
118
|
auto svg_dom = builder.make(*stream);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
getContext());
|
|
119
|
+
return makeJsiObject(
|
|
120
|
+
runtime, std::make_shared<JsiSkSVG>(getContext(), std::move(svg_dom)));
|
|
126
121
|
}
|
|
127
122
|
|
|
128
123
|
public:
|
|
@@ -160,15 +155,17 @@ public:
|
|
|
160
155
|
std::move(assets));
|
|
161
156
|
}
|
|
162
157
|
|
|
163
|
-
size_t getMemoryPressure()
|
|
164
|
-
|
|
165
|
-
std::string getObjectType() const override { return "JsiSkSVGFactory"; }
|
|
158
|
+
size_t getMemoryPressure() override { return kMinMemoryPressure; }
|
|
166
159
|
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
161
|
+
installHostMethod(runtime, prototype, "MakeFromData",
|
|
162
|
+
&JsiSkSVGFactory::MakeFromData);
|
|
163
|
+
installHostMethod(runtime, prototype, "MakeFromString",
|
|
164
|
+
&JsiSkSVGFactory::MakeFromString);
|
|
165
|
+
}
|
|
169
166
|
|
|
170
167
|
explicit JsiSkSVGFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
171
|
-
:
|
|
168
|
+
: JsiSkNativeObject<JsiSkSVGFactory>(std::move(context)) {}
|
|
172
169
|
};
|
|
173
170
|
|
|
174
171
|
} // namespace RNSkia
|
package/cpp/api/JsiSkShader.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"
|
|
@@ -19,18 +19,25 @@ namespace RNSkia {
|
|
|
19
19
|
|
|
20
20
|
namespace jsi = facebook::jsi;
|
|
21
21
|
|
|
22
|
-
class JsiSkShader
|
|
22
|
+
class JsiSkShader
|
|
23
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkShader, SkShader> {
|
|
23
24
|
public:
|
|
25
|
+
static constexpr const char *CLASS_NAME = "Shader";
|
|
26
|
+
|
|
24
27
|
JsiSkShader(std::shared_ptr<RNSkPlatformContext> context,
|
|
25
28
|
sk_sp<SkShader> shader)
|
|
26
|
-
:
|
|
27
|
-
|
|
29
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkShader, SkShader>(
|
|
30
|
+
std::move(context), std::move(shader)) {}
|
|
28
31
|
|
|
29
|
-
size_t getMemoryPressure()
|
|
32
|
+
size_t getMemoryPressure() override { return 1024 * 1024; }
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
static sk_sp<SkShader> fromValue(jsi::Runtime &runtime,
|
|
35
|
+
const jsi::Value &obj) {
|
|
36
|
+
return objectFromValue(runtime, obj);
|
|
37
|
+
}
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
40
|
+
installCommon(runtime, prototype);
|
|
41
|
+
}
|
|
35
42
|
};
|
|
36
43
|
} // namespace RNSkia
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#include <jsi/jsi.h>
|
|
8
8
|
|
|
9
9
|
#include "JsiSkColorFilter.h"
|
|
10
|
-
#include "
|
|
10
|
+
#include "JsiSkNativeObjects.h"
|
|
11
11
|
|
|
12
12
|
#pragma clang diagnostic push
|
|
13
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -75,8 +75,10 @@ std::vector<SkScalar> getPositions(jsi::Runtime &runtime,
|
|
|
75
75
|
return positions;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
class JsiSkShaderFactory : public
|
|
78
|
+
class JsiSkShaderFactory : public JsiSkNativeObject<JsiSkShaderFactory> {
|
|
79
79
|
public:
|
|
80
|
+
static constexpr const char *CLASS_NAME = "ShaderFactory";
|
|
81
|
+
|
|
80
82
|
JSI_HOST_FUNCTION(MakeLinearGradient) {
|
|
81
83
|
auto p1 =
|
|
82
84
|
*JsiSkPoint::fromValue(runtime, arguments[0].asObject(runtime)).get();
|
|
@@ -107,10 +109,8 @@ public:
|
|
|
107
109
|
SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(flag));
|
|
108
110
|
sk_sp<SkShader> gradient =
|
|
109
111
|
SkShaders::LinearGradient(pts, grad, localMatrix);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
113
|
-
getContext());
|
|
112
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
113
|
+
getContext(), std::move(gradient)));
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
JSI_HOST_FUNCTION(MakeRadialGradient) {
|
|
@@ -141,10 +141,8 @@ public:
|
|
|
141
141
|
SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(flag));
|
|
142
142
|
sk_sp<SkShader> gradient =
|
|
143
143
|
SkShaders::RadialGradient(center, r, grad, localMatrix);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
147
|
-
getContext());
|
|
144
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
145
|
+
getContext(), std::move(gradient)));
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
JSI_HOST_FUNCTION(MakeSweepGradient) {
|
|
@@ -179,10 +177,8 @@ public:
|
|
|
179
177
|
SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(flag));
|
|
180
178
|
sk_sp<SkShader> gradient = SkShaders::SweepGradient(
|
|
181
179
|
SkPoint::Make(x, y), startAngle, endAngle, grad, localMatrix);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
185
|
-
getContext());
|
|
180
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
181
|
+
getContext(), std::move(gradient)));
|
|
186
182
|
}
|
|
187
183
|
|
|
188
184
|
JSI_HOST_FUNCTION(MakeTwoPointConicalGradient) {
|
|
@@ -218,10 +214,8 @@ public:
|
|
|
218
214
|
sk_sp<SkShader> gradient = SkShaders::TwoPointConicalGradient(
|
|
219
215
|
start, startRadius, end, endRadius, grad, localMatrix);
|
|
220
216
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
224
|
-
getContext());
|
|
217
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
218
|
+
getContext(), std::move(gradient)));
|
|
225
219
|
}
|
|
226
220
|
|
|
227
221
|
JSI_HOST_FUNCTION(MakeTurbulence) {
|
|
@@ -234,10 +228,8 @@ public:
|
|
|
234
228
|
SkISize size = SkISize::Make(tileW, tileH);
|
|
235
229
|
sk_sp<SkShader> gradient =
|
|
236
230
|
SkShaders::MakeTurbulence(baseFreqX, baseFreqY, octaves, seed, &size);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
240
|
-
getContext());
|
|
231
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
232
|
+
getContext(), std::move(gradient)));
|
|
241
233
|
}
|
|
242
234
|
|
|
243
235
|
JSI_HOST_FUNCTION(MakeFractalNoise) {
|
|
@@ -250,10 +242,8 @@ public:
|
|
|
250
242
|
SkISize size = SkISize::Make(tileW, tileH);
|
|
251
243
|
sk_sp<SkShader> gradient =
|
|
252
244
|
SkShaders::MakeFractalNoise(baseFreqX, baseFreqY, octaves, seed, &size);
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
256
|
-
getContext());
|
|
245
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
246
|
+
getContext(), std::move(gradient)));
|
|
257
247
|
}
|
|
258
248
|
|
|
259
249
|
JSI_HOST_FUNCTION(MakeBlend) {
|
|
@@ -261,37 +251,40 @@ public:
|
|
|
261
251
|
auto one = JsiSkShader::fromValue(runtime, arguments[1]);
|
|
262
252
|
auto two = JsiSkShader::fromValue(runtime, arguments[2]);
|
|
263
253
|
sk_sp<SkShader> gradient = SkShaders::Blend(blendMode, one, two);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
267
|
-
getContext());
|
|
254
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
255
|
+
getContext(), std::move(gradient)));
|
|
268
256
|
}
|
|
269
257
|
|
|
270
258
|
JSI_HOST_FUNCTION(MakeColor) {
|
|
271
259
|
auto color = JsiSkColor::fromValue(runtime, arguments[0]);
|
|
272
260
|
sk_sp<SkShader> gradient = SkShaders::Color(color);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
276
|
-
getContext());
|
|
261
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
262
|
+
getContext(), std::move(gradient)));
|
|
277
263
|
}
|
|
278
264
|
|
|
279
|
-
size_t getMemoryPressure()
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
265
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
266
|
+
|
|
267
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
268
|
+
installHostMethod(runtime, prototype, "MakeLinearGradient",
|
|
269
|
+
&JsiSkShaderFactory::MakeLinearGradient);
|
|
270
|
+
installHostMethod(runtime, prototype, "MakeRadialGradient",
|
|
271
|
+
&JsiSkShaderFactory::MakeRadialGradient);
|
|
272
|
+
installHostMethod(runtime, prototype, "MakeSweepGradient",
|
|
273
|
+
&JsiSkShaderFactory::MakeSweepGradient);
|
|
274
|
+
installHostMethod(runtime, prototype, "MakeTwoPointConicalGradient",
|
|
275
|
+
&JsiSkShaderFactory::MakeTwoPointConicalGradient);
|
|
276
|
+
installHostMethod(runtime, prototype, "MakeTurbulence",
|
|
277
|
+
&JsiSkShaderFactory::MakeTurbulence);
|
|
278
|
+
installHostMethod(runtime, prototype, "MakeFractalNoise",
|
|
279
|
+
&JsiSkShaderFactory::MakeFractalNoise);
|
|
280
|
+
installHostMethod(runtime, prototype, "MakeBlend",
|
|
281
|
+
&JsiSkShaderFactory::MakeBlend);
|
|
282
|
+
installHostMethod(runtime, prototype, "MakeColor",
|
|
283
|
+
&JsiSkShaderFactory::MakeColor);
|
|
284
|
+
}
|
|
292
285
|
|
|
293
286
|
explicit JsiSkShaderFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
294
|
-
:
|
|
287
|
+
: JsiSkNativeObject<JsiSkShaderFactory>(std::move(context)) {}
|
|
295
288
|
};
|
|
296
289
|
|
|
297
290
|
} // namespace RNSkia
|
package/cpp/api/JsiSkSkottie.h
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#include "JsiSkCanvas.h"
|
|
6
6
|
#include "JsiSkColor.h"
|
|
7
|
-
#include "
|
|
7
|
+
#include "JsiSkNativeObjects.h"
|
|
8
8
|
#include "JsiSkPoint.h"
|
|
9
9
|
#include "JsiSkRect.h"
|
|
10
10
|
#include "api/third_party/SkottieUtils.h"
|
|
@@ -146,8 +146,12 @@ public:
|
|
|
146
146
|
std::unique_ptr<CustomPropertyManager> _propManager = nullptr;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
class JsiSkSkottie
|
|
149
|
+
class JsiSkSkottie
|
|
150
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkSkottie,
|
|
151
|
+
ManagedAnimation> {
|
|
150
152
|
public:
|
|
153
|
+
static constexpr const char *CLASS_NAME = "Skottie";
|
|
154
|
+
|
|
151
155
|
// #region Properties
|
|
152
156
|
JSI_HOST_FUNCTION(duration) {
|
|
153
157
|
return static_cast<double>(getObject()->_animation->duration());
|
|
@@ -155,12 +159,6 @@ public:
|
|
|
155
159
|
JSI_HOST_FUNCTION(fps) {
|
|
156
160
|
return static_cast<double>(getObject()->_animation->fps());
|
|
157
161
|
}
|
|
158
|
-
|
|
159
|
-
JSI_PROPERTY_GET(__typename__) {
|
|
160
|
-
return jsi::String::createFromUtf8(runtime, "Skottie");
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkSkottie, __typename__))
|
|
164
162
|
// #endregion
|
|
165
163
|
|
|
166
164
|
// #region Methods
|
|
@@ -186,10 +184,7 @@ public:
|
|
|
186
184
|
}
|
|
187
185
|
|
|
188
186
|
JSI_HOST_FUNCTION(render) {
|
|
189
|
-
auto canvas = arguments[0]
|
|
190
|
-
.asObject(runtime)
|
|
191
|
-
.asHostObject<JsiSkCanvas>(runtime)
|
|
192
|
-
->getCanvas();
|
|
187
|
+
auto canvas = getJsiObject<JsiSkCanvas>(runtime, arguments[0])->getCanvas();
|
|
193
188
|
if (count > 1) {
|
|
194
189
|
auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
|
|
195
190
|
getObject()->_animation->render(canvas, rect.get());
|
|
@@ -554,29 +549,46 @@ public:
|
|
|
554
549
|
return transformProps;
|
|
555
550
|
}
|
|
556
551
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
552
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
553
|
+
installCommon(runtime, prototype);
|
|
554
|
+
installHostMethod(runtime, prototype, "duration", &JsiSkSkottie::duration);
|
|
555
|
+
installHostMethod(runtime, prototype, "fps", &JsiSkSkottie::fps);
|
|
556
|
+
installHostMethod(runtime, prototype, "seekFrame",
|
|
557
|
+
&JsiSkSkottie::seekFrame);
|
|
558
|
+
installHostMethod(runtime, prototype, "render", &JsiSkSkottie::render);
|
|
559
|
+
installHostMethod(runtime, prototype, "size", &JsiSkSkottie::size);
|
|
560
|
+
installHostMethod(runtime, prototype, "version", &JsiSkSkottie::version);
|
|
561
|
+
installHostMethod(runtime, prototype, "getSlotInfo",
|
|
562
|
+
&JsiSkSkottie::getSlotInfo);
|
|
563
|
+
installHostMethod(runtime, prototype, "setColorSlot",
|
|
564
|
+
&JsiSkSkottie::setColorSlot);
|
|
565
|
+
installHostMethod(runtime, prototype, "setScalarSlot",
|
|
566
|
+
&JsiSkSkottie::setScalarSlot);
|
|
567
|
+
installHostMethod(runtime, prototype, "setVec2Slot",
|
|
568
|
+
&JsiSkSkottie::setVec2Slot);
|
|
569
|
+
installHostMethod(runtime, prototype, "setTextSlot",
|
|
570
|
+
&JsiSkSkottie::setTextSlot);
|
|
571
|
+
installHostMethod(runtime, prototype, "setImageSlot",
|
|
572
|
+
&JsiSkSkottie::setImageSlot);
|
|
573
|
+
installHostMethod(runtime, prototype, "getColorSlot",
|
|
574
|
+
&JsiSkSkottie::getColorSlot);
|
|
575
|
+
installHostMethod(runtime, prototype, "getScalarSlot",
|
|
576
|
+
&JsiSkSkottie::getScalarSlot);
|
|
577
|
+
installHostMethod(runtime, prototype, "getVec2Slot",
|
|
578
|
+
&JsiSkSkottie::getVec2Slot);
|
|
579
|
+
installHostMethod(runtime, prototype, "getTextSlot",
|
|
580
|
+
&JsiSkSkottie::getTextSlot);
|
|
581
|
+
installHostMethod(runtime, prototype, "getColorProps",
|
|
582
|
+
&JsiSkSkottie::getColorProps);
|
|
583
|
+
installHostMethod(runtime, prototype, "getOpacityProps",
|
|
584
|
+
&JsiSkSkottie::getOpacityProps);
|
|
585
|
+
installHostMethod(runtime, prototype, "getTransformProps",
|
|
586
|
+
&JsiSkSkottie::getTransformProps);
|
|
587
|
+
installHostMethod(runtime, prototype, "getTextProps",
|
|
588
|
+
&JsiSkSkottie::getTextProps);
|
|
589
|
+
installHostMethod(runtime, prototype, "setColor", &JsiSkSkottie::setColor);
|
|
590
|
+
installHostMethod(runtime, prototype, "setText", &JsiSkSkottie::setText);
|
|
591
|
+
}
|
|
580
592
|
// #endregion
|
|
581
593
|
|
|
582
594
|
/**
|
|
@@ -584,10 +596,10 @@ public:
|
|
|
584
596
|
*/
|
|
585
597
|
JsiSkSkottie(std::shared_ptr<RNSkPlatformContext> context,
|
|
586
598
|
std::shared_ptr<ManagedAnimation> animation)
|
|
587
|
-
:
|
|
599
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkSkottie, ManagedAnimation>(
|
|
588
600
|
std::move(context), std::move(animation)) {}
|
|
589
601
|
|
|
590
|
-
size_t getMemoryPressure()
|
|
602
|
+
size_t getMemoryPressure() override {
|
|
591
603
|
auto animation = getObject();
|
|
592
604
|
if (!animation || !animation->_animation) {
|
|
593
605
|
return 1024; // Base size if no animation
|
|
@@ -615,7 +627,5 @@ public:
|
|
|
615
627
|
|
|
616
628
|
return animationMemory + baseOverhead;
|
|
617
629
|
}
|
|
618
|
-
|
|
619
|
-
std::string getObjectType() const override { return "JsiSkSkottie"; }
|
|
620
630
|
};
|
|
621
631
|
} // namespace RNSkia
|
|
@@ -32,6 +32,16 @@ bool asBool(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
|
32
32
|
*/
|
|
33
33
|
class JsiSkStrutStyle {
|
|
34
34
|
public:
|
|
35
|
+
// A property set to undefined or null is treated as absent, like on web.
|
|
36
|
+
static bool hasValue(jsi::Runtime &runtime, const jsi::Object &object,
|
|
37
|
+
const char *name) {
|
|
38
|
+
if (!object.hasProperty(runtime, name)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
auto propValue = object.getProperty(runtime, name);
|
|
42
|
+
return !propValue.isUndefined() && !propValue.isNull();
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
static para::StrutStyle fromValue(jsi::Runtime &runtime,
|
|
36
46
|
const jsi::Value &value) {
|
|
37
47
|
// Read values from the argument - expected to be a TextStyle shaped object
|
|
@@ -52,11 +62,11 @@ public:
|
|
|
52
62
|
|
|
53
63
|
para::StrutStyle retVal;
|
|
54
64
|
|
|
55
|
-
if (
|
|
65
|
+
if (hasValue(runtime, object, "strutEnabled")) {
|
|
56
66
|
auto propValue = object.getProperty(runtime, "strutEnabled");
|
|
57
67
|
retVal.setStrutEnabled(asBool(runtime, propValue));
|
|
58
68
|
}
|
|
59
|
-
if (
|
|
69
|
+
if (hasValue(runtime, object, "fontFamilies")) {
|
|
60
70
|
auto propValue = object.getProperty(runtime, "fontFamilies")
|
|
61
71
|
.asObject(runtime)
|
|
62
72
|
.asArray(runtime);
|
|
@@ -70,28 +80,28 @@ public:
|
|
|
70
80
|
}
|
|
71
81
|
}
|
|
72
82
|
|
|
73
|
-
if (
|
|
83
|
+
if (hasValue(runtime, object, "fontStyle")) {
|
|
74
84
|
auto propValue = object.getProperty(runtime, "fontStyle");
|
|
75
85
|
retVal.setFontStyle(*JsiSkFontStyle::fromValue(runtime, propValue).get());
|
|
76
86
|
}
|
|
77
|
-
if (
|
|
87
|
+
if (hasValue(runtime, object, "fontSize")) {
|
|
78
88
|
auto propValue = object.getProperty(runtime, "fontSize");
|
|
79
89
|
retVal.setFontSize(propValue.asNumber());
|
|
80
90
|
}
|
|
81
|
-
if (
|
|
91
|
+
if (hasValue(runtime, object, "heightMultiplier")) {
|
|
82
92
|
auto propValue = object.getProperty(runtime, "heightMultiplier");
|
|
83
93
|
retVal.setHeight(propValue.asNumber());
|
|
84
94
|
retVal.setHeightOverride(true);
|
|
85
95
|
}
|
|
86
|
-
if (
|
|
96
|
+
if (hasValue(runtime, object, "halfLeading")) {
|
|
87
97
|
auto propValue = object.getProperty(runtime, "halfLeading");
|
|
88
98
|
retVal.setHalfLeading(asBool(runtime, propValue));
|
|
89
99
|
}
|
|
90
|
-
if (
|
|
100
|
+
if (hasValue(runtime, object, "leading")) {
|
|
91
101
|
auto propValue = object.getProperty(runtime, "leading");
|
|
92
102
|
retVal.setLeading(propValue.asNumber());
|
|
93
103
|
}
|
|
94
|
-
if (
|
|
104
|
+
if (hasValue(runtime, object, "forceStrutHeight")) {
|
|
95
105
|
auto propValue = object.getProperty(runtime, "forceStrutHeight");
|
|
96
106
|
retVal.setForceStrutHeight(asBool(runtime, propValue));
|
|
97
107
|
}
|