@shopify/react-native-skia 2.5.5 → 2.6.1
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 +0 -1
- package/android/cpp/jni/JniWebGPUView.cpp +3 -3
- package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
- package/apple/MetalContext.h +5 -6
- package/apple/MetalWindowContext.mm +3 -4
- package/apple/RNSkApplePlatformContext.h +1 -1
- package/apple/RNSkApplePlatformContext.mm +4 -3
- package/apple/SkiaCVPixelBufferUtils.h +1 -1
- package/apple/SkiaCVPixelBufferUtils.mm +31 -30
- package/apple/SkiaPlatformContext.mm +2 -2
- package/apple/SkiaUIView.mm +1 -1
- package/apple/SkiaWebGPUView.mm +8 -4
- package/apple/WebGPUMetalView.h +1 -1
- package/apple/WebGPUMetalView.mm +1 -1
- package/cpp/api/CustomBlendModes.h +1 -0
- package/cpp/api/JsiSkApi.h +4 -0
- package/cpp/api/JsiSkCanvas.h +2 -2
- package/cpp/api/JsiSkColor.h +8 -4
- package/cpp/api/JsiSkContourMeasure.h +4 -3
- package/cpp/api/JsiSkContourMeasureIter.h +1 -1
- package/cpp/api/JsiSkImage.h +17 -9
- package/cpp/api/JsiSkParagraphBuilder.h +14 -1
- package/cpp/api/JsiSkPath.h +475 -357
- package/cpp/api/JsiSkPathBuilder.h +415 -0
- package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
- package/cpp/api/JsiSkPathEffectFactory.h +3 -2
- package/cpp/api/JsiSkPathFactory.h +287 -20
- package/cpp/api/JsiSkShader.h +1 -1
- package/cpp/api/JsiSkShaderFactory.h +50 -26
- package/cpp/api/JsiSkSurfaceFactory.h +2 -1
- package/cpp/api/recorder/DataTypes.h +1 -1
- package/cpp/api/recorder/Drawings.h +11 -9
- package/cpp/api/recorder/Shaders.h +77 -22
- package/cpp/jsi2/JSIConverter.h +1 -1
- package/cpp/rnskia/RNDawnContext.h +29 -9
- package/cpp/rnskia/RNDawnUtils.h +112 -113
- package/cpp/rnskia/RNDawnWindowContext.h +1 -1
- package/cpp/rnskia/RNSkManager.cpp +5 -4
- package/cpp/rnskia/RNSkPlatformContext.h +2 -2
- package/cpp/rnwgpu/api/GPU.cpp +21 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
- package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
- package/cpp/rnwgpu/api/GPUTexture.h +14 -2
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
- package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
- package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
- package/cpp/skia/include/android/SkImageAndroid.h +7 -2
- package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
- package/cpp/skia/include/codec/SkCodec.h +42 -15
- package/cpp/skia/include/config/SkUserConfig.h +8 -0
- package/cpp/skia/include/core/SkBitmap.h +0 -5
- package/cpp/skia/include/core/SkCanvas.h +2 -39
- package/cpp/skia/include/core/SkColor.h +12 -0
- package/cpp/skia/include/core/SkColorSpace.h +9 -0
- package/cpp/skia/include/core/SkContourMeasure.h +1 -5
- package/cpp/skia/include/core/SkData.h +8 -0
- package/cpp/skia/include/core/SkFont.h +1 -55
- package/cpp/skia/include/core/SkFontArguments.h +15 -0
- package/cpp/skia/include/core/SkGraphics.h +0 -5
- package/cpp/skia/include/core/SkImage.h +0 -4
- package/cpp/skia/include/core/SkImageGenerator.h +1 -4
- package/cpp/skia/include/core/SkMatrix.h +0 -37
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPath.h +11 -911
- package/cpp/skia/include/core/SkPathBuilder.h +42 -32
- package/cpp/skia/include/core/SkPathEffect.h +0 -9
- package/cpp/skia/include/core/SkPathMeasure.h +1 -4
- package/cpp/skia/include/core/SkPathUtils.h +0 -10
- package/cpp/skia/include/core/SkRect.h +0 -12
- package/cpp/skia/include/core/SkRegion.h +1 -6
- package/cpp/skia/include/core/SkSerialProcs.h +4 -5
- package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
- package/cpp/skia/include/core/SkTextBlob.h +0 -22
- package/cpp/skia/include/core/SkTypeface.h +14 -32
- package/cpp/skia/include/core/SkTypes.h +0 -8
- package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
- package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
- package/cpp/skia/include/effects/SkGradient.h +206 -0
- package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
- package/cpp/skia/include/gpu/GpuTypes.h +2 -0
- package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
- package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
- package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
- package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
- package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
- package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
- package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
- package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
- package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
- package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
- package/cpp/skia/include/private/SkPathRef.h +0 -457
- package/cpp/skia/include/private/base/SkFeatures.h +4 -0
- package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
- package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
- package/cpp/skia/include/private/base/SkLog.h +68 -0
- package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
- package/cpp/skia/include/private/base/SkMacros.h +9 -0
- package/cpp/skia/include/private/base/SkTArray.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
- package/cpp/skia/include/utils/SkEventTracer.h +5 -7
- package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
- package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
- package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
- package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
- package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
- package/cpp/skia/src/base/SkMathPriv.h +27 -132
- package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
- package/lib/commonjs/external/reanimated/interpolators.js +21 -4
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
- package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
- package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
- package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
- package/lib/commonjs/skia/types/Path/index.js +22 -0
- package/lib/commonjs/skia/types/Path/index.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +2 -1
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +1 -3
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
- package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +8 -1
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +5 -4
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +11 -2
- package/lib/module/external/reanimated/interpolators.js +21 -4
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/module/skia/types/Path/PathBuilder.js +2 -0
- package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
- package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
- package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
- package/lib/module/skia/types/Path/index.d.ts +2 -0
- package/lib/module/skia/types/Path/index.js +2 -0
- package/lib/module/skia/types/Path/index.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +2 -1
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/Host.js +1 -3
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +6 -2
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/module/skia/web/JsiSkPath.js +300 -110
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
- package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
- package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +8 -1
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/module/specs/WebGPUViewNativeComponent.js +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
- package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
- package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
- package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
- package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
- package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
- package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
- package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
- package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
- package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
- package/package.json +7 -6
- package/scripts/install-libs.js +16 -6
- package/src/animation/functions/interpolatePaths.ts +5 -6
- package/src/external/reanimated/interpolators.ts +25 -5
- package/src/skia/types/Path/PathBuilder.ts +303 -0
- package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
- package/src/skia/types/Path/PathFactory.ts +108 -1
- package/src/skia/types/Path/index.ts +2 -0
- package/src/skia/types/Skia.ts +2 -1
- package/src/skia/web/Host.ts +7 -1
- package/src/skia/web/JsiSkCanvas.ts +6 -6
- package/src/skia/web/JsiSkContourMeasure.ts +4 -4
- package/src/skia/web/JsiSkPath.ts +451 -168
- package/src/skia/web/JsiSkPathBuilder.ts +293 -0
- package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
- package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
- package/src/skia/web/JsiSkPathFactory.ts +231 -8
- package/src/skia/web/JsiSkia.ts +11 -8
- package/src/sksg/Recorder/commands/Drawing.ts +20 -7
- package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
- package/src/specs/WebGPUViewNativeComponent.ts +2 -2
- package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
- package/cpp/skia/include/effects/SkGradientShader.h +0 -359
- package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <utility>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
#include <jsi/jsi.h>
|
|
8
|
+
|
|
9
|
+
#include "JsiSkHostObjects.h"
|
|
10
|
+
#include "JsiSkMatrix.h"
|
|
11
|
+
#include "JsiSkPath.h"
|
|
12
|
+
#include "JsiSkPoint.h"
|
|
13
|
+
#include "JsiSkRRect.h"
|
|
14
|
+
#include "JsiSkRect.h"
|
|
15
|
+
|
|
16
|
+
#pragma clang diagnostic push
|
|
17
|
+
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
18
|
+
|
|
19
|
+
#include "include/core/SkPath.h"
|
|
20
|
+
#include "include/core/SkPathBuilder.h"
|
|
21
|
+
#include "include/core/SkPathTypes.h"
|
|
22
|
+
|
|
23
|
+
#pragma clang diagnostic pop
|
|
24
|
+
|
|
25
|
+
namespace RNSkia {
|
|
26
|
+
|
|
27
|
+
namespace jsi = facebook::jsi;
|
|
28
|
+
|
|
29
|
+
class JsiSkPathBuilder
|
|
30
|
+
: public JsiSkWrappingSharedPtrHostObject<SkPathBuilder> {
|
|
31
|
+
public:
|
|
32
|
+
// Movement methods
|
|
33
|
+
JSI_HOST_FUNCTION(moveTo) {
|
|
34
|
+
SkScalar x = arguments[0].asNumber();
|
|
35
|
+
SkScalar y = arguments[1].asNumber();
|
|
36
|
+
getObject()->moveTo(x, y);
|
|
37
|
+
return thisValue.getObject(runtime);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
JSI_HOST_FUNCTION(rMoveTo) {
|
|
41
|
+
SkScalar x = arguments[0].asNumber();
|
|
42
|
+
SkScalar y = arguments[1].asNumber();
|
|
43
|
+
getObject()->rMoveTo({x, y});
|
|
44
|
+
return thisValue.getObject(runtime);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
JSI_HOST_FUNCTION(lineTo) {
|
|
48
|
+
SkScalar x = arguments[0].asNumber();
|
|
49
|
+
SkScalar y = arguments[1].asNumber();
|
|
50
|
+
getObject()->lineTo(x, y);
|
|
51
|
+
return thisValue.getObject(runtime);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
JSI_HOST_FUNCTION(rLineTo) {
|
|
55
|
+
SkScalar x = arguments[0].asNumber();
|
|
56
|
+
SkScalar y = arguments[1].asNumber();
|
|
57
|
+
getObject()->rLineTo(x, y);
|
|
58
|
+
return thisValue.getObject(runtime);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Curve methods
|
|
62
|
+
JSI_HOST_FUNCTION(quadTo) {
|
|
63
|
+
auto x1 = arguments[0].asNumber();
|
|
64
|
+
auto y1 = arguments[1].asNumber();
|
|
65
|
+
auto x2 = arguments[2].asNumber();
|
|
66
|
+
auto y2 = arguments[3].asNumber();
|
|
67
|
+
getObject()->quadTo(x1, y1, x2, y2);
|
|
68
|
+
return thisValue.getObject(runtime);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
JSI_HOST_FUNCTION(rQuadTo) {
|
|
72
|
+
auto x1 = arguments[0].asNumber();
|
|
73
|
+
auto y1 = arguments[1].asNumber();
|
|
74
|
+
auto x2 = arguments[2].asNumber();
|
|
75
|
+
auto y2 = arguments[3].asNumber();
|
|
76
|
+
getObject()->rQuadTo(x1, y1, x2, y2);
|
|
77
|
+
return thisValue.getObject(runtime);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
JSI_HOST_FUNCTION(conicTo) {
|
|
81
|
+
auto x1 = arguments[0].asNumber();
|
|
82
|
+
auto y1 = arguments[1].asNumber();
|
|
83
|
+
auto x2 = arguments[2].asNumber();
|
|
84
|
+
auto y2 = arguments[3].asNumber();
|
|
85
|
+
auto w = arguments[4].asNumber();
|
|
86
|
+
getObject()->conicTo(x1, y1, x2, y2, w);
|
|
87
|
+
return thisValue.getObject(runtime);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
JSI_HOST_FUNCTION(rConicTo) {
|
|
91
|
+
auto x1 = arguments[0].asNumber();
|
|
92
|
+
auto y1 = arguments[1].asNumber();
|
|
93
|
+
auto x2 = arguments[2].asNumber();
|
|
94
|
+
auto y2 = arguments[3].asNumber();
|
|
95
|
+
auto w = arguments[4].asNumber();
|
|
96
|
+
getObject()->rConicTo(x1, y1, x2, y2, w);
|
|
97
|
+
return thisValue.getObject(runtime);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
JSI_HOST_FUNCTION(cubicTo) {
|
|
101
|
+
auto x1 = arguments[0].asNumber();
|
|
102
|
+
auto y1 = arguments[1].asNumber();
|
|
103
|
+
auto x2 = arguments[2].asNumber();
|
|
104
|
+
auto y2 = arguments[3].asNumber();
|
|
105
|
+
auto x3 = arguments[4].asNumber();
|
|
106
|
+
auto y3 = arguments[5].asNumber();
|
|
107
|
+
getObject()->cubicTo(x1, y1, x2, y2, x3, y3);
|
|
108
|
+
return thisValue.getObject(runtime);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
JSI_HOST_FUNCTION(rCubicTo) {
|
|
112
|
+
auto x1 = arguments[0].asNumber();
|
|
113
|
+
auto y1 = arguments[1].asNumber();
|
|
114
|
+
auto x2 = arguments[2].asNumber();
|
|
115
|
+
auto y2 = arguments[3].asNumber();
|
|
116
|
+
auto x3 = arguments[4].asNumber();
|
|
117
|
+
auto y3 = arguments[5].asNumber();
|
|
118
|
+
getObject()->rCubicTo(x1, y1, x2, y2, x3, y3);
|
|
119
|
+
return thisValue.getObject(runtime);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
JSI_HOST_FUNCTION(close) {
|
|
123
|
+
getObject()->close();
|
|
124
|
+
return thisValue.getObject(runtime);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Arc methods
|
|
128
|
+
JSI_HOST_FUNCTION(arcToOval) {
|
|
129
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
130
|
+
auto start = arguments[1].asNumber();
|
|
131
|
+
auto sweep = arguments[2].asNumber();
|
|
132
|
+
auto forceMoveTo = arguments[3].getBool();
|
|
133
|
+
getObject()->arcTo(*rect, start, sweep, forceMoveTo);
|
|
134
|
+
return thisValue.getObject(runtime);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
JSI_HOST_FUNCTION(arcToRotated) {
|
|
138
|
+
auto rx = arguments[0].asNumber();
|
|
139
|
+
auto ry = arguments[1].asNumber();
|
|
140
|
+
auto xAxisRotate = arguments[2].asNumber();
|
|
141
|
+
auto useSmallArc = arguments[3].getBool();
|
|
142
|
+
auto arcSize = useSmallArc ? SkPathBuilder::ArcSize::kSmall_ArcSize
|
|
143
|
+
: SkPathBuilder::ArcSize::kLarge_ArcSize;
|
|
144
|
+
auto sweep =
|
|
145
|
+
arguments[4].getBool() ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
146
|
+
auto x = arguments[5].asNumber();
|
|
147
|
+
auto y = arguments[6].asNumber();
|
|
148
|
+
getObject()->arcTo(SkPoint::Make(rx, ry), xAxisRotate, arcSize, sweep,
|
|
149
|
+
SkPoint::Make(x, y));
|
|
150
|
+
return thisValue.getObject(runtime);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
JSI_HOST_FUNCTION(rArcTo) {
|
|
154
|
+
auto rx = arguments[0].asNumber();
|
|
155
|
+
auto ry = arguments[1].asNumber();
|
|
156
|
+
auto xAxisRotate = arguments[2].asNumber();
|
|
157
|
+
auto useSmallArc = arguments[3].getBool();
|
|
158
|
+
auto arcSize = useSmallArc ? SkPathBuilder::ArcSize::kSmall_ArcSize
|
|
159
|
+
: SkPathBuilder::ArcSize::kLarge_ArcSize;
|
|
160
|
+
auto sweep =
|
|
161
|
+
arguments[4].getBool() ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
162
|
+
auto dx = arguments[5].asNumber();
|
|
163
|
+
auto dy = arguments[6].asNumber();
|
|
164
|
+
SkPoint r(rx, ry);
|
|
165
|
+
SkVector d(dx, dy);
|
|
166
|
+
getObject()->rArcTo(r, xAxisRotate, arcSize, sweep, d);
|
|
167
|
+
return thisValue.getObject(runtime);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
JSI_HOST_FUNCTION(arcToTangent) {
|
|
171
|
+
auto x1 = arguments[0].asNumber();
|
|
172
|
+
auto y1 = arguments[1].asNumber();
|
|
173
|
+
auto x2 = arguments[2].asNumber();
|
|
174
|
+
auto y2 = arguments[3].asNumber();
|
|
175
|
+
auto r = arguments[4].asNumber();
|
|
176
|
+
getObject()->arcTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), r);
|
|
177
|
+
return thisValue.getObject(runtime);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Shape methods
|
|
181
|
+
JSI_HOST_FUNCTION(addRect) {
|
|
182
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
183
|
+
auto direction = SkPathDirection::kCW;
|
|
184
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
185
|
+
direction = SkPathDirection::kCCW;
|
|
186
|
+
}
|
|
187
|
+
getObject()->addRect(*rect, direction);
|
|
188
|
+
return thisValue.getObject(runtime);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
JSI_HOST_FUNCTION(addOval) {
|
|
192
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
193
|
+
auto direction = SkPathDirection::kCW;
|
|
194
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
195
|
+
direction = SkPathDirection::kCCW;
|
|
196
|
+
}
|
|
197
|
+
unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
|
|
198
|
+
getObject()->addOval(*rect, direction, startIndex);
|
|
199
|
+
return thisValue.getObject(runtime);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
JSI_HOST_FUNCTION(addArc) {
|
|
203
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
204
|
+
auto start = arguments[1].asNumber();
|
|
205
|
+
auto sweep = arguments[2].asNumber();
|
|
206
|
+
getObject()->addArc(*rect, start, sweep);
|
|
207
|
+
return thisValue.getObject(runtime);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
JSI_HOST_FUNCTION(addRRect) {
|
|
211
|
+
auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
|
|
212
|
+
auto direction = SkPathDirection::kCW;
|
|
213
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
214
|
+
direction = SkPathDirection::kCCW;
|
|
215
|
+
}
|
|
216
|
+
getObject()->addRRect(*rrect, direction);
|
|
217
|
+
return thisValue.getObject(runtime);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
JSI_HOST_FUNCTION(addCircle) {
|
|
221
|
+
auto x = arguments[0].asNumber();
|
|
222
|
+
auto y = arguments[1].asNumber();
|
|
223
|
+
auto r = arguments[2].asNumber();
|
|
224
|
+
auto direction = SkPathDirection::kCW;
|
|
225
|
+
if (count >= 4 && arguments[3].getBool()) {
|
|
226
|
+
direction = SkPathDirection::kCCW;
|
|
227
|
+
}
|
|
228
|
+
getObject()->addCircle(x, y, r, direction);
|
|
229
|
+
return thisValue.getObject(runtime);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
JSI_HOST_FUNCTION(addPoly) {
|
|
233
|
+
std::vector<SkPoint> points;
|
|
234
|
+
auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
|
|
235
|
+
auto close = arguments[1].getBool();
|
|
236
|
+
auto pointsSize = jsiPoints.size(runtime);
|
|
237
|
+
points.reserve(pointsSize);
|
|
238
|
+
for (int i = 0; i < pointsSize; i++) {
|
|
239
|
+
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
|
240
|
+
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
|
241
|
+
points.push_back(*point.get());
|
|
242
|
+
}
|
|
243
|
+
getObject()->addPolygon(SkSpan(points.data(), points.size()), close);
|
|
244
|
+
return thisValue.getObject(runtime);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
JSI_HOST_FUNCTION(addPath) {
|
|
248
|
+
auto src = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
249
|
+
auto srcPath = src->snapshot();
|
|
250
|
+
auto matrix =
|
|
251
|
+
count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
|
252
|
+
? JsiSkMatrix::fromValue(runtime, arguments[1])
|
|
253
|
+
: nullptr;
|
|
254
|
+
auto mode = count > 2 && arguments[2].isBool() && arguments[2].getBool()
|
|
255
|
+
? SkPath::kExtend_AddPathMode
|
|
256
|
+
: SkPath::kAppend_AddPathMode;
|
|
257
|
+
if (matrix == nullptr) {
|
|
258
|
+
getObject()->addPath(srcPath, mode);
|
|
259
|
+
} else {
|
|
260
|
+
getObject()->addPath(srcPath, *matrix, mode);
|
|
261
|
+
}
|
|
262
|
+
return thisValue.getObject(runtime);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Configuration methods
|
|
266
|
+
JSI_HOST_FUNCTION(setFillType) {
|
|
267
|
+
auto ft = (SkPathFillType)arguments[0].asNumber();
|
|
268
|
+
getObject()->setFillType(ft);
|
|
269
|
+
return thisValue.getObject(runtime);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
JSI_HOST_FUNCTION(setIsVolatile) {
|
|
273
|
+
auto v = arguments[0].getBool();
|
|
274
|
+
getObject()->setIsVolatile(v);
|
|
275
|
+
return thisValue.getObject(runtime);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
JSI_HOST_FUNCTION(reset) {
|
|
279
|
+
getObject()->reset();
|
|
280
|
+
return thisValue.getObject(runtime);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
JSI_HOST_FUNCTION(offset) {
|
|
284
|
+
SkScalar dx = arguments[0].asNumber();
|
|
285
|
+
SkScalar dy = arguments[1].asNumber();
|
|
286
|
+
getObject()->offset(dx, dy);
|
|
287
|
+
return thisValue.getObject(runtime);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
JSI_HOST_FUNCTION(transform) {
|
|
291
|
+
auto m3 = *JsiSkMatrix::fromValue(runtime, arguments[0]);
|
|
292
|
+
// Create a path from current state, transform, then rebuild
|
|
293
|
+
auto path = getObject()->snapshot().makeTransform(m3);
|
|
294
|
+
*getObject() = SkPathBuilder(path);
|
|
295
|
+
return thisValue.getObject(runtime);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Query methods
|
|
299
|
+
JSI_HOST_FUNCTION(computeBounds) {
|
|
300
|
+
auto path = getObject()->snapshot();
|
|
301
|
+
auto result = path.getBounds();
|
|
302
|
+
auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
|
|
303
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
304
|
+
runtime, hostObjectInstance, getContext());
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
JSI_HOST_FUNCTION(isEmpty) {
|
|
308
|
+
return jsi::Value(getObject()->snapshot().isEmpty());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
JSI_HOST_FUNCTION(getLastPt) {
|
|
312
|
+
SkPoint last;
|
|
313
|
+
getObject()->snapshot().getLastPt(&last);
|
|
314
|
+
auto point = jsi::Object(runtime);
|
|
315
|
+
point.setProperty(runtime, "x", static_cast<double>(last.fX));
|
|
316
|
+
point.setProperty(runtime, "y", static_cast<double>(last.fY));
|
|
317
|
+
return point;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
JSI_HOST_FUNCTION(countPoints) {
|
|
321
|
+
auto points = getObject()->snapshot().countPoints();
|
|
322
|
+
return jsi::Value(points);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Build methods
|
|
326
|
+
JSI_HOST_FUNCTION(build) {
|
|
327
|
+
// snapshot() returns a copy without resetting the builder
|
|
328
|
+
auto path = getObject()->snapshot();
|
|
329
|
+
auto hostObjectInstance =
|
|
330
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
331
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
332
|
+
runtime, hostObjectInstance, getContext());
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
JSI_HOST_FUNCTION(detach) {
|
|
336
|
+
// detach() returns the path and resets the builder
|
|
337
|
+
auto path = getObject()->detach();
|
|
338
|
+
auto hostObjectInstance =
|
|
339
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
340
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
341
|
+
runtime, hostObjectInstance, getContext());
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
EXPORT_JSI_API_TYPENAME(JsiSkPathBuilder, PathBuilder)
|
|
345
|
+
|
|
346
|
+
JSI_EXPORT_FUNCTIONS(
|
|
347
|
+
// Movement
|
|
348
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, moveTo),
|
|
349
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, rMoveTo),
|
|
350
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, lineTo),
|
|
351
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, rLineTo),
|
|
352
|
+
// Curves
|
|
353
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, quadTo),
|
|
354
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, rQuadTo),
|
|
355
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, conicTo),
|
|
356
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, rConicTo),
|
|
357
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, cubicTo),
|
|
358
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, rCubicTo),
|
|
359
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, close),
|
|
360
|
+
// Arcs
|
|
361
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, arcToOval),
|
|
362
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, arcToRotated),
|
|
363
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, rArcTo),
|
|
364
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, arcToTangent),
|
|
365
|
+
// Shapes
|
|
366
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, addRect),
|
|
367
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, addOval),
|
|
368
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, addArc),
|
|
369
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, addRRect),
|
|
370
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, addCircle),
|
|
371
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, addPoly),
|
|
372
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, addPath),
|
|
373
|
+
// Config
|
|
374
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, setFillType),
|
|
375
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, setIsVolatile),
|
|
376
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, reset),
|
|
377
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, offset),
|
|
378
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, transform),
|
|
379
|
+
// Query
|
|
380
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, computeBounds),
|
|
381
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, isEmpty),
|
|
382
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, getLastPt),
|
|
383
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, countPoints),
|
|
384
|
+
// Build
|
|
385
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, build),
|
|
386
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, detach),
|
|
387
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilder, dispose))
|
|
388
|
+
|
|
389
|
+
JsiSkPathBuilder(std::shared_ptr<RNSkPlatformContext> context,
|
|
390
|
+
SkPathBuilder builder)
|
|
391
|
+
: JsiSkWrappingSharedPtrHostObject<SkPathBuilder>(
|
|
392
|
+
std::move(context),
|
|
393
|
+
std::make_shared<SkPathBuilder>(std::move(builder))) {}
|
|
394
|
+
|
|
395
|
+
size_t getMemoryPressure() const override {
|
|
396
|
+
auto builder = getObject();
|
|
397
|
+
if (!builder)
|
|
398
|
+
return 0;
|
|
399
|
+
// Estimate memory usage based on snapshot
|
|
400
|
+
return builder->snapshot().approximateBytesUsed();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
std::string getObjectType() const override { return "JsiSkPathBuilder"; }
|
|
404
|
+
|
|
405
|
+
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
406
|
+
std::shared_ptr<RNSkPlatformContext> context,
|
|
407
|
+
const SkPathBuilder &builder) {
|
|
408
|
+
auto hostObjectInstance =
|
|
409
|
+
std::make_shared<JsiSkPathBuilder>(context, builder);
|
|
410
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
411
|
+
runtime, hostObjectInstance, context);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
} // namespace RNSkia
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <utility>
|
|
5
|
+
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
|
|
8
|
+
#include "JsiSkHostObjects.h"
|
|
9
|
+
#include "JsiSkPathBuilder.h"
|
|
10
|
+
|
|
11
|
+
#pragma clang diagnostic push
|
|
12
|
+
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
13
|
+
|
|
14
|
+
#include "include/core/SkPath.h"
|
|
15
|
+
#include "include/core/SkPathBuilder.h"
|
|
16
|
+
|
|
17
|
+
#pragma clang diagnostic pop
|
|
18
|
+
|
|
19
|
+
namespace RNSkia {
|
|
20
|
+
|
|
21
|
+
namespace jsi = facebook::jsi;
|
|
22
|
+
|
|
23
|
+
class JsiSkPathBuilderFactory : public JsiSkHostObject {
|
|
24
|
+
public:
|
|
25
|
+
JSI_HOST_FUNCTION(Make) {
|
|
26
|
+
auto hostObjectInstance =
|
|
27
|
+
std::make_shared<JsiSkPathBuilder>(getContext(), SkPathBuilder());
|
|
28
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
29
|
+
runtime, hostObjectInstance, getContext());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
JSI_HOST_FUNCTION(MakeFromPath) {
|
|
33
|
+
auto path = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
34
|
+
auto hostObjectInstance =
|
|
35
|
+
std::make_shared<JsiSkPathBuilder>(getContext(), SkPathBuilder(*path));
|
|
36
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
37
|
+
runtime, hostObjectInstance, getContext());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
size_t getMemoryPressure() const override { return 1024; }
|
|
41
|
+
|
|
42
|
+
std::string getObjectType() const override {
|
|
43
|
+
return "JsiSkPathBuilderFactory";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathBuilderFactory, Make),
|
|
47
|
+
JSI_EXPORT_FUNC(JsiSkPathBuilderFactory, MakeFromPath))
|
|
48
|
+
|
|
49
|
+
explicit JsiSkPathBuilderFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
50
|
+
: JsiSkHostObject(std::move(context)) {}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace RNSkia
|
|
@@ -92,7 +92,8 @@ public:
|
|
|
92
92
|
auto style =
|
|
93
93
|
static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
|
|
94
94
|
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
95
|
-
getContext(),
|
|
95
|
+
getContext(),
|
|
96
|
+
SkPath1DPathEffect::Make(path->snapshot(), advance, phase, style));
|
|
96
97
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, pathEffect,
|
|
97
98
|
getContext());
|
|
98
99
|
}
|
|
@@ -101,7 +102,7 @@ public:
|
|
|
101
102
|
auto matrix = JsiSkMatrix::fromValue(runtime, arguments[0]);
|
|
102
103
|
auto path = JsiSkPath::fromValue(runtime, arguments[1]);
|
|
103
104
|
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
104
|
-
getContext(), SkPath2DPathEffect::Make(*matrix,
|
|
105
|
+
getContext(), SkPath2DPathEffect::Make(*matrix, path->snapshot()));
|
|
105
106
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, pathEffect,
|
|
106
107
|
getContext());
|
|
107
108
|
}
|