@shopify/react-native-skia 2.9.1 → 2.10.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 +8 -46
- package/android/build.gradle +33 -0
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
- package/cpp/api/JsiNativeBuffer.h +23 -24
- package/cpp/api/JsiSkAnimatedImage.h +24 -25
- package/cpp/api/JsiSkAnimatedImageFactory.h +18 -17
- package/cpp/api/JsiSkApi.h +254 -96
- package/cpp/api/JsiSkCanvas.h +141 -266
- package/cpp/api/JsiSkColor.h +7 -5
- package/cpp/api/JsiSkColorFilter.h +15 -8
- package/cpp/api/JsiSkColorFilterFactory.h +49 -67
- package/cpp/api/JsiSkContourMeasure.h +31 -38
- package/cpp/api/JsiSkContourMeasureIter.h +20 -23
- package/cpp/api/JsiSkConverters.h +410 -0
- package/cpp/api/JsiSkData.h +13 -7
- package/cpp/api/JsiSkDataFactory.h +27 -32
- package/cpp/api/JsiSkFont.h +123 -192
- package/cpp/api/JsiSkFontMgr.h +33 -26
- package/cpp/api/JsiSkFontMgrFactory.h +12 -11
- package/cpp/api/JsiSkFontStyle.h +14 -12
- package/cpp/api/JsiSkImage.h +90 -79
- package/cpp/api/JsiSkImageFactory.h +93 -95
- package/cpp/api/JsiSkImageFilter.h +21 -11
- package/cpp/api/JsiSkImageFilterFactory.h +375 -629
- package/cpp/api/JsiSkImageInfo.h +25 -25
- package/cpp/api/JsiSkMaskFilter.h +21 -11
- package/cpp/api/JsiSkMaskFilterFactory.h +17 -17
- package/cpp/api/JsiSkMatrix.h +51 -88
- package/cpp/api/JsiSkNativeObjects.h +387 -0
- package/cpp/api/JsiSkPaint.h +104 -142
- package/cpp/api/JsiSkParagraph.h +54 -64
- package/cpp/api/JsiSkParagraphBuilder.h +43 -68
- package/cpp/api/JsiSkParagraphBuilderFactory.h +20 -24
- package/cpp/api/JsiSkPath.h +242 -350
- package/cpp/api/JsiSkPathBuilder.h +153 -273
- package/cpp/api/JsiSkPathBuilderFactory.h +19 -20
- package/cpp/api/JsiSkPathEffect.h +21 -11
- package/cpp/api/JsiSkPathEffectFactory.h +61 -80
- package/cpp/api/JsiSkPathFactory.h +148 -238
- package/cpp/api/JsiSkPicture.h +32 -27
- package/cpp/api/JsiSkPictureFactory.h +21 -26
- package/cpp/api/JsiSkPictureRecorder.h +27 -29
- package/cpp/api/JsiSkPoint.h +20 -23
- package/cpp/api/JsiSkRRect.h +24 -32
- package/cpp/api/JsiSkRSXform.h +31 -48
- package/cpp/api/JsiSkRect.h +40 -50
- package/cpp/api/JsiSkRuntimeEffect.h +85 -92
- package/cpp/api/JsiSkRuntimeEffectFactory.h +14 -18
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +28 -30
- package/cpp/api/JsiSkSVG.h +15 -15
- package/cpp/api/JsiSkSVGFactory.h +17 -20
- package/cpp/api/JsiSkShader.h +15 -8
- package/cpp/api/JsiSkShaderFactory.h +159 -238
- package/cpp/api/JsiSkSkottie.h +131 -143
- package/cpp/api/JsiSkSurface.h +29 -32
- package/cpp/api/JsiSkSurfaceFactory.h +18 -20
- package/cpp/api/JsiSkTextBlob.h +15 -8
- package/cpp/api/JsiSkTextBlobFactory.h +40 -66
- package/cpp/api/JsiSkTypeface.h +25 -22
- package/cpp/api/JsiSkTypefaceFactory.h +17 -15
- package/cpp/api/JsiSkTypefaceFontProvider.h +43 -39
- package/cpp/api/JsiSkTypefaceFontProviderFactory.h +13 -12
- package/cpp/api/JsiSkVertices.h +23 -22
- package/cpp/api/JsiSkiaContext.h +22 -23
- package/cpp/api/JsiSkottieFactory.h +16 -17
- package/cpp/api/JsiVideo.h +43 -81
- package/cpp/api/recorder/Convertor.h +31 -61
- package/cpp/api/recorder/DataTypes.h +8 -16
- package/cpp/api/recorder/JsiRecorder.h +83 -55
- package/cpp/api/recorder/RNRecorder.h +1 -1
- package/cpp/jsi/BoxedNativeObject.h +146 -0
- package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
- package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -31
- package/cpp/{jsi2 → jsi}/NativeObject.h +131 -152
- package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
- package/cpp/jsi/RuntimeAwareCache.h +26 -8
- package/cpp/jsi/ViewProperty.h +5 -11
- package/cpp/rnskia/RNDawnContext.h +18 -2
- package/cpp/rnskia/RNDawnInterop.cpp +19 -0
- package/cpp/rnskia/RNDawnUtils.h +18 -1
- package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
- package/cpp/rnskia/RNSkManager.cpp +9 -168
- package/cpp/rnskia/RNSkPictureView.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/NativeSetup.js +4 -0
- package/lib/commonjs/skia/NativeSetup.js.map +1 -1
- package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
- package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +5 -15
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +0 -1
- package/lib/commonjs/skia/types/index.js +0 -11
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +1 -4
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.js +20 -1
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/views/index.d.ts +0 -1
- package/lib/commonjs/views/index.js +0 -11
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/module/external/reanimated/renderHelpers.js +29 -0
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/mock/index.js +0 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/NativeSetup.js +4 -0
- package/lib/module/skia/NativeSetup.js.map +1 -1
- package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
- package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
- package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +5 -15
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +0 -1
- package/lib/module/skia/types/index.js +0 -1
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +1 -4
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Container.native.js +21 -2
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/views/index.d.ts +0 -1
- package/lib/module/views/index.js +0 -1
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
- package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/typescript/lib/module/mock/index.d.ts +0 -2
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
- package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
- package/lib/typescript/lib/module/views/index.d.ts +0 -1
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
- package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
- package/lib/typescript/src/skia/types/index.d.ts +0 -1
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/typescript/src/views/index.d.ts +0 -1
- package/package.json +8 -5
- package/react-native-skia.podspec +38 -5
- package/src/external/reanimated/renderHelpers.ts +30 -0
- package/src/mock/index.ts +0 -1
- package/src/skia/NativeSetup.ts +5 -0
- package/src/skia/SkiaWorkletSerialization.ts +67 -0
- package/src/skia/types/Image/ImageFactory.ts +15 -6
- package/src/skia/types/Skia.ts +5 -15
- package/src/skia/types/index.ts +0 -1
- package/src/skia/web/JsiSkImageFactory.ts +3 -3
- package/src/skia/web/JsiSkia.ts +2 -5
- package/src/sksg/Container.native.ts +40 -2
- package/src/views/index.ts +0 -1
- package/android/cpp/jni/JniWebGPUView.cpp +0 -112
- package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
- package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
- package/apple/SkiaPlatformContext.h +0 -20
- package/apple/SkiaPlatformContext.mm +0 -21
- package/apple/SkiaWebGPUView.mm +0 -81
- package/apple/WebGPUMetalView.mm +0 -136
- package/cpp/api/JsiSkHostObjects.h +0 -257
- package/cpp/jsi/JsiHostObject.cpp +0 -137
- package/cpp/jsi/JsiHostObject.h +0 -385
- package/cpp/rnwgpu/ArrayBuffer.h +0 -117
- package/cpp/rnwgpu/Canvas.h +0 -50
- package/cpp/rnwgpu/PlatformContext.h +0 -18
- package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
- package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
- package/cpp/rnwgpu/api/Convertors.h +0 -783
- package/cpp/rnwgpu/api/External.h +0 -12
- package/cpp/rnwgpu/api/GPU.cpp +0 -162
- package/cpp/rnwgpu/api/GPU.h +0 -60
- package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -240
- package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
- package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
- package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
- package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
- package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
- package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
- package/cpp/rnwgpu/api/GPUDevice.cpp +0 -614
- package/cpp/rnwgpu/api/GPUDevice.h +0 -258
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
- package/cpp/rnwgpu/api/GPUError.h +0 -35
- package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
- package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
- package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
- package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
- package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
- package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
- package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
- package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
- package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
- package/cpp/rnwgpu/api/GPUQueue.h +0 -84
- package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
- package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
- package/cpp/rnwgpu/api/GPUSampler.h +0 -44
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
- package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
- package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
- package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
- package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
- package/cpp/rnwgpu/api/GPUTexture.h +0 -162
- package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
- package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
- package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
- package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
- package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
- package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
- package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
- package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
- package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -214
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
- package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
- package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
- package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
- package/lib/commonjs/skia/types/WebGPU.js +0 -105
- package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/specs/utils.d.ts +0 -1
- package/lib/commonjs/specs/utils.js +0 -11
- package/lib/commonjs/specs/utils.js.map +0 -1
- package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
- package/lib/commonjs/views/WebGPUCanvas.js +0 -79
- package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
- package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
- package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
- package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
- package/lib/module/skia/types/WebGPU.d.ts +0 -184
- package/lib/module/skia/types/WebGPU.js +0 -99
- package/lib/module/skia/types/WebGPU.js.map +0 -1
- package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
- package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
- package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
- package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
- package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
- package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
- package/lib/module/specs/utils.d.ts +0 -1
- package/lib/module/specs/utils.js +0 -5
- package/lib/module/specs/utils.js.map +0 -1
- package/lib/module/views/WebGPUCanvas.d.ts +0 -33
- package/lib/module/views/WebGPUCanvas.js +0 -70
- package/lib/module/views/WebGPUCanvas.js.map +0 -1
- package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
- package/lib/module/views/WebGPUCanvas.web.js +0 -12
- package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
- package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
- package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
- package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
- package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
- package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
- package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
- package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
- package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
- package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
- package/lib/typescript/src/specs/utils.d.ts +0 -1
- package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
- package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
- package/src/skia/types/WebGPU.ts +0 -226
- package/src/specs/WebGPUViewNativeComponent.ts +0 -11
- package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
- package/src/specs/utils.ts +0 -4
- package/src/views/WebGPUCanvas.tsx +0 -125
- package/src/views/WebGPUCanvas.web.tsx +0 -36
- /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
- /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
#include <algorithm>
|
|
4
4
|
#include <memory>
|
|
5
|
+
#include <string>
|
|
5
6
|
#include <utility>
|
|
7
|
+
#include <variant>
|
|
6
8
|
#include <vector>
|
|
7
9
|
|
|
8
10
|
#include <jsi/jsi.h>
|
|
9
11
|
|
|
10
|
-
#include "
|
|
12
|
+
#include "JsiSkConverters.h"
|
|
13
|
+
#include "JsiSkFont.h"
|
|
11
14
|
#include "JsiSkMatrix.h"
|
|
15
|
+
#include "JsiSkNativeObjects.h"
|
|
16
|
+
#include "JsiSkPath.h"
|
|
12
17
|
#include "JsiSkPathEffect.h"
|
|
13
18
|
#include "JsiSkPoint.h"
|
|
14
19
|
#include "JsiSkRRect.h"
|
|
@@ -17,7 +22,6 @@
|
|
|
17
22
|
#pragma clang diagnostic push
|
|
18
23
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
19
24
|
|
|
20
|
-
#include "utils/RNSkLog.h"
|
|
21
25
|
#include "include/core/SkPath.h"
|
|
22
26
|
#include "include/core/SkPathBuilder.h"
|
|
23
27
|
#include "include/core/SkPathUtils.h"
|
|
@@ -26,6 +30,7 @@
|
|
|
26
30
|
#include "include/effects/SkTrimPathEffect.h"
|
|
27
31
|
#include "include/pathops/SkPathOps.h"
|
|
28
32
|
#include "include/utils/SkTextUtils.h"
|
|
33
|
+
#include "utils/RNSkLog.h"
|
|
29
34
|
|
|
30
35
|
#pragma clang diagnostic pop
|
|
31
36
|
|
|
@@ -33,7 +38,7 @@ namespace RNSkia {
|
|
|
33
38
|
|
|
34
39
|
namespace jsi = facebook::jsi;
|
|
35
40
|
|
|
36
|
-
class JsiSkPathFactory : public
|
|
41
|
+
class JsiSkPathFactory : public JsiSkNativeObject<JsiSkPathFactory> {
|
|
37
42
|
|
|
38
43
|
static const int MOVE = 0;
|
|
39
44
|
static const int LINE = 1;
|
|
@@ -42,111 +47,83 @@ class JsiSkPathFactory : public JsiSkHostObject {
|
|
|
42
47
|
static const int CUBIC = 4;
|
|
43
48
|
static const int CLOSE = 5;
|
|
44
49
|
|
|
50
|
+
using NullablePath = std::variant<std::nullptr_t, std::shared_ptr<JsiSkPath>>;
|
|
51
|
+
|
|
45
52
|
public:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
runtime, hostObjectInstance, getContext());
|
|
53
|
+
static constexpr const char *CLASS_NAME = "PathFactory";
|
|
54
|
+
|
|
55
|
+
std::shared_ptr<JsiSkPath> Make() {
|
|
56
|
+
return std::make_shared<JsiSkPath>(getContext(), SkPath());
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
auto svgString = arguments[0].asString(runtime).utf8(runtime);
|
|
59
|
+
std::shared_ptr<JsiSkPath> MakeFromSVGString(std::string svgString) {
|
|
55
60
|
auto result = SkParsePath::FromSVGString(svgString.c_str());
|
|
56
61
|
if (!result.has_value()) {
|
|
57
|
-
throw
|
|
58
|
-
return jsi::Value(nullptr);
|
|
62
|
+
throw std::runtime_error("Could not parse Svg path");
|
|
59
63
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
63
|
-
runtime, hostObjectInstance, getContext());
|
|
64
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
65
|
+
std::move(result.value()));
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
auto
|
|
69
|
-
|
|
70
|
-
auto result = Op(one, two, op);
|
|
68
|
+
NullablePath MakeFromOp(std::shared_ptr<SkPathBuilder> pathOne,
|
|
69
|
+
std::shared_ptr<SkPathBuilder> pathTwo, double op) {
|
|
70
|
+
auto one = pathOne->snapshot();
|
|
71
|
+
auto two = pathTwo->snapshot();
|
|
72
|
+
auto result = Op(one, two, static_cast<SkPathOp>(op));
|
|
71
73
|
if (!result.has_value()) {
|
|
72
|
-
return
|
|
74
|
+
return nullptr;
|
|
73
75
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
77
|
-
runtime, hostObjectInstance, getContext());
|
|
76
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
77
|
+
std::move(result.value()));
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
NullablePath MakeFromCmds(std::vector<std::vector<double>> cmds) {
|
|
81
81
|
SkPathBuilder builder;
|
|
82
|
-
auto
|
|
83
|
-
|
|
84
|
-
for (int i = 0; i < cmdCount; i++) {
|
|
85
|
-
auto cmd =
|
|
86
|
-
cmds.getValueAtIndex(runtime, i).asObject(runtime).asArray(runtime);
|
|
87
|
-
if (cmd.size(runtime) < 1) {
|
|
82
|
+
for (const auto &cmd : cmds) {
|
|
83
|
+
if (cmd.size() < 1) {
|
|
88
84
|
RNSkLogger::logToConsole("Invalid command found (got an empty array)");
|
|
89
|
-
return
|
|
85
|
+
return nullptr;
|
|
90
86
|
}
|
|
91
|
-
auto verb = static_cast<int>(cmd
|
|
87
|
+
auto verb = static_cast<int>(cmd[0]);
|
|
92
88
|
switch (verb) {
|
|
93
89
|
case MOVE: {
|
|
94
|
-
if (cmd.size(
|
|
90
|
+
if (cmd.size() < 3) {
|
|
95
91
|
RNSkLogger::logToConsole("Invalid move command found");
|
|
96
|
-
return
|
|
92
|
+
return nullptr;
|
|
97
93
|
}
|
|
98
|
-
|
|
99
|
-
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
100
|
-
builder.moveTo(x, y);
|
|
94
|
+
builder.moveTo(cmd[1], cmd[2]);
|
|
101
95
|
break;
|
|
102
96
|
}
|
|
103
97
|
case LINE: {
|
|
104
|
-
if (cmd.size(
|
|
98
|
+
if (cmd.size() < 3) {
|
|
105
99
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
106
|
-
return
|
|
100
|
+
return nullptr;
|
|
107
101
|
}
|
|
108
|
-
|
|
109
|
-
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
110
|
-
builder.lineTo(x, y);
|
|
102
|
+
builder.lineTo(cmd[1], cmd[2]);
|
|
111
103
|
break;
|
|
112
104
|
}
|
|
113
105
|
case QUAD: {
|
|
114
|
-
if (cmd.size(
|
|
106
|
+
if (cmd.size() < 5) {
|
|
115
107
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
116
|
-
return
|
|
108
|
+
return nullptr;
|
|
117
109
|
}
|
|
118
|
-
|
|
119
|
-
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
120
|
-
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
121
|
-
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
122
|
-
builder.quadTo(x1, y1, x2, y2);
|
|
110
|
+
builder.quadTo(cmd[1], cmd[2], cmd[3], cmd[4]);
|
|
123
111
|
break;
|
|
124
112
|
}
|
|
125
113
|
case CONIC: {
|
|
126
|
-
if (cmd.size(
|
|
114
|
+
if (cmd.size() < 6) {
|
|
127
115
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
128
|
-
return
|
|
116
|
+
return nullptr;
|
|
129
117
|
}
|
|
130
|
-
|
|
131
|
-
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
132
|
-
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
133
|
-
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
134
|
-
auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
135
|
-
builder.conicTo(x1, y1, x2, y2, w);
|
|
118
|
+
builder.conicTo(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5]);
|
|
136
119
|
break;
|
|
137
120
|
}
|
|
138
121
|
case CUBIC: {
|
|
139
|
-
if (cmd.size(
|
|
122
|
+
if (cmd.size() < 7) {
|
|
140
123
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
141
|
-
return
|
|
124
|
+
return nullptr;
|
|
142
125
|
}
|
|
143
|
-
|
|
144
|
-
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
145
|
-
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
146
|
-
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
147
|
-
auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
148
|
-
auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
|
|
149
|
-
builder.cubicTo(x1, y1, x2, y2, x3, y3);
|
|
126
|
+
builder.cubicTo(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6]);
|
|
150
127
|
break;
|
|
151
128
|
}
|
|
152
129
|
case CLOSE: {
|
|
@@ -155,118 +132,68 @@ public:
|
|
|
155
132
|
}
|
|
156
133
|
default: {
|
|
157
134
|
RNSkLogger::logToConsole("Found an unknown command");
|
|
158
|
-
return
|
|
135
|
+
return nullptr;
|
|
159
136
|
}
|
|
160
137
|
}
|
|
161
138
|
}
|
|
162
|
-
|
|
163
|
-
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
164
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
165
|
-
runtime, hostObjectInstance, getContext());
|
|
139
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
166
140
|
}
|
|
167
141
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
auto x = arguments[1].asNumber();
|
|
171
|
-
auto y = arguments[2].asNumber();
|
|
172
|
-
auto font = JsiSkFont::fromValue(runtime, arguments[3]);
|
|
142
|
+
std::shared_ptr<JsiSkPath> MakeFromText(std::string text, double x, double y,
|
|
143
|
+
std::shared_ptr<SkFont> font) {
|
|
173
144
|
SkPath path;
|
|
174
145
|
SkTextUtils::GetPath(text.c_str(), strlen(text.c_str()),
|
|
175
146
|
SkTextEncoding::kUTF8, x, y, *font, &path);
|
|
176
|
-
|
|
177
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
178
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
179
|
-
runtime, hostObjectInstance, getContext());
|
|
147
|
+
return std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
180
148
|
}
|
|
181
149
|
|
|
182
150
|
// Static shape factories
|
|
183
|
-
|
|
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
|
-
}
|
|
151
|
+
std::shared_ptr<JsiSkPath> Rect(SkRect rect, JsiOptional<bool> isCCW) {
|
|
189
152
|
SkPathBuilder builder;
|
|
190
|
-
builder.addRect(
|
|
191
|
-
|
|
192
|
-
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
193
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
194
|
-
runtime, hostObjectInstance, getContext());
|
|
153
|
+
builder.addRect(rect, toDirection(isCCW));
|
|
154
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
195
155
|
}
|
|
196
156
|
|
|
197
|
-
|
|
198
|
-
|
|
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();
|
|
157
|
+
std::shared_ptr<JsiSkPath> Oval(SkRect rect, JsiOptional<bool> isCCW,
|
|
158
|
+
JsiOptional<double> startIndex) {
|
|
204
159
|
SkPathBuilder builder;
|
|
205
|
-
builder.addOval(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
160
|
+
builder.addOval(rect, toDirection(isCCW),
|
|
161
|
+
startIndex.has_value()
|
|
162
|
+
? static_cast<unsigned>(*startIndex)
|
|
163
|
+
: 0);
|
|
164
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
210
165
|
}
|
|
211
166
|
|
|
212
|
-
|
|
213
|
-
auto x = arguments[0].asNumber();
|
|
214
|
-
auto y = arguments[1].asNumber();
|
|
215
|
-
auto r = arguments[2].asNumber();
|
|
167
|
+
std::shared_ptr<JsiSkPath> Circle(double x, double y, double r) {
|
|
216
168
|
SkPathBuilder builder;
|
|
217
169
|
builder.addCircle(x, y, r);
|
|
218
|
-
|
|
219
|
-
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
220
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
221
|
-
runtime, hostObjectInstance, getContext());
|
|
170
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
222
171
|
}
|
|
223
172
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
auto direction = SkPathDirection::kCW;
|
|
227
|
-
if (count >= 2 && arguments[1].getBool()) {
|
|
228
|
-
direction = SkPathDirection::kCCW;
|
|
229
|
-
}
|
|
173
|
+
std::shared_ptr<JsiSkPath> RRect(std::shared_ptr<SkRRect> rrect,
|
|
174
|
+
JsiOptional<bool> isCCW) {
|
|
230
175
|
SkPathBuilder builder;
|
|
231
|
-
builder.addRRect(*rrect,
|
|
232
|
-
|
|
233
|
-
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
234
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
235
|
-
runtime, hostObjectInstance, getContext());
|
|
176
|
+
builder.addRRect(*rrect, toDirection(isCCW));
|
|
177
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
236
178
|
}
|
|
237
179
|
|
|
238
|
-
|
|
239
|
-
auto p1 = JsiSkPoint::fromValue(runtime, arguments[0].asObject(runtime));
|
|
240
|
-
auto p2 = JsiSkPoint::fromValue(runtime, arguments[1].asObject(runtime));
|
|
180
|
+
std::shared_ptr<JsiSkPath> Line(SkPoint p1, SkPoint p2) {
|
|
241
181
|
SkPathBuilder builder;
|
|
242
|
-
builder.moveTo(
|
|
243
|
-
builder.lineTo(
|
|
244
|
-
|
|
245
|
-
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
246
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
247
|
-
runtime, hostObjectInstance, getContext());
|
|
182
|
+
builder.moveTo(p1);
|
|
183
|
+
builder.lineTo(p2);
|
|
184
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
248
185
|
}
|
|
249
186
|
|
|
250
|
-
|
|
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
|
-
}
|
|
187
|
+
std::shared_ptr<JsiSkPath> Polygon(std::vector<SkPoint> points, bool close) {
|
|
261
188
|
SkPathBuilder builder;
|
|
262
189
|
builder.addPolygon(SkSpan(points), close);
|
|
263
|
-
|
|
264
|
-
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
265
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
266
|
-
runtime, hostObjectInstance, getContext());
|
|
190
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
267
191
|
}
|
|
268
192
|
|
|
269
193
|
// Static path operations
|
|
194
|
+
|
|
195
|
+
// Stays raw: the options object is read leniently property by property
|
|
196
|
+
// (unknown properties and non-numeric values are ignored).
|
|
270
197
|
JSI_HOST_FUNCTION(Stroke) {
|
|
271
198
|
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
272
199
|
SkPath path = srcPath->snapshot();
|
|
@@ -307,148 +234,131 @@ public:
|
|
|
307
234
|
auto success =
|
|
308
235
|
skpathutils::FillPathWithPaint(path, p, &resultBuilder, nullptr, ctm);
|
|
309
236
|
if (success) {
|
|
310
|
-
|
|
311
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
312
|
-
|
|
313
|
-
runtime, hostObjectInstance, getContext());
|
|
237
|
+
return makeJsiObject(
|
|
238
|
+
runtime, std::make_shared<JsiSkPath>(getContext(),
|
|
239
|
+
resultBuilder.snapshot()));
|
|
314
240
|
}
|
|
315
241
|
} else {
|
|
316
242
|
SkPathBuilder resultBuilder;
|
|
317
243
|
auto success = skpathutils::FillPathWithPaint(path, p, &resultBuilder);
|
|
318
244
|
if (success) {
|
|
319
|
-
|
|
320
|
-
std::make_shared<JsiSkPath>(getContext(),
|
|
321
|
-
|
|
322
|
-
runtime, hostObjectInstance, getContext());
|
|
245
|
+
return makeJsiObject(
|
|
246
|
+
runtime, std::make_shared<JsiSkPath>(getContext(),
|
|
247
|
+
resultBuilder.snapshot()));
|
|
323
248
|
}
|
|
324
249
|
}
|
|
325
250
|
return jsi::Value::null();
|
|
326
251
|
}
|
|
327
252
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
float start =
|
|
331
|
-
|
|
332
|
-
float end =
|
|
333
|
-
std::clamp(static_cast<float>(arguments[2].asNumber()), 0.0f, 1.0f);
|
|
334
|
-
auto isComplement = arguments[3].getBool();
|
|
253
|
+
NullablePath Trim(std::shared_ptr<SkPathBuilder> srcPath, double startValue,
|
|
254
|
+
double endValue, bool isComplement) {
|
|
255
|
+
float start = std::clamp(static_cast<float>(startValue), 0.0f, 1.0f);
|
|
256
|
+
float end = std::clamp(static_cast<float>(endValue), 0.0f, 1.0f);
|
|
335
257
|
// If requesting the full path in normal mode, just return a copy
|
|
336
258
|
if (start <= 0 && end >= 1 && !isComplement) {
|
|
337
|
-
|
|
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());
|
|
259
|
+
return std::make_shared<JsiSkPath>(getContext(), srcPath->snapshot());
|
|
342
260
|
}
|
|
343
261
|
SkPath path = srcPath->snapshot();
|
|
344
262
|
auto mode = isComplement ? SkTrimPathEffect::Mode::kInverted
|
|
345
263
|
: SkTrimPathEffect::Mode::kNormal;
|
|
346
264
|
auto pe = SkTrimPathEffect::Make(start, end, mode);
|
|
347
265
|
if (!pe) {
|
|
348
|
-
return
|
|
266
|
+
return nullptr;
|
|
349
267
|
}
|
|
350
268
|
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
351
269
|
SkPathBuilder resultBuilder;
|
|
352
270
|
if (pe->filterPath(&resultBuilder, path, &rec)) {
|
|
353
|
-
|
|
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());
|
|
271
|
+
return std::make_shared<JsiSkPath>(getContext(), resultBuilder.detach());
|
|
358
272
|
}
|
|
359
|
-
return
|
|
273
|
+
return nullptr;
|
|
360
274
|
}
|
|
361
275
|
|
|
362
|
-
|
|
363
|
-
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
276
|
+
NullablePath Simplify(std::shared_ptr<SkPathBuilder> srcPath) {
|
|
364
277
|
auto result = ::Simplify(srcPath->snapshot());
|
|
365
278
|
if (result.has_value()) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
369
|
-
runtime, hostObjectInstance, getContext());
|
|
279
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
280
|
+
std::move(result.value()));
|
|
370
281
|
}
|
|
371
|
-
return
|
|
282
|
+
return nullptr;
|
|
372
283
|
}
|
|
373
284
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
SkScalar
|
|
377
|
-
|
|
378
|
-
auto phase = arguments[3].asNumber();
|
|
379
|
-
SkScalar intervals[] = {on, off};
|
|
285
|
+
NullablePath Dash(std::shared_ptr<SkPathBuilder> srcPath, double on,
|
|
286
|
+
double off, double phase) {
|
|
287
|
+
SkScalar intervals[] = {static_cast<SkScalar>(on),
|
|
288
|
+
static_cast<SkScalar>(off)};
|
|
380
289
|
auto i = SkSpan(intervals, 2);
|
|
381
290
|
auto pe = SkDashPathEffect::Make(i, phase);
|
|
382
291
|
if (!pe) {
|
|
383
|
-
return
|
|
292
|
+
return nullptr;
|
|
384
293
|
}
|
|
385
294
|
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
386
295
|
SkPathBuilder resultBuilder;
|
|
387
296
|
if (pe->filterPath(&resultBuilder, srcPath->snapshot(), &rec)) {
|
|
388
|
-
|
|
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());
|
|
297
|
+
return std::make_shared<JsiSkPath>(getContext(), resultBuilder.detach());
|
|
393
298
|
}
|
|
394
|
-
return
|
|
299
|
+
return nullptr;
|
|
395
300
|
}
|
|
396
301
|
|
|
397
|
-
|
|
398
|
-
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
302
|
+
NullablePath AsWinding(std::shared_ptr<SkPathBuilder> srcPath) {
|
|
399
303
|
auto result = ::AsWinding(srcPath->snapshot());
|
|
400
304
|
if (result.has_value()) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
404
|
-
runtime, hostObjectInstance, getContext());
|
|
305
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
306
|
+
std::move(result.value()));
|
|
405
307
|
}
|
|
406
|
-
return
|
|
308
|
+
return nullptr;
|
|
407
309
|
}
|
|
408
310
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
auto
|
|
413
|
-
auto
|
|
414
|
-
auto p2 = path2->snapshot();
|
|
311
|
+
NullablePath Interpolate(std::shared_ptr<SkPathBuilder> pathOne,
|
|
312
|
+
std::shared_ptr<SkPathBuilder> pathTwo,
|
|
313
|
+
double weight) {
|
|
314
|
+
auto p1 = pathOne->snapshot();
|
|
315
|
+
auto p2 = pathTwo->snapshot();
|
|
415
316
|
SkPath result;
|
|
416
317
|
auto succeed = p1.interpolate(p2, weight, &result);
|
|
417
318
|
if (!succeed) {
|
|
418
|
-
return
|
|
319
|
+
return nullptr;
|
|
419
320
|
}
|
|
420
|
-
|
|
421
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
422
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
423
|
-
runtime, hostObjectInstance, getContext());
|
|
321
|
+
return std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
424
322
|
}
|
|
425
323
|
|
|
426
|
-
size_t getMemoryPressure()
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
324
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
325
|
+
|
|
326
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
327
|
+
installMethod(runtime, prototype, "Make", &JsiSkPathFactory::Make);
|
|
328
|
+
installMethod(runtime, prototype, "MakeFromSVGString",
|
|
329
|
+
&JsiSkPathFactory::MakeFromSVGString);
|
|
330
|
+
installMethod(runtime, prototype, "MakeFromOp",
|
|
331
|
+
&JsiSkPathFactory::MakeFromOp);
|
|
332
|
+
installMethod(runtime, prototype, "MakeFromCmds",
|
|
333
|
+
&JsiSkPathFactory::MakeFromCmds);
|
|
334
|
+
installMethod(runtime, prototype, "MakeFromText",
|
|
335
|
+
&JsiSkPathFactory::MakeFromText);
|
|
336
|
+
// Static shape factories
|
|
337
|
+
installMethod(runtime, prototype, "Rect", &JsiSkPathFactory::Rect);
|
|
338
|
+
installMethod(runtime, prototype, "Oval", &JsiSkPathFactory::Oval);
|
|
339
|
+
installMethod(runtime, prototype, "Circle", &JsiSkPathFactory::Circle);
|
|
340
|
+
installMethod(runtime, prototype, "RRect", &JsiSkPathFactory::RRect);
|
|
341
|
+
installMethod(runtime, prototype, "Line", &JsiSkPathFactory::Line);
|
|
342
|
+
installMethod(runtime, prototype, "Polygon", &JsiSkPathFactory::Polygon);
|
|
343
|
+
// Static path operations
|
|
344
|
+
installHostMethod(runtime, prototype, "Stroke", &JsiSkPathFactory::Stroke);
|
|
345
|
+
installMethod(runtime, prototype, "Trim", &JsiSkPathFactory::Trim);
|
|
346
|
+
installMethod(runtime, prototype, "Simplify", &JsiSkPathFactory::Simplify);
|
|
347
|
+
installMethod(runtime, prototype, "Dash", &JsiSkPathFactory::Dash);
|
|
348
|
+
installMethod(runtime, prototype, "AsWinding",
|
|
349
|
+
&JsiSkPathFactory::AsWinding);
|
|
350
|
+
installMethod(runtime, prototype, "Interpolate",
|
|
351
|
+
&JsiSkPathFactory::Interpolate);
|
|
352
|
+
}
|
|
449
353
|
|
|
450
354
|
explicit JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
451
|
-
:
|
|
355
|
+
: JsiSkNativeObject<JsiSkPathFactory>(std::move(context)) {}
|
|
356
|
+
|
|
357
|
+
private:
|
|
358
|
+
static SkPathDirection toDirection(const JsiOptional<bool> &isCCW) {
|
|
359
|
+
return isCCW.has_value() && *isCCW ? SkPathDirection::kCCW
|
|
360
|
+
: SkPathDirection::kCW;
|
|
361
|
+
}
|
|
452
362
|
};
|
|
453
363
|
|
|
454
364
|
} // namespace RNSkia
|