@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
package/cpp/api/JsiSkCanvas.h
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
+
#include <string>
|
|
4
5
|
#include <utility>
|
|
5
6
|
#include <vector>
|
|
6
7
|
|
|
8
|
+
#include "JsiSkConverters.h"
|
|
7
9
|
#include "JsiSkFont.h"
|
|
8
|
-
#include "JsiSkHostObjects.h"
|
|
9
10
|
#include "JsiSkImage.h"
|
|
10
11
|
#include "JsiSkImageInfo.h"
|
|
11
12
|
#include "JsiSkMatrix.h"
|
|
13
|
+
#include "JsiSkNativeObjects.h"
|
|
12
14
|
#include "JsiSkPaint.h"
|
|
13
15
|
#include "JsiSkPath.h"
|
|
14
16
|
#include "JsiSkPicture.h"
|
|
@@ -49,31 +51,25 @@ namespace RNSkia {
|
|
|
49
51
|
|
|
50
52
|
namespace jsi = facebook::jsi;
|
|
51
53
|
|
|
52
|
-
class JsiSkCanvas : public
|
|
54
|
+
class JsiSkCanvas : public JsiSkNativeObject<JsiSkCanvas> {
|
|
53
55
|
public:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
static constexpr const char *CLASS_NAME = "Canvas";
|
|
57
|
+
|
|
58
|
+
void drawPaint(std::shared_ptr<SkPaint> paint) {
|
|
56
59
|
_canvas->drawPaint(*paint);
|
|
57
|
-
return jsi::Value::undefined();
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
SkScalar y1 = arguments[1].asNumber();
|
|
63
|
-
SkScalar x2 = arguments[2].asNumber();
|
|
64
|
-
SkScalar y2 = arguments[3].asNumber();
|
|
65
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[4]);
|
|
62
|
+
void drawLine(double x1, double y1, double x2, double y2,
|
|
63
|
+
std::shared_ptr<SkPaint> paint) {
|
|
66
64
|
_canvas->drawLine(x1, y1, x2, y2, *paint);
|
|
67
|
-
return jsi::Value::undefined();
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
72
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
|
|
67
|
+
void drawRect(std::shared_ptr<SkRect> rect, std::shared_ptr<SkPaint> paint) {
|
|
73
68
|
_canvas->drawRect(*rect, *paint);
|
|
74
|
-
return jsi::Value::undefined();
|
|
75
69
|
}
|
|
76
70
|
|
|
71
|
+
// The drawImage* variants stay raw: they dispatch on exact argument counts
|
|
72
|
+
// (count == 4 / count == 6) with null-tolerant trailing paints.
|
|
77
73
|
JSI_HOST_FUNCTION(drawImage) {
|
|
78
74
|
auto image = JsiSkImage::fromValue(runtime, arguments[0]);
|
|
79
75
|
auto x = arguments[1].asNumber();
|
|
@@ -183,108 +179,55 @@ public:
|
|
|
183
179
|
return jsi::Value::undefined();
|
|
184
180
|
}
|
|
185
181
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
SkScalar cy = arguments[1].asNumber();
|
|
189
|
-
SkScalar radius = arguments[2].asNumber();
|
|
190
|
-
|
|
191
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[3]);
|
|
182
|
+
void drawCircle(double cx, double cy, double radius,
|
|
183
|
+
std::shared_ptr<SkPaint> paint) {
|
|
192
184
|
_canvas->drawCircle(cx, cy, radius, *paint);
|
|
193
|
-
|
|
194
|
-
return jsi::Value::undefined();
|
|
195
185
|
}
|
|
196
186
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
SkScalar startAngle = arguments[1].asNumber();
|
|
201
|
-
SkScalar sweepAngle = arguments[2].asNumber();
|
|
202
|
-
bool useCenter = arguments[3].getBool();
|
|
203
|
-
|
|
204
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[4]);
|
|
187
|
+
void drawArc(std::shared_ptr<SkRect> oval, double startAngle,
|
|
188
|
+
double sweepAngle, bool useCenter,
|
|
189
|
+
std::shared_ptr<SkPaint> paint) {
|
|
205
190
|
_canvas->drawArc(*oval, startAngle, sweepAngle, useCenter, *paint);
|
|
206
|
-
|
|
207
|
-
return jsi::Value::undefined();
|
|
208
191
|
}
|
|
209
192
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
|
|
213
|
-
|
|
193
|
+
void drawRRect(std::shared_ptr<SkRRect> rect,
|
|
194
|
+
std::shared_ptr<SkPaint> paint) {
|
|
214
195
|
_canvas->drawRRect(*rect, *paint);
|
|
215
|
-
|
|
216
|
-
return jsi::Value::undefined();
|
|
217
196
|
}
|
|
218
197
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[2]);
|
|
223
|
-
|
|
198
|
+
void drawDRRect(std::shared_ptr<SkRRect> outer,
|
|
199
|
+
std::shared_ptr<SkRRect> inner,
|
|
200
|
+
std::shared_ptr<SkPaint> paint) {
|
|
224
201
|
_canvas->drawDRRect(*outer, *inner, *paint);
|
|
225
|
-
|
|
226
|
-
return jsi::Value::undefined();
|
|
227
202
|
}
|
|
228
203
|
|
|
229
|
-
|
|
230
|
-
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
231
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
|
|
232
|
-
|
|
204
|
+
void drawOval(std::shared_ptr<SkRect> rect, std::shared_ptr<SkPaint> paint) {
|
|
233
205
|
_canvas->drawOval(*rect, *paint);
|
|
234
|
-
|
|
235
|
-
return jsi::Value::undefined();
|
|
236
206
|
}
|
|
237
207
|
|
|
238
|
-
|
|
239
|
-
auto c = arguments[0].asNumber();
|
|
240
|
-
_canvas->restoreToCount(c);
|
|
241
|
-
return jsi::Value::undefined();
|
|
242
|
-
}
|
|
208
|
+
void restoreToCount(double c) { _canvas->restoreToCount(c); }
|
|
243
209
|
|
|
244
|
-
|
|
245
|
-
return static_cast<int>(_canvas->getSaveCount());
|
|
246
|
-
}
|
|
210
|
+
int getSaveCount() { return static_cast<int>(_canvas->getSaveCount()); }
|
|
247
211
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, matrix,
|
|
252
|
-
getContext());
|
|
212
|
+
std::shared_ptr<JsiSkMatrix> getTotalMatrix() {
|
|
213
|
+
return std::make_shared<JsiSkMatrix>(getContext(),
|
|
214
|
+
_canvas->getTotalMatrix());
|
|
253
215
|
}
|
|
254
216
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
std::vector<SkPoint> points;
|
|
258
|
-
|
|
259
|
-
auto jsiPoints = arguments[1].asObject(runtime).asArray(runtime);
|
|
260
|
-
auto pointsSize = jsiPoints.size(runtime);
|
|
261
|
-
|
|
217
|
+
void drawPoints(double pointMode, std::vector<SkPoint> points,
|
|
218
|
+
std::shared_ptr<SkPaint> paint) {
|
|
262
219
|
// Check if we have at least one point
|
|
263
|
-
if (
|
|
220
|
+
if (points.empty()) {
|
|
264
221
|
throw std::invalid_argument("Points array must not be empty");
|
|
265
222
|
}
|
|
266
|
-
|
|
267
|
-
points.reserve(pointsSize);
|
|
268
|
-
|
|
269
|
-
for (int i = 0; i < pointsSize; i++) {
|
|
270
|
-
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
|
271
|
-
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
|
|
272
|
-
points.push_back(*point.get());
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[2]);
|
|
276
223
|
auto p = SkSpan(points.data(), points.size());
|
|
277
|
-
_canvas->drawPoints(
|
|
278
|
-
|
|
279
|
-
return jsi::Value::undefined();
|
|
224
|
+
_canvas->drawPoints(static_cast<SkCanvas::PointMode>(pointMode), p, *paint);
|
|
280
225
|
}
|
|
281
226
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
_canvas->drawVertices(vertices, blendMode, *paint);
|
|
287
|
-
return jsi::Value::undefined();
|
|
227
|
+
void drawVertices(sk_sp<SkVertices> vertices, double blendMode,
|
|
228
|
+
std::shared_ptr<SkPaint> paint) {
|
|
229
|
+
_canvas->drawVertices(vertices, static_cast<SkBlendMode>(blendMode),
|
|
230
|
+
*paint);
|
|
288
231
|
}
|
|
289
232
|
|
|
290
233
|
JSI_HOST_FUNCTION(drawPatch) {
|
|
@@ -352,118 +295,71 @@ public:
|
|
|
352
295
|
return jsi::Value::undefined();
|
|
353
296
|
}
|
|
354
297
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[1]);
|
|
358
|
-
|
|
298
|
+
void drawPath(std::shared_ptr<SkPathBuilder> path,
|
|
299
|
+
std::shared_ptr<SkPaint> paint) {
|
|
359
300
|
_canvas->drawPath(path->snapshot(), *paint);
|
|
360
|
-
|
|
361
|
-
return jsi::Value::undefined();
|
|
362
301
|
}
|
|
363
302
|
|
|
364
|
-
|
|
365
|
-
|
|
303
|
+
void drawText(std::string textVal, double x, double y,
|
|
304
|
+
std::shared_ptr<SkPaint> paint, std::shared_ptr<SkFont> font) {
|
|
366
305
|
auto text = textVal.c_str();
|
|
367
|
-
SkScalar x = arguments[1].asNumber();
|
|
368
|
-
SkScalar y = arguments[2].asNumber();
|
|
369
|
-
|
|
370
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[3]);
|
|
371
|
-
auto font = JsiSkFont::fromValue(runtime, arguments[4]);
|
|
372
|
-
|
|
373
306
|
_canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, x, y,
|
|
374
307
|
*font, *paint);
|
|
375
|
-
|
|
376
|
-
return jsi::Value::undefined();
|
|
377
308
|
}
|
|
378
309
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
SkScalar x = arguments[1].asNumber();
|
|
382
|
-
SkScalar y = arguments[2].asNumber();
|
|
383
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[3]);
|
|
310
|
+
void drawTextBlob(sk_sp<SkTextBlob> blob, double x, double y,
|
|
311
|
+
std::shared_ptr<SkPaint> paint) {
|
|
384
312
|
_canvas->drawTextBlob(blob, x, y, *paint);
|
|
385
|
-
return jsi::Value::undefined();
|
|
386
313
|
}
|
|
387
314
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
auto x = arguments[2].asNumber();
|
|
392
|
-
auto y = arguments[3].asNumber();
|
|
393
|
-
auto font = JsiSkFont::fromValue(runtime, arguments[4]);
|
|
394
|
-
auto paint = JsiSkPaint::fromValue(runtime, arguments[5]);
|
|
315
|
+
void drawGlyphs(std::vector<int> glyphIds, std::vector<SkPoint> positions,
|
|
316
|
+
double x, double y, std::shared_ptr<SkFont> font,
|
|
317
|
+
std::shared_ptr<SkPaint> paint) {
|
|
395
318
|
SkPoint origin = SkPoint::Make(x, y);
|
|
396
319
|
|
|
397
|
-
std::vector<SkPoint> positions;
|
|
398
|
-
int pointsSize = static_cast<int>(jsiPositions.size(runtime));
|
|
399
|
-
positions.reserve(pointsSize);
|
|
400
|
-
for (int i = 0; i < pointsSize; i++) {
|
|
401
|
-
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
|
402
|
-
runtime, jsiPositions.getValueAtIndex(runtime, i).asObject(runtime));
|
|
403
|
-
positions.push_back(*point.get());
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
std::vector<SkGlyphID> glyphs;
|
|
407
|
-
int glyphsSize = static_cast<int>(jsiGlyphs.size(runtime));
|
|
408
|
-
|
|
409
320
|
// Validate that glyphs and positions arrays have the same size
|
|
410
|
-
if (
|
|
321
|
+
if (glyphIds.size() != positions.size()) {
|
|
411
322
|
throw std::invalid_argument(
|
|
412
323
|
"Glyphs and positions arrays must have the same length");
|
|
413
324
|
}
|
|
414
325
|
|
|
415
|
-
glyphs
|
|
416
|
-
|
|
417
|
-
|
|
326
|
+
std::vector<SkGlyphID> glyphs;
|
|
327
|
+
glyphs.reserve(glyphIds.size());
|
|
328
|
+
for (auto glyph : glyphIds) {
|
|
329
|
+
glyphs.push_back(static_cast<SkGlyphID>(glyph));
|
|
418
330
|
}
|
|
419
331
|
|
|
420
332
|
auto g = SkSpan(glyphs.data(), glyphs.size());
|
|
421
333
|
auto p = SkSpan(positions.data(), positions.size());
|
|
422
334
|
_canvas->drawGlyphs(g, p, origin, *font, *paint);
|
|
423
|
-
|
|
424
|
-
return jsi::Value::undefined();
|
|
425
335
|
}
|
|
426
336
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
if (
|
|
430
|
-
|
|
431
|
-
auto w = arguments[1].asNumber();
|
|
432
|
-
auto h = arguments[2].asNumber();
|
|
433
|
-
svgdom->setContainerSize(SkSize::Make(w, h));
|
|
337
|
+
void drawSvg(sk_sp<SkSVGDOM> svgdom, JsiOptional<double> w,
|
|
338
|
+
JsiOptional<double> h) {
|
|
339
|
+
if (w.has_value() && h.has_value()) {
|
|
340
|
+
svgdom->setContainerSize(SkSize::Make(*w, *h));
|
|
434
341
|
} else {
|
|
435
342
|
auto canvasSize = _canvas->getBaseLayerSize();
|
|
436
343
|
svgdom->setContainerSize(SkSize::Make(canvasSize));
|
|
437
344
|
}
|
|
438
345
|
svgdom->render(_canvas);
|
|
439
|
-
return jsi::Value::undefined();
|
|
440
346
|
}
|
|
441
347
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
_canvas->clipPath(path->snapshot(), op, doAntiAlias);
|
|
447
|
-
return jsi::Value::undefined();
|
|
348
|
+
void clipPath(std::shared_ptr<SkPathBuilder> path, double op,
|
|
349
|
+
bool doAntiAlias) {
|
|
350
|
+
_canvas->clipPath(path->snapshot(), static_cast<SkClipOp>(op),
|
|
351
|
+
doAntiAlias);
|
|
448
352
|
}
|
|
449
353
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
auto op = (SkClipOp)arguments[1].asNumber();
|
|
453
|
-
auto doAntiAlias = arguments[2].getBool();
|
|
454
|
-
_canvas->clipRect(*rect, op, doAntiAlias);
|
|
455
|
-
return jsi::Value::undefined();
|
|
354
|
+
void clipRect(std::shared_ptr<SkRect> rect, double op, bool doAntiAlias) {
|
|
355
|
+
_canvas->clipRect(*rect, static_cast<SkClipOp>(op), doAntiAlias);
|
|
456
356
|
}
|
|
457
357
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
auto op = (SkClipOp)arguments[1].asNumber();
|
|
461
|
-
auto doAntiAlias = arguments[2].getBool();
|
|
462
|
-
_canvas->clipRRect(*rrect, op, doAntiAlias);
|
|
463
|
-
return jsi::Value::undefined();
|
|
358
|
+
void clipRRect(std::shared_ptr<SkRRect> rrect, double op, bool doAntiAlias) {
|
|
359
|
+
_canvas->clipRRect(*rrect, static_cast<SkClipOp>(op), doAntiAlias);
|
|
464
360
|
}
|
|
465
361
|
|
|
466
|
-
|
|
362
|
+
int save() { return _canvas->save(); }
|
|
467
363
|
|
|
468
364
|
JSI_HOST_FUNCTION(saveLayer) {
|
|
469
365
|
SkPaint *paint = (count >= 1 && !arguments[0].isUndefined())
|
|
@@ -482,67 +378,32 @@ public:
|
|
|
482
378
|
SkCanvas::SaveLayerRec(bounds, paint, backdrop, flags)));
|
|
483
379
|
}
|
|
484
380
|
|
|
485
|
-
|
|
486
|
-
_canvas->restore();
|
|
487
|
-
return jsi::Value::undefined();
|
|
488
|
-
}
|
|
381
|
+
void restore() { _canvas->restore(); }
|
|
489
382
|
|
|
490
|
-
|
|
491
|
-
SkScalar degrees = arguments[0].asNumber();
|
|
492
|
-
SkScalar rx = arguments[1].asNumber();
|
|
493
|
-
SkScalar ry = arguments[2].asNumber();
|
|
383
|
+
void rotate(double degrees, double rx, double ry) {
|
|
494
384
|
_canvas->rotate(degrees, rx, ry);
|
|
495
|
-
return jsi::Value::undefined();
|
|
496
385
|
}
|
|
497
386
|
|
|
498
|
-
|
|
499
|
-
SkScalar dx = arguments[0].asNumber();
|
|
500
|
-
SkScalar dy = arguments[1].asNumber();
|
|
501
|
-
_canvas->translate(dx, dy);
|
|
502
|
-
return jsi::Value::undefined();
|
|
503
|
-
}
|
|
387
|
+
void translate(double dx, double dy) { _canvas->translate(dx, dy); }
|
|
504
388
|
|
|
505
|
-
|
|
506
|
-
SkScalar sx = arguments[0].asNumber();
|
|
507
|
-
SkScalar sy = arguments[1].asNumber();
|
|
508
|
-
_canvas->scale(sx, sy);
|
|
509
|
-
return jsi::Value::undefined();
|
|
510
|
-
}
|
|
389
|
+
void scale(double sx, double sy) { _canvas->scale(sx, sy); }
|
|
511
390
|
|
|
512
|
-
|
|
513
|
-
SkScalar sx = arguments[0].asNumber();
|
|
514
|
-
SkScalar sy = arguments[1].asNumber();
|
|
515
|
-
_canvas->skew(sx, sy);
|
|
516
|
-
return jsi::Value::undefined();
|
|
517
|
-
}
|
|
391
|
+
void skew(double sx, double sy) { _canvas->skew(sx, sy); }
|
|
518
392
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
_canvas->drawColor(cl);
|
|
393
|
+
void drawColor(JsiColor cl, JsiOptional<double> mode) {
|
|
394
|
+
if (mode.has_value()) {
|
|
395
|
+
_canvas->drawColor(cl, static_cast<SkBlendMode>(*mode));
|
|
523
396
|
} else {
|
|
524
|
-
|
|
525
|
-
_canvas->drawColor(cl, mode);
|
|
397
|
+
_canvas->drawColor(cl);
|
|
526
398
|
}
|
|
527
|
-
return jsi::Value::undefined();
|
|
528
399
|
}
|
|
529
400
|
|
|
530
|
-
|
|
531
|
-
SkColor cl = JsiSkColor::fromValue(runtime, arguments[0]);
|
|
532
|
-
_canvas->clear(cl);
|
|
533
|
-
return jsi::Value::undefined();
|
|
534
|
-
}
|
|
401
|
+
void clear(JsiColor cl) { _canvas->clear(cl); }
|
|
535
402
|
|
|
536
|
-
|
|
537
|
-
auto matrix = JsiSkMatrix::fromValue(runtime, arguments[0]);
|
|
538
|
-
_canvas->concat(*matrix.get());
|
|
539
|
-
return jsi::Value::undefined();
|
|
540
|
-
}
|
|
403
|
+
void concat(std::shared_ptr<SkMatrix> matrix) { _canvas->concat(*matrix); }
|
|
541
404
|
|
|
542
|
-
|
|
543
|
-
auto picture = JsiSkPicture::fromValue(runtime, arguments[0]);
|
|
405
|
+
void drawPicture(sk_sp<SkPicture> picture) {
|
|
544
406
|
_canvas->drawPicture(picture);
|
|
545
|
-
return jsi::Value::undefined();
|
|
546
407
|
}
|
|
547
408
|
|
|
548
409
|
JSI_HOST_FUNCTION(drawAtlas) {
|
|
@@ -651,9 +512,10 @@ public:
|
|
|
651
512
|
#if defined(SK_GRAPHITE)
|
|
652
513
|
// Graphite records draws lazily and offers no synchronous GPU readback. If
|
|
653
514
|
// this canvas belongs to a surface, snap & submit its recording, snapshot
|
|
654
|
-
// it to a CPU raster image and read from that (mirroring
|
|
655
|
-
// A canvas without an owning surface (e.g. a
|
|
656
|
-
// no texture to read back, so fall through to
|
|
515
|
+
// it to a CPU raster image and read from that (mirroring
|
|
516
|
+
// makeImageSnapshot). A canvas without an owning surface (e.g. a
|
|
517
|
+
// picture-recording canvas) has no texture to read back, so fall through to
|
|
518
|
+
// the raster canvas read below.
|
|
657
519
|
if (_surface) {
|
|
658
520
|
// Snapshot first: makeImageSnapshot records a copy task into the recorder
|
|
659
521
|
// that must be submitted before the texture can be read back (this is the
|
|
@@ -663,8 +525,8 @@ public:
|
|
|
663
525
|
DawnContext::getInstance().submitRecording(recorder->snap().get());
|
|
664
526
|
}
|
|
665
527
|
auto raster = DawnContext::getInstance().MakeRasterImage(snapshot);
|
|
666
|
-
if (!raster ||
|
|
667
|
-
|
|
528
|
+
if (!raster || !raster->readPixels(nullptr, *info, bfrPtr, bytesPerRow,
|
|
529
|
+
srcX, srcY)) {
|
|
668
530
|
return jsi::Value::null();
|
|
669
531
|
}
|
|
670
532
|
return dest;
|
|
@@ -677,55 +539,68 @@ public:
|
|
|
677
539
|
return dest;
|
|
678
540
|
}
|
|
679
541
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
542
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
543
|
+
installMethod(runtime, prototype, "drawPaint", &JsiSkCanvas::drawPaint);
|
|
544
|
+
installMethod(runtime, prototype, "drawLine", &JsiSkCanvas::drawLine);
|
|
545
|
+
installMethod(runtime, prototype, "drawRect", &JsiSkCanvas::drawRect);
|
|
546
|
+
installHostMethod(runtime, prototype, "drawImage", &JsiSkCanvas::drawImage);
|
|
547
|
+
installHostMethod(runtime, prototype, "drawImageRect",
|
|
548
|
+
&JsiSkCanvas::drawImageRect);
|
|
549
|
+
installHostMethod(runtime, prototype, "drawImageCubic",
|
|
550
|
+
&JsiSkCanvas::drawImageCubic);
|
|
551
|
+
installHostMethod(runtime, prototype, "drawImageOptions",
|
|
552
|
+
&JsiSkCanvas::drawImageOptions);
|
|
553
|
+
installHostMethod(runtime, prototype, "drawImageNine",
|
|
554
|
+
&JsiSkCanvas::drawImageNine);
|
|
555
|
+
installHostMethod(runtime, prototype, "drawImageRectCubic",
|
|
556
|
+
&JsiSkCanvas::drawImageRectCubic);
|
|
557
|
+
installHostMethod(runtime, prototype, "drawImageRectOptions",
|
|
558
|
+
&JsiSkCanvas::drawImageRectOptions);
|
|
559
|
+
installMethod(runtime, prototype, "drawCircle", &JsiSkCanvas::drawCircle);
|
|
560
|
+
installMethod(runtime, prototype, "drawArc", &JsiSkCanvas::drawArc);
|
|
561
|
+
installMethod(runtime, prototype, "drawRRect", &JsiSkCanvas::drawRRect);
|
|
562
|
+
installMethod(runtime, prototype, "drawDRRect", &JsiSkCanvas::drawDRRect);
|
|
563
|
+
installMethod(runtime, prototype, "drawOval", &JsiSkCanvas::drawOval);
|
|
564
|
+
installMethod(runtime, prototype, "restoreToCount",
|
|
565
|
+
&JsiSkCanvas::restoreToCount);
|
|
566
|
+
installMethod(runtime, prototype, "getSaveCount",
|
|
567
|
+
&JsiSkCanvas::getSaveCount);
|
|
568
|
+
installMethod(runtime, prototype, "getTotalMatrix",
|
|
569
|
+
&JsiSkCanvas::getTotalMatrix);
|
|
570
|
+
installMethod(runtime, prototype, "drawPoints", &JsiSkCanvas::drawPoints);
|
|
571
|
+
installHostMethod(runtime, prototype, "drawPatch", &JsiSkCanvas::drawPatch);
|
|
572
|
+
installMethod(runtime, prototype, "drawPath", &JsiSkCanvas::drawPath);
|
|
573
|
+
installMethod(runtime, prototype, "drawVertices",
|
|
574
|
+
&JsiSkCanvas::drawVertices);
|
|
575
|
+
installMethod(runtime, prototype, "drawText", &JsiSkCanvas::drawText);
|
|
576
|
+
installMethod(runtime, prototype, "drawTextBlob",
|
|
577
|
+
&JsiSkCanvas::drawTextBlob);
|
|
578
|
+
installMethod(runtime, prototype, "drawGlyphs", &JsiSkCanvas::drawGlyphs);
|
|
579
|
+
installMethod(runtime, prototype, "drawSvg", &JsiSkCanvas::drawSvg);
|
|
580
|
+
installMethod(runtime, prototype, "clipPath", &JsiSkCanvas::clipPath);
|
|
581
|
+
installMethod(runtime, prototype, "clipRect", &JsiSkCanvas::clipRect);
|
|
582
|
+
installMethod(runtime, prototype, "clipRRect", &JsiSkCanvas::clipRRect);
|
|
583
|
+
installMethod(runtime, prototype, "save", &JsiSkCanvas::save);
|
|
584
|
+
installHostMethod(runtime, prototype, "saveLayer", &JsiSkCanvas::saveLayer);
|
|
585
|
+
installMethod(runtime, prototype, "restore", &JsiSkCanvas::restore);
|
|
586
|
+
installMethod(runtime, prototype, "rotate", &JsiSkCanvas::rotate);
|
|
587
|
+
installMethod(runtime, prototype, "translate", &JsiSkCanvas::translate);
|
|
588
|
+
installMethod(runtime, prototype, "scale", &JsiSkCanvas::scale);
|
|
589
|
+
installMethod(runtime, prototype, "skew", &JsiSkCanvas::skew);
|
|
590
|
+
installMethod(runtime, prototype, "drawColor", &JsiSkCanvas::drawColor);
|
|
591
|
+
installMethod(runtime, prototype, "clear", &JsiSkCanvas::clear);
|
|
592
|
+
installMethod(runtime, prototype, "concat", &JsiSkCanvas::concat);
|
|
593
|
+
installMethod(runtime, prototype, "drawPicture",
|
|
594
|
+
&JsiSkCanvas::drawPicture);
|
|
595
|
+
installHostMethod(runtime, prototype, "drawAtlas", &JsiSkCanvas::drawAtlas);
|
|
596
|
+
installHostMethod(runtime, prototype, "readPixels",
|
|
597
|
+
&JsiSkCanvas::readPixels);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
size_t getMemoryPressure() override { return 1024; }
|
|
726
601
|
|
|
727
602
|
explicit JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context)
|
|
728
|
-
:
|
|
603
|
+
: JsiSkNativeObject<JsiSkCanvas>(std::move(context)) {}
|
|
729
604
|
|
|
730
605
|
JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context, SkCanvas *canvas)
|
|
731
606
|
: JsiSkCanvas(std::move(context)) {
|
package/cpp/api/JsiSkColor.h
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#include <jsi/jsi.h>
|
|
8
8
|
|
|
9
|
-
#include "
|
|
9
|
+
#include "JsiSkNativeObjects.h"
|
|
10
10
|
#include "api/third_party/CSSColorParser.h"
|
|
11
11
|
|
|
12
12
|
#pragma clang diagnostic push
|
|
@@ -20,11 +20,13 @@ namespace RNSkia {
|
|
|
20
20
|
|
|
21
21
|
namespace jsi = facebook::jsi;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* JsiSkColor is a pure utility class — colors are represented as
|
|
25
|
+
* Float32Arrays on the JS side, so there is no wrapper object.
|
|
26
|
+
*/
|
|
27
|
+
class JsiSkColor {
|
|
24
28
|
public:
|
|
25
|
-
JsiSkColor()
|
|
26
|
-
|
|
27
|
-
~JsiSkColor() override = default;
|
|
29
|
+
JsiSkColor() = default;
|
|
28
30
|
|
|
29
31
|
static jsi::Object toValue(jsi::Runtime &runtime, SkColor color) {
|
|
30
32
|
auto result = runtime.global()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include "
|
|
3
|
+
#include "JsiSkNativeObjects.h"
|
|
4
4
|
#include <jsi/jsi.h>
|
|
5
5
|
#include <memory>
|
|
6
6
|
#include <utility>
|
|
@@ -16,19 +16,26 @@ namespace RNSkia {
|
|
|
16
16
|
|
|
17
17
|
namespace jsi = facebook::jsi;
|
|
18
18
|
|
|
19
|
-
class JsiSkColorFilter
|
|
19
|
+
class JsiSkColorFilter
|
|
20
|
+
: public JsiSkWrappingSkPtrNativeObject<JsiSkColorFilter, SkColorFilter> {
|
|
20
21
|
public:
|
|
22
|
+
static constexpr const char *CLASS_NAME = "ColorFilter";
|
|
23
|
+
|
|
21
24
|
JsiSkColorFilter(std::shared_ptr<RNSkPlatformContext> context,
|
|
22
25
|
sk_sp<SkColorFilter> colorFilter)
|
|
23
|
-
:
|
|
24
|
-
|
|
26
|
+
: JsiSkWrappingSkPtrNativeObject<JsiSkColorFilter, SkColorFilter>(
|
|
27
|
+
std::move(context), std::move(colorFilter)) {}
|
|
25
28
|
|
|
26
|
-
size_t getMemoryPressure()
|
|
29
|
+
size_t getMemoryPressure() override { return 2048; }
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
static sk_sp<SkColorFilter> fromValue(jsi::Runtime &runtime,
|
|
32
|
+
const jsi::Value &obj) {
|
|
33
|
+
return objectFromValue(runtime, obj);
|
|
34
|
+
}
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
37
|
+
installCommon(runtime, prototype);
|
|
38
|
+
}
|
|
32
39
|
};
|
|
33
40
|
|
|
34
41
|
} // namespace RNSkia
|