@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include "JsiSkColor.h"
|
|
4
4
|
#include "JsiSkColorFilter.h"
|
|
5
|
-
#include "
|
|
5
|
+
#include "JsiSkNativeObjects.h"
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
#include <memory>
|
|
8
8
|
#include <utility>
|
|
@@ -19,8 +19,11 @@ namespace RNSkia {
|
|
|
19
19
|
|
|
20
20
|
namespace jsi = facebook::jsi;
|
|
21
21
|
|
|
22
|
-
class JsiSkColorFilterFactory
|
|
22
|
+
class JsiSkColorFilterFactory
|
|
23
|
+
: public JsiSkNativeObject<JsiSkColorFilterFactory> {
|
|
23
24
|
public:
|
|
25
|
+
static constexpr const char *CLASS_NAME = "ColorFilterFactory";
|
|
26
|
+
|
|
24
27
|
JSI_HOST_FUNCTION(MakeMatrix) {
|
|
25
28
|
auto jsiMatrix = arguments[0].asObject(runtime).asArray(runtime);
|
|
26
29
|
float matrix[20];
|
|
@@ -30,31 +33,28 @@ public:
|
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
// Return the newly constructed object
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
getContext());
|
|
36
|
+
return makeJsiObject(
|
|
37
|
+
runtime, std::make_shared<JsiSkColorFilter>(
|
|
38
|
+
getContext(), SkColorFilters::Matrix(std::move(matrix))));
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
JSI_HOST_FUNCTION(MakeBlend) {
|
|
40
42
|
auto color = JsiSkColor::fromValue(runtime, arguments[0]);
|
|
41
43
|
SkBlendMode blend = (SkBlendMode)arguments[1].asNumber();
|
|
42
44
|
// Return the newly constructed object
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
getContext());
|
|
45
|
+
return makeJsiObject(
|
|
46
|
+
runtime, std::make_shared<JsiSkColorFilter>(
|
|
47
|
+
getContext(), SkColorFilters::Blend(color, blend)));
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
JSI_HOST_FUNCTION(MakeCompose) {
|
|
50
51
|
auto outer = JsiSkColorFilter::fromValue(runtime, arguments[0]);
|
|
51
52
|
auto inner = JsiSkColorFilter::fromValue(runtime, arguments[1]);
|
|
52
53
|
// Return the newly constructed object
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
getContext());
|
|
54
|
+
return makeJsiObject(
|
|
55
|
+
runtime, std::make_shared<JsiSkColorFilter>(
|
|
56
|
+
getContext(), SkColorFilters::Compose(std::move(outer),
|
|
57
|
+
std::move(inner))));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
JSI_HOST_FUNCTION(MakeLerp) {
|
|
@@ -62,52 +62,52 @@ public:
|
|
|
62
62
|
auto dst = JsiSkColorFilter::fromValue(runtime, arguments[1]);
|
|
63
63
|
auto src = JsiSkColorFilter::fromValue(runtime, arguments[2]);
|
|
64
64
|
// Return the newly constructed object
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
return makeJsiObject(
|
|
66
|
+
runtime, std::make_shared<JsiSkColorFilter>(
|
|
67
|
+
getContext(),
|
|
68
|
+
SkColorFilters::Lerp(t, std::move(dst), std::move(src))));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
JSI_HOST_FUNCTION(MakeSRGBToLinearGamma) {
|
|
72
72
|
// Return the newly constructed object
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
getContext());
|
|
73
|
+
return makeJsiObject(
|
|
74
|
+
runtime, std::make_shared<JsiSkColorFilter>(
|
|
75
|
+
getContext(), SkColorFilters::SRGBToLinearGamma()));
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
JSI_HOST_FUNCTION(MakeLinearToSRGBGamma) {
|
|
80
79
|
// Return the newly constructed object
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
getContext());
|
|
80
|
+
return makeJsiObject(
|
|
81
|
+
runtime, std::make_shared<JsiSkColorFilter>(
|
|
82
|
+
getContext(), SkColorFilters::LinearToSRGBGamma()));
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
JSI_HOST_FUNCTION(MakeLumaColorFilter) {
|
|
88
86
|
// Return the newly constructed object
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, colorFilter,
|
|
92
|
-
getContext());
|
|
87
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkColorFilter>(
|
|
88
|
+
getContext(), SkLumaColorFilter::Make()));
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
size_t getMemoryPressure()
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
92
|
+
|
|
93
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
94
|
+
installHostMethod(runtime, prototype, "MakeMatrix",
|
|
95
|
+
&JsiSkColorFilterFactory::MakeMatrix);
|
|
96
|
+
installHostMethod(runtime, prototype, "MakeBlend",
|
|
97
|
+
&JsiSkColorFilterFactory::MakeBlend);
|
|
98
|
+
installHostMethod(runtime, prototype, "MakeCompose",
|
|
99
|
+
&JsiSkColorFilterFactory::MakeCompose);
|
|
100
|
+
installHostMethod(runtime, prototype, "MakeLerp",
|
|
101
|
+
&JsiSkColorFilterFactory::MakeLerp);
|
|
102
|
+
installHostMethod(runtime, prototype, "MakeSRGBToLinearGamma",
|
|
103
|
+
&JsiSkColorFilterFactory::MakeSRGBToLinearGamma);
|
|
104
|
+
installHostMethod(runtime, prototype, "MakeLinearToSRGBGamma",
|
|
105
|
+
&JsiSkColorFilterFactory::MakeLinearToSRGBGamma);
|
|
106
|
+
installHostMethod(runtime, prototype, "MakeLumaColorFilter",
|
|
107
|
+
&JsiSkColorFilterFactory::MakeLumaColorFilter);
|
|
99
108
|
}
|
|
100
109
|
|
|
101
|
-
JSI_EXPORT_FUNCTIONS(
|
|
102
|
-
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeMatrix),
|
|
103
|
-
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeBlend),
|
|
104
|
-
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeCompose),
|
|
105
|
-
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLerp),
|
|
106
|
-
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeSRGBToLinearGamma),
|
|
107
|
-
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLinearToSRGBGamma),
|
|
108
|
-
JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLumaColorFilter))
|
|
109
|
-
|
|
110
110
|
explicit JsiSkColorFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
111
|
-
:
|
|
111
|
+
: JsiSkNativeObject<JsiSkColorFilterFactory>(std::move(context)) {}
|
|
112
112
|
};
|
|
113
113
|
} // namespace RNSkia
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JsiSkNativeObjects.h"
|
|
9
9
|
|
|
10
10
|
#pragma clang diagnostic push
|
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -21,12 +21,15 @@ namespace RNSkia {
|
|
|
21
21
|
namespace jsi = facebook::jsi;
|
|
22
22
|
|
|
23
23
|
class JsiSkContourMeasure
|
|
24
|
-
: public
|
|
24
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkContourMeasure,
|
|
25
|
+
SkContourMeasure> {
|
|
25
26
|
public:
|
|
27
|
+
static constexpr const char *CLASS_NAME = "ContourMeasure";
|
|
28
|
+
|
|
26
29
|
JsiSkContourMeasure(std::shared_ptr<RNSkPlatformContext> context,
|
|
27
30
|
const sk_sp<SkContourMeasure> contourMeasure)
|
|
28
|
-
:
|
|
29
|
-
|
|
31
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkContourMeasure, SkContourMeasure>(
|
|
32
|
+
std::move(context), std::move(contourMeasure)) {}
|
|
30
33
|
|
|
31
34
|
JSI_HOST_FUNCTION(getPosTan) {
|
|
32
35
|
auto dist = arguments[0].asNumber();
|
|
@@ -37,12 +40,10 @@ public:
|
|
|
37
40
|
throw jsi::JSError(runtime, "getPosTan() failed");
|
|
38
41
|
}
|
|
39
42
|
auto posTan = jsi::Array(runtime, 2);
|
|
40
|
-
auto
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
auto tan = JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, tanPoint,
|
|
45
|
-
getContext());
|
|
43
|
+
auto pos = makeJsiObject(
|
|
44
|
+
runtime, std::make_shared<JsiSkPoint>(getContext(), position));
|
|
45
|
+
auto tan = makeJsiObject(
|
|
46
|
+
runtime, std::make_shared<JsiSkPoint>(getContext(), tangent));
|
|
46
47
|
posTan.setValueAtIndex(runtime, 0, pos);
|
|
47
48
|
posTan.setValueAtIndex(runtime, 1, tan);
|
|
48
49
|
return posTan;
|
|
@@ -67,16 +68,18 @@ public:
|
|
|
67
68
|
return JsiSkPath::toValue(runtime, getContext(), builder.snapshot());
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
size_t getMemoryPressure()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
72
|
+
|
|
73
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
74
|
+
installCommon(runtime, prototype);
|
|
75
|
+
installHostMethod(runtime, prototype, "getPosTan",
|
|
76
|
+
&JsiSkContourMeasure::getPosTan);
|
|
77
|
+
installHostMethod(runtime, prototype, "length",
|
|
78
|
+
&JsiSkContourMeasure::length);
|
|
79
|
+
installHostMethod(runtime, prototype, "isClosed",
|
|
80
|
+
&JsiSkContourMeasure::isClosed);
|
|
81
|
+
installHostMethod(runtime, prototype, "getSegment",
|
|
82
|
+
&JsiSkContourMeasure::getSegment);
|
|
83
|
+
}
|
|
81
84
|
};
|
|
82
85
|
} // namespace RNSkia
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#include <utility>
|
|
5
5
|
|
|
6
6
|
#include "JsiSkContourMeasure.h"
|
|
7
|
-
#include "
|
|
7
|
+
#include "JsiSkNativeObjects.h"
|
|
8
8
|
|
|
9
9
|
#pragma clang diagnostic push
|
|
10
10
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -20,12 +20,16 @@ namespace RNSkia {
|
|
|
20
20
|
namespace jsi = facebook::jsi;
|
|
21
21
|
|
|
22
22
|
class JsiSkContourMeasureIter
|
|
23
|
-
: public
|
|
23
|
+
: public JsiSkWrappingSharedPtrNativeObject<JsiSkContourMeasureIter,
|
|
24
|
+
SkContourMeasureIter> {
|
|
24
25
|
public:
|
|
26
|
+
static constexpr const char *CLASS_NAME = "ContourMeasureIter";
|
|
27
|
+
|
|
25
28
|
JsiSkContourMeasureIter(std::shared_ptr<RNSkPlatformContext> context,
|
|
26
29
|
const SkPath &path, bool forceClosed,
|
|
27
30
|
SkScalar resScale = 1)
|
|
28
|
-
:
|
|
31
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkContourMeasureIter,
|
|
32
|
+
SkContourMeasureIter>(
|
|
29
33
|
std::move(context), std::make_shared<SkContourMeasureIter>(
|
|
30
34
|
path, forceClosed, resScale)) {}
|
|
31
35
|
|
|
@@ -34,24 +38,18 @@ public:
|
|
|
34
38
|
if (next == nullptr) {
|
|
35
39
|
return jsi::Value::undefined();
|
|
36
40
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, nextObject,
|
|
41
|
-
getContext());
|
|
41
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkContourMeasure>(
|
|
42
|
+
getContext(), std::move(next)));
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
size_t getMemoryPressure() const override {
|
|
50
|
-
return std::max(sizeof(SkContourMeasureIter), kMinMemoryPressure);
|
|
45
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
46
|
+
installCommon(runtime, prototype);
|
|
47
|
+
installHostMethod(runtime, prototype, "next",
|
|
48
|
+
&JsiSkContourMeasureIter::next);
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
return
|
|
51
|
+
size_t getMemoryPressure() override {
|
|
52
|
+
return std::max(sizeof(SkContourMeasureIter), kMinMemoryPressure);
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
/**
|
|
@@ -68,10 +66,9 @@ public:
|
|
|
68
66
|
auto forceClosed = arguments[1].getBool();
|
|
69
67
|
auto resScale = arguments[2].asNumber();
|
|
70
68
|
// Return the newly constructed object
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
context);
|
|
69
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkContourMeasureIter>(
|
|
70
|
+
std::move(context), path->snapshot(),
|
|
71
|
+
forceClosed, resScale));
|
|
75
72
|
};
|
|
76
73
|
}
|
|
77
74
|
};
|
package/cpp/api/JsiSkData.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,19 +19,25 @@ namespace RNSkia {
|
|
|
19
19
|
|
|
20
20
|
namespace jsi = facebook::jsi;
|
|
21
21
|
|
|
22
|
-
class JsiSkData : public
|
|
22
|
+
class JsiSkData : public JsiSkWrappingSkPtrNativeObject<JsiSkData, SkData> {
|
|
23
23
|
public:
|
|
24
|
+
static constexpr const char *CLASS_NAME = "Data";
|
|
25
|
+
|
|
24
26
|
JsiSkData(std::shared_ptr<RNSkPlatformContext> context, sk_sp<SkData> asset)
|
|
25
|
-
:
|
|
27
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkData, SkData>(std::move(context),
|
|
28
|
+
std::move(asset)) {}
|
|
26
29
|
|
|
27
|
-
size_t getMemoryPressure()
|
|
30
|
+
size_t getMemoryPressure() override {
|
|
28
31
|
auto data = getObject();
|
|
29
32
|
return data ? data->size() : 0;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
static sk_sp<SkData> fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
36
|
+
return objectFromValue(runtime, obj);
|
|
37
|
+
}
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
40
|
+
installCommon(runtime, prototype);
|
|
41
|
+
}
|
|
36
42
|
};
|
|
37
43
|
} // namespace RNSkia
|
|
@@ -5,16 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
-
#include "jsi/JsiPromises.h"
|
|
9
8
|
#include "JsiSkData.h"
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
#include "api/third_party/base64.h"
|
|
11
|
+
#include "jsi/JsiPromises.h"
|
|
11
12
|
|
|
12
13
|
namespace RNSkia {
|
|
13
14
|
|
|
14
15
|
namespace jsi = facebook::jsi;
|
|
15
16
|
|
|
16
|
-
class JsiSkDataFactory : public
|
|
17
|
+
class JsiSkDataFactory : public JsiSkNativeObject<JsiSkDataFactory> {
|
|
17
18
|
public:
|
|
19
|
+
static constexpr const char *CLASS_NAME = "DataFactory";
|
|
20
|
+
|
|
18
21
|
JSI_HOST_FUNCTION(fromURI) {
|
|
19
22
|
auto jsiLocalUri = arguments[0].asString(runtime);
|
|
20
23
|
auto localUri = jsiLocalUri.utf8(runtime);
|
|
@@ -38,10 +41,9 @@ public:
|
|
|
38
41
|
context = std::move(context),
|
|
39
42
|
promise = std::move(promise),
|
|
40
43
|
result = std::move(result)]() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
runtime, hostObjectInstance, context));
|
|
44
|
+
promise->resolve(makeJsiObject(
|
|
45
|
+
runtime,
|
|
46
|
+
std::make_shared<JsiSkData>(context, std::move(result))));
|
|
45
47
|
});
|
|
46
48
|
});
|
|
47
49
|
});
|
|
@@ -56,10 +58,8 @@ public:
|
|
|
56
58
|
|
|
57
59
|
auto data =
|
|
58
60
|
SkData::MakeWithCopy(buffer.data(runtime), buffer.size(runtime));
|
|
59
|
-
|
|
60
|
-
std::make_shared<JsiSkData>(getContext(), std::move(data));
|
|
61
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
62
|
-
runtime, hostObjectInstance, getContext());
|
|
61
|
+
return makeJsiObject(
|
|
62
|
+
runtime, std::make_shared<JsiSkData>(getContext(), std::move(data)));
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
JSI_HOST_FUNCTION(fromBase64) {
|
|
@@ -85,22 +85,23 @@ public:
|
|
|
85
85
|
return jsi::Value::undefined();
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
std::make_shared<JsiSkData>(getContext(), std::move(data));
|
|
90
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
91
|
-
runtime, hostObjectInstance, getContext());
|
|
88
|
+
return makeJsiObject(
|
|
89
|
+
runtime, std::make_shared<JsiSkData>(getContext(), std::move(data)));
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
size_t getMemoryPressure()
|
|
92
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
95
|
+
installHostMethod(runtime, prototype, "fromURI",
|
|
96
|
+
&JsiSkDataFactory::fromURI);
|
|
97
|
+
installHostMethod(runtime, prototype, "fromBytes",
|
|
98
|
+
&JsiSkDataFactory::fromBytes);
|
|
99
|
+
installHostMethod(runtime, prototype, "fromBase64",
|
|
100
|
+
&JsiSkDataFactory::fromBase64);
|
|
101
|
+
}
|
|
101
102
|
|
|
102
103
|
explicit JsiSkDataFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
103
|
-
:
|
|
104
|
+
: JsiSkNativeObject<JsiSkDataFactory>(std::move(context)) {}
|
|
104
105
|
};
|
|
105
106
|
|
|
106
107
|
} // namespace RNSkia
|
package/cpp/api/JsiSkFont.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
|
|
|
@@ -26,8 +26,10 @@ namespace RNSkia {
|
|
|
26
26
|
|
|
27
27
|
namespace jsi = facebook::jsi;
|
|
28
28
|
|
|
29
|
-
class JsiSkFont : public
|
|
29
|
+
class JsiSkFont : public JsiSkWrappingSharedPtrNativeObject<JsiSkFont, SkFont> {
|
|
30
30
|
public:
|
|
31
|
+
static constexpr const char *CLASS_NAME = "Font";
|
|
32
|
+
|
|
31
33
|
JSI_HOST_FUNCTION(getGlyphWidths) {
|
|
32
34
|
auto jsiGlyphs = arguments[0].asObject(runtime).asArray(runtime);
|
|
33
35
|
std::vector<SkGlyphID> glyphs;
|
|
@@ -91,9 +93,8 @@ public:
|
|
|
91
93
|
getObject()->measureText(str.c_str(), str.length(), SkTextEncoding::kUTF8,
|
|
92
94
|
&bounds);
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
getContext());
|
|
96
|
+
return makeJsiObject(
|
|
97
|
+
runtime, std::make_shared<JsiSkRect>(getContext(), std::move(bounds)));
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
JSI_HOST_FUNCTION(getMetrics) {
|
|
@@ -251,39 +252,56 @@ public:
|
|
|
251
252
|
return jsi::Value::undefined();
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
255
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
256
|
+
installCommon(runtime, prototype);
|
|
257
|
+
installHostMethod(runtime, prototype, "getSize", &JsiSkFont::getSize);
|
|
258
|
+
installHostMethod(runtime, prototype, "getMetrics", &JsiSkFont::getMetrics);
|
|
259
|
+
installHostMethod(runtime, prototype, "getGlyphIDs",
|
|
260
|
+
&JsiSkFont::getGlyphIDs);
|
|
261
|
+
installHostMethod(runtime, prototype, "getGlyphIntercepts",
|
|
262
|
+
&JsiSkFont::getGlyphIntercepts);
|
|
263
|
+
installHostMethod(runtime, prototype, "getScaleX", &JsiSkFont::getScaleX);
|
|
264
|
+
installHostMethod(runtime, prototype, "getSkewX", &JsiSkFont::getSkewX);
|
|
265
|
+
installHostMethod(runtime, prototype, "getTypeface",
|
|
266
|
+
&JsiSkFont::getTypeface);
|
|
267
|
+
installHostMethod(runtime, prototype, "setEdging", &JsiSkFont::setEdging);
|
|
268
|
+
installHostMethod(runtime, prototype, "embeddedBitmaps",
|
|
269
|
+
&JsiSkFont::embeddedBitmaps);
|
|
270
|
+
installHostMethod(runtime, prototype, "setHinting", &JsiSkFont::setHinting);
|
|
271
|
+
installHostMethod(runtime, prototype, "setLinearMetrics",
|
|
272
|
+
&JsiSkFont::setLinearMetrics);
|
|
273
|
+
installHostMethod(runtime, prototype, "setScaleX", &JsiSkFont::setScaleX);
|
|
274
|
+
installHostMethod(runtime, prototype, "setSkewX", &JsiSkFont::setSkewX);
|
|
275
|
+
installHostMethod(runtime, prototype, "setSize", &JsiSkFont::setSize);
|
|
276
|
+
installHostMethod(runtime, prototype, "setEmbolden",
|
|
277
|
+
&JsiSkFont::setEmbolden);
|
|
278
|
+
installHostMethod(runtime, prototype, "setSubpixel",
|
|
279
|
+
&JsiSkFont::setSubpixel);
|
|
280
|
+
installHostMethod(runtime, prototype, "setTypeface",
|
|
281
|
+
&JsiSkFont::setTypeface);
|
|
282
|
+
installHostMethod(runtime, prototype, "getGlyphWidths",
|
|
283
|
+
&JsiSkFont::getGlyphWidths);
|
|
284
|
+
installHostMethod(runtime, prototype, "getTextWidth",
|
|
285
|
+
&JsiSkFont::getTextWidth);
|
|
286
|
+
installHostMethod(runtime, prototype, "measureText",
|
|
287
|
+
&JsiSkFont::measureText);
|
|
288
|
+
}
|
|
277
289
|
|
|
278
290
|
JsiSkFont(std::shared_ptr<RNSkPlatformContext> context, const SkFont &font)
|
|
279
|
-
:
|
|
280
|
-
|
|
291
|
+
: JsiSkWrappingSharedPtrNativeObject<JsiSkFont, SkFont>(
|
|
292
|
+
std::move(context), std::make_shared<SkFont>(font)) {}
|
|
281
293
|
|
|
282
|
-
size_t getMemoryPressure()
|
|
294
|
+
size_t getMemoryPressure() override {
|
|
283
295
|
return std::max(sizeof(SkFont), kMinMemoryPressure);
|
|
284
296
|
}
|
|
285
297
|
|
|
286
|
-
|
|
298
|
+
/**
|
|
299
|
+
Returns the underlying object from a host object of this type
|
|
300
|
+
*/
|
|
301
|
+
static std::shared_ptr<SkFont> fromValue(jsi::Runtime &runtime,
|
|
302
|
+
const jsi::Value &obj) {
|
|
303
|
+
return objectFromValue(runtime, obj);
|
|
304
|
+
}
|
|
287
305
|
|
|
288
306
|
/**
|
|
289
307
|
* Creates the function for construction a new instance of the SkFont
|
|
@@ -299,22 +317,16 @@ public:
|
|
|
299
317
|
if (count == 2) {
|
|
300
318
|
auto typeface = JsiSkTypeface::fromValue(runtime, arguments[0]);
|
|
301
319
|
auto size = arguments[1].asNumber();
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
305
|
-
runtime, hostObjectInstance, std::move(context));
|
|
320
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkFont>(
|
|
321
|
+
context, SkFont(typeface, size)));
|
|
306
322
|
} else if (count == 1) {
|
|
307
323
|
auto typeface = JsiSkTypeface::fromValue(runtime, arguments[0]);
|
|
308
|
-
|
|
309
|
-
std::make_shared<JsiSkFont>(context, SkFont(typeface));
|
|
310
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
311
|
-
runtime, hostObjectInstance, std::move(context));
|
|
324
|
+
return makeJsiObject(
|
|
325
|
+
runtime, std::make_shared<JsiSkFont>(context, SkFont(typeface)));
|
|
312
326
|
} else {
|
|
313
327
|
// Return the newly constructed object
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
317
|
-
runtime, hostObjectInstance, std::move(context));
|
|
328
|
+
return makeJsiObject(runtime,
|
|
329
|
+
std::make_shared<JsiSkFont>(context, SkFont()));
|
|
318
330
|
}
|
|
319
331
|
};
|
|
320
332
|
}
|
package/cpp/api/JsiSkFontMgr.h
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
8
|
#include "JsiSkFontStyle.h"
|
|
9
|
-
#include "
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
#include "utils/RNSkLog.h"
|
|
11
11
|
#include <jsi/jsi.h>
|
|
12
12
|
|
|
@@ -21,13 +21,15 @@ namespace RNSkia {
|
|
|
21
21
|
|
|
22
22
|
namespace jsi = facebook::jsi;
|
|
23
23
|
|
|
24
|
-
class JsiSkFontMgr
|
|
24
|
+
class JsiSkFontMgr
|
|
25
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkFontMgr, SkFontMgr> {
|
|
25
26
|
public:
|
|
26
|
-
|
|
27
|
+
static constexpr const char *CLASS_NAME = "FontMgr";
|
|
27
28
|
|
|
28
29
|
JsiSkFontMgr(std::shared_ptr<RNSkPlatformContext> context,
|
|
29
30
|
sk_sp<SkFontMgr> fontMgr)
|
|
30
|
-
:
|
|
31
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkFontMgr, SkFontMgr>(context,
|
|
32
|
+
fontMgr),
|
|
31
33
|
_systemFontFamilies(context->getSystemFontFamilies()) {}
|
|
32
34
|
|
|
33
35
|
JSI_HOST_FUNCTION(countFamilies) {
|
|
@@ -63,19 +65,26 @@ public:
|
|
|
63
65
|
auto fontStyle = JsiSkFontStyle::fromValue(runtime, arguments[1]);
|
|
64
66
|
auto typeface =
|
|
65
67
|
getObject()->matchFamilyStyle(resolvedName.c_str(), *fontStyle);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
69
|
-
runtime, hostObjectInstance, getContext());
|
|
68
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkTypeface>(
|
|
69
|
+
getContext(), std::move(typeface)));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
size_t getMemoryPressure()
|
|
72
|
+
size_t getMemoryPressure() override { return 2048; }
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
static sk_sp<SkFontMgr> fromValue(jsi::Runtime &runtime,
|
|
75
|
+
const jsi::Value &obj) {
|
|
76
|
+
return objectFromValue(runtime, obj);
|
|
77
|
+
}
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
80
|
+
installCommon(runtime, prototype);
|
|
81
|
+
installHostMethod(runtime, prototype, "countFamilies",
|
|
82
|
+
&JsiSkFontMgr::countFamilies);
|
|
83
|
+
installHostMethod(runtime, prototype, "getFamilyName",
|
|
84
|
+
&JsiSkFontMgr::getFamilyName);
|
|
85
|
+
installHostMethod(runtime, prototype, "matchFamilyStyle",
|
|
86
|
+
&JsiSkFontMgr::matchFamilyStyle);
|
|
87
|
+
}
|
|
79
88
|
|
|
80
89
|
private:
|
|
81
90
|
std::vector<std::string> _systemFontFamilies;
|