@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
package/cpp/api/JsiSkParagraph.h
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#include "JsiSkCanvas.h"
|
|
11
11
|
#include "JsiSkFont.h"
|
|
12
|
-
#include "
|
|
12
|
+
#include "JsiSkNativeObjects.h"
|
|
13
13
|
#include "JsiSkPath.h"
|
|
14
14
|
#include "JsiSkRect.h"
|
|
15
15
|
|
|
@@ -31,9 +31,10 @@ namespace para = skia::textlayout;
|
|
|
31
31
|
* Implementation of the Paragraph object in JSI
|
|
32
32
|
*/
|
|
33
33
|
class JsiSkParagraph
|
|
34
|
-
: public
|
|
34
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkParagraph,
|
|
35
|
+
para::Paragraph> {
|
|
35
36
|
public:
|
|
36
|
-
|
|
37
|
+
static constexpr const char *CLASS_NAME = "Paragraph";
|
|
37
38
|
|
|
38
39
|
JSI_HOST_FUNCTION(layout) {
|
|
39
40
|
auto width = getArgumentAsNumber(runtime, arguments, count, 0);
|
|
@@ -42,8 +43,8 @@ public:
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
JSI_HOST_FUNCTION(paint) {
|
|
45
|
-
auto jsiCanvas =
|
|
46
|
-
|
|
46
|
+
auto jsiCanvas = getJsiObject<JsiSkCanvas>(
|
|
47
|
+
runtime, getArgument(runtime, arguments, count, 0));
|
|
47
48
|
auto x = getArgumentAsNumber(runtime, arguments, count, 1);
|
|
48
49
|
auto y = getArgumentAsNumber(runtime, arguments, count, 2);
|
|
49
50
|
getObject()->paint(jsiCanvas->getCanvas(), x, y);
|
|
@@ -182,10 +183,8 @@ public:
|
|
|
182
183
|
&rec);
|
|
183
184
|
});
|
|
184
185
|
SkPath path = builder.detach();
|
|
185
|
-
|
|
186
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
187
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
188
|
-
runtime, hostObjectInstance, getContext());
|
|
186
|
+
return makeJsiObject(
|
|
187
|
+
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
JSI_HOST_FUNCTION(extendedVisit) {
|
|
@@ -203,10 +202,9 @@ public:
|
|
|
203
202
|
}
|
|
204
203
|
auto value = jsi::Object(runtime);
|
|
205
204
|
|
|
206
|
-
auto fontInstance = std::make_shared<JsiSkFont>(context, info->font);
|
|
207
205
|
value.setProperty(runtime, "font",
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
makeJsiObject(runtime, std::make_shared<JsiSkFont>(
|
|
207
|
+
context, info->font)));
|
|
210
208
|
|
|
211
209
|
auto origin = jsi::Object(runtime);
|
|
212
210
|
origin.setProperty(runtime, "x",
|
|
@@ -269,29 +267,38 @@ public:
|
|
|
269
267
|
return returnValue;
|
|
270
268
|
}
|
|
271
269
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
270
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
271
|
+
installCommon(runtime, prototype);
|
|
272
|
+
installHostMethod(runtime, prototype, "layout", &JsiSkParagraph::layout);
|
|
273
|
+
installHostMethod(runtime, prototype, "paint", &JsiSkParagraph::paint);
|
|
274
|
+
installHostMethod(runtime, prototype, "getMaxWidth",
|
|
275
|
+
&JsiSkParagraph::getMaxWidth);
|
|
276
|
+
installHostMethod(runtime, prototype, "getMinIntrinsicWidth",
|
|
277
|
+
&JsiSkParagraph::getMinIntrinsicWidth);
|
|
278
|
+
installHostMethod(runtime, prototype, "getMaxIntrinsicWidth",
|
|
279
|
+
&JsiSkParagraph::getMaxIntrinsicWidth);
|
|
280
|
+
installHostMethod(runtime, prototype, "getLongestLine",
|
|
281
|
+
&JsiSkParagraph::getLongestLine);
|
|
282
|
+
installHostMethod(runtime, prototype, "getHeight",
|
|
283
|
+
&JsiSkParagraph::getHeight);
|
|
284
|
+
installHostMethod(runtime, prototype, "getRectsForPlaceholders",
|
|
285
|
+
&JsiSkParagraph::getRectsForPlaceholders);
|
|
286
|
+
installHostMethod(runtime, prototype, "getGlyphPositionAtCoordinate",
|
|
287
|
+
&JsiSkParagraph::getGlyphPositionAtCoordinate);
|
|
288
|
+
installHostMethod(runtime, prototype, "getRectsForRange",
|
|
289
|
+
&JsiSkParagraph::getRectsForRange);
|
|
290
|
+
installHostMethod(runtime, prototype, "getLineMetrics",
|
|
291
|
+
&JsiSkParagraph::getLineMetrics);
|
|
292
|
+
installHostMethod(runtime, prototype, "getPath", &JsiSkParagraph::getPath);
|
|
293
|
+
installHostMethod(runtime, prototype, "extendedVisit",
|
|
294
|
+
&JsiSkParagraph::extendedVisit);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
size_t getMemoryPressure() override { return 1024 * 1024; }
|
|
291
298
|
|
|
292
299
|
explicit JsiSkParagraph(std::shared_ptr<RNSkPlatformContext> context,
|
|
293
300
|
para::ParagraphBuilder *paragraphBuilder)
|
|
294
|
-
:
|
|
301
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkParagraph, para::Paragraph>(
|
|
295
302
|
std::move(context), paragraphBuilder->Build()) {}
|
|
296
303
|
};
|
|
297
304
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
#include "JsiSkFont.h"
|
|
9
9
|
#include "JsiSkFontMgr.h"
|
|
10
10
|
#include "JsiSkFontMgrFactory.h"
|
|
11
|
-
#include "
|
|
11
|
+
#include "JsiSkNativeObjects.h"
|
|
12
12
|
#include "JsiSkParagraph.h"
|
|
13
13
|
#include "JsiSkParagraphStyle.h"
|
|
14
14
|
#include "JsiSkTextStyle.h"
|
|
@@ -36,15 +36,13 @@ namespace para = skia::textlayout;
|
|
|
36
36
|
/**
|
|
37
37
|
Implementation of the ParagraphBuilder object in JSI
|
|
38
38
|
*/
|
|
39
|
-
class JsiSkParagraphBuilder : public
|
|
39
|
+
class JsiSkParagraphBuilder : public JsiSkNativeObject<JsiSkParagraphBuilder> {
|
|
40
40
|
public:
|
|
41
|
-
|
|
41
|
+
static constexpr const char *CLASS_NAME = "ParagraphBuilder";
|
|
42
42
|
|
|
43
43
|
JSI_HOST_FUNCTION(build) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, paragraph,
|
|
47
|
-
getContext());
|
|
44
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkParagraph>(
|
|
45
|
+
getContext(), _builder.get()));
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
JSI_HOST_FUNCTION(reset) {
|
|
@@ -84,16 +82,16 @@ public:
|
|
|
84
82
|
auto textStyle = JsiSkTextStyle::fromValue(runtime, arguments[0]);
|
|
85
83
|
// Foreground paint
|
|
86
84
|
if (count >= 2) {
|
|
87
|
-
auto foreground =
|
|
88
|
-
|
|
85
|
+
auto foreground = tryGetJsiObject<JsiSkPaint>(
|
|
86
|
+
runtime, getArgument(runtime, arguments, count, 1));
|
|
89
87
|
if (foreground) {
|
|
90
88
|
textStyle.setForegroundPaint(*foreground->getObject().get());
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
// Background paint
|
|
94
92
|
if (count >= 3) {
|
|
95
|
-
auto background =
|
|
96
|
-
|
|
93
|
+
auto background = tryGetJsiObject<JsiSkPaint>(
|
|
94
|
+
runtime, getArgument(runtime, arguments, count, 2));
|
|
97
95
|
if (background) {
|
|
98
96
|
textStyle.setBackgroundPaint(*background->getObject().get());
|
|
99
97
|
}
|
|
@@ -109,21 +107,26 @@ public:
|
|
|
109
107
|
return thisValue.asObject(runtime);
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
111
|
+
installHostMethod(runtime, prototype, "build",
|
|
112
|
+
&JsiSkParagraphBuilder::build);
|
|
113
|
+
installHostMethod(runtime, prototype, "reset",
|
|
114
|
+
&JsiSkParagraphBuilder::reset);
|
|
115
|
+
installHostMethod(runtime, prototype, "addText",
|
|
116
|
+
&JsiSkParagraphBuilder::addText);
|
|
117
|
+
installHostMethod(runtime, prototype, "addPlaceholder",
|
|
118
|
+
&JsiSkParagraphBuilder::addPlaceholder);
|
|
119
|
+
installHostMethod(runtime, prototype, "pushStyle",
|
|
120
|
+
&JsiSkParagraphBuilder::pushStyle);
|
|
121
|
+
installHostMethod(runtime, prototype, "pop", &JsiSkParagraphBuilder::pop);
|
|
122
|
+
}
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
size_t getMemoryPressure() override { return 1024 * 1024; }
|
|
122
125
|
|
|
123
126
|
explicit JsiSkParagraphBuilder(std::shared_ptr<RNSkPlatformContext> context,
|
|
124
127
|
para::ParagraphStyle paragraphStyle,
|
|
125
128
|
sk_sp<SkFontMgr> fontManager)
|
|
126
|
-
:
|
|
129
|
+
: JsiSkNativeObject<JsiSkParagraphBuilder>(std::move(context)) {
|
|
127
130
|
_fontCollection = sk_make_sp<para::FontCollection>();
|
|
128
131
|
auto fontMgr = JsiSkFontMgrFactory::getFontMgr(getContext());
|
|
129
132
|
_fontCollection->setDefaultFontManager(fontMgr);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
8
9
|
#include "JsiSkParagraphBuilder.h"
|
|
9
10
|
#include "JsiSkParagraphStyle.h"
|
|
10
11
|
|
|
@@ -25,8 +26,11 @@ namespace para = skia::textlayout;
|
|
|
25
26
|
Implementation of the ParagraphBuilderFactory for making ParagraphBuilder JSI
|
|
26
27
|
object
|
|
27
28
|
*/
|
|
28
|
-
class JsiSkParagraphBuilderFactory
|
|
29
|
+
class JsiSkParagraphBuilderFactory
|
|
30
|
+
: public JsiSkNativeObject<JsiSkParagraphBuilderFactory> {
|
|
29
31
|
public:
|
|
32
|
+
static constexpr const char *CLASS_NAME = "ParagraphBuilderFactory";
|
|
33
|
+
|
|
30
34
|
JSI_HOST_FUNCTION(Make) {
|
|
31
35
|
// Get paragraph style from params
|
|
32
36
|
auto paragraphStyle =
|
|
@@ -39,23 +43,20 @@ public:
|
|
|
39
43
|
: nullptr;
|
|
40
44
|
|
|
41
45
|
// Create the paragraph builder
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, builder,
|
|
45
|
-
getContext());
|
|
46
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkParagraphBuilder>(
|
|
47
|
+
getContext(), paragraphStyle, fontMgr));
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
std::string getObjectType() const override {
|
|
53
|
-
return "JsiSkParagraphBuilderFactory";
|
|
50
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
51
|
+
installHostMethod(runtime, prototype, "Make",
|
|
52
|
+
&JsiSkParagraphBuilderFactory::Make);
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
size_t getMemoryPressure() override { return 1024 * 1024; }
|
|
56
|
+
|
|
56
57
|
explicit JsiSkParagraphBuilderFactory(
|
|
57
58
|
std::shared_ptr<RNSkPlatformContext> context)
|
|
58
|
-
:
|
|
59
|
+
: JsiSkNativeObject<JsiSkParagraphBuilderFactory>(std::move(context)) {}
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
} // namespace RNSkia
|
|
@@ -42,6 +42,16 @@ public:
|
|
|
42
42
|
textHeightBehavior?: SkTextHeightBehavior;
|
|
43
43
|
textStyle?: SkTextStyle;
|
|
44
44
|
*/
|
|
45
|
+
// A property set to undefined or null is treated as absent, like on web.
|
|
46
|
+
static bool hasValue(jsi::Runtime &runtime, const jsi::Object &object,
|
|
47
|
+
const char *name) {
|
|
48
|
+
if (!object.hasProperty(runtime, name)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
auto propValue = object.getProperty(runtime, name);
|
|
52
|
+
return !propValue.isUndefined() && !propValue.isNull();
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
static para::ParagraphStyle fromValue(jsi::Runtime &runtime,
|
|
46
56
|
const jsi::Value &value) {
|
|
47
57
|
para::ParagraphStyle retVal;
|
|
@@ -59,52 +69,52 @@ public:
|
|
|
59
69
|
|
|
60
70
|
auto object = value.asObject(runtime);
|
|
61
71
|
|
|
62
|
-
if (
|
|
72
|
+
if (hasValue(runtime, object, "disableHinting")) {
|
|
63
73
|
auto propValue = object.getProperty(runtime, "disableHinting");
|
|
64
74
|
if (asBool(runtime, propValue)) {
|
|
65
75
|
retVal.turnHintingOff();
|
|
66
76
|
}
|
|
67
77
|
}
|
|
68
|
-
if (
|
|
78
|
+
if (hasValue(runtime, object, "ellipsis")) {
|
|
69
79
|
auto propValue = object.getProperty(runtime, "ellipsis");
|
|
70
80
|
auto inStr = propValue.asString(runtime).utf8(runtime);
|
|
71
81
|
std::u16string uStr;
|
|
72
82
|
fromUTF8(inStr, uStr);
|
|
73
83
|
retVal.setEllipsis(uStr);
|
|
74
84
|
}
|
|
75
|
-
if (
|
|
85
|
+
if (hasValue(runtime, object, "heightMultiplier")) {
|
|
76
86
|
auto propValue = object.getProperty(runtime, "heightMultiplier");
|
|
77
87
|
retVal.setHeight(propValue.asNumber());
|
|
78
88
|
}
|
|
79
|
-
if (
|
|
89
|
+
if (hasValue(runtime, object, "maxLines")) {
|
|
80
90
|
auto propValue = object.getProperty(runtime, "maxLines");
|
|
81
91
|
if (propValue.asNumber() != 0) {
|
|
82
92
|
retVal.setMaxLines(propValue.asNumber());
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
|
-
if (
|
|
95
|
+
if (hasValue(runtime, object, "replaceTabCharacters")) {
|
|
86
96
|
auto propValue = object.getProperty(runtime, "replaceTabCharacters");
|
|
87
97
|
retVal.setReplaceTabCharacters(asBool(runtime, propValue));
|
|
88
98
|
}
|
|
89
|
-
if (
|
|
99
|
+
if (hasValue(runtime, object, "textAlign")) {
|
|
90
100
|
auto propValue = object.getProperty(runtime, "textAlign");
|
|
91
101
|
retVal.setTextAlign(static_cast<para::TextAlign>(propValue.asNumber()));
|
|
92
102
|
}
|
|
93
|
-
if (
|
|
103
|
+
if (hasValue(runtime, object, "textDirection")) {
|
|
94
104
|
auto propValue = object.getProperty(runtime, "textDirection");
|
|
95
105
|
retVal.setTextDirection(
|
|
96
106
|
static_cast<para::TextDirection>(propValue.asNumber()));
|
|
97
107
|
}
|
|
98
|
-
if (
|
|
108
|
+
if (hasValue(runtime, object, "textHeightBehavior")) {
|
|
99
109
|
auto propValue = object.getProperty(runtime, "textHeightBehavior");
|
|
100
110
|
retVal.setTextHeightBehavior(
|
|
101
111
|
static_cast<para::TextHeightBehavior>(propValue.asNumber()));
|
|
102
112
|
}
|
|
103
|
-
if (
|
|
113
|
+
if (hasValue(runtime, object, "strutStyle")) {
|
|
104
114
|
auto propValue = object.getProperty(runtime, "strutStyle");
|
|
105
115
|
retVal.setStrutStyle(JsiSkStrutStyle::fromValue(runtime, propValue));
|
|
106
116
|
}
|
|
107
|
-
if (
|
|
117
|
+
if (hasValue(runtime, object, "textStyle")) {
|
|
108
118
|
auto propValue = object.getProperty(runtime, "textStyle");
|
|
109
119
|
retVal.setTextStyle(JsiSkTextStyle::fromValue(runtime, propValue));
|
|
110
120
|
}
|
package/cpp/api/JsiSkPath.h
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
#include <jsi/jsi.h>
|
|
11
11
|
|
|
12
|
-
#include "JsiSkHostObjects.h"
|
|
13
12
|
#include "JsiSkMatrix.h"
|
|
13
|
+
#include "JsiSkNativeObjects.h"
|
|
14
14
|
#include "JsiSkPoint.h"
|
|
15
15
|
#include "JsiSkRRect.h"
|
|
16
16
|
#include "JsiSkRect.h"
|
|
@@ -61,7 +61,11 @@ inline void warnDeprecatedPathMethod(jsi::Runtime &runtime,
|
|
|
61
61
|
RNSkLogger::warnToJavascriptConsole(runtime, message);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
class JsiSkPath
|
|
64
|
+
class JsiSkPath
|
|
65
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkPath, SkPathBuilder> {
|
|
66
|
+
public:
|
|
67
|
+
static constexpr const char *CLASS_NAME = "Path";
|
|
68
|
+
|
|
65
69
|
private:
|
|
66
70
|
static const int MOVE = 0;
|
|
67
71
|
static const int LINE = 1;
|
|
@@ -529,16 +533,14 @@ public:
|
|
|
529
533
|
JSI_HOST_FUNCTION(computeTightBounds) {
|
|
530
534
|
auto path = asPath();
|
|
531
535
|
auto result = path.computeTightBounds();
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
runtime, hostObjectInstance, getContext());
|
|
536
|
+
return makeJsiObject(runtime,
|
|
537
|
+
std::make_shared<JsiSkRect>(getContext(), result));
|
|
535
538
|
}
|
|
536
539
|
|
|
537
540
|
JSI_HOST_FUNCTION(getBounds) {
|
|
538
541
|
auto result = getObject()->computeBounds();
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
runtime, hostObjectInstance, getContext());
|
|
542
|
+
return makeJsiObject(runtime,
|
|
543
|
+
std::make_shared<JsiSkRect>(getContext(), result));
|
|
542
544
|
}
|
|
543
545
|
|
|
544
546
|
JSI_HOST_FUNCTION(contains) {
|
|
@@ -557,9 +559,8 @@ public:
|
|
|
557
559
|
JSI_HOST_FUNCTION(getPoint) {
|
|
558
560
|
auto index = arguments[0].asNumber();
|
|
559
561
|
auto point = asPath().getPoint(index);
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
runtime, hostObjectInstance, getContext());
|
|
562
|
+
return makeJsiObject(runtime,
|
|
563
|
+
std::make_shared<JsiSkPoint>(getContext(), point));
|
|
563
564
|
}
|
|
564
565
|
|
|
565
566
|
JSI_HOST_FUNCTION(isEmpty) { return jsi::Value(getObject()->isEmpty()); }
|
|
@@ -596,9 +597,8 @@ public:
|
|
|
596
597
|
|
|
597
598
|
JSI_HOST_FUNCTION(copy) {
|
|
598
599
|
auto path = asPath();
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
runtime, hostObjectInstance, getContext());
|
|
600
|
+
return makeJsiObject(runtime,
|
|
601
|
+
std::make_shared<JsiSkPath>(getContext(), path));
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
JSI_HOST_FUNCTION(isInterpolatable) {
|
|
@@ -618,10 +618,8 @@ public:
|
|
|
618
618
|
if (!succeed) {
|
|
619
619
|
return jsi::Value::null();
|
|
620
620
|
}
|
|
621
|
-
|
|
622
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
623
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
624
|
-
runtime, hostObjectInstance, getContext());
|
|
621
|
+
return makeJsiObject(
|
|
622
|
+
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(result)));
|
|
625
623
|
}
|
|
626
624
|
|
|
627
625
|
JSI_HOST_FUNCTION(toCmds) {
|
|
@@ -703,51 +701,76 @@ public:
|
|
|
703
701
|
return cmds;
|
|
704
702
|
}
|
|
705
703
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
704
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
705
|
+
installCommon(runtime, prototype);
|
|
706
|
+
// Mutable building methods
|
|
707
|
+
installHostMethod(runtime, prototype, "moveTo", &JsiSkPath::moveTo);
|
|
708
|
+
installHostMethod(runtime, prototype, "rMoveTo", &JsiSkPath::rMoveTo);
|
|
709
|
+
installHostMethod(runtime, prototype, "lineTo", &JsiSkPath::lineTo);
|
|
710
|
+
installHostMethod(runtime, prototype, "rLineTo", &JsiSkPath::rLineTo);
|
|
711
|
+
installHostMethod(runtime, prototype, "quadTo", &JsiSkPath::quadTo);
|
|
712
|
+
installHostMethod(runtime, prototype, "rQuadTo", &JsiSkPath::rQuadTo);
|
|
713
|
+
installHostMethod(runtime, prototype, "conicTo", &JsiSkPath::conicTo);
|
|
714
|
+
installHostMethod(runtime, prototype, "rConicTo", &JsiSkPath::rConicTo);
|
|
715
|
+
installHostMethod(runtime, prototype, "cubicTo", &JsiSkPath::cubicTo);
|
|
716
|
+
installHostMethod(runtime, prototype, "rCubicTo", &JsiSkPath::rCubicTo);
|
|
717
|
+
installHostMethod(runtime, prototype, "close", &JsiSkPath::close);
|
|
718
|
+
installHostMethod(runtime, prototype, "reset", &JsiSkPath::reset);
|
|
719
|
+
installHostMethod(runtime, prototype, "rewind", &JsiSkPath::rewind);
|
|
720
|
+
installHostMethod(runtime, prototype, "addPath", &JsiSkPath::addPath);
|
|
721
|
+
installHostMethod(runtime, prototype, "addArc", &JsiSkPath::addArc);
|
|
722
|
+
installHostMethod(runtime, prototype, "addOval", &JsiSkPath::addOval);
|
|
723
|
+
installHostMethod(runtime, prototype, "addRect", &JsiSkPath::addRect);
|
|
724
|
+
installHostMethod(runtime, prototype, "addRRect", &JsiSkPath::addRRect);
|
|
725
|
+
installHostMethod(runtime, prototype, "addCircle", &JsiSkPath::addCircle);
|
|
726
|
+
installHostMethod(runtime, prototype, "addPoly", &JsiSkPath::addPoly);
|
|
727
|
+
installHostMethod(runtime, prototype, "arcToOval", &JsiSkPath::arcToOval);
|
|
728
|
+
installHostMethod(runtime, prototype, "arcToRotated",
|
|
729
|
+
&JsiSkPath::arcToRotated);
|
|
730
|
+
installHostMethod(runtime, prototype, "rArcTo", &JsiSkPath::rArcTo);
|
|
731
|
+
installHostMethod(runtime, prototype, "arcToTangent",
|
|
732
|
+
&JsiSkPath::arcToTangent);
|
|
733
|
+
installHostMethod(runtime, prototype, "setFillType",
|
|
734
|
+
&JsiSkPath::setFillType);
|
|
735
|
+
installHostMethod(runtime, prototype, "setIsVolatile",
|
|
736
|
+
&JsiSkPath::setIsVolatile);
|
|
737
|
+
// Mutable transform methods
|
|
738
|
+
installHostMethod(runtime, prototype, "transform", &JsiSkPath::transform);
|
|
739
|
+
installHostMethod(runtime, prototype, "offset", &JsiSkPath::offset);
|
|
740
|
+
// Mutable path operations
|
|
741
|
+
installHostMethod(runtime, prototype, "simplify", &JsiSkPath::simplify);
|
|
742
|
+
installHostMethod(runtime, prototype, "op", &JsiSkPath::op);
|
|
743
|
+
installHostMethod(runtime, prototype, "makeAsWinding",
|
|
744
|
+
&JsiSkPath::makeAsWinding);
|
|
745
|
+
installHostMethod(runtime, prototype, "dash", &JsiSkPath::dash);
|
|
746
|
+
installHostMethod(runtime, prototype, "stroke", &JsiSkPath::stroke);
|
|
747
|
+
installHostMethod(runtime, prototype, "trim", &JsiSkPath::trim);
|
|
748
|
+
// Query methods
|
|
749
|
+
installHostMethod(runtime, prototype, "computeTightBounds",
|
|
750
|
+
&JsiSkPath::computeTightBounds);
|
|
751
|
+
installHostMethod(runtime, prototype, "getBounds", &JsiSkPath::getBounds);
|
|
752
|
+
installHostMethod(runtime, prototype, "contains", &JsiSkPath::contains);
|
|
753
|
+
installHostMethod(runtime, prototype, "getFillType",
|
|
754
|
+
&JsiSkPath::getFillType);
|
|
755
|
+
installHostMethod(runtime, prototype, "isVolatile", &JsiSkPath::isVolatile);
|
|
756
|
+
installHostMethod(runtime, prototype, "getPoint", &JsiSkPath::getPoint);
|
|
757
|
+
installHostMethod(runtime, prototype, "isEmpty", &JsiSkPath::isEmpty);
|
|
758
|
+
installHostMethod(runtime, prototype, "countPoints",
|
|
759
|
+
&JsiSkPath::countPoints);
|
|
760
|
+
installHostMethod(runtime, prototype, "getLastPt", &JsiSkPath::getLastPt);
|
|
761
|
+
installHostMethod(runtime, prototype, "toSVGString",
|
|
762
|
+
&JsiSkPath::toSVGString);
|
|
763
|
+
installHostMethod(runtime, prototype, "equals", &JsiSkPath::equals);
|
|
764
|
+
installHostMethod(runtime, prototype, "copy", &JsiSkPath::copy);
|
|
765
|
+
installHostMethod(runtime, prototype, "isInterpolatable",
|
|
766
|
+
&JsiSkPath::isInterpolatable);
|
|
767
|
+
installHostMethod(runtime, prototype, "interpolate",
|
|
768
|
+
&JsiSkPath::interpolate);
|
|
769
|
+
installHostMethod(runtime, prototype, "toCmds", &JsiSkPath::toCmds);
|
|
770
|
+
}
|
|
748
771
|
|
|
749
772
|
JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, SkPathBuilder builder)
|
|
750
|
-
:
|
|
773
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkPath, SkPathBuilder>(
|
|
751
774
|
std::move(context),
|
|
752
775
|
std::make_shared<SkPathBuilder>(std::move(builder))) {}
|
|
753
776
|
|
|
@@ -755,7 +778,7 @@ public:
|
|
|
755
778
|
JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, const SkPath &path)
|
|
756
779
|
: JsiSkPath(std::move(context), SkPathBuilder(path)) {}
|
|
757
780
|
|
|
758
|
-
size_t getMemoryPressure()
|
|
781
|
+
size_t getMemoryPressure() override {
|
|
759
782
|
auto builder = getObject();
|
|
760
783
|
if (!builder)
|
|
761
784
|
return 0;
|
|
@@ -763,7 +786,13 @@ public:
|
|
|
763
786
|
return builder->snapshot().approximateBytesUsed();
|
|
764
787
|
}
|
|
765
788
|
|
|
766
|
-
|
|
789
|
+
/**
|
|
790
|
+
Returns the underlying object from a host object of this type
|
|
791
|
+
*/
|
|
792
|
+
static std::shared_ptr<SkPathBuilder> fromValue(jsi::Runtime &runtime,
|
|
793
|
+
const jsi::Value &obj) {
|
|
794
|
+
return objectFromValue(runtime, obj);
|
|
795
|
+
}
|
|
767
796
|
|
|
768
797
|
static SkPath pathFromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
769
798
|
return fromValue(runtime, obj)->snapshot();
|
|
@@ -772,18 +801,14 @@ public:
|
|
|
772
801
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
773
802
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
774
803
|
const SkPath &path) {
|
|
775
|
-
|
|
776
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
777
|
-
runtime, hostObjectInstance, context);
|
|
804
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkPath>(context, path));
|
|
778
805
|
}
|
|
779
806
|
|
|
780
807
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
781
808
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
782
809
|
SkPath &&path) {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
786
|
-
runtime, hostObjectInstance, context);
|
|
810
|
+
return makeJsiObject(runtime,
|
|
811
|
+
std::make_shared<JsiSkPath>(context, std::move(path)));
|
|
787
812
|
}
|
|
788
813
|
};
|
|
789
814
|
|