@shopify/react-native-skia 2.10.0 → 2.11.0-next.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 +7 -41
- package/android/build.gradle +33 -0
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
- package/cpp/api/JsiNativeBuffer.h +14 -20
- package/cpp/api/JsiSkAnimatedImage.h +13 -16
- package/cpp/api/JsiSkAnimatedImageFactory.h +9 -7
- package/cpp/api/JsiSkApi.h +94 -90
- package/cpp/api/JsiSkCanvas.h +108 -251
- package/cpp/api/JsiSkColorFilterFactory.h +45 -63
- package/cpp/api/JsiSkContourMeasure.h +19 -29
- package/cpp/api/JsiSkContourMeasureIter.h +6 -6
- package/cpp/api/JsiSkConverters.h +410 -0
- package/cpp/api/JsiSkDataFactory.h +9 -15
- package/cpp/api/JsiSkFont.h +99 -180
- package/cpp/api/JsiSkFontMgr.h +19 -21
- package/cpp/api/JsiSkFontMgrFactory.h +4 -5
- package/cpp/api/JsiSkImage.h +66 -66
- package/cpp/api/JsiSkImageFactory.h +66 -63
- package/cpp/api/JsiSkImageFilterFactory.h +354 -608
- package/cpp/api/JsiSkImageInfo.h +10 -13
- package/cpp/api/JsiSkMaskFilterFactory.h +8 -11
- package/cpp/api/JsiSkMatrix.h +36 -73
- package/cpp/api/JsiSkNativeObjects.h +60 -92
- package/cpp/api/JsiSkPaint.h +73 -131
- package/cpp/api/JsiSkParagraph.h +36 -53
- package/cpp/api/JsiSkParagraphBuilder.h +36 -64
- package/cpp/api/JsiSkParagraphBuilderFactory.h +11 -16
- package/cpp/api/JsiSkPath.h +216 -349
- package/cpp/api/JsiSkPathBuilder.h +133 -269
- package/cpp/api/JsiSkPathBuilderFactory.h +11 -11
- package/cpp/api/JsiSkPathEffectFactory.h +52 -72
- package/cpp/api/JsiSkPathFactory.h +129 -195
- package/cpp/api/JsiSkPicture.h +12 -18
- package/cpp/api/JsiSkPictureRecorder.h +14 -15
- package/cpp/api/JsiSkPoint.h +4 -4
- package/cpp/api/JsiSkRRect.h +7 -8
- package/cpp/api/JsiSkRSXform.h +10 -23
- package/cpp/api/JsiSkRect.h +23 -31
- package/cpp/api/JsiSkRuntimeEffect.h +67 -83
- package/cpp/api/JsiSkRuntimeEffectFactory.h +6 -10
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +5 -14
- package/cpp/api/JsiSkSVG.h +4 -4
- package/cpp/api/JsiSkShaderFactory.h +153 -225
- package/cpp/api/JsiSkSkottie.h +104 -126
- package/cpp/api/JsiSkSurface.h +11 -14
- package/cpp/api/JsiSkSurfaceFactory.h +6 -7
- package/cpp/api/JsiSkTextBlobFactory.h +31 -54
- package/cpp/api/JsiSkTypeface.h +8 -12
- package/cpp/api/JsiSkTypefaceFactory.h +9 -7
- package/cpp/api/JsiSkTypefaceFontProvider.h +22 -23
- package/cpp/api/JsiSkTypefaceFontProviderFactory.h +5 -6
- package/cpp/api/JsiSkVertices.h +6 -8
- package/cpp/api/JsiSkiaContext.h +10 -11
- package/cpp/api/JsiVideo.h +31 -71
- package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
- package/cpp/dawn/include/dawn/dawn_proc_table.h +330 -0
- package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/include/dawn/dawn_version.h +41 -0
- package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
- package/cpp/dawn/include/dawn/native/D3D12Backend.h +86 -0
- package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/DawnNative.h +369 -0
- package/cpp/dawn/include/dawn/native/MetalBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
- package/cpp/dawn/include/dawn/native/VulkanBackend.h +183 -0
- package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
- package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/include/dawn/platform/DawnPlatform.h +210 -0
- package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
- package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
- package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2844 -0
- package/cpp/dawn/include/tint/tint.h +90 -0
- package/cpp/dawn/include/webgpu/webgpu.h +4987 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +10080 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +161 -0
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
- package/cpp/jsi/JSIConverter.h +0 -31
- package/cpp/jsi/NativeObject.h +11 -6
- package/cpp/rnskia/RNDawnContext.h +18 -2
- package/cpp/rnskia/RNDawnInterop.cpp +19 -0
- package/cpp/rnskia/RNDawnUtils.h +18 -1
- package/cpp/rnskia/RNSkManager.cpp +5 -162
- package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
- package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
- package/cpp/skia/src/gpu/graphite/ResourceTypes.h +360 -0
- package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- 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/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/mock/index.js +0 -1
- package/lib/module/mock/index.js.map +1 -1
- 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/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/mock/index.d.ts +0 -1
- 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/mock/index.d.ts +0 -2
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
- 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/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/libs/.graphite +1 -0
- package/package.json +8 -9
- package/react-native-skia.podspec +38 -4
- package/src/mock/index.ts +0 -1
- 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/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/rnwgpu/ArrayBuffer.h +0 -116
- package/cpp/rnwgpu/Canvas.h +0 -52
- 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 -239
- 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 -613
- 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 -213
- 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
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
+
#include <optional>
|
|
4
5
|
#include <utility>
|
|
6
|
+
#include <variant>
|
|
5
7
|
#include <vector>
|
|
6
8
|
|
|
7
9
|
#include <jsi/jsi.h>
|
|
8
10
|
|
|
11
|
+
#include "JsiSkConverters.h"
|
|
12
|
+
#include "JsiSkMatrix.h"
|
|
9
13
|
#include "JsiSkNativeObjects.h"
|
|
14
|
+
#include "JsiSkPath.h"
|
|
10
15
|
#include "JsiSkPathEffect.h"
|
|
11
16
|
|
|
12
17
|
#pragma clang diagnostic push
|
|
@@ -30,104 +35,79 @@ class JsiSkPathEffectFactory
|
|
|
30
35
|
public:
|
|
31
36
|
static constexpr const char *CLASS_NAME = "PathEffectFactory";
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
getContext(), SkCornerPathEffect::Make(radius));
|
|
37
|
-
return makeJsiObject(runtime, std::move(pathEffect));
|
|
38
|
+
std::shared_ptr<JsiSkPathEffect> MakeCorner(int radius) {
|
|
39
|
+
return std::make_shared<JsiSkPathEffect>(getContext(),
|
|
40
|
+
SkCornerPathEffect::Make(radius));
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
std::vector<SkScalar> intervals;
|
|
44
|
-
intervals.reserve(size);
|
|
45
|
-
for (int i = 0; i < size; i++) {
|
|
46
|
-
SkScalar interval = jsiIntervals.getValueAtIndex(runtime, i).asNumber();
|
|
47
|
-
intervals.push_back(interval);
|
|
48
|
-
}
|
|
49
|
-
int phase =
|
|
50
|
-
count >= 2 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
|
51
|
-
? arguments[1].asNumber()
|
|
52
|
-
: 0;
|
|
43
|
+
std::shared_ptr<JsiSkPathEffect>
|
|
44
|
+
MakeDash(std::vector<float> intervals, JsiOptional<double> phaseValue) {
|
|
45
|
+
int phase = phaseValue.has_value() ? *phaseValue : 0;
|
|
53
46
|
auto i = SkSpan(intervals.data(), intervals.size());
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return makeJsiObject(runtime, std::move(pathEffect));
|
|
47
|
+
return std::make_shared<JsiSkPathEffect>(getContext(),
|
|
48
|
+
SkDashPathEffect::Make(i, phase));
|
|
57
49
|
}
|
|
58
50
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
int seedAssist = arguments[2].asNumber();
|
|
63
|
-
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
51
|
+
std::shared_ptr<JsiSkPathEffect> MakeDiscrete(int segLength, int dec,
|
|
52
|
+
int seedAssist) {
|
|
53
|
+
return std::make_shared<JsiSkPathEffect>(
|
|
64
54
|
getContext(), SkDiscretePathEffect::Make(segLength, dec, seedAssist));
|
|
65
|
-
return makeJsiObject(runtime, std::move(pathEffect));
|
|
66
55
|
}
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
57
|
+
std::shared_ptr<JsiSkPathEffect> MakeCompose(sk_sp<SkPathEffect> outer,
|
|
58
|
+
sk_sp<SkPathEffect> inner) {
|
|
59
|
+
return std::make_shared<JsiSkPathEffect>(
|
|
72
60
|
getContext(),
|
|
73
61
|
SkPathEffect::MakeCompose(std::move(outer), std::move(inner)));
|
|
74
|
-
return makeJsiObject(runtime, std::move(pathEffect));
|
|
75
62
|
}
|
|
76
63
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
64
|
+
std::shared_ptr<JsiSkPathEffect> MakeSum(sk_sp<SkPathEffect> outer,
|
|
65
|
+
sk_sp<SkPathEffect> inner) {
|
|
66
|
+
return std::make_shared<JsiSkPathEffect>(
|
|
81
67
|
getContext(),
|
|
82
68
|
SkPathEffect::MakeSum(std::move(outer), std::move(inner)));
|
|
83
|
-
return makeJsiObject(runtime, std::move(pathEffect));
|
|
84
69
|
}
|
|
85
70
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
auto style =
|
|
91
|
-
static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
|
|
92
|
-
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
71
|
+
std::shared_ptr<JsiSkPathEffect>
|
|
72
|
+
MakePath1D(std::shared_ptr<SkPathBuilder> path, double advance, double phase,
|
|
73
|
+
double style) {
|
|
74
|
+
return std::make_shared<JsiSkPathEffect>(
|
|
93
75
|
getContext(),
|
|
94
|
-
SkPath1DPathEffect::Make(
|
|
95
|
-
|
|
76
|
+
SkPath1DPathEffect::Make(
|
|
77
|
+
path->snapshot(), advance, phase,
|
|
78
|
+
static_cast<SkPath1DPathEffect::Style>(style)));
|
|
96
79
|
}
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
81
|
+
std::shared_ptr<JsiSkPathEffect>
|
|
82
|
+
MakePath2D(std::shared_ptr<SkMatrix> matrix,
|
|
83
|
+
std::shared_ptr<SkPathBuilder> path) {
|
|
84
|
+
return std::make_shared<JsiSkPathEffect>(
|
|
102
85
|
getContext(), SkPath2DPathEffect::Make(*matrix, path->snapshot()));
|
|
103
|
-
return makeJsiObject(runtime, std::move(pathEffect));
|
|
104
86
|
}
|
|
105
87
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
auto pathEffect = std::make_shared<JsiSkPathEffect>(
|
|
88
|
+
std::shared_ptr<JsiSkPathEffect>
|
|
89
|
+
MakeLine2D(double width, std::shared_ptr<SkMatrix> matrix) {
|
|
90
|
+
return std::make_shared<JsiSkPathEffect>(
|
|
110
91
|
getContext(), SkLine2DPathEffect::Make(width, *matrix));
|
|
111
|
-
return makeJsiObject(runtime, std::move(pathEffect));
|
|
112
92
|
}
|
|
113
93
|
|
|
114
94
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
95
|
+
installMethod(runtime, prototype, "MakeCorner",
|
|
96
|
+
&JsiSkPathEffectFactory::MakeCorner);
|
|
97
|
+
installMethod(runtime, prototype, "MakeDash",
|
|
98
|
+
&JsiSkPathEffectFactory::MakeDash);
|
|
99
|
+
installMethod(runtime, prototype, "MakeDiscrete",
|
|
100
|
+
&JsiSkPathEffectFactory::MakeDiscrete);
|
|
101
|
+
installMethod(runtime, prototype, "MakeCompose",
|
|
102
|
+
&JsiSkPathEffectFactory::MakeCompose);
|
|
103
|
+
installMethod(runtime, prototype, "MakeSum",
|
|
104
|
+
&JsiSkPathEffectFactory::MakeSum);
|
|
105
|
+
installMethod(runtime, prototype, "MakeLine2D",
|
|
106
|
+
&JsiSkPathEffectFactory::MakeLine2D);
|
|
107
|
+
installMethod(runtime, prototype, "MakePath1D",
|
|
108
|
+
&JsiSkPathEffectFactory::MakePath1D);
|
|
109
|
+
installMethod(runtime, prototype, "MakePath2D",
|
|
110
|
+
&JsiSkPathEffectFactory::MakePath2D);
|
|
131
111
|
}
|
|
132
112
|
|
|
133
113
|
size_t getMemoryPressure() override { return 1024; }
|
|
@@ -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
|
|
|
12
|
+
#include "JsiSkConverters.h"
|
|
13
|
+
#include "JsiSkFont.h"
|
|
10
14
|
#include "JsiSkMatrix.h"
|
|
11
15
|
#include "JsiSkNativeObjects.h"
|
|
16
|
+
#include "JsiSkPath.h"
|
|
12
17
|
#include "JsiSkPathEffect.h"
|
|
13
18
|
#include "JsiSkPoint.h"
|
|
14
19
|
#include "JsiSkRRect.h"
|
|
@@ -42,107 +47,83 @@ class JsiSkPathFactory : public JsiSkNativeObject<JsiSkPathFactory> {
|
|
|
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
53
|
static constexpr const char *CLASS_NAME = "PathFactory";
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
std::make_shared<JsiSkPath>(getContext(), SkPath()));
|
|
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
|
-
return
|
|
61
|
-
|
|
64
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
65
|
+
std::move(result.value()));
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
auto
|
|
67
|
-
|
|
68
|
-
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));
|
|
69
73
|
if (!result.has_value()) {
|
|
70
|
-
return
|
|
74
|
+
return nullptr;
|
|
71
75
|
}
|
|
72
|
-
return
|
|
73
|
-
|
|
76
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
77
|
+
std::move(result.value()));
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
NullablePath MakeFromCmds(std::vector<std::vector<double>> cmds) {
|
|
77
81
|
SkPathBuilder builder;
|
|
78
|
-
auto
|
|
79
|
-
|
|
80
|
-
for (int i = 0; i < cmdCount; i++) {
|
|
81
|
-
auto cmd =
|
|
82
|
-
cmds.getValueAtIndex(runtime, i).asObject(runtime).asArray(runtime);
|
|
83
|
-
if (cmd.size(runtime) < 1) {
|
|
82
|
+
for (const auto &cmd : cmds) {
|
|
83
|
+
if (cmd.size() < 1) {
|
|
84
84
|
RNSkLogger::logToConsole("Invalid command found (got an empty array)");
|
|
85
|
-
return
|
|
85
|
+
return nullptr;
|
|
86
86
|
}
|
|
87
|
-
auto verb = static_cast<int>(cmd
|
|
87
|
+
auto verb = static_cast<int>(cmd[0]);
|
|
88
88
|
switch (verb) {
|
|
89
89
|
case MOVE: {
|
|
90
|
-
if (cmd.size(
|
|
90
|
+
if (cmd.size() < 3) {
|
|
91
91
|
RNSkLogger::logToConsole("Invalid move command found");
|
|
92
|
-
return
|
|
92
|
+
return nullptr;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
96
|
-
builder.moveTo(x, y);
|
|
94
|
+
builder.moveTo(cmd[1], cmd[2]);
|
|
97
95
|
break;
|
|
98
96
|
}
|
|
99
97
|
case LINE: {
|
|
100
|
-
if (cmd.size(
|
|
98
|
+
if (cmd.size() < 3) {
|
|
101
99
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
102
|
-
return
|
|
100
|
+
return nullptr;
|
|
103
101
|
}
|
|
104
|
-
|
|
105
|
-
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
106
|
-
builder.lineTo(x, y);
|
|
102
|
+
builder.lineTo(cmd[1], cmd[2]);
|
|
107
103
|
break;
|
|
108
104
|
}
|
|
109
105
|
case QUAD: {
|
|
110
|
-
if (cmd.size(
|
|
106
|
+
if (cmd.size() < 5) {
|
|
111
107
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
112
|
-
return
|
|
108
|
+
return nullptr;
|
|
113
109
|
}
|
|
114
|
-
|
|
115
|
-
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
116
|
-
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
117
|
-
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
118
|
-
builder.quadTo(x1, y1, x2, y2);
|
|
110
|
+
builder.quadTo(cmd[1], cmd[2], cmd[3], cmd[4]);
|
|
119
111
|
break;
|
|
120
112
|
}
|
|
121
113
|
case CONIC: {
|
|
122
|
-
if (cmd.size(
|
|
114
|
+
if (cmd.size() < 6) {
|
|
123
115
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
124
|
-
return
|
|
116
|
+
return nullptr;
|
|
125
117
|
}
|
|
126
|
-
|
|
127
|
-
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
128
|
-
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
129
|
-
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
130
|
-
auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
131
|
-
builder.conicTo(x1, y1, x2, y2, w);
|
|
118
|
+
builder.conicTo(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5]);
|
|
132
119
|
break;
|
|
133
120
|
}
|
|
134
121
|
case CUBIC: {
|
|
135
|
-
if (cmd.size(
|
|
122
|
+
if (cmd.size() < 7) {
|
|
136
123
|
RNSkLogger::logToConsole("Invalid line command found");
|
|
137
|
-
return
|
|
124
|
+
return nullptr;
|
|
138
125
|
}
|
|
139
|
-
|
|
140
|
-
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
|
|
141
|
-
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
|
|
142
|
-
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
|
|
143
|
-
auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
|
|
144
|
-
auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
|
|
145
|
-
builder.cubicTo(x1, y1, x2, y2, x3, y3);
|
|
126
|
+
builder.cubicTo(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6]);
|
|
146
127
|
break;
|
|
147
128
|
}
|
|
148
129
|
case CLOSE: {
|
|
@@ -151,102 +132,68 @@ public:
|
|
|
151
132
|
}
|
|
152
133
|
default: {
|
|
153
134
|
RNSkLogger::logToConsole("Found an unknown command");
|
|
154
|
-
return
|
|
135
|
+
return nullptr;
|
|
155
136
|
}
|
|
156
137
|
}
|
|
157
138
|
}
|
|
158
|
-
return
|
|
159
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
|
|
139
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
160
140
|
}
|
|
161
141
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
auto x = arguments[1].asNumber();
|
|
165
|
-
auto y = arguments[2].asNumber();
|
|
166
|
-
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) {
|
|
167
144
|
SkPath path;
|
|
168
145
|
SkTextUtils::GetPath(text.c_str(), strlen(text.c_str()),
|
|
169
146
|
SkTextEncoding::kUTF8, x, y, *font, &path);
|
|
170
|
-
return
|
|
171
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
|
|
147
|
+
return std::make_shared<JsiSkPath>(getContext(), std::move(path));
|
|
172
148
|
}
|
|
173
149
|
|
|
174
150
|
// Static shape factories
|
|
175
|
-
|
|
176
|
-
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
177
|
-
auto direction = SkPathDirection::kCW;
|
|
178
|
-
if (count >= 2 && arguments[1].getBool()) {
|
|
179
|
-
direction = SkPathDirection::kCCW;
|
|
180
|
-
}
|
|
151
|
+
std::shared_ptr<JsiSkPath> Rect(SkRect rect, JsiOptional<bool> isCCW) {
|
|
181
152
|
SkPathBuilder builder;
|
|
182
|
-
builder.addRect(
|
|
183
|
-
return
|
|
184
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
|
|
153
|
+
builder.addRect(rect, toDirection(isCCW));
|
|
154
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
185
155
|
}
|
|
186
156
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
auto direction = SkPathDirection::kCW;
|
|
190
|
-
if (count >= 2 && arguments[1].getBool()) {
|
|
191
|
-
direction = SkPathDirection::kCCW;
|
|
192
|
-
}
|
|
193
|
-
unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
|
|
157
|
+
std::shared_ptr<JsiSkPath> Oval(SkRect rect, JsiOptional<bool> isCCW,
|
|
158
|
+
JsiOptional<double> startIndex) {
|
|
194
159
|
SkPathBuilder builder;
|
|
195
|
-
builder.addOval(
|
|
196
|
-
|
|
197
|
-
|
|
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());
|
|
198
165
|
}
|
|
199
166
|
|
|
200
|
-
|
|
201
|
-
auto x = arguments[0].asNumber();
|
|
202
|
-
auto y = arguments[1].asNumber();
|
|
203
|
-
auto r = arguments[2].asNumber();
|
|
167
|
+
std::shared_ptr<JsiSkPath> Circle(double x, double y, double r) {
|
|
204
168
|
SkPathBuilder builder;
|
|
205
169
|
builder.addCircle(x, y, r);
|
|
206
|
-
return
|
|
207
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
|
|
170
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
208
171
|
}
|
|
209
172
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
auto direction = SkPathDirection::kCW;
|
|
213
|
-
if (count >= 2 && arguments[1].getBool()) {
|
|
214
|
-
direction = SkPathDirection::kCCW;
|
|
215
|
-
}
|
|
173
|
+
std::shared_ptr<JsiSkPath> RRect(std::shared_ptr<SkRRect> rrect,
|
|
174
|
+
JsiOptional<bool> isCCW) {
|
|
216
175
|
SkPathBuilder builder;
|
|
217
|
-
builder.addRRect(*rrect,
|
|
218
|
-
return
|
|
219
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
|
|
176
|
+
builder.addRRect(*rrect, toDirection(isCCW));
|
|
177
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
220
178
|
}
|
|
221
179
|
|
|
222
|
-
|
|
223
|
-
auto p1 = JsiSkPoint::fromValue(runtime, arguments[0].asObject(runtime));
|
|
224
|
-
auto p2 = JsiSkPoint::fromValue(runtime, arguments[1].asObject(runtime));
|
|
180
|
+
std::shared_ptr<JsiSkPath> Line(SkPoint p1, SkPoint p2) {
|
|
225
181
|
SkPathBuilder builder;
|
|
226
|
-
builder.moveTo(
|
|
227
|
-
builder.lineTo(
|
|
228
|
-
return
|
|
229
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
|
|
182
|
+
builder.moveTo(p1);
|
|
183
|
+
builder.lineTo(p2);
|
|
184
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
230
185
|
}
|
|
231
186
|
|
|
232
|
-
|
|
233
|
-
std::vector<SkPoint> points;
|
|
234
|
-
auto jsiPoints = arguments[0].asObject(runtime).asArray(runtime);
|
|
235
|
-
auto close = arguments[1].getBool();
|
|
236
|
-
auto pointsSize = jsiPoints.size(runtime);
|
|
237
|
-
points.reserve(pointsSize);
|
|
238
|
-
for (int i = 0; i < pointsSize; i++) {
|
|
239
|
-
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
|
240
|
-
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
|
241
|
-
points.push_back(*point.get());
|
|
242
|
-
}
|
|
187
|
+
std::shared_ptr<JsiSkPath> Polygon(std::vector<SkPoint> points, bool close) {
|
|
243
188
|
SkPathBuilder builder;
|
|
244
189
|
builder.addPolygon(SkSpan(points), close);
|
|
245
|
-
return
|
|
246
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), builder.snapshot()));
|
|
190
|
+
return std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
|
|
247
191
|
}
|
|
248
192
|
|
|
249
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).
|
|
250
197
|
JSI_HOST_FUNCTION(Stroke) {
|
|
251
198
|
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
252
199
|
SkPath path = srcPath->snapshot();
|
|
@@ -303,128 +250,115 @@ public:
|
|
|
303
250
|
return jsi::Value::null();
|
|
304
251
|
}
|
|
305
252
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
float start =
|
|
309
|
-
|
|
310
|
-
float end =
|
|
311
|
-
std::clamp(static_cast<float>(arguments[2].asNumber()), 0.0f, 1.0f);
|
|
312
|
-
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);
|
|
313
257
|
// If requesting the full path in normal mode, just return a copy
|
|
314
258
|
if (start <= 0 && end >= 1 && !isComplement) {
|
|
315
|
-
|
|
316
|
-
return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
|
|
317
|
-
getContext(), std::move(result)));
|
|
259
|
+
return std::make_shared<JsiSkPath>(getContext(), srcPath->snapshot());
|
|
318
260
|
}
|
|
319
261
|
SkPath path = srcPath->snapshot();
|
|
320
262
|
auto mode = isComplement ? SkTrimPathEffect::Mode::kInverted
|
|
321
263
|
: SkTrimPathEffect::Mode::kNormal;
|
|
322
264
|
auto pe = SkTrimPathEffect::Make(start, end, mode);
|
|
323
265
|
if (!pe) {
|
|
324
|
-
return
|
|
266
|
+
return nullptr;
|
|
325
267
|
}
|
|
326
268
|
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
327
269
|
SkPathBuilder resultBuilder;
|
|
328
270
|
if (pe->filterPath(&resultBuilder, path, &rec)) {
|
|
329
|
-
|
|
330
|
-
return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
|
|
331
|
-
getContext(), std::move(result)));
|
|
271
|
+
return std::make_shared<JsiSkPath>(getContext(), resultBuilder.detach());
|
|
332
272
|
}
|
|
333
|
-
return
|
|
273
|
+
return nullptr;
|
|
334
274
|
}
|
|
335
275
|
|
|
336
|
-
|
|
337
|
-
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
276
|
+
NullablePath Simplify(std::shared_ptr<SkPathBuilder> srcPath) {
|
|
338
277
|
auto result = ::Simplify(srcPath->snapshot());
|
|
339
278
|
if (result.has_value()) {
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result.value())));
|
|
279
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
280
|
+
std::move(result.value()));
|
|
343
281
|
}
|
|
344
|
-
return
|
|
282
|
+
return nullptr;
|
|
345
283
|
}
|
|
346
284
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
SkScalar
|
|
350
|
-
|
|
351
|
-
auto phase = arguments[3].asNumber();
|
|
352
|
-
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)};
|
|
353
289
|
auto i = SkSpan(intervals, 2);
|
|
354
290
|
auto pe = SkDashPathEffect::Make(i, phase);
|
|
355
291
|
if (!pe) {
|
|
356
|
-
return
|
|
292
|
+
return nullptr;
|
|
357
293
|
}
|
|
358
294
|
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
|
359
295
|
SkPathBuilder resultBuilder;
|
|
360
296
|
if (pe->filterPath(&resultBuilder, srcPath->snapshot(), &rec)) {
|
|
361
|
-
|
|
362
|
-
return makeJsiObject(runtime, std::make_shared<JsiSkPath>(
|
|
363
|
-
getContext(), std::move(result)));
|
|
297
|
+
return std::make_shared<JsiSkPath>(getContext(), resultBuilder.detach());
|
|
364
298
|
}
|
|
365
|
-
return
|
|
299
|
+
return nullptr;
|
|
366
300
|
}
|
|
367
301
|
|
|
368
|
-
|
|
369
|
-
auto srcPath = JsiSkPath::fromValue(runtime, arguments[0]);
|
|
302
|
+
NullablePath AsWinding(std::shared_ptr<SkPathBuilder> srcPath) {
|
|
370
303
|
auto result = ::AsWinding(srcPath->snapshot());
|
|
371
304
|
if (result.has_value()) {
|
|
372
|
-
return
|
|
373
|
-
|
|
374
|
-
std::make_shared<JsiSkPath>(getContext(), std::move(result.value())));
|
|
305
|
+
return std::make_shared<JsiSkPath>(getContext(),
|
|
306
|
+
std::move(result.value()));
|
|
375
307
|
}
|
|
376
|
-
return
|
|
308
|
+
return nullptr;
|
|
377
309
|
}
|
|
378
310
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
auto
|
|
383
|
-
auto
|
|
384
|
-
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();
|
|
385
316
|
SkPath result;
|
|
386
317
|
auto succeed = p1.interpolate(p2, weight, &result);
|
|
387
318
|
if (!succeed) {
|
|
388
|
-
return
|
|
319
|
+
return nullptr;
|
|
389
320
|
}
|
|
390
|
-
return
|
|
391
|
-
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(result)));
|
|
321
|
+
return std::make_shared<JsiSkPath>(getContext(), std::move(result));
|
|
392
322
|
}
|
|
393
323
|
|
|
394
324
|
size_t getMemoryPressure() override { return 1024; }
|
|
395
325
|
|
|
396
326
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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);
|
|
406
336
|
// Static shape factories
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
&JsiSkPathFactory::Polygon);
|
|
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);
|
|
414
343
|
// Static path operations
|
|
415
344
|
installHostMethod(runtime, prototype, "Stroke", &JsiSkPathFactory::Stroke);
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
&JsiSkPathFactory::Interpolate);
|
|
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);
|
|
424
352
|
}
|
|
425
353
|
|
|
426
354
|
explicit JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
427
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
|
+
}
|
|
428
362
|
};
|
|
429
363
|
|
|
430
364
|
} // namespace RNSkia
|