@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
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <algorithm>
|
|
3
4
|
#include <memory>
|
|
4
5
|
#include <utility>
|
|
6
|
+
#include <vector>
|
|
5
7
|
|
|
6
8
|
#include <jsi/jsi.h>
|
|
7
9
|
|
|
8
10
|
#include "JsiSkHostObjects.h"
|
|
11
|
+
#include "JsiSkMatrix.h"
|
|
9
12
|
#include "JsiSkPathEffect.h"
|
|
13
|
+
#include "JsiSkPoint.h"
|
|
14
|
+
#include "JsiSkRRect.h"
|
|
15
|
+
#include "JsiSkRect.h"
|
|
10
16
|
|
|
11
17
|
#pragma clang diagnostic push
|
|
12
18
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
13
19
|
|
|
14
20
|
#include "RNSkLog.h"
|
|
15
21
|
#include "include/core/SkPath.h"
|
|
22
|
+
#include "include/core/SkPathBuilder.h"
|
|
23
|
+
#include "include/core/SkPathUtils.h"
|
|
24
|
+
#include "include/core/SkStrokeRec.h"
|
|
25
|
+
#include "include/effects/SkDashPathEffect.h"
|
|
26
|
+
#include "include/effects/SkTrimPathEffect.h"
|
|
16
27
|
#include "include/pathops/SkPathOps.h"
|
|
28
|
+
#include "include/utils/SkTextUtils.h"
|
|
17
29
|
|
|
18
30
|
#pragma clang diagnostic pop
|
|
19
31
|
|
|
@@ -40,36 +52,33 @@ public:
|
|
|
40
52
|
|
|
41
53
|
JSI_HOST_FUNCTION(MakeFromSVGString) {
|
|
42
54
|
auto svgString = arguments[0].asString(runtime).utf8(runtime);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!SkParsePath::FromSVGString(svgString.c_str(), &result)) {
|
|
55
|
+
auto result = SkParsePath::FromSVGString(svgString.c_str());
|
|
56
|
+
if (!result.has_value()) {
|
|
46
57
|
throw jsi::JSError(runtime, "Could not parse Svg path");
|
|
47
58
|
return jsi::Value(nullptr);
|
|
48
59
|
}
|
|
49
|
-
|
|
50
60
|
auto hostObjectInstance =
|
|
51
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
61
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
52
62
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
53
63
|
runtime, hostObjectInstance, getContext());
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
JSI_HOST_FUNCTION(MakeFromOp) {
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
auto one = JsiSkPath::fromValue(runtime, arguments[0])->snapshot();
|
|
68
|
+
auto two = JsiSkPath::fromValue(runtime, arguments[1])->snapshot();
|
|
59
69
|
SkPathOp op = (SkPathOp)arguments[2].asNumber();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (!success) {
|
|
70
|
+
auto result = Op(one, two, op);
|
|
71
|
+
if (!result.has_value()) {
|
|
63
72
|
return jsi::Value(nullptr);
|
|
64
73
|
}
|
|
65
74
|
auto hostObjectInstance =
|
|
66
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
75
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
67
76
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
68
77
|
runtime, hostObjectInstance, getContext());
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
JSI_HOST_FUNCTION(MakeFromCmds) {
|
|
72
|
-
|
|
81
|
+
SkPathBuilder builder;
|
|
73
82
|
auto cmds = arguments[0].asObject(runtime).asArray(runtime);
|
|
74
83
|
auto cmdCount = cmds.size(runtime);
|
|
75
84
|
for (int i = 0; i < cmdCount; i++) {
|
|
@@ -88,7 +97,7 @@ public:
|
|
|
88
97
|
}
|
|
89
98
|
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
|
90
99
|
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
91
|
-
|
|
100
|
+
builder.moveTo(x, y);
|
|
92
101
|
break;
|
|
93
102
|
}
|
|
94
103
|
case LINE: {
|
|
@@ -98,7 +107,7 @@ public:
|
|
|
98
107
|
}
|
|
99
108
|
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
|
|
100
109
|
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
101
|
-
|
|
110
|
+
builder.lineTo(x, y);
|
|
102
111
|
break;
|
|
103
112
|
}
|
|
104
113
|
case QUAD: {
|
|
@@ -110,7 +119,7 @@ public:
|
|
|
110
119
|
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
111
120
|
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
112
121
|
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
113
|
-
|
|
122
|
+
builder.quadTo(x1, y1, x2, y2);
|
|
114
123
|
break;
|
|
115
124
|
}
|
|
116
125
|
case CONIC: {
|
|
@@ -123,7 +132,7 @@ public:
|
|
|
123
132
|
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
124
133
|
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
125
134
|
auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
126
|
-
|
|
135
|
+
builder.conicTo(x1, y1, x2, y2, w);
|
|
127
136
|
break;
|
|
128
137
|
}
|
|
129
138
|
case CUBIC: {
|
|
@@ -137,11 +146,11 @@ public:
|
|
|
137
146
|
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
138
147
|
auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
139
148
|
auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
|
|
140
|
-
|
|
149
|
+
builder.cubicTo(x1, y1, x2, y2, x3, y3);
|
|
141
150
|
break;
|
|
142
151
|
}
|
|
143
152
|
case CLOSE: {
|
|
144
|
-
|
|
153
|
+
builder.close();
|
|
145
154
|
break;
|
|
146
155
|
}
|
|
147
156
|
default: {
|
|
@@ -151,7 +160,7 @@ public:
|
|
|
151
160
|
}
|
|
152
161
|
}
|
|
153
162
|
auto hostObjectInstance =
|
|
154
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
163
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
155
164
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
156
165
|
runtime, hostObjectInstance, getContext());
|
|
157
166
|
}
|
|
@@ -170,6 +179,250 @@ public:
|
|
|
170
179
|
runtime, hostObjectInstance, getContext());
|
|
171
180
|
}
|
|
172
181
|
|
|
182
|
+
// Static shape factories
|
|
183
|
+
JSI_HOST_FUNCTION(Rect) {
|
|
184
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
185
|
+
auto direction = SkPathDirection::kCW;
|
|
186
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
187
|
+
direction = SkPathDirection::kCCW;
|
|
188
|
+
}
|
|
189
|
+
SkPathBuilder builder;
|
|
190
|
+
builder.addRect(*rect, direction);
|
|
191
|
+
auto hostObjectInstance =
|
|
192
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
193
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
194
|
+
runtime, hostObjectInstance, getContext());
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
JSI_HOST_FUNCTION(Oval) {
|
|
198
|
+
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
199
|
+
auto direction = SkPathDirection::kCW;
|
|
200
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
201
|
+
direction = SkPathDirection::kCCW;
|
|
202
|
+
}
|
|
203
|
+
unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
|
|
204
|
+
SkPathBuilder builder;
|
|
205
|
+
builder.addOval(*rect, direction, startIndex);
|
|
206
|
+
auto hostObjectInstance =
|
|
207
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
208
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
209
|
+
runtime, hostObjectInstance, getContext());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
JSI_HOST_FUNCTION(Circle) {
|
|
213
|
+
auto x = arguments[0].asNumber();
|
|
214
|
+
auto y = arguments[1].asNumber();
|
|
215
|
+
auto r = arguments[2].asNumber();
|
|
216
|
+
SkPathBuilder builder;
|
|
217
|
+
builder.addCircle(x, y, r);
|
|
218
|
+
auto hostObjectInstance =
|
|
219
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
220
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
221
|
+
runtime, hostObjectInstance, getContext());
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
JSI_HOST_FUNCTION(RRect) {
|
|
225
|
+
auto rrect = JsiSkRRect::fromValue(runtime, arguments[0]);
|
|
226
|
+
auto direction = SkPathDirection::kCW;
|
|
227
|
+
if (count >= 2 && arguments[1].getBool()) {
|
|
228
|
+
direction = SkPathDirection::kCCW;
|
|
229
|
+
}
|
|
230
|
+
SkPathBuilder builder;
|
|
231
|
+
builder.addRRect(*rrect, direction);
|
|
232
|
+
auto hostObjectInstance =
|
|
233
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
234
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
235
|
+
runtime, hostObjectInstance, getContext());
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
JSI_HOST_FUNCTION(Line) {
|
|
239
|
+
auto p1 = JsiSkPoint::fromValue(runtime, arguments[0].asObject(runtime));
|
|
240
|
+
auto p2 = JsiSkPoint::fromValue(runtime, arguments[1].asObject(runtime));
|
|
241
|
+
SkPathBuilder builder;
|
|
242
|
+
builder.moveTo(*p1);
|
|
243
|
+
builder.lineTo(*p2);
|
|
244
|
+
auto hostObjectInstance =
|
|
245
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
246
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
247
|
+
runtime, hostObjectInstance, getContext());
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
JSI_HOST_FUNCTION(Polygon) {
|
|
251
|
+
std::vector<SkPoint> points;
|
|
252
|
+
auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
|
|
253
|
+
auto close = arguments[1].getBool();
|
|
254
|
+
auto pointsSize = jsiPoints.size(runtime);
|
|
255
|
+
points.reserve(pointsSize);
|
|
256
|
+
for (int i = 0; i < pointsSize; i++) {
|
|
257
|
+
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
|
258
|
+
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
|
259
|
+
points.push_back(*point.get());
|
|
260
|
+
}
|
|
261
|
+
SkPathBuilder builder;
|
|
262
|
+
builder.addPolygon(SkSpan(points), close);
|
|
263
|
+
auto hostObjectInstance =
|
|
264
|
+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
265
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
266
|
+
runtime, hostObjectInstance, getContext());
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Static path operations
|
|
270
|
+
JSI_HOST_FUNCTION(Stroke) {
|
|
271
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
272
|
+
SkPath path = srcPath->snapshot();
|
|
273
|
+
SkPaint p;
|
|
274
|
+
p.setStyle(SkPaint::kStroke_Style);
|
|
275
|
+
|
|
276
|
+
if (count > 1 && !arguments[1].isUndefined()) {
|
|
277
|
+
auto opts = arguments[1].asObject(runtime);
|
|
278
|
+
|
|
279
|
+
auto jsiCap = opts.getProperty(runtime, "cap");
|
|
280
|
+
if (!jsiCap.isUndefined()) {
|
|
281
|
+
auto cap = (SkPaint::Cap)jsiCap.asNumber();
|
|
282
|
+
p.setStrokeCap(cap);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
auto jsiJoin = opts.getProperty(runtime, "join");
|
|
286
|
+
if (!jsiJoin.isUndefined()) {
|
|
287
|
+
auto join = (SkPaint::Join)jsiJoin.asNumber();
|
|
288
|
+
p.setStrokeJoin(join);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
auto jsiWidth = opts.getProperty(runtime, "width");
|
|
292
|
+
if (!jsiWidth.isUndefined()) {
|
|
293
|
+
auto width = jsiWidth.asNumber();
|
|
294
|
+
p.setStrokeWidth(width);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
auto jsiMiterLimit = opts.getProperty(runtime, "miter_limit");
|
|
298
|
+
if (!jsiMiterLimit.isUndefined()) {
|
|
299
|
+
auto miter_limit = jsiMiterLimit.asNumber();
|
|
300
|
+
p.setStrokeMiter(miter_limit);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
auto jsiPrecision = opts.getProperty(runtime, "precision");
|
|
304
|
+
auto precision = jsiPrecision.isUndefined() ? 1 : jsiPrecision.asNumber();
|
|
305
|
+
SkPathBuilder resultBuilder;
|
|
306
|
+
auto ctm = SkMatrix::Scale(precision, precision);
|
|
307
|
+
auto success =
|
|
308
|
+
skpathutils::FillPathWithPaint(path, p, &resultBuilder, nullptr, ctm);
|
|
309
|
+
if (success) {
|
|
310
|
+
auto hostObjectInstance =
|
|
311
|
+
std::make_shared<JsiSkPath>(getContext(), resultBuilder.snapshot());
|
|
312
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
313
|
+
runtime, hostObjectInstance, getContext());
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
SkPathBuilder resultBuilder;
|
|
317
|
+
auto success = skpathutils::FillPathWithPaint(path, p, &resultBuilder);
|
|
318
|
+
if (success) {
|
|
319
|
+
auto hostObjectInstance =
|
|
320
|
+
std::make_shared<JsiSkPath>(getContext(), resultBuilder.snapshot());
|
|
321
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
322
|
+
runtime, hostObjectInstance, getContext());
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return jsi::Value::null();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
JSI_HOST_FUNCTION(Trim) {
|
|
329
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
330
|
+
float start =
|
|
331
|
+
std::clamp(static_cast<float>(arguments[1].asNumber()), 0.0f, 1.0f);
|
|
332
|
+
float end =
|
|
333
|
+
std::clamp(static_cast<float>(arguments[2].asNumber()), 0.0f, 1.0f);
|
|
334
|
+
auto isComplement = arguments[3].getBool();
|
|
335
|
+
// If requesting the full path in normal mode, just return a copy
|
|
336
|
+
if (start <= 0 && end >= 1 && !isComplement) {
|
|
337
|
+
SkPath result = srcPath->snapshot();
|
|
338
|
+
auto hostObjectInstance =
|
|
339
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
340
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
341
|
+
runtime, hostObjectInstance, getContext());
|
|
342
|
+
}
|
|
343
|
+
SkPath path = srcPath->snapshot();
|
|
344
|
+
auto mode = isComplement ? SkTrimPathEffect::Mode::kInverted
|
|
345
|
+
: SkTrimPathEffect::Mode::kNormal;
|
|
346
|
+
auto pe = SkTrimPathEffect::Make(start, end, mode);
|
|
347
|
+
if (!pe) {
|
|
348
|
+
return jsi::Value::null();
|
|
349
|
+
}
|
|
350
|
+
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
351
|
+
SkPathBuilder resultBuilder;
|
|
352
|
+
if (pe->filterPath(&resultBuilder, path, &rec)) {
|
|
353
|
+
auto result = resultBuilder.detach();
|
|
354
|
+
auto hostObjectInstance =
|
|
355
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
356
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
357
|
+
runtime, hostObjectInstance, getContext());
|
|
358
|
+
}
|
|
359
|
+
return jsi::Value::null();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
JSI_HOST_FUNCTION(Simplify) {
|
|
363
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
364
|
+
auto result = ::Simplify(srcPath->snapshot());
|
|
365
|
+
if (result.has_value()) {
|
|
366
|
+
auto hostObjectInstance =
|
|
367
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
368
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
369
|
+
runtime, hostObjectInstance, getContext());
|
|
370
|
+
}
|
|
371
|
+
return jsi::Value::null();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
JSI_HOST_FUNCTION(Dash) {
|
|
375
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
376
|
+
SkScalar on = arguments[1].asNumber();
|
|
377
|
+
SkScalar off = arguments[2].asNumber();
|
|
378
|
+
auto phase = arguments[3].asNumber();
|
|
379
|
+
SkScalar intervals[] = {on, off};
|
|
380
|
+
auto i = SkSpan(intervals, 2);
|
|
381
|
+
auto pe = SkDashPathEffect::Make(i, phase);
|
|
382
|
+
if (!pe) {
|
|
383
|
+
return jsi::Value::null();
|
|
384
|
+
}
|
|
385
|
+
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
386
|
+
SkPathBuilder resultBuilder;
|
|
387
|
+
if (pe->filterPath(&resultBuilder, srcPath->snapshot(), &rec)) {
|
|
388
|
+
auto result = resultBuilder.detach();
|
|
389
|
+
auto hostObjectInstance =
|
|
390
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
391
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
392
|
+
runtime, hostObjectInstance, getContext());
|
|
393
|
+
}
|
|
394
|
+
return jsi::Value::null();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
JSI_HOST_FUNCTION(AsWinding) {
|
|
398
|
+
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
399
|
+
auto result = ::AsWinding(srcPath->snapshot());
|
|
400
|
+
if (result.has_value()) {
|
|
401
|
+
auto hostObjectInstance =
|
|
402
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
|
|
403
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
404
|
+
runtime, hostObjectInstance, getContext());
|
|
405
|
+
}
|
|
406
|
+
return jsi::Value::null();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
JSI_HOST_FUNCTION(Interpolate) {
|
|
410
|
+
auto path1 = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
411
|
+
auto path2 = JsiSkPath::fromValue(runtime, arguments[1]);
|
|
412
|
+
auto weight = arguments[2].asNumber();
|
|
413
|
+
auto p1 = path1->snapshot();
|
|
414
|
+
auto p2 = path2->snapshot();
|
|
415
|
+
SkPath result;
|
|
416
|
+
auto succeed = p1.interpolate(p2, weight, &result);
|
|
417
|
+
if (!succeed) {
|
|
418
|
+
return jsi::Value::null();
|
|
419
|
+
}
|
|
420
|
+
auto hostObjectInstance =
|
|
421
|
+
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
422
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
423
|
+
runtime, hostObjectInstance, getContext());
|
|
424
|
+
}
|
|
425
|
+
|
|
173
426
|
size_t getMemoryPressure() const override { return 1024; }
|
|
174
427
|
|
|
175
428
|
std::string getObjectType() const override { return "JsiSkPathFactory"; }
|
|
@@ -178,7 +431,21 @@ public:
|
|
|
178
431
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromSVGString),
|
|
179
432
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromOp),
|
|
180
433
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromCmds),
|
|
181
|
-
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromText)
|
|
434
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromText),
|
|
435
|
+
// Static shape factories
|
|
436
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Rect),
|
|
437
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Oval),
|
|
438
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Circle),
|
|
439
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, RRect),
|
|
440
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Line),
|
|
441
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Polygon),
|
|
442
|
+
// Static path operations
|
|
443
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Stroke),
|
|
444
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Trim),
|
|
445
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Simplify),
|
|
446
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Dash),
|
|
447
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, AsWinding),
|
|
448
|
+
JSI_EXPORT_FUNC(JsiSkPathFactory, Interpolate))
|
|
182
449
|
|
|
183
450
|
explicit JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
184
451
|
: JsiSkHostObject(std::move(context)) {}
|
package/cpp/api/JsiSkShader.h
CHANGED
|
@@ -44,8 +44,9 @@ SkTileMode getTileMode(const jsi::Value *values, int i, size_t size) {
|
|
|
44
44
|
return static_cast<SkTileMode>(values[i].asNumber());
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
std::vector<
|
|
48
|
-
|
|
47
|
+
std::vector<SkColor4f> getColors(jsi::Runtime &runtime,
|
|
48
|
+
const jsi::Value &value) {
|
|
49
|
+
std::vector<SkColor4f> colors;
|
|
49
50
|
if (!value.isNull()) {
|
|
50
51
|
auto jsiColors = value.asObject(runtime).asArray(runtime);
|
|
51
52
|
auto size = jsiColors.size(runtime);
|
|
@@ -53,7 +54,7 @@ std::vector<SkColor> getColors(jsi::Runtime &runtime, const jsi::Value &value) {
|
|
|
53
54
|
for (int i = 0; i < size; i++) {
|
|
54
55
|
SkColor color =
|
|
55
56
|
JsiSkColor::fromValue(runtime, jsiColors.getValueAtIndex(runtime, i));
|
|
56
|
-
colors.push_back(color);
|
|
57
|
+
colors.push_back(SkColor4f::FromColor(color));
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
return colors;
|
|
@@ -83,7 +84,7 @@ public:
|
|
|
83
84
|
*JsiSkPoint::fromValue(runtime, arguments[1].asObject(runtime)).get();
|
|
84
85
|
SkPoint pts[] = {p1, p2};
|
|
85
86
|
|
|
86
|
-
std::vector<
|
|
87
|
+
std::vector<SkColor4f> colors = getColors(runtime, arguments[2]);
|
|
87
88
|
auto colorsSize = colors.size();
|
|
88
89
|
if (colorsSize < 2) {
|
|
89
90
|
throw std::invalid_argument("colors must have at least 2 colors");
|
|
@@ -97,9 +98,15 @@ public:
|
|
|
97
98
|
auto flag = getFlag(arguments, 6, count);
|
|
98
99
|
auto localMatrix = getLocalMatrix(runtime, arguments, 5, count);
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
SkGradient::Colors gradColors(
|
|
102
|
+
SkSpan(colors),
|
|
103
|
+
!positions.empty()
|
|
104
|
+
? SkSpan<const float>(positions.data(), positions.size())
|
|
105
|
+
: SkSpan<const float>(),
|
|
106
|
+
tileMode);
|
|
107
|
+
SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(flag));
|
|
108
|
+
sk_sp<SkShader> gradient =
|
|
109
|
+
SkShaders::LinearGradient(pts, grad, localMatrix);
|
|
103
110
|
auto shader =
|
|
104
111
|
std::make_shared<JsiSkShader>(getContext(), std::move(gradient));
|
|
105
112
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
@@ -111,7 +118,7 @@ public:
|
|
|
111
118
|
*JsiSkPoint::fromValue(runtime, arguments[0].asObject(runtime)).get();
|
|
112
119
|
auto r = arguments[1].asNumber();
|
|
113
120
|
|
|
114
|
-
std::vector<
|
|
121
|
+
std::vector<SkColor4f> colors = getColors(runtime, arguments[2]);
|
|
115
122
|
auto colorsSize = colors.size();
|
|
116
123
|
if (colorsSize < 2) {
|
|
117
124
|
throw std::invalid_argument("colors must have at least 2 colors");
|
|
@@ -125,10 +132,15 @@ public:
|
|
|
125
132
|
auto flag = getFlag(arguments, 6, count);
|
|
126
133
|
auto localMatrix = getLocalMatrix(runtime, arguments, 5, count);
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
!positions.empty()
|
|
131
|
-
|
|
135
|
+
SkGradient::Colors gradColors(
|
|
136
|
+
SkSpan(colors),
|
|
137
|
+
!positions.empty()
|
|
138
|
+
? SkSpan<const float>(positions.data(), positions.size())
|
|
139
|
+
: SkSpan<const float>(),
|
|
140
|
+
tileMode);
|
|
141
|
+
SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(flag));
|
|
142
|
+
sk_sp<SkShader> gradient =
|
|
143
|
+
SkShaders::RadialGradient(center, r, grad, localMatrix);
|
|
132
144
|
auto shader =
|
|
133
145
|
std::make_shared<JsiSkShader>(getContext(), std::move(gradient));
|
|
134
146
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
@@ -138,7 +150,7 @@ public:
|
|
|
138
150
|
JSI_HOST_FUNCTION(MakeSweepGradient) {
|
|
139
151
|
auto x = arguments[0].asNumber();
|
|
140
152
|
auto y = arguments[1].asNumber();
|
|
141
|
-
std::vector<
|
|
153
|
+
std::vector<SkColor4f> colors = getColors(runtime, arguments[2]);
|
|
142
154
|
auto colorsSize = colors.size();
|
|
143
155
|
if (colorsSize < 2) {
|
|
144
156
|
throw std::invalid_argument("colors must have at least 2 colors");
|
|
@@ -151,15 +163,22 @@ public:
|
|
|
151
163
|
auto tileMode = getTileMode(arguments, 4, count);
|
|
152
164
|
auto localMatrix = getLocalMatrix(runtime, arguments, 5, count);
|
|
153
165
|
auto flag = getFlag(arguments, 6, count);
|
|
154
|
-
auto startAngle =
|
|
155
|
-
|
|
166
|
+
auto startAngle = (count < 8 || arguments[7].isUndefined())
|
|
167
|
+
? 0.0f
|
|
168
|
+
: static_cast<float>(arguments[7].asNumber());
|
|
156
169
|
auto endAngle = (count < 9 || arguments[8].isUndefined())
|
|
157
|
-
? 360
|
|
158
|
-
: arguments[8].asNumber();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
? 360.0f
|
|
171
|
+
: static_cast<float>(arguments[8].asNumber());
|
|
172
|
+
|
|
173
|
+
SkGradient::Colors gradColors(
|
|
174
|
+
SkSpan(colors),
|
|
175
|
+
!positions.empty()
|
|
176
|
+
? SkSpan<const float>(positions.data(), positions.size())
|
|
177
|
+
: SkSpan<const float>(),
|
|
178
|
+
tileMode);
|
|
179
|
+
SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(flag));
|
|
180
|
+
sk_sp<SkShader> gradient = SkShaders::SweepGradient(
|
|
181
|
+
SkPoint::Make(x, y), startAngle, endAngle, grad, localMatrix);
|
|
163
182
|
auto shader =
|
|
164
183
|
std::make_shared<JsiSkShader>(getContext(), std::move(gradient));
|
|
165
184
|
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, shader,
|
|
@@ -175,7 +194,7 @@ public:
|
|
|
175
194
|
*JsiSkPoint::fromValue(runtime, arguments[2].asObject(runtime)).get();
|
|
176
195
|
auto endRadius = arguments[3].asNumber();
|
|
177
196
|
|
|
178
|
-
std::vector<
|
|
197
|
+
std::vector<SkColor4f> colors = getColors(runtime, arguments[4]);
|
|
179
198
|
auto colorsSize = colors.size();
|
|
180
199
|
if (colorsSize < 2) {
|
|
181
200
|
throw std::invalid_argument("colors must have at least 2 colors");
|
|
@@ -189,10 +208,15 @@ public:
|
|
|
189
208
|
auto localMatrix = getLocalMatrix(runtime, arguments, 7, count);
|
|
190
209
|
auto flag = getFlag(arguments, 8, count);
|
|
191
210
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
!positions.empty()
|
|
195
|
-
|
|
211
|
+
SkGradient::Colors gradColors(
|
|
212
|
+
SkSpan(colors),
|
|
213
|
+
!positions.empty()
|
|
214
|
+
? SkSpan<const float>(positions.data(), positions.size())
|
|
215
|
+
: SkSpan<const float>(),
|
|
216
|
+
tileMode);
|
|
217
|
+
SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(flag));
|
|
218
|
+
sk_sp<SkShader> gradient = SkShaders::TwoPointConicalGradient(
|
|
219
|
+
start, startRadius, end, endRadius, grad, localMatrix);
|
|
196
220
|
|
|
197
221
|
auto shader =
|
|
198
222
|
std::make_shared<JsiSkShader>(getContext(), std::move(gradient));
|
|
@@ -51,7 +51,8 @@ public:
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
auto context = getContext();
|
|
54
|
-
auto surface =
|
|
54
|
+
auto surface =
|
|
55
|
+
context->makeOffscreenSurface(width, height, useP3ColorSpace);
|
|
55
56
|
if (surface == nullptr) {
|
|
56
57
|
return jsi::Value::null();
|
|
57
58
|
}
|
|
@@ -141,7 +141,7 @@ std::shared_ptr<SkPath> processPath(jsi::Runtime &runtime,
|
|
|
141
141
|
auto ptr = std::dynamic_pointer_cast<JsiSkPath>(
|
|
142
142
|
value.asObject(runtime).asHostObject(runtime));
|
|
143
143
|
if (ptr != nullptr) {
|
|
144
|
-
return ptr->getObject();
|
|
144
|
+
return std::make_shared<SkPath>(ptr->getObject()->snapshot());
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
return nullptr;
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
#include "ImageFit.h"
|
|
9
9
|
#include "RNSkPlatformContext.h"
|
|
10
10
|
|
|
11
|
+
#include "include/core/SkPathBuilder.h"
|
|
12
|
+
#include "include/core/SkStrokeRec.h"
|
|
13
|
+
|
|
11
14
|
namespace RNSkia {
|
|
12
15
|
|
|
13
16
|
struct CircleCmdProps {
|
|
@@ -123,12 +126,13 @@ public:
|
|
|
123
126
|
SkTrimPathEffect::Make(start, end, SkTrimPathEffect::Mode::kNormal);
|
|
124
127
|
if (pe != nullptr) {
|
|
125
128
|
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
126
|
-
|
|
129
|
+
SkPathBuilder filteredBuilder;
|
|
130
|
+
if (!pe->filterPath(&filteredBuilder, filteredPath, &rec)) {
|
|
127
131
|
throw std::runtime_error(
|
|
128
132
|
"Failed trimming path with parameters start: " +
|
|
129
133
|
std::to_string(start) + ", end: " + std::to_string(end));
|
|
130
134
|
}
|
|
131
|
-
filteredPath.
|
|
135
|
+
filteredPath = filteredBuilder.detach();
|
|
132
136
|
} else {
|
|
133
137
|
throw std::runtime_error(
|
|
134
138
|
"Failed trimming path with parameters start: " +
|
|
@@ -162,14 +166,11 @@ public:
|
|
|
162
166
|
strokePaint.setStrokeMiter(stroke.miter_limit.value());
|
|
163
167
|
}
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
auto strokedPath = std::make_shared<SkPath>();
|
|
168
|
-
if (!skpathutils::FillPathWithPaint(*p, strokePaint, strokedPath.get(),
|
|
169
|
-
nullptr, precision)) {
|
|
169
|
+
SkPathBuilder resultBuilder;
|
|
170
|
+
if (!skpathutils::FillPathWithPaint(*p, strokePaint, &resultBuilder)) {
|
|
170
171
|
throw std::runtime_error("Failed to apply stroke to path");
|
|
171
172
|
}
|
|
172
|
-
pathToUse = std::
|
|
173
|
+
pathToUse = std::make_shared<const SkPath>(resultBuilder.snapshot());
|
|
173
174
|
} else {
|
|
174
175
|
pathToUse = std::const_pointer_cast<const SkPath>(p);
|
|
175
176
|
}
|
|
@@ -935,7 +936,8 @@ public:
|
|
|
935
936
|
convertProperty(runtime, object, "sprites", props.sprites, variables);
|
|
936
937
|
convertProperty(runtime, object, "transforms", props.transforms, variables);
|
|
937
938
|
convertProperty(runtime, object, "colors", props.colors, variables);
|
|
938
|
-
convertProperty(runtime, object, "colorBlendMode", props.blendMode,
|
|
939
|
+
convertProperty(runtime, object, "colorBlendMode", props.blendMode,
|
|
940
|
+
variables);
|
|
939
941
|
convertProperty(runtime, object, "sampling", props.sampling, variables);
|
|
940
942
|
}
|
|
941
943
|
|