@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
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
8
|
#include "JsiSkFontStyle.h"
|
|
9
|
-
#include "
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
#include "JsiSkTypeface.h"
|
|
11
11
|
|
|
12
12
|
#include "utils/RNSkLog.h"
|
|
@@ -25,16 +25,10 @@ namespace jsi = facebook::jsi;
|
|
|
25
25
|
namespace para = skia::textlayout;
|
|
26
26
|
|
|
27
27
|
class JsiSkTypefaceFontProvider
|
|
28
|
-
: public
|
|
28
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkTypefaceFontProvider,
|
|
29
|
+
para::TypefaceFontProvider> {
|
|
29
30
|
public:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
JSI_EXPORT_FUNCTIONS(
|
|
33
|
-
JSI_EXPORT_FUNC(JsiSkTypefaceFontProvider, dispose),
|
|
34
|
-
JSI_EXPORT_FUNC(JsiSkTypefaceFontProvider, registerFont),
|
|
35
|
-
JSI_EXPORT_FUNC(JsiSkTypefaceFontProvider, matchFamilyStyle),
|
|
36
|
-
JSI_EXPORT_FUNC(JsiSkTypefaceFontProvider, countFamilies),
|
|
37
|
-
JSI_EXPORT_FUNC(JsiSkTypefaceFontProvider, getFamilyName))
|
|
31
|
+
static constexpr const char *CLASS_NAME = "TypefaceFontProvider";
|
|
38
32
|
|
|
39
33
|
JSI_HOST_FUNCTION(registerFont) {
|
|
40
34
|
sk_sp<SkTypeface> typeface =
|
|
@@ -59,10 +53,8 @@ public:
|
|
|
59
53
|
if (!typeface) {
|
|
60
54
|
throw std::runtime_error("Could not find font style for " + name);
|
|
61
55
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
65
|
-
runtime, hostObjectInstance, getContext());
|
|
56
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkTypeface>(
|
|
57
|
+
getContext(), std::move(typeface)));
|
|
66
58
|
}
|
|
67
59
|
|
|
68
60
|
JSI_HOST_FUNCTION(countFamilies) { return getObject()->countFamilies(); }
|
|
@@ -76,14 +68,11 @@ public:
|
|
|
76
68
|
|
|
77
69
|
JsiSkTypefaceFontProvider(std::shared_ptr<RNSkPlatformContext> context,
|
|
78
70
|
sk_sp<para::TypefaceFontProvider> tfProvider)
|
|
79
|
-
:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
size_t getMemoryPressure() const override { return 4096; }
|
|
71
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkTypefaceFontProvider,
|
|
72
|
+
para::TypefaceFontProvider>(
|
|
73
|
+
std::move(context), std::move(tfProvider)) {}
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
return "JsiSkTypefaceFontProvider";
|
|
86
|
-
}
|
|
75
|
+
size_t getMemoryPressure() override { return 4096; }
|
|
87
76
|
|
|
88
77
|
/**
|
|
89
78
|
Returns the jsi object from a host object of this type
|
|
@@ -91,10 +80,26 @@ public:
|
|
|
91
80
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
92
81
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
93
82
|
sk_sp<para::TypefaceFontProvider> tfProvider) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
return makeJsiObject(runtime,
|
|
84
|
+
std::make_shared<JsiSkTypefaceFontProvider>(
|
|
85
|
+
std::move(context), std::move(tfProvider)));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static sk_sp<para::TypefaceFontProvider> fromValue(jsi::Runtime &runtime,
|
|
89
|
+
const jsi::Value &obj) {
|
|
90
|
+
return objectFromValue(runtime, obj);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
94
|
+
installCommon(runtime, prototype);
|
|
95
|
+
installHostMethod(runtime, prototype, "registerFont",
|
|
96
|
+
&JsiSkTypefaceFontProvider::registerFont);
|
|
97
|
+
installHostMethod(runtime, prototype, "matchFamilyStyle",
|
|
98
|
+
&JsiSkTypefaceFontProvider::matchFamilyStyle);
|
|
99
|
+
installHostMethod(runtime, prototype, "countFamilies",
|
|
100
|
+
&JsiSkTypefaceFontProvider::countFamilies);
|
|
101
|
+
installHostMethod(runtime, prototype, "getFamilyName",
|
|
102
|
+
&JsiSkTypefaceFontProvider::getFamilyName);
|
|
98
103
|
}
|
|
99
104
|
};
|
|
100
105
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
8
|
#include "JsiSkData.h"
|
|
9
|
-
#include "
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
#include "JsiSkTypefaceFontProvider.h"
|
|
11
11
|
|
|
12
12
|
namespace RNSkia {
|
|
@@ -14,26 +14,28 @@ namespace RNSkia {
|
|
|
14
14
|
namespace jsi = facebook::jsi;
|
|
15
15
|
namespace para = skia::textlayout;
|
|
16
16
|
|
|
17
|
-
class JsiSkTypefaceFontProviderFactory
|
|
17
|
+
class JsiSkTypefaceFontProviderFactory
|
|
18
|
+
: public JsiSkNativeObject<JsiSkTypefaceFontProviderFactory> {
|
|
18
19
|
public:
|
|
20
|
+
static constexpr const char *CLASS_NAME = "TypefaceFontProviderFactory";
|
|
21
|
+
|
|
19
22
|
JSI_HOST_FUNCTION(Make) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
getContext());
|
|
23
|
+
return makeJsiObject(
|
|
24
|
+
runtime, std::make_shared<JsiSkTypefaceFontProvider>(
|
|
25
|
+
getContext(), sk_make_sp<para::TypefaceFontProvider>()));
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
size_t getMemoryPressure() const override { return 2048; }
|
|
28
|
+
size_t getMemoryPressure() override { return 2048; }
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
31
|
+
installHostMethod(runtime, prototype, "Make",
|
|
32
|
+
&JsiSkTypefaceFontProviderFactory::Make);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
explicit JsiSkTypefaceFontProviderFactory(
|
|
35
36
|
std::shared_ptr<RNSkPlatformContext> context)
|
|
36
|
-
:
|
|
37
|
+
: JsiSkNativeObject<JsiSkTypefaceFontProviderFactory>(
|
|
38
|
+
std::move(context)) {}
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
} // namespace RNSkia
|
package/cpp/api/JsiSkVertices.h
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#include <utility>
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
9
9
|
|
|
10
10
|
#pragma clang diagnostic push
|
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -18,27 +18,27 @@ namespace RNSkia {
|
|
|
18
18
|
|
|
19
19
|
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class JsiSkVertices
|
|
21
|
+
class JsiSkVertices
|
|
22
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkVertices, SkVertices> {
|
|
22
23
|
public:
|
|
24
|
+
static constexpr const char *CLASS_NAME = "Vertices";
|
|
25
|
+
|
|
23
26
|
JsiSkVertices(std::shared_ptr<RNSkPlatformContext> context,
|
|
24
27
|
sk_sp<SkVertices> vertices)
|
|
25
|
-
:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
EXPORT_JSI_API_TYPENAME(JsiSkVertices, Vertices)
|
|
28
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkVertices, SkVertices>(
|
|
29
|
+
std::move(context), std::move(vertices)) {}
|
|
29
30
|
|
|
30
31
|
JSI_HOST_FUNCTION(bounds) {
|
|
31
32
|
const auto &result = getObject()->bounds();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
runtime, hostObjectInstance, getContext());
|
|
33
|
+
return makeJsiObject(runtime,
|
|
34
|
+
std::make_shared<JsiSkRect>(getContext(), result));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
JSI_HOST_FUNCTION(uniqueID) {
|
|
38
38
|
return static_cast<double>(getObject()->uniqueID());
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
size_t getMemoryPressure()
|
|
41
|
+
size_t getMemoryPressure() override {
|
|
42
42
|
auto vertices = getObject();
|
|
43
43
|
if (!vertices)
|
|
44
44
|
return 0;
|
|
@@ -47,11 +47,16 @@ public:
|
|
|
47
47
|
return vertices->approximateSize();
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
static sk_sp<SkVertices> fromValue(jsi::Runtime &runtime,
|
|
51
|
+
const jsi::Value &obj) {
|
|
52
|
+
return objectFromValue(runtime, obj);
|
|
53
|
+
}
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
56
|
+
installCommon(runtime, prototype);
|
|
57
|
+
installHostMethod(runtime, prototype, "bounds", &JsiSkVertices::bounds);
|
|
58
|
+
installHostMethod(runtime, prototype, "uniqueID", &JsiSkVertices::uniqueID);
|
|
59
|
+
}
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
62
|
* Creates the function for construction a new instance of the SkVertices
|
|
@@ -158,10 +163,8 @@ public:
|
|
|
158
163
|
texs.size() > 0 ? texs.data() : nullptr,
|
|
159
164
|
colors.size() > 0 ? colors.data() : nullptr,
|
|
160
165
|
indicesSize, indices.data());
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
164
|
-
runtime, hostObjectInstance, context);
|
|
166
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkVertices>(
|
|
167
|
+
context, std::move(vertices)));
|
|
165
168
|
};
|
|
166
169
|
}
|
|
167
170
|
};
|
package/cpp/api/JsiSkiaContext.h
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#include <utility>
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
9
9
|
#include "utils/RNSkLog.h"
|
|
10
10
|
#include <jsi/jsi.h>
|
|
11
11
|
|
|
@@ -28,19 +28,18 @@ namespace RNSkia {
|
|
|
28
28
|
|
|
29
29
|
namespace jsi = facebook::jsi;
|
|
30
30
|
|
|
31
|
-
class JsiSkiaContext
|
|
31
|
+
class JsiSkiaContext
|
|
32
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkiaContext, WindowContext> {
|
|
32
33
|
public:
|
|
33
|
-
|
|
34
|
+
static constexpr const char *CLASS_NAME = "SkiaContext";
|
|
34
35
|
|
|
35
36
|
JSI_HOST_FUNCTION(getSurface) {
|
|
36
37
|
auto surface = getObject()->getSurface();
|
|
37
38
|
if (surface == nullptr) {
|
|
38
39
|
return jsi::Value::null();
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
43
|
-
runtime, hostObjectInstance, getContext());
|
|
41
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkSurface>(
|
|
42
|
+
getContext(), std::move(surface)));
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
JSI_HOST_FUNCTION(present) {
|
|
@@ -48,16 +47,19 @@ public:
|
|
|
48
47
|
return jsi::Value::undefined();
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
51
|
+
installCommon(runtime, prototype);
|
|
52
|
+
installHostMethod(runtime, prototype, "getSurface",
|
|
53
|
+
&JsiSkiaContext::getSurface);
|
|
54
|
+
installHostMethod(runtime, prototype, "present", &JsiSkiaContext::present);
|
|
55
|
+
}
|
|
53
56
|
|
|
54
57
|
JsiSkiaContext(std::shared_ptr<RNSkPlatformContext> context,
|
|
55
58
|
std::shared_ptr<WindowContext> ctx)
|
|
56
|
-
:
|
|
57
|
-
|
|
58
|
-
size_t getMemoryPressure() const override { return 10 * 1024 * 1024; }
|
|
59
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkiaContext, WindowContext>(
|
|
60
|
+
std::move(context), std::move(ctx)) {}
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
size_t getMemoryPressure() override { return 10 * 1024 * 1024; }
|
|
61
63
|
|
|
62
64
|
/**
|
|
63
65
|
* Creates the function for construction a new instance of the SkFont
|
|
@@ -84,10 +86,8 @@ public:
|
|
|
84
86
|
"Couldn't create a Skia context from the native surface");
|
|
85
87
|
}
|
|
86
88
|
// Return the newly constructed object
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
90
|
-
runtime, hostObjectInstance, context);
|
|
89
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkiaContext>(
|
|
90
|
+
context, std::move(result)));
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
};
|
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
8
9
|
#include "JsiSkSkottie.h"
|
|
9
10
|
|
|
10
11
|
namespace RNSkia {
|
|
11
12
|
|
|
12
13
|
namespace jsi = facebook::jsi;
|
|
13
14
|
|
|
14
|
-
class JsiSkottieFactory : public
|
|
15
|
+
class JsiSkottieFactory : public JsiSkNativeObject<JsiSkottieFactory> {
|
|
15
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "SkottieFactory";
|
|
18
|
+
|
|
16
19
|
JSI_HOST_FUNCTION(Make) {
|
|
17
20
|
auto fontMgr = JsiSkFontMgrFactory::getFontMgr(getContext());
|
|
18
21
|
auto json = arguments[0].asString(runtime).utf8(runtime);
|
|
@@ -34,13 +37,10 @@ public:
|
|
|
34
37
|
auto jsObject = jsValue.asObject(runtime);
|
|
35
38
|
|
|
36
39
|
// Check if the object is a SkData host object
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
std::string k = key;
|
|
42
|
-
assets[k] = skData->getObject();
|
|
43
|
-
}
|
|
40
|
+
auto skData = tryGetJsiObject<JsiSkData>(runtime, jsObject);
|
|
41
|
+
if (skData) {
|
|
42
|
+
std::string k = key;
|
|
43
|
+
assets[k] = skData->getObject();
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -51,20 +51,19 @@ public:
|
|
|
51
51
|
if (!managedAnimation->_animation) {
|
|
52
52
|
return jsi::Value::null();
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
getContext());
|
|
54
|
+
return makeJsiObject(
|
|
55
|
+
runtime, std::make_shared<JsiSkSkottie>(getContext(),
|
|
56
|
+
std::move(managedAnimation)));
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
size_t getMemoryPressure() const override { return 4096; }
|
|
59
|
+
size_t getMemoryPressure() override { return 4096; }
|
|
63
60
|
|
|
64
|
-
|
|
61
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
62
|
+
installHostMethod(runtime, prototype, "Make", &JsiSkottieFactory::Make);
|
|
63
|
+
}
|
|
65
64
|
|
|
66
65
|
explicit JsiSkottieFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
67
|
-
:
|
|
66
|
+
: JsiSkNativeObject<JsiSkottieFactory>(std::move(context)) {}
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
} // namespace RNSkia
|
package/cpp/api/JsiVideo.h
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#include <utility>
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
9
9
|
#include "utils/RNSkLog.h"
|
|
10
10
|
#include <jsi/jsi.h>
|
|
11
11
|
|
|
@@ -28,9 +28,10 @@ namespace RNSkia {
|
|
|
28
28
|
|
|
29
29
|
namespace jsi = facebook::jsi;
|
|
30
30
|
|
|
31
|
-
class JsiVideo
|
|
31
|
+
class JsiVideo
|
|
32
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiVideo, RNSkVideo> {
|
|
32
33
|
public:
|
|
33
|
-
|
|
34
|
+
static constexpr const char *CLASS_NAME = "Video";
|
|
34
35
|
|
|
35
36
|
JSI_HOST_FUNCTION(nextImage) {
|
|
36
37
|
double timestamp = 0;
|
|
@@ -39,10 +40,8 @@ public:
|
|
|
39
40
|
if (!image) {
|
|
40
41
|
return jsi::Value::null();
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
std::make_shared<JsiSkImage>(getContext(), std::move(image));
|
|
44
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
45
|
-
runtime, hostObjectInstance, getContext());
|
|
43
|
+
return makeJsiObject(
|
|
44
|
+
runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
JSI_HOST_FUNCTION(duration) { return getObject()->duration(); }
|
|
@@ -96,24 +95,29 @@ public:
|
|
|
96
95
|
return jsi::Value::undefined();
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
99
|
+
installCommon(runtime, prototype);
|
|
100
|
+
installHostMethod(runtime, prototype, "nextImage", &JsiVideo::nextImage);
|
|
101
|
+
installHostMethod(runtime, prototype, "duration", &JsiVideo::duration);
|
|
102
|
+
installHostMethod(runtime, prototype, "framerate", &JsiVideo::framerate);
|
|
103
|
+
installHostMethod(runtime, prototype, "currentTime",
|
|
104
|
+
&JsiVideo::currentTime);
|
|
105
|
+
installHostMethod(runtime, prototype, "isPlaying", &JsiVideo::isPlaying);
|
|
106
|
+
installHostMethod(runtime, prototype, "seek", &JsiVideo::seek);
|
|
107
|
+
installHostMethod(runtime, prototype, "rotation", &JsiVideo::rotation);
|
|
108
|
+
installHostMethod(runtime, prototype, "size", &JsiVideo::size);
|
|
109
|
+
installHostMethod(runtime, prototype, "play", &JsiVideo::play);
|
|
110
|
+
installHostMethod(runtime, prototype, "pause", &JsiVideo::pause);
|
|
111
|
+
installHostMethod(runtime, prototype, "setVolume", &JsiVideo::setVolume);
|
|
112
|
+
installHostMethod(runtime, prototype, "setLooping", &JsiVideo::setLooping);
|
|
113
|
+
}
|
|
108
114
|
|
|
109
115
|
JsiVideo(std::shared_ptr<RNSkPlatformContext> context,
|
|
110
116
|
std::shared_ptr<RNSkVideo> video)
|
|
111
|
-
:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
size_t getMemoryPressure() const override { return 32768; }
|
|
117
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiVideo, RNSkVideo>(
|
|
118
|
+
std::move(context), std::move(video)) {}
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
size_t getMemoryPressure() override { return 32768; }
|
|
117
121
|
|
|
118
122
|
/**
|
|
119
123
|
* Creates the function for construction a new instance of the SkFont
|
|
@@ -128,10 +132,8 @@ public:
|
|
|
128
132
|
auto url = arguments[0].asString(runtime).utf8(runtime);
|
|
129
133
|
auto video = context->createVideo(url);
|
|
130
134
|
// Return the newly constructed object
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, videoObj,
|
|
134
|
-
context);
|
|
135
|
+
return makeJsiObject(runtime, std::make_shared<JsiVideo>(
|
|
136
|
+
std::move(context), std::move(video)));
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
139
|
};
|
|
@@ -394,8 +394,7 @@ SkSamplingOptions getPropertyValue(jsi::Runtime &runtime,
|
|
|
394
394
|
template <>
|
|
395
395
|
SkFont getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
396
396
|
if (value.isObject()) {
|
|
397
|
-
auto font =
|
|
398
|
-
value.asObject(runtime).asHostObject<JsiSkFont>(runtime)->getObject();
|
|
397
|
+
auto font = getJsiObject<JsiSkFont>(runtime, value)->getObject();
|
|
399
398
|
return SkFont(*font);
|
|
400
399
|
}
|
|
401
400
|
throw std::runtime_error("Invalid prop value for SkFont received");
|
|
@@ -427,9 +426,7 @@ GlyphData getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
|
427
426
|
template <>
|
|
428
427
|
SkRSXform getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
429
428
|
if (value.isObject()) {
|
|
430
|
-
auto form =
|
|
431
|
-
.asHostObject<JsiSkRSXform>(runtime)
|
|
432
|
-
->getObject();
|
|
429
|
+
auto form = getJsiObject<JsiSkRSXform>(runtime, value)->getObject();
|
|
433
430
|
return SkRSXform::Make(form->fSCos, form->fSSin, form->fTx, form->fTy);
|
|
434
431
|
}
|
|
435
432
|
throw std::runtime_error("Invalid prop value for SkRSXform received");
|
|
@@ -438,13 +435,11 @@ SkRSXform getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
|
438
435
|
template <>
|
|
439
436
|
sk_sp<SkSVGDOM> getPropertyValue(jsi::Runtime &runtime,
|
|
440
437
|
const jsi::Value &value) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
} else if (value.isNull()) {
|
|
438
|
+
auto ptr = tryGetJsiObject<JsiSkSVG>(runtime, value);
|
|
439
|
+
if (ptr != nullptr) {
|
|
440
|
+
return ptr->getObject();
|
|
441
|
+
}
|
|
442
|
+
if (value.isNull()) {
|
|
448
443
|
return nullptr;
|
|
449
444
|
}
|
|
450
445
|
throw std::runtime_error(
|
|
@@ -454,13 +449,11 @@ sk_sp<SkSVGDOM> getPropertyValue(jsi::Runtime &runtime,
|
|
|
454
449
|
template <>
|
|
455
450
|
sk_sp<skottie::Animation> getPropertyValue(jsi::Runtime &runtime,
|
|
456
451
|
const jsi::Value &value) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
} else if (value.isNull()) {
|
|
452
|
+
auto ptr = tryGetJsiObject<JsiSkSkottie>(runtime, value);
|
|
453
|
+
if (ptr != nullptr) {
|
|
454
|
+
return ptr->getObject()->_animation;
|
|
455
|
+
}
|
|
456
|
+
if (value.isNull()) {
|
|
464
457
|
return nullptr;
|
|
465
458
|
}
|
|
466
459
|
throw std::runtime_error(
|
|
@@ -470,13 +463,11 @@ sk_sp<skottie::Animation> getPropertyValue(jsi::Runtime &runtime,
|
|
|
470
463
|
template <>
|
|
471
464
|
sk_sp<SkImageFilter> getPropertyValue(jsi::Runtime &runtime,
|
|
472
465
|
const jsi::Value &value) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
} else if (value.isNull()) {
|
|
466
|
+
auto ptr = tryGetJsiObject<JsiSkImageFilter>(runtime, value);
|
|
467
|
+
if (ptr != nullptr) {
|
|
468
|
+
return ptr->getObject();
|
|
469
|
+
}
|
|
470
|
+
if (value.isNull()) {
|
|
480
471
|
return nullptr;
|
|
481
472
|
}
|
|
482
473
|
throw std::runtime_error(
|
|
@@ -487,9 +478,7 @@ template <>
|
|
|
487
478
|
sk_sp<SkPicture> getPropertyValue(jsi::Runtime &runtime,
|
|
488
479
|
const jsi::Value &value) {
|
|
489
480
|
if (value.isObject()) {
|
|
490
|
-
auto picture =
|
|
491
|
-
.asHostObject<JsiSkPicture>(runtime)
|
|
492
|
-
->getObject();
|
|
481
|
+
auto picture = getJsiObject<JsiSkPicture>(runtime, value)->getObject();
|
|
493
482
|
return picture;
|
|
494
483
|
}
|
|
495
484
|
throw std::runtime_error("Invalid prop value for SkTextBlob received");
|
|
@@ -498,8 +487,7 @@ sk_sp<SkPicture> getPropertyValue(jsi::Runtime &runtime,
|
|
|
498
487
|
template <>
|
|
499
488
|
SkPaint getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
500
489
|
if (value.isObject()) {
|
|
501
|
-
auto paint =
|
|
502
|
-
value.asObject(runtime).asHostObject<JsiSkPaint>(runtime)->getObject();
|
|
490
|
+
auto paint = getJsiObject<JsiSkPaint>(runtime, value)->getObject();
|
|
503
491
|
return SkPaint(*paint);
|
|
504
492
|
}
|
|
505
493
|
throw std::runtime_error("Invalid prop value for SkPaint received");
|
|
@@ -508,28 +496,15 @@ SkPaint getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
|
508
496
|
template <>
|
|
509
497
|
std::shared_ptr<JsiSkParagraph> getPropertyValue(jsi::Runtime &runtime,
|
|
510
498
|
const jsi::Value &value) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
if (!hostObject) {
|
|
514
|
-
return nullptr;
|
|
515
|
-
}
|
|
516
|
-
auto para = std::dynamic_pointer_cast<JsiSkParagraph>(hostObject);
|
|
517
|
-
if (!para) {
|
|
518
|
-
return nullptr;
|
|
519
|
-
}
|
|
520
|
-
// Return a shared_ptr instead of raw pointer
|
|
521
|
-
return para;
|
|
522
|
-
}
|
|
523
|
-
return nullptr;
|
|
499
|
+
// Return a shared_ptr instead of raw pointer
|
|
500
|
+
return tryGetJsiObject<JsiSkParagraph>(runtime, value);
|
|
524
501
|
}
|
|
525
502
|
|
|
526
503
|
template <>
|
|
527
504
|
sk_sp<SkTextBlob> getPropertyValue(jsi::Runtime &runtime,
|
|
528
505
|
const jsi::Value &value) {
|
|
529
506
|
if (value.isObject()) {
|
|
530
|
-
auto blob =
|
|
531
|
-
.asHostObject<JsiSkTextBlob>(runtime)
|
|
532
|
-
->getObject();
|
|
507
|
+
auto blob = getJsiObject<JsiSkTextBlob>(runtime, value)->getObject();
|
|
533
508
|
return blob;
|
|
534
509
|
}
|
|
535
510
|
throw std::runtime_error("Invalid prop value for SkTextBlob received");
|
|
@@ -539,9 +514,7 @@ template <>
|
|
|
539
514
|
sk_sp<SkRuntimeEffect> getPropertyValue(jsi::Runtime &runtime,
|
|
540
515
|
const jsi::Value &value) {
|
|
541
516
|
if (value.isObject()) {
|
|
542
|
-
auto effect =
|
|
543
|
-
.asHostObject<JsiSkRuntimeEffect>(runtime)
|
|
544
|
-
->getObject();
|
|
517
|
+
auto effect = getJsiObject<JsiSkRuntimeEffect>(runtime, value)->getObject();
|
|
545
518
|
return effect;
|
|
546
519
|
}
|
|
547
520
|
throw std::runtime_error("Invalid prop value for SkRuntimeEffect received");
|
|
@@ -552,8 +525,7 @@ sk_sp<SkImage> getPropertyValue(jsi::Runtime &runtime,
|
|
|
552
525
|
const jsi::Value &value) {
|
|
553
526
|
|
|
554
527
|
if (value.isObject()) {
|
|
555
|
-
auto effect =
|
|
556
|
-
value.asObject(runtime).asHostObject<JsiSkImage>(runtime)->getObject();
|
|
528
|
+
auto effect = getJsiObject<JsiSkImage>(runtime, value)->getObject();
|
|
557
529
|
return effect;
|
|
558
530
|
} else if (value.isNull()) {
|
|
559
531
|
return nullptr;
|
|
@@ -564,11 +536,9 @@ sk_sp<SkImage> getPropertyValue(jsi::Runtime &runtime,
|
|
|
564
536
|
template <>
|
|
565
537
|
SkMatrix getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
566
538
|
if (value.isObject()) {
|
|
567
|
-
auto
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
auto matrix =
|
|
571
|
-
object.asHostObject<JsiSkMatrix>(runtime)->getObject().get();
|
|
539
|
+
auto ptr = tryGetJsiObject<JsiSkMatrix>(runtime, value);
|
|
540
|
+
if (ptr != nullptr) {
|
|
541
|
+
auto matrix = ptr->getObject().get();
|
|
572
542
|
return SkMatrix(*matrix);
|
|
573
543
|
} else {
|
|
574
544
|
return JsiSkMatrix::getMatrix(runtime, value);
|
|
@@ -1008,10 +978,10 @@ Layer getPropertyValue(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
|
1008
978
|
if (value.isBool()) {
|
|
1009
979
|
Layer layer = value.asBool();
|
|
1010
980
|
return layer;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
981
|
+
}
|
|
982
|
+
auto ptr = tryGetJsiObject<JsiSkPaint>(runtime, value);
|
|
983
|
+
if (ptr != nullptr) {
|
|
984
|
+
auto paint = ptr->getObject();
|
|
1015
985
|
Layer layer = SkPaint(*paint);
|
|
1016
986
|
return layer;
|
|
1017
987
|
}
|