@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
package/cpp/api/JsiSkPath.h
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
#include <algorithm>
|
|
4
4
|
#include <memory>
|
|
5
|
+
#include <set>
|
|
6
|
+
#include <string>
|
|
5
7
|
#include <utility>
|
|
6
8
|
#include <vector>
|
|
7
9
|
|
|
@@ -12,11 +14,13 @@
|
|
|
12
14
|
#include "JsiSkPoint.h"
|
|
13
15
|
#include "JsiSkRRect.h"
|
|
14
16
|
#include "JsiSkRect.h"
|
|
17
|
+
#include "RNSkLog.h"
|
|
15
18
|
|
|
16
19
|
#pragma clang diagnostic push
|
|
17
20
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
18
21
|
|
|
19
22
|
#include "include/core/SkPath.h"
|
|
23
|
+
#include "include/core/SkPathBuilder.h"
|
|
20
24
|
#include "include/core/SkPathEffect.h"
|
|
21
25
|
#include "include/core/SkPathTypes.h"
|
|
22
26
|
#include "include/core/SkPathUtils.h"
|
|
@@ -25,7 +29,6 @@
|
|
|
25
29
|
#include "include/effects/SkDashPathEffect.h"
|
|
26
30
|
#include "include/effects/SkTrimPathEffect.h"
|
|
27
31
|
#include "include/utils/SkParsePath.h"
|
|
28
|
-
#include "include/utils/SkTextUtils.h"
|
|
29
32
|
|
|
30
33
|
#include "include/pathops/SkPathOps.h"
|
|
31
34
|
|
|
@@ -35,7 +38,30 @@ namespace RNSkia {
|
|
|
35
38
|
|
|
36
39
|
namespace jsi = facebook::jsi;
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
// Track which deprecation warnings have been shown to avoid spam
|
|
42
|
+
inline std::set<std::string> &getShownPathDeprecationWarnings() {
|
|
43
|
+
static std::set<std::string> warnings;
|
|
44
|
+
return warnings;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
inline void warnDeprecatedPathMethod(jsi::Runtime &runtime,
|
|
48
|
+
const char *methodName,
|
|
49
|
+
const char *suggestion) {
|
|
50
|
+
auto &warnings = getShownPathDeprecationWarnings();
|
|
51
|
+
if (warnings.find(methodName) != warnings.end()) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
warnings.insert(methodName);
|
|
55
|
+
std::string message =
|
|
56
|
+
std::string("[react-native-skia] SkPath.") + methodName +
|
|
57
|
+
"() is deprecated and will be removed in a future release. " +
|
|
58
|
+
suggestion +
|
|
59
|
+
" See migration guide: "
|
|
60
|
+
"https://shopify.github.io/react-native-skia/docs/shapes/path-migration";
|
|
61
|
+
RNSkLogger::warnToJavascriptConsole(runtime, message);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPathBuilder> {
|
|
39
65
|
private:
|
|
40
66
|
static const int MOVE = 0;
|
|
41
67
|
static const int LINE = 1;
|
|
@@ -44,30 +70,163 @@ private:
|
|
|
44
70
|
static const int CUBIC = 4;
|
|
45
71
|
static const int CLOSE = 5;
|
|
46
72
|
|
|
47
|
-
|
|
48
|
-
// Clamp the double value between 0 and 1 and then cast it to float
|
|
49
|
-
return static_cast<float>(std::clamp(value, 0.0, 1.0));
|
|
50
|
-
}
|
|
73
|
+
SkPath asPath() const { return getObject()->snapshot(); }
|
|
51
74
|
|
|
52
75
|
public:
|
|
76
|
+
// Mutable building methods (deprecated)
|
|
77
|
+
|
|
78
|
+
JSI_HOST_FUNCTION(moveTo) {
|
|
79
|
+
warnDeprecatedPathMethod(runtime, "moveTo",
|
|
80
|
+
"Use Skia.PathBuilder.Make().moveTo() instead.");
|
|
81
|
+
SkScalar x = arguments[0].asNumber();
|
|
82
|
+
SkScalar y = arguments[1].asNumber();
|
|
83
|
+
getObject()->moveTo(x, y);
|
|
84
|
+
return thisValue.getObject(runtime);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
JSI_HOST_FUNCTION(rMoveTo) {
|
|
88
|
+
warnDeprecatedPathMethod(runtime, "rMoveTo",
|
|
89
|
+
"Use Skia.PathBuilder.Make().rMoveTo() instead.");
|
|
90
|
+
SkScalar x = arguments[0].asNumber();
|
|
91
|
+
SkScalar y = arguments[1].asNumber();
|
|
92
|
+
getObject()->rMoveTo({x, y});
|
|
93
|
+
return thisValue.getObject(runtime);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
JSI_HOST_FUNCTION(lineTo) {
|
|
97
|
+
warnDeprecatedPathMethod(runtime, "lineTo",
|
|
98
|
+
"Use Skia.PathBuilder.Make().lineTo() instead.");
|
|
99
|
+
SkScalar x = arguments[0].asNumber();
|
|
100
|
+
SkScalar y = arguments[1].asNumber();
|
|
101
|
+
getObject()->lineTo(x, y);
|
|
102
|
+
return thisValue.getObject(runtime);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
JSI_HOST_FUNCTION(rLineTo) {
|
|
106
|
+
warnDeprecatedPathMethod(runtime, "rLineTo",
|
|
107
|
+
"Use Skia.PathBuilder.Make().rLineTo() instead.");
|
|
108
|
+
SkScalar x = arguments[0].asNumber();
|
|
109
|
+
SkScalar y = arguments[1].asNumber();
|
|
110
|
+
getObject()->rLineTo(x, y);
|
|
111
|
+
return thisValue.getObject(runtime);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
JSI_HOST_FUNCTION(quadTo) {
|
|
115
|
+
warnDeprecatedPathMethod(runtime, "quadTo",
|
|
116
|
+
"Use Skia.PathBuilder.Make().quadTo() instead.");
|
|
117
|
+
SkScalar x1 = arguments[0].asNumber();
|
|
118
|
+
SkScalar y1 = arguments[1].asNumber();
|
|
119
|
+
SkScalar x2 = arguments[2].asNumber();
|
|
120
|
+
SkScalar y2 = arguments[3].asNumber();
|
|
121
|
+
getObject()->quadTo(x1, y1, x2, y2);
|
|
122
|
+
return thisValue.getObject(runtime);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
JSI_HOST_FUNCTION(rQuadTo) {
|
|
126
|
+
warnDeprecatedPathMethod(runtime, "rQuadTo",
|
|
127
|
+
"Use Skia.PathBuilder.Make().rQuadTo() instead.");
|
|
128
|
+
SkScalar x1 = arguments[0].asNumber();
|
|
129
|
+
SkScalar y1 = arguments[1].asNumber();
|
|
130
|
+
SkScalar x2 = arguments[2].asNumber();
|
|
131
|
+
SkScalar y2 = arguments[3].asNumber();
|
|
132
|
+
getObject()->rQuadTo(x1, y1, x2, y2);
|
|
133
|
+
return thisValue.getObject(runtime);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
JSI_HOST_FUNCTION(conicTo) {
|
|
137
|
+
warnDeprecatedPathMethod(runtime, "conicTo",
|
|
138
|
+
"Use Skia.PathBuilder.Make().conicTo() instead.");
|
|
139
|
+
SkScalar x1 = arguments[0].asNumber();
|
|
140
|
+
SkScalar y1 = arguments[1].asNumber();
|
|
141
|
+
SkScalar x2 = arguments[2].asNumber();
|
|
142
|
+
SkScalar y2 = arguments[3].asNumber();
|
|
143
|
+
SkScalar w = arguments[4].asNumber();
|
|
144
|
+
getObject()->conicTo(x1, y1, x2, y2, w);
|
|
145
|
+
return thisValue.getObject(runtime);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
JSI_HOST_FUNCTION(rConicTo) {
|
|
149
|
+
warnDeprecatedPathMethod(runtime, "rConicTo",
|
|
150
|
+
"Use Skia.PathBuilder.Make().rConicTo() instead.");
|
|
151
|
+
SkScalar x1 = arguments[0].asNumber();
|
|
152
|
+
SkScalar y1 = arguments[1].asNumber();
|
|
153
|
+
SkScalar x2 = arguments[2].asNumber();
|
|
154
|
+
SkScalar y2 = arguments[3].asNumber();
|
|
155
|
+
SkScalar w = arguments[4].asNumber();
|
|
156
|
+
getObject()->rConicTo(x1, y1, x2, y2, w);
|
|
157
|
+
return thisValue.getObject(runtime);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
JSI_HOST_FUNCTION(cubicTo) {
|
|
161
|
+
warnDeprecatedPathMethod(runtime, "cubicTo",
|
|
162
|
+
"Use Skia.PathBuilder.Make().cubicTo() instead.");
|
|
163
|
+
SkScalar x1 = arguments[0].asNumber();
|
|
164
|
+
SkScalar y1 = arguments[1].asNumber();
|
|
165
|
+
SkScalar x2 = arguments[2].asNumber();
|
|
166
|
+
SkScalar y2 = arguments[3].asNumber();
|
|
167
|
+
SkScalar x3 = arguments[4].asNumber();
|
|
168
|
+
SkScalar y3 = arguments[5].asNumber();
|
|
169
|
+
getObject()->cubicTo(x1, y1, x2, y2, x3, y3);
|
|
170
|
+
return thisValue.getObject(runtime);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
JSI_HOST_FUNCTION(rCubicTo) {
|
|
174
|
+
warnDeprecatedPathMethod(runtime, "rCubicTo",
|
|
175
|
+
"Use Skia.PathBuilder.Make().rCubicTo() instead.");
|
|
176
|
+
SkScalar x1 = arguments[0].asNumber();
|
|
177
|
+
SkScalar y1 = arguments[1].asNumber();
|
|
178
|
+
SkScalar x2 = arguments[2].asNumber();
|
|
179
|
+
SkScalar y2 = arguments[3].asNumber();
|
|
180
|
+
SkScalar x3 = arguments[4].asNumber();
|
|
181
|
+
SkScalar y3 = arguments[5].asNumber();
|
|
182
|
+
getObject()->rCubicTo(x1, y1, x2, y2, x3, y3);
|
|
183
|
+
return thisValue.getObject(runtime);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
JSI_HOST_FUNCTION(close) {
|
|
187
|
+
warnDeprecatedPathMethod(runtime, "close",
|
|
188
|
+
"Use Skia.PathBuilder.Make().close() instead.");
|
|
189
|
+
getObject()->close();
|
|
190
|
+
return thisValue.getObject(runtime);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
JSI_HOST_FUNCTION(reset) {
|
|
194
|
+
warnDeprecatedPathMethod(runtime, "reset",
|
|
195
|
+
"Use Skia.PathBuilder.Make().reset() instead.");
|
|
196
|
+
getObject()->reset();
|
|
197
|
+
return thisValue.getObject(runtime);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
JSI_HOST_FUNCTION(rewind) {
|
|
201
|
+
warnDeprecatedPathMethod(runtime, "rewind",
|
|
202
|
+
"Use Skia.PathBuilder.Make().reset() instead.");
|
|
203
|
+
getObject()->reset();
|
|
204
|
+
return thisValue.getObject(runtime);
|
|
205
|
+
}
|
|
206
|
+
|
|
53
207
|
JSI_HOST_FUNCTION(addPath) {
|
|
208
|
+
warnDeprecatedPathMethod(runtime, "addPath",
|
|
209
|
+
"Use Skia.PathBuilder.Make().addPath() instead.");
|
|
54
210
|
auto src = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
211
|
+
auto srcPath = src->snapshot();
|
|
55
212
|
auto matrix =
|
|
56
213
|
count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
|
57
214
|
? JsiSkMatrix::fromValue(runtime, arguments[1])
|
|
58
215
|
: nullptr;
|
|
59
|
-
auto
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (matrix
|
|
63
|
-
getObject()->addPath(*
|
|
216
|
+
auto extend = count > 2 && arguments[2].getBool();
|
|
217
|
+
auto mode =
|
|
218
|
+
extend ? SkPath::kExtend_AddPathMode : SkPath::kAppend_AddPathMode;
|
|
219
|
+
if (matrix) {
|
|
220
|
+
getObject()->addPath(srcPath, *matrix, mode);
|
|
64
221
|
} else {
|
|
65
|
-
getObject()->addPath(
|
|
222
|
+
getObject()->addPath(srcPath, mode);
|
|
66
223
|
}
|
|
67
224
|
return thisValue.getObject(runtime);
|
|
68
225
|
}
|
|
69
226
|
|
|
70
227
|
JSI_HOST_FUNCTION(addArc) {
|
|
228
|
+
warnDeprecatedPathMethod(runtime, "addArc",
|
|
229
|
+
"Use Skia.PathBuilder.Make().addArc() instead.");
|
|
71
230
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
72
231
|
auto start = arguments[1].asNumber();
|
|
73
232
|
auto sweep = arguments[2].asNumber();
|
|
@@ -76,53 +235,76 @@ public:
|
|
|
76
235
|
}
|
|
77
236
|
|
|
78
237
|
JSI_HOST_FUNCTION(addOval) {
|
|
238
|
+
warnDeprecatedPathMethod(
|
|
239
|
+
runtime, "addOval",
|
|
240
|
+
"Use Skia.Path.Oval() or Skia.PathBuilder.Make().addOval() instead.");
|
|
79
241
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
80
|
-
auto
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
auto result = getObject()->addOval(*rect, direction, startIndex);
|
|
86
|
-
return thisValue.getObject(runtime);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
JSI_HOST_FUNCTION(addPoly) {
|
|
90
|
-
std::vector<SkPoint> points;
|
|
91
|
-
auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
|
|
92
|
-
auto close = arguments[1].getBool();
|
|
93
|
-
auto pointsSize = jsiPoints.size(runtime);
|
|
94
|
-
points.reserve(pointsSize);
|
|
95
|
-
for (int i = 0; i < pointsSize; i++) {
|
|
96
|
-
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
|
97
|
-
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
|
98
|
-
points.push_back(*point.get());
|
|
99
|
-
}
|
|
100
|
-
auto p = SkSpan(points.data(), points.size());
|
|
101
|
-
getObject()->addPoly(p, close);
|
|
242
|
+
auto isCCW = count > 1 && arguments[1].getBool();
|
|
243
|
+
auto startIndex =
|
|
244
|
+
count > 2 ? static_cast<unsigned>(arguments[2].asNumber()) : 1;
|
|
245
|
+
auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
246
|
+
getObject()->addOval(*rect, direction, startIndex);
|
|
102
247
|
return thisValue.getObject(runtime);
|
|
103
248
|
}
|
|
104
249
|
|
|
105
250
|
JSI_HOST_FUNCTION(addRect) {
|
|
251
|
+
warnDeprecatedPathMethod(
|
|
252
|
+
runtime, "addRect",
|
|
253
|
+
"Use Skia.Path.Rect() or Skia.PathBuilder.Make().addRect() instead.");
|
|
106
254
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
107
|
-
auto
|
|
108
|
-
|
|
109
|
-
direction = SkPathDirection::kCCW;
|
|
110
|
-
}
|
|
255
|
+
auto isCCW = count > 1 && arguments[1].getBool();
|
|
256
|
+
auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
111
257
|
getObject()->addRect(*rect, direction);
|
|
112
258
|
return thisValue.getObject(runtime);
|
|
113
259
|
}
|
|
114
260
|
|
|
115
261
|
JSI_HOST_FUNCTION(addRRect) {
|
|
262
|
+
warnDeprecatedPathMethod(
|
|
263
|
+
runtime, "addRRect",
|
|
264
|
+
"Use Skia.Path.RRect() or Skia.PathBuilder.Make().addRRect() instead.");
|
|
116
265
|
auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
|
|
117
|
-
auto
|
|
118
|
-
|
|
119
|
-
direction = SkPathDirection::kCCW;
|
|
120
|
-
}
|
|
266
|
+
auto isCCW = count > 1 && arguments[1].getBool();
|
|
267
|
+
auto direction = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
121
268
|
getObject()->addRRect(*rrect, direction);
|
|
122
269
|
return thisValue.getObject(runtime);
|
|
123
270
|
}
|
|
124
271
|
|
|
272
|
+
JSI_HOST_FUNCTION(addCircle) {
|
|
273
|
+
warnDeprecatedPathMethod(
|
|
274
|
+
runtime, "addCircle",
|
|
275
|
+
"Use Skia.Path.Circle() or Skia.PathBuilder.Make().addCircle() "
|
|
276
|
+
"instead.");
|
|
277
|
+
SkScalar x = arguments[0].asNumber();
|
|
278
|
+
SkScalar y = arguments[1].asNumber();
|
|
279
|
+
SkScalar r = arguments[2].asNumber();
|
|
280
|
+
getObject()->addCircle(x, y, r);
|
|
281
|
+
return thisValue.getObject(runtime);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
JSI_HOST_FUNCTION(addPoly) {
|
|
285
|
+
warnDeprecatedPathMethod(
|
|
286
|
+
runtime, "addPoly",
|
|
287
|
+
"Use Skia.Path.Polygon() or Skia.PathBuilder.Make().addPoly() "
|
|
288
|
+
"instead.");
|
|
289
|
+
auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
|
|
290
|
+
auto close = arguments[1].getBool();
|
|
291
|
+
auto pointsSize = static_cast<int>(jsiPoints.size(runtime));
|
|
292
|
+
std::vector<SkPoint> points;
|
|
293
|
+
points.reserve(pointsSize);
|
|
294
|
+
for (int i = 0; i < pointsSize; i++) {
|
|
295
|
+
auto pt =
|
|
296
|
+
JsiSkPoint::fromValue(runtime, jsiPoints.getValueAtIndex(runtime, i));
|
|
297
|
+
points.push_back(*pt);
|
|
298
|
+
}
|
|
299
|
+
getObject()->addPolygon(SkSpan<const SkPoint>(points.data(), points.size()),
|
|
300
|
+
close);
|
|
301
|
+
return thisValue.getObject(runtime);
|
|
302
|
+
}
|
|
303
|
+
|
|
125
304
|
JSI_HOST_FUNCTION(arcToOval) {
|
|
305
|
+
warnDeprecatedPathMethod(
|
|
306
|
+
runtime, "arcToOval",
|
|
307
|
+
"Use Skia.PathBuilder.Make().arcToOval() instead.");
|
|
126
308
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
127
309
|
auto start = arguments[1].asNumber();
|
|
128
310
|
auto sweep = arguments[2].asNumber();
|
|
@@ -132,395 +314,318 @@ public:
|
|
|
132
314
|
}
|
|
133
315
|
|
|
134
316
|
JSI_HOST_FUNCTION(arcToRotated) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
317
|
+
warnDeprecatedPathMethod(
|
|
318
|
+
runtime, "arcToRotated",
|
|
319
|
+
"Use Skia.PathBuilder.Make().arcToRotated() instead.");
|
|
320
|
+
SkScalar rx = arguments[0].asNumber();
|
|
321
|
+
SkScalar ry = arguments[1].asNumber();
|
|
322
|
+
SkScalar xAxisRotate = arguments[2].asNumber();
|
|
138
323
|
auto useSmallArc = arguments[3].getBool();
|
|
139
|
-
auto
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
auto
|
|
145
|
-
getObject()->arcTo(rx, ry, xAxisRotate, arcSize, sweep,
|
|
324
|
+
auto isCCW = arguments[4].getBool();
|
|
325
|
+
SkScalar x = arguments[5].asNumber();
|
|
326
|
+
SkScalar y = arguments[6].asNumber();
|
|
327
|
+
auto arcSize = useSmallArc ? SkPathBuilder::kSmall_ArcSize
|
|
328
|
+
: SkPathBuilder::kLarge_ArcSize;
|
|
329
|
+
auto sweep = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
330
|
+
getObject()->arcTo(SkPoint::Make(rx, ry), xAxisRotate, arcSize, sweep,
|
|
331
|
+
SkPoint::Make(x, y));
|
|
146
332
|
return thisValue.getObject(runtime);
|
|
147
333
|
}
|
|
148
334
|
|
|
149
335
|
JSI_HOST_FUNCTION(rArcTo) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
336
|
+
warnDeprecatedPathMethod(runtime, "rArcTo",
|
|
337
|
+
"Use Skia.PathBuilder.Make().rArcTo() instead.");
|
|
338
|
+
SkScalar rx = arguments[0].asNumber();
|
|
339
|
+
SkScalar ry = arguments[1].asNumber();
|
|
340
|
+
SkScalar xAxisRotate = arguments[2].asNumber();
|
|
153
341
|
auto useSmallArc = arguments[3].getBool();
|
|
154
|
-
auto
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
auto
|
|
160
|
-
|
|
342
|
+
auto isCCW = arguments[4].getBool();
|
|
343
|
+
SkScalar dx = arguments[5].asNumber();
|
|
344
|
+
SkScalar dy = arguments[6].asNumber();
|
|
345
|
+
auto arcSize = useSmallArc ? SkPathBuilder::kSmall_ArcSize
|
|
346
|
+
: SkPathBuilder::kLarge_ArcSize;
|
|
347
|
+
auto sweep = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
|
|
348
|
+
SkVector dxdy(dx, dy);
|
|
349
|
+
SkPoint r(rx, ry);
|
|
350
|
+
getObject()->rArcTo(r, xAxisRotate, arcSize, sweep, dxdy);
|
|
161
351
|
return thisValue.getObject(runtime);
|
|
162
352
|
}
|
|
163
353
|
|
|
164
354
|
JSI_HOST_FUNCTION(arcToTangent) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
355
|
+
warnDeprecatedPathMethod(
|
|
356
|
+
runtime, "arcToTangent",
|
|
357
|
+
"Use Skia.PathBuilder.Make().arcToTangent() instead.");
|
|
358
|
+
SkScalar x1 = arguments[0].asNumber();
|
|
359
|
+
SkScalar y1 = arguments[1].asNumber();
|
|
360
|
+
SkScalar x2 = arguments[2].asNumber();
|
|
361
|
+
SkScalar y2 = arguments[3].asNumber();
|
|
362
|
+
SkScalar r = arguments[4].asNumber();
|
|
363
|
+
getObject()->arcTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), r);
|
|
171
364
|
return thisValue.getObject(runtime);
|
|
172
365
|
}
|
|
173
366
|
|
|
174
|
-
JSI_HOST_FUNCTION(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
// TODO-API: Should this be a property?
|
|
182
|
-
JSI_HOST_FUNCTION(getBounds) {
|
|
183
|
-
auto result = getObject()->getBounds();
|
|
184
|
-
auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
|
|
185
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
186
|
-
runtime, hostObjectInstance, getContext());
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
JSI_HOST_FUNCTION(conicTo) {
|
|
190
|
-
auto x1 = arguments[0].asNumber();
|
|
191
|
-
auto y1 = arguments[1].asNumber();
|
|
192
|
-
auto x2 = arguments[2].asNumber();
|
|
193
|
-
auto y2 = arguments[3].asNumber();
|
|
194
|
-
auto w = arguments[4].asNumber();
|
|
195
|
-
getObject()->conicTo(x1, y1, x2, y2, w);
|
|
367
|
+
JSI_HOST_FUNCTION(setFillType) {
|
|
368
|
+
warnDeprecatedPathMethod(
|
|
369
|
+
runtime, "setFillType",
|
|
370
|
+
"Use Skia.PathBuilder.Make().setFillType() instead.");
|
|
371
|
+
auto ft = arguments[0].asNumber();
|
|
372
|
+
getObject()->setFillType(static_cast<SkPathFillType>(static_cast<int>(ft)));
|
|
196
373
|
return thisValue.getObject(runtime);
|
|
197
374
|
}
|
|
198
375
|
|
|
199
|
-
JSI_HOST_FUNCTION(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
auto
|
|
204
|
-
|
|
205
|
-
getObject()->rConicTo(x1, y1, x2, y2, w);
|
|
376
|
+
JSI_HOST_FUNCTION(setIsVolatile) {
|
|
377
|
+
warnDeprecatedPathMethod(
|
|
378
|
+
runtime, "setIsVolatile",
|
|
379
|
+
"Use Skia.PathBuilder.Make().setIsVolatile() instead.");
|
|
380
|
+
auto v = arguments[0].getBool();
|
|
381
|
+
getObject()->setIsVolatile(v);
|
|
206
382
|
return thisValue.getObject(runtime);
|
|
207
383
|
}
|
|
208
384
|
|
|
209
|
-
|
|
210
|
-
auto x = arguments[0].asNumber();
|
|
211
|
-
auto y = arguments[1].asNumber();
|
|
212
|
-
return jsi::Value(getObject()->contains(x, y));
|
|
213
|
-
}
|
|
385
|
+
// Mutable transform methods (deprecated)
|
|
214
386
|
|
|
215
|
-
JSI_HOST_FUNCTION(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (!pe) {
|
|
223
|
-
// TODO: SkDebugf("Invalid args to dash()\n");
|
|
224
|
-
return jsi::Value(false);
|
|
225
|
-
}
|
|
226
|
-
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
227
|
-
SkPath &path = *getObject();
|
|
228
|
-
// TODO: why we don't need to swap here? In trim() which is the same
|
|
229
|
-
// API, we need to swap
|
|
230
|
-
if (pe->filterPath(&path, path, &rec, nullptr)) {
|
|
231
|
-
return jsi::Value(true);
|
|
232
|
-
}
|
|
233
|
-
SkDebugf("Could not make dashed path\n");
|
|
234
|
-
return jsi::Value(false);
|
|
387
|
+
JSI_HOST_FUNCTION(transform) {
|
|
388
|
+
warnDeprecatedPathMethod(
|
|
389
|
+
runtime, "transform",
|
|
390
|
+
"Use Skia.PathBuilder.Make().transform() instead.");
|
|
391
|
+
auto m3 = *JsiSkMatrix::fromValue(runtime, arguments[0]);
|
|
392
|
+
getObject()->transform(m3);
|
|
393
|
+
return thisValue.getObject(runtime);
|
|
235
394
|
}
|
|
236
395
|
|
|
237
|
-
JSI_HOST_FUNCTION(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
396
|
+
JSI_HOST_FUNCTION(offset) {
|
|
397
|
+
warnDeprecatedPathMethod(runtime, "offset",
|
|
398
|
+
"Use Skia.PathBuilder.Make().offset() instead.");
|
|
399
|
+
SkScalar dx = arguments[0].asNumber();
|
|
400
|
+
SkScalar dy = arguments[1].asNumber();
|
|
401
|
+
getObject()->offset(dx, dy);
|
|
402
|
+
return thisValue.getObject(runtime);
|
|
241
403
|
}
|
|
242
404
|
|
|
243
|
-
//
|
|
244
|
-
JSI_HOST_FUNCTION(getFillType) {
|
|
245
|
-
auto fillType = getObject()->getFillType();
|
|
246
|
-
return jsi::Value(static_cast<int>(fillType));
|
|
247
|
-
}
|
|
405
|
+
// Mutable path operations (deprecated)
|
|
248
406
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
407
|
+
JSI_HOST_FUNCTION(simplify) {
|
|
408
|
+
warnDeprecatedPathMethod(runtime, "simplify",
|
|
409
|
+
"Use Skia.Path.Simplify(path) instead.");
|
|
410
|
+
auto path = asPath();
|
|
411
|
+
auto result = ::Simplify(path);
|
|
412
|
+
if (result.has_value()) {
|
|
413
|
+
*getObject() = SkPathBuilder(result.value());
|
|
414
|
+
}
|
|
253
415
|
return thisValue.getObject(runtime);
|
|
254
416
|
}
|
|
255
417
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
418
|
+
JSI_HOST_FUNCTION(op) {
|
|
419
|
+
warnDeprecatedPathMethod(runtime, "op",
|
|
420
|
+
"Use Skia.Path.MakeFromOp() instead.");
|
|
421
|
+
auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
422
|
+
auto pathOp =
|
|
423
|
+
static_cast<SkPathOp>(static_cast<int>(arguments[1].asNumber()));
|
|
424
|
+
auto p1 = asPath();
|
|
425
|
+
auto p2 = path2->snapshot();
|
|
426
|
+
auto result = ::Op(p1, p2, pathOp);
|
|
427
|
+
if (result.has_value()) {
|
|
428
|
+
*getObject() = SkPathBuilder(result.value());
|
|
429
|
+
}
|
|
260
430
|
return thisValue.getObject(runtime);
|
|
261
431
|
}
|
|
262
432
|
|
|
263
|
-
JSI_HOST_FUNCTION(
|
|
264
|
-
|
|
433
|
+
JSI_HOST_FUNCTION(makeAsWinding) {
|
|
434
|
+
warnDeprecatedPathMethod(runtime, "makeAsWinding",
|
|
435
|
+
"Use Skia.Path.AsWinding(path) instead.");
|
|
436
|
+
auto path = asPath();
|
|
437
|
+
auto result = ::AsWinding(path);
|
|
438
|
+
if (result.has_value()) {
|
|
439
|
+
*getObject() = SkPathBuilder(result.value());
|
|
440
|
+
}
|
|
441
|
+
return thisValue.getObject(runtime);
|
|
265
442
|
}
|
|
266
443
|
|
|
267
|
-
JSI_HOST_FUNCTION(
|
|
268
|
-
|
|
269
|
-
|
|
444
|
+
JSI_HOST_FUNCTION(dash) {
|
|
445
|
+
warnDeprecatedPathMethod(
|
|
446
|
+
runtime, "dash", "Use Skia.Path.Dash(path, on, off, phase) instead.");
|
|
447
|
+
auto path = asPath();
|
|
448
|
+
SkScalar on = arguments[0].asNumber();
|
|
449
|
+
SkScalar off = arguments[1].asNumber();
|
|
450
|
+
auto phase = arguments[2].asNumber();
|
|
451
|
+
SkScalar intervals[] = {on, off};
|
|
452
|
+
auto pe = SkDashPathEffect::Make(SkSpan(intervals, 2), phase);
|
|
453
|
+
if (pe) {
|
|
454
|
+
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
455
|
+
SkPathBuilder resultBuilder;
|
|
456
|
+
if (pe->filterPath(&resultBuilder, path, &rec)) {
|
|
457
|
+
*getObject() = std::move(resultBuilder);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
270
460
|
return thisValue.getObject(runtime);
|
|
271
461
|
}
|
|
272
462
|
|
|
273
463
|
JSI_HOST_FUNCTION(stroke) {
|
|
274
|
-
|
|
275
|
-
|
|
464
|
+
warnDeprecatedPathMethod(runtime, "stroke",
|
|
465
|
+
"Use Skia.Path.Stroke(path, opts) instead.");
|
|
466
|
+
auto path = asPath();
|
|
276
467
|
SkPaint p;
|
|
277
468
|
p.setStyle(SkPaint::kStroke_Style);
|
|
278
469
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
auto cap = (SkPaint::Cap)jsiCap.asNumber();
|
|
282
|
-
p.setStrokeCap(cap);
|
|
283
|
-
}
|
|
470
|
+
if (count > 0 && !arguments[0].isUndefined()) {
|
|
471
|
+
auto opts = arguments[0].asObject(runtime);
|
|
284
472
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
473
|
+
auto jsiCap = opts.getProperty(runtime, "cap");
|
|
474
|
+
if (!jsiCap.isUndefined()) {
|
|
475
|
+
p.setStrokeCap(
|
|
476
|
+
static_cast<SkPaint::Cap>(static_cast<int>(jsiCap.asNumber())));
|
|
477
|
+
}
|
|
290
478
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
479
|
+
auto jsiJoin = opts.getProperty(runtime, "join");
|
|
480
|
+
if (!jsiJoin.isUndefined()) {
|
|
481
|
+
p.setStrokeJoin(
|
|
482
|
+
static_cast<SkPaint::Join>(static_cast<int>(jsiJoin.asNumber())));
|
|
483
|
+
}
|
|
296
484
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
485
|
+
auto jsiWidth = opts.getProperty(runtime, "width");
|
|
486
|
+
if (!jsiWidth.isUndefined()) {
|
|
487
|
+
p.setStrokeWidth(jsiWidth.asNumber());
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
auto jsiMiterLimit = opts.getProperty(runtime, "miter_limit");
|
|
491
|
+
if (!jsiMiterLimit.isUndefined()) {
|
|
492
|
+
p.setStrokeMiter(jsiMiterLimit.asNumber());
|
|
493
|
+
}
|
|
301
494
|
}
|
|
302
495
|
|
|
303
|
-
|
|
304
|
-
auto
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (result) {
|
|
308
|
-
getObject()->swap(path);
|
|
496
|
+
SkPathBuilder resultBuilder;
|
|
497
|
+
auto success = skpathutils::FillPathWithPaint(path, p, &resultBuilder);
|
|
498
|
+
if (success) {
|
|
499
|
+
*getObject() = std::move(resultBuilder);
|
|
309
500
|
}
|
|
310
|
-
return
|
|
501
|
+
return thisValue.getObject(runtime);
|
|
311
502
|
}
|
|
312
503
|
|
|
313
504
|
JSI_HOST_FUNCTION(trim) {
|
|
314
|
-
|
|
315
|
-
|
|
505
|
+
warnDeprecatedPathMethod(
|
|
506
|
+
runtime, "trim",
|
|
507
|
+
"Use Skia.Path.Trim(path, start, end, isComplement) instead.");
|
|
508
|
+
auto path = asPath();
|
|
509
|
+
float start =
|
|
510
|
+
std::clamp(static_cast<float>(arguments[0].asNumber()), 0.0f, 1.0f);
|
|
511
|
+
float end =
|
|
512
|
+
std::clamp(static_cast<float>(arguments[1].asNumber()), 0.0f, 1.0f);
|
|
316
513
|
auto isComplement = arguments[2].getBool();
|
|
317
|
-
auto path = *getObject();
|
|
318
514
|
auto mode = isComplement ? SkTrimPathEffect::Mode::kInverted
|
|
319
515
|
: SkTrimPathEffect::Mode::kNormal;
|
|
320
516
|
auto pe = SkTrimPathEffect::Make(start, end, mode);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return thisValue.getObject(runtime);
|
|
328
|
-
}
|
|
329
|
-
return jsi::Value::null();
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
JSI_HOST_FUNCTION(getPoint) {
|
|
333
|
-
auto index = arguments[0].asNumber();
|
|
334
|
-
auto point = getObject()->getPoint(index);
|
|
335
|
-
auto hostObjectInstance = std::make_shared<JsiSkPoint>(getContext(), point);
|
|
336
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
337
|
-
runtime, hostObjectInstance, getContext());
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
JSI_HOST_FUNCTION(toSVGString) {
|
|
341
|
-
SkPath path = *getObject();
|
|
342
|
-
auto s = SkParsePath::ToSVGString(path);
|
|
343
|
-
return jsi::String::createFromUtf8(runtime, s.c_str());
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
JSI_HOST_FUNCTION(makeAsWinding) {
|
|
347
|
-
SkPath out;
|
|
348
|
-
if (AsWinding(*getObject(), &out)) {
|
|
349
|
-
getObject()->swap(out);
|
|
350
|
-
return thisValue.getObject(runtime);
|
|
517
|
+
if (pe) {
|
|
518
|
+
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
519
|
+
SkPathBuilder resultBuilder;
|
|
520
|
+
if (pe->filterPath(&resultBuilder, path, &rec)) {
|
|
521
|
+
*getObject() = std::move(resultBuilder);
|
|
522
|
+
}
|
|
351
523
|
}
|
|
352
|
-
return jsi::Value::null();
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
JSI_HOST_FUNCTION(isEmpty) { return jsi::Value(getObject()->isEmpty()); }
|
|
356
|
-
|
|
357
|
-
JSI_HOST_FUNCTION(offset) {
|
|
358
|
-
SkScalar dx = arguments[0].asNumber();
|
|
359
|
-
SkScalar dy = arguments[1].asNumber();
|
|
360
|
-
getObject()->offset(dx, dy);
|
|
361
|
-
return thisValue.getObject(runtime);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
JSI_HOST_FUNCTION(moveTo) {
|
|
365
|
-
SkScalar x = arguments[0].asNumber();
|
|
366
|
-
SkScalar y = arguments[1].asNumber();
|
|
367
|
-
getObject()->moveTo(x, y);
|
|
368
524
|
return thisValue.getObject(runtime);
|
|
369
525
|
}
|
|
370
526
|
|
|
371
|
-
|
|
372
|
-
SkScalar x = arguments[0].asNumber();
|
|
373
|
-
SkScalar y = arguments[1].asNumber();
|
|
374
|
-
getObject()->rMoveTo(x, y);
|
|
375
|
-
return thisValue.getObject(runtime);
|
|
376
|
-
}
|
|
377
|
-
JSI_HOST_FUNCTION(lineTo) {
|
|
378
|
-
SkScalar x = arguments[0].asNumber();
|
|
379
|
-
SkScalar y = arguments[1].asNumber();
|
|
380
|
-
getObject()->lineTo(x, y);
|
|
381
|
-
return thisValue.getObject(runtime);
|
|
382
|
-
}
|
|
527
|
+
// Query methods
|
|
383
528
|
|
|
384
|
-
JSI_HOST_FUNCTION(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
return
|
|
529
|
+
JSI_HOST_FUNCTION(computeTightBounds) {
|
|
530
|
+
auto path = asPath();
|
|
531
|
+
auto result = path.computeTightBounds();
|
|
532
|
+
auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
|
|
533
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
534
|
+
runtime, hostObjectInstance, getContext());
|
|
389
535
|
}
|
|
390
536
|
|
|
391
|
-
JSI_HOST_FUNCTION(
|
|
392
|
-
auto
|
|
393
|
-
auto
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
auto x3 = arguments[4].asNumber();
|
|
397
|
-
auto y3 = arguments[5].asNumber();
|
|
398
|
-
getObject()->cubicTo(x1, y1, x2, y2, x3, y3);
|
|
399
|
-
return thisValue.getObject(runtime);
|
|
537
|
+
JSI_HOST_FUNCTION(getBounds) {
|
|
538
|
+
auto result = getObject()->computeBounds();
|
|
539
|
+
auto hostObjectInstance = std::make_shared<JsiSkRect>(getContext(), result);
|
|
540
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
541
|
+
runtime, hostObjectInstance, getContext());
|
|
400
542
|
}
|
|
401
543
|
|
|
402
|
-
JSI_HOST_FUNCTION(
|
|
403
|
-
auto
|
|
404
|
-
auto
|
|
405
|
-
|
|
406
|
-
auto y2 = arguments[3].asNumber();
|
|
407
|
-
auto x3 = arguments[4].asNumber();
|
|
408
|
-
auto y3 = arguments[5].asNumber();
|
|
409
|
-
getObject()->rCubicTo(x1, y1, x2, y2, x3, y3);
|
|
410
|
-
return thisValue.getObject(runtime);
|
|
544
|
+
JSI_HOST_FUNCTION(contains) {
|
|
545
|
+
auto x = arguments[0].asNumber();
|
|
546
|
+
auto y = arguments[1].asNumber();
|
|
547
|
+
return jsi::Value(asPath().contains(x, y));
|
|
411
548
|
}
|
|
412
549
|
|
|
413
|
-
JSI_HOST_FUNCTION(
|
|
414
|
-
getObject()->
|
|
415
|
-
return
|
|
550
|
+
JSI_HOST_FUNCTION(getFillType) {
|
|
551
|
+
auto fillType = getObject()->fillType();
|
|
552
|
+
return jsi::Value(static_cast<int>(fillType));
|
|
416
553
|
}
|
|
417
554
|
|
|
418
|
-
JSI_HOST_FUNCTION(
|
|
419
|
-
getObject()->rewind();
|
|
420
|
-
return thisValue.getObject(runtime);
|
|
421
|
-
}
|
|
555
|
+
JSI_HOST_FUNCTION(isVolatile) { return jsi::Value(asPath().isVolatile()); }
|
|
422
556
|
|
|
423
|
-
JSI_HOST_FUNCTION(
|
|
424
|
-
auto
|
|
425
|
-
auto
|
|
426
|
-
auto
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
return thisValue.getObject(runtime);
|
|
557
|
+
JSI_HOST_FUNCTION(getPoint) {
|
|
558
|
+
auto index = arguments[0].asNumber();
|
|
559
|
+
auto point = asPath().getPoint(index);
|
|
560
|
+
auto hostObjectInstance = std::make_shared<JsiSkPoint>(getContext(), point);
|
|
561
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
562
|
+
runtime, hostObjectInstance, getContext());
|
|
430
563
|
}
|
|
431
564
|
|
|
432
|
-
JSI_HOST_FUNCTION(
|
|
433
|
-
auto x1 = arguments[0].asNumber();
|
|
434
|
-
auto y1 = arguments[1].asNumber();
|
|
435
|
-
auto x2 = arguments[2].asNumber();
|
|
436
|
-
auto y2 = arguments[3].asNumber();
|
|
437
|
-
getObject()->rQuadTo(x1, y1, x2, y2);
|
|
438
|
-
return thisValue.getObject(runtime);
|
|
439
|
-
}
|
|
565
|
+
JSI_HOST_FUNCTION(isEmpty) { return jsi::Value(getObject()->isEmpty()); }
|
|
440
566
|
|
|
441
|
-
JSI_HOST_FUNCTION(
|
|
442
|
-
auto
|
|
443
|
-
|
|
444
|
-
auto r = arguments[2].asNumber();
|
|
445
|
-
getObject()->addCircle(x, y, r);
|
|
446
|
-
return thisValue.getObject(runtime);
|
|
567
|
+
JSI_HOST_FUNCTION(countPoints) {
|
|
568
|
+
auto points = asPath().countPoints();
|
|
569
|
+
return jsi::Value(points);
|
|
447
570
|
}
|
|
448
571
|
|
|
449
572
|
JSI_HOST_FUNCTION(getLastPt) {
|
|
450
|
-
|
|
451
|
-
getObject()->getLastPt(&last);
|
|
573
|
+
auto last = getObject()->getLastPt();
|
|
452
574
|
auto point = jsi::Object(runtime);
|
|
453
|
-
|
|
454
|
-
|
|
575
|
+
if (last.has_value()) {
|
|
576
|
+
point.setProperty(runtime, "x", static_cast<double>(last->fX));
|
|
577
|
+
point.setProperty(runtime, "y", static_cast<double>(last->fY));
|
|
578
|
+
} else {
|
|
579
|
+
point.setProperty(runtime, "x", 0.0);
|
|
580
|
+
point.setProperty(runtime, "y", 0.0);
|
|
581
|
+
}
|
|
455
582
|
return point;
|
|
456
583
|
}
|
|
457
584
|
|
|
458
|
-
JSI_HOST_FUNCTION(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
JSI_HOST_FUNCTION(simplify) {
|
|
464
|
-
SkPath result;
|
|
465
|
-
if (Simplify(*getObject(), &result)) {
|
|
466
|
-
getObject()->swap(result);
|
|
467
|
-
return jsi::Value(true);
|
|
468
|
-
}
|
|
469
|
-
return jsi::Value(false);
|
|
585
|
+
JSI_HOST_FUNCTION(toSVGString) {
|
|
586
|
+
auto path = asPath();
|
|
587
|
+
auto s = SkParsePath::ToSVGString(path);
|
|
588
|
+
return jsi::String::createFromUtf8(runtime, s.c_str());
|
|
470
589
|
}
|
|
471
590
|
|
|
472
|
-
JSI_HOST_FUNCTION(
|
|
473
|
-
auto
|
|
474
|
-
|
|
591
|
+
JSI_HOST_FUNCTION(equals) {
|
|
592
|
+
auto p1 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
593
|
+
auto p2 = JsiSkPath::fromValue(runtime, arguments[1]);
|
|
594
|
+
return jsi::Value(p1->snapshot() == p2->snapshot());
|
|
475
595
|
}
|
|
476
596
|
|
|
477
597
|
JSI_HOST_FUNCTION(copy) {
|
|
478
|
-
|
|
479
|
-
auto hostObjectInstance =
|
|
480
|
-
std::make_shared<JsiSkPath>(getContext(), SkPath(*path));
|
|
598
|
+
auto path = asPath();
|
|
599
|
+
auto hostObjectInstance = std::make_shared<JsiSkPath>(getContext(), path);
|
|
481
600
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
482
601
|
runtime, hostObjectInstance, getContext());
|
|
483
602
|
}
|
|
484
603
|
|
|
485
|
-
JSI_HOST_FUNCTION(op) {
|
|
486
|
-
auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
487
|
-
int pathOp = arguments[1].asNumber();
|
|
488
|
-
SkPath result;
|
|
489
|
-
if (Op(*getObject(), *path2, SkPathOp(pathOp), &result)) {
|
|
490
|
-
getObject()->swap(result);
|
|
491
|
-
return jsi::Value(true);
|
|
492
|
-
}
|
|
493
|
-
return jsi::Value(false);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
604
|
JSI_HOST_FUNCTION(isInterpolatable) {
|
|
497
605
|
auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
498
|
-
|
|
606
|
+
auto p1 = asPath();
|
|
607
|
+
auto p2 = path2->snapshot();
|
|
608
|
+
return p1.isInterpolatable(p2);
|
|
499
609
|
}
|
|
500
610
|
|
|
501
611
|
JSI_HOST_FUNCTION(interpolate) {
|
|
502
612
|
auto path2 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
503
613
|
auto weight = arguments[1].asNumber();
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
auto succeed = getObject()->interpolate(*path2, weight, path3.get());
|
|
507
|
-
if (!succeed) {
|
|
508
|
-
return nullptr;
|
|
509
|
-
}
|
|
510
|
-
return arguments[2].asObject(runtime);
|
|
511
|
-
}
|
|
614
|
+
auto p1 = asPath();
|
|
615
|
+
auto p2 = path2->snapshot();
|
|
512
616
|
SkPath result;
|
|
513
|
-
auto succeed =
|
|
617
|
+
auto succeed = p1.interpolate(p2, weight, &result);
|
|
514
618
|
if (!succeed) {
|
|
515
|
-
return
|
|
619
|
+
return jsi::Value::null();
|
|
516
620
|
}
|
|
517
621
|
auto hostObjectInstance =
|
|
518
622
|
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
519
623
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
520
624
|
runtime, hostObjectInstance, getContext());
|
|
521
625
|
}
|
|
626
|
+
|
|
522
627
|
JSI_HOST_FUNCTION(toCmds) {
|
|
523
|
-
auto path =
|
|
628
|
+
auto path = asPath();
|
|
524
629
|
std::vector<jsi::Array> cmdList;
|
|
525
630
|
SkPoint pts[4];
|
|
526
631
|
SkPath::Iter iter(path, false);
|
|
@@ -601,56 +706,69 @@ public:
|
|
|
601
706
|
EXPORT_JSI_API_TYPENAME(JsiSkPath, Path)
|
|
602
707
|
|
|
603
708
|
JSI_EXPORT_FUNCTIONS(
|
|
604
|
-
|
|
605
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
709
|
+
// Mutable building methods
|
|
710
|
+
JSI_EXPORT_FUNC(JsiSkPath, moveTo), JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
|
|
711
|
+
JSI_EXPORT_FUNC(JsiSkPath, lineTo), JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
|
|
712
|
+
JSI_EXPORT_FUNC(JsiSkPath, quadTo), JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
|
|
713
|
+
JSI_EXPORT_FUNC(JsiSkPath, conicTo), JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
|
|
714
|
+
JSI_EXPORT_FUNC(JsiSkPath, cubicTo), JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
|
|
715
|
+
JSI_EXPORT_FUNC(JsiSkPath, close), JSI_EXPORT_FUNC(JsiSkPath, reset),
|
|
716
|
+
JSI_EXPORT_FUNC(JsiSkPath, rewind), JSI_EXPORT_FUNC(JsiSkPath, addPath),
|
|
717
|
+
JSI_EXPORT_FUNC(JsiSkPath, addArc), JSI_EXPORT_FUNC(JsiSkPath, addOval),
|
|
606
718
|
JSI_EXPORT_FUNC(JsiSkPath, addRect), JSI_EXPORT_FUNC(JsiSkPath, addRRect),
|
|
719
|
+
JSI_EXPORT_FUNC(JsiSkPath, addCircle),
|
|
720
|
+
JSI_EXPORT_FUNC(JsiSkPath, addPoly),
|
|
607
721
|
JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
|
|
608
722
|
JSI_EXPORT_FUNC(JsiSkPath, arcToRotated),
|
|
609
723
|
JSI_EXPORT_FUNC(JsiSkPath, rArcTo),
|
|
610
724
|
JSI_EXPORT_FUNC(JsiSkPath, arcToTangent),
|
|
725
|
+
JSI_EXPORT_FUNC(JsiSkPath, setFillType),
|
|
726
|
+
JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
|
|
727
|
+
// Mutable transform methods
|
|
728
|
+
JSI_EXPORT_FUNC(JsiSkPath, transform), JSI_EXPORT_FUNC(JsiSkPath, offset),
|
|
729
|
+
// Mutable path operations
|
|
730
|
+
JSI_EXPORT_FUNC(JsiSkPath, simplify), JSI_EXPORT_FUNC(JsiSkPath, op),
|
|
731
|
+
JSI_EXPORT_FUNC(JsiSkPath, makeAsWinding),
|
|
732
|
+
JSI_EXPORT_FUNC(JsiSkPath, dash), JSI_EXPORT_FUNC(JsiSkPath, stroke),
|
|
733
|
+
JSI_EXPORT_FUNC(JsiSkPath, trim),
|
|
734
|
+
// Query methods
|
|
611
735
|
JSI_EXPORT_FUNC(JsiSkPath, computeTightBounds),
|
|
612
736
|
JSI_EXPORT_FUNC(JsiSkPath, getBounds),
|
|
613
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
614
|
-
JSI_EXPORT_FUNC(JsiSkPath, contains), JSI_EXPORT_FUNC(JsiSkPath, dash),
|
|
615
|
-
JSI_EXPORT_FUNC(JsiSkPath, equals),
|
|
737
|
+
JSI_EXPORT_FUNC(JsiSkPath, contains),
|
|
616
738
|
JSI_EXPORT_FUNC(JsiSkPath, getFillType),
|
|
617
|
-
JSI_EXPORT_FUNC(JsiSkPath, setFillType),
|
|
618
|
-
JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
|
|
619
739
|
JSI_EXPORT_FUNC(JsiSkPath, isVolatile),
|
|
620
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
621
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
740
|
+
JSI_EXPORT_FUNC(JsiSkPath, getPoint), JSI_EXPORT_FUNC(JsiSkPath, isEmpty),
|
|
741
|
+
JSI_EXPORT_FUNC(JsiSkPath, countPoints),
|
|
742
|
+
JSI_EXPORT_FUNC(JsiSkPath, getLastPt),
|
|
622
743
|
JSI_EXPORT_FUNC(JsiSkPath, toSVGString),
|
|
623
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
|
624
|
-
JSI_EXPORT_FUNC(JsiSkPath, isEmpty), JSI_EXPORT_FUNC(JsiSkPath, offset),
|
|
625
|
-
JSI_EXPORT_FUNC(JsiSkPath, moveTo), JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
|
|
626
|
-
JSI_EXPORT_FUNC(JsiSkPath, lineTo), JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
|
|
627
|
-
JSI_EXPORT_FUNC(JsiSkPath, cubicTo), JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
|
|
628
|
-
JSI_EXPORT_FUNC(JsiSkPath, reset), JSI_EXPORT_FUNC(JsiSkPath, rewind),
|
|
629
|
-
JSI_EXPORT_FUNC(JsiSkPath, quadTo), JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
|
|
630
|
-
JSI_EXPORT_FUNC(JsiSkPath, addCircle),
|
|
631
|
-
JSI_EXPORT_FUNC(JsiSkPath, getLastPt), JSI_EXPORT_FUNC(JsiSkPath, close),
|
|
632
|
-
JSI_EXPORT_FUNC(JsiSkPath, simplify),
|
|
633
|
-
JSI_EXPORT_FUNC(JsiSkPath, countPoints), JSI_EXPORT_FUNC(JsiSkPath, copy),
|
|
634
|
-
JSI_EXPORT_FUNC(JsiSkPath, op),
|
|
744
|
+
JSI_EXPORT_FUNC(JsiSkPath, equals), JSI_EXPORT_FUNC(JsiSkPath, copy),
|
|
635
745
|
JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
|
|
636
746
|
JSI_EXPORT_FUNC(JsiSkPath, interpolate),
|
|
637
747
|
JSI_EXPORT_FUNC(JsiSkPath, toCmds), JSI_EXPORT_FUNC(JsiSkPath, dispose))
|
|
638
748
|
|
|
639
|
-
JsiSkPath(std::shared_ptr<RNSkPlatformContext> context,
|
|
640
|
-
: JsiSkWrappingSharedPtrHostObject<
|
|
641
|
-
std::move(context),
|
|
749
|
+
JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, SkPathBuilder builder)
|
|
750
|
+
: JsiSkWrappingSharedPtrHostObject<SkPathBuilder>(
|
|
751
|
+
std::move(context),
|
|
752
|
+
std::make_shared<SkPathBuilder>(std::move(builder))) {}
|
|
753
|
+
|
|
754
|
+
// Convenience: construct from SkPath
|
|
755
|
+
JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, const SkPath &path)
|
|
756
|
+
: JsiSkPath(std::move(context), SkPathBuilder(path)) {}
|
|
642
757
|
|
|
643
758
|
size_t getMemoryPressure() const override {
|
|
644
|
-
auto
|
|
645
|
-
if (!
|
|
759
|
+
auto builder = getObject();
|
|
760
|
+
if (!builder)
|
|
646
761
|
return 0;
|
|
647
762
|
|
|
648
|
-
|
|
649
|
-
return path->approximateBytesUsed();
|
|
763
|
+
return builder->snapshot().approximateBytesUsed();
|
|
650
764
|
}
|
|
651
765
|
|
|
652
766
|
std::string getObjectType() const override { return "JsiSkPath"; }
|
|
653
767
|
|
|
768
|
+
static SkPath pathFromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
|
|
769
|
+
return fromValue(runtime, obj)->snapshot();
|
|
770
|
+
}
|
|
771
|
+
|
|
654
772
|
static jsi::Value toValue(jsi::Runtime &runtime,
|
|
655
773
|
std::shared_ptr<RNSkPlatformContext> context,
|
|
656
774
|
const SkPath &path) {
|