@shopify/react-native-skia 2.10.0 → 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 +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/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/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/package.json +3 -4
- 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
package/cpp/api/JsiSkPicture.h
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
+
#include <optional>
|
|
4
5
|
|
|
6
|
+
#include "JsiSkConverters.h"
|
|
5
7
|
#include "JsiSkData.h"
|
|
6
8
|
#include "JsiSkDispatcher.h"
|
|
7
9
|
#include "JsiSkMatrix.h"
|
|
@@ -56,22 +58,15 @@ public:
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
auto
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
? JsiSkRect::fromValue(runtime, arguments[4]).get()
|
|
69
|
-
: nullptr;
|
|
70
|
-
|
|
71
|
-
// Create shader
|
|
72
|
-
auto shader = getObject()->makeShader(tmx, tmy, fm, m, tr);
|
|
73
|
-
return makeJsiObject(runtime,
|
|
74
|
-
std::make_shared<JsiSkShader>(getContext(), shader));
|
|
61
|
+
std::shared_ptr<JsiSkShader>
|
|
62
|
+
makeShader(double tmx, double tmy, double fm,
|
|
63
|
+
std::optional<std::shared_ptr<SkMatrix>> m,
|
|
64
|
+
std::optional<std::shared_ptr<SkRect>> tr) {
|
|
65
|
+
auto shader = getObject()->makeShader(
|
|
66
|
+
static_cast<SkTileMode>(tmx), static_cast<SkTileMode>(tmy),
|
|
67
|
+
static_cast<SkFilterMode>(fm), m.has_value() ? m->get() : nullptr,
|
|
68
|
+
tr.has_value() ? tr->get() : nullptr);
|
|
69
|
+
return std::make_shared<JsiSkShader>(getContext(), shader);
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
JSI_HOST_FUNCTION(serialize) {
|
|
@@ -103,8 +98,7 @@ public:
|
|
|
103
98
|
|
|
104
99
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
105
100
|
installCommon(runtime, prototype);
|
|
106
|
-
|
|
107
|
-
&JsiSkPicture::makeShader);
|
|
101
|
+
installMethod(runtime, prototype, "makeShader", &JsiSkPicture::makeShader);
|
|
108
102
|
installHostMethod(runtime, prototype, "serialize",
|
|
109
103
|
&JsiSkPicture::serialize);
|
|
110
104
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
|
|
5
5
|
#include "JsiSkCanvas.h"
|
|
6
|
+
#include "JsiSkConverters.h"
|
|
6
7
|
#include "JsiSkNativeObjects.h"
|
|
7
8
|
#include "JsiSkPicture.h"
|
|
8
9
|
#include "JsiSkRect.h"
|
|
@@ -30,33 +31,31 @@ public:
|
|
|
30
31
|
SkPictureRecorder>(
|
|
31
32
|
context, std::make_shared<SkPictureRecorder>()) {}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
std::shared_ptr<JsiSkCanvas>
|
|
35
|
+
beginRecording(JsiOptional<std::shared_ptr<SkRect>> rect) {
|
|
34
36
|
SkCanvas *canvas;
|
|
35
|
-
if (
|
|
36
|
-
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
|
37
|
+
if (rect.has_value()) {
|
|
37
38
|
SkRTreeFactory factory;
|
|
38
|
-
canvas = getObject()->beginRecording(
|
|
39
|
+
canvas = getObject()->beginRecording(**rect, &factory);
|
|
39
40
|
} else {
|
|
40
41
|
SkISize size = SkISize::Make(2'000'000, 2'000'000);
|
|
41
|
-
SkRect
|
|
42
|
-
canvas = getObject()->beginRecording(
|
|
42
|
+
SkRect bounds = SkRect::Make(size);
|
|
43
|
+
canvas = getObject()->beginRecording(bounds, nullptr);
|
|
43
44
|
}
|
|
44
|
-
return
|
|
45
|
-
std::make_shared<JsiSkCanvas>(getContext(), canvas));
|
|
45
|
+
return std::make_shared<JsiSkCanvas>(getContext(), canvas);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
std::shared_ptr<JsiSkPicture> finishRecordingAsPicture() {
|
|
49
49
|
auto picture = getObject()->finishRecordingAsPicture();
|
|
50
|
-
return
|
|
51
|
-
getContext(), std::move(picture)));
|
|
50
|
+
return std::make_shared<JsiSkPicture>(getContext(), std::move(picture));
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
55
54
|
installCommon(runtime, prototype);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
installMethod(runtime, prototype, "beginRecording",
|
|
56
|
+
&JsiSkPictureRecorder::beginRecording);
|
|
57
|
+
installMethod(runtime, prototype, "finishRecordingAsPicture",
|
|
58
|
+
&JsiSkPictureRecorder::finishRecordingAsPicture);
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
size_t getMemoryPressure() override { return 1024 * 1024; }
|
package/cpp/api/JsiSkPoint.h
CHANGED
|
@@ -23,14 +23,14 @@ class JsiSkPoint
|
|
|
23
23
|
public:
|
|
24
24
|
static constexpr const char *CLASS_NAME = "Point";
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
double getX() { return static_cast<double>(getObject()->x()); }
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
double getY() { return static_cast<double>(getObject()->y()); }
|
|
29
29
|
|
|
30
30
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
31
31
|
installCommon(runtime, prototype);
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
installGetter(runtime, prototype, "x", &JsiSkPoint::getX);
|
|
33
|
+
installGetter(runtime, prototype, "y", &JsiSkPoint::getY);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
JsiSkPoint(std::shared_ptr<RNSkPlatformContext> context, const SkPoint &point)
|
package/cpp/api/JsiSkRRect.h
CHANGED
|
@@ -26,22 +26,21 @@ class JsiSkRRect
|
|
|
26
26
|
public:
|
|
27
27
|
static constexpr const char *CLASS_NAME = "RRect";
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
double getRx() {
|
|
30
30
|
return static_cast<double>(getObject()->getSimpleRadii().x());
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
double getRy() {
|
|
33
33
|
return static_cast<double>(getObject()->getSimpleRadii().y());
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
return
|
|
37
|
-
getContext(), getObject()->getBounds()));
|
|
35
|
+
std::shared_ptr<JsiSkRect> getRect() {
|
|
36
|
+
return std::make_shared<JsiSkRect>(getContext(), getObject()->getBounds());
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
41
40
|
installCommon(runtime, prototype);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
installGetter(runtime, prototype, "rx", &JsiSkRRect::getRx);
|
|
42
|
+
installGetter(runtime, prototype, "ry", &JsiSkRRect::getRy);
|
|
43
|
+
installGetter(runtime, prototype, "rect", &JsiSkRRect::getRect);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
JsiSkRRect(std::shared_ptr<RNSkPlatformContext> context, const SkRRect &rect)
|
package/cpp/api/JsiSkRSXform.h
CHANGED
|
@@ -28,38 +28,25 @@ public:
|
|
|
28
28
|
: JsiSkWrappingSharedPtrNativeObject<JsiSkRSXform, SkRSXform>(
|
|
29
29
|
std::move(context), std::make_shared<SkRSXform>(rsxform)) {}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return jsi::Value(SkScalarToDouble(getObject()->fSSin));
|
|
36
|
-
}
|
|
37
|
-
JSI_PROPERTY_GET(tx) {
|
|
38
|
-
return jsi::Value(SkScalarToDouble(getObject()->fTx));
|
|
39
|
-
}
|
|
40
|
-
JSI_PROPERTY_GET(ty) {
|
|
41
|
-
return jsi::Value(SkScalarToDouble(getObject()->fTy));
|
|
42
|
-
}
|
|
31
|
+
double getScos() { return SkScalarToDouble(getObject()->fSCos); }
|
|
32
|
+
double getSsin() { return SkScalarToDouble(getObject()->fSSin); }
|
|
33
|
+
double getTx() { return SkScalarToDouble(getObject()->fTx); }
|
|
34
|
+
double getTy() { return SkScalarToDouble(getObject()->fTy); }
|
|
43
35
|
|
|
44
36
|
#pragma clang diagnostic push
|
|
45
37
|
#pragma clang diagnostic ignored "-Woverloaded-virtual"
|
|
46
|
-
|
|
47
|
-
auto scos = arguments[0].asNumber();
|
|
48
|
-
auto ssin = arguments[1].asNumber();
|
|
49
|
-
auto tx = arguments[2].asNumber();
|
|
50
|
-
auto ty = arguments[3].asNumber();
|
|
38
|
+
void set(double scos, double ssin, double tx, double ty) {
|
|
51
39
|
getObject()->set(scos, ssin, tx, ty);
|
|
52
|
-
return jsi::Value::undefined();
|
|
53
40
|
}
|
|
54
41
|
#pragma clang diagnostic pop
|
|
55
42
|
|
|
56
43
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
57
44
|
installCommon(runtime, prototype);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
installGetter(runtime, prototype, "scos", &JsiSkRSXform::getScos);
|
|
46
|
+
installGetter(runtime, prototype, "ssin", &JsiSkRSXform::getSsin);
|
|
47
|
+
installGetter(runtime, prototype, "tx", &JsiSkRSXform::getTx);
|
|
48
|
+
installGetter(runtime, prototype, "ty", &JsiSkRSXform::getTy);
|
|
49
|
+
installMethod(runtime, prototype, "set", &JsiSkRSXform::set);
|
|
63
50
|
}
|
|
64
51
|
|
|
65
52
|
/**
|
package/cpp/api/JsiSkRect.h
CHANGED
|
@@ -22,43 +22,35 @@ class JsiSkRect : public JsiSkWrappingSharedPtrNativeObject<JsiSkRect, SkRect> {
|
|
|
22
22
|
public:
|
|
23
23
|
static constexpr const char *CLASS_NAME = "Rect";
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
JSI_HOST_FUNCTION(setXYWH) {
|
|
39
|
-
getObject()->setXYWH(arguments[0].asNumber(), arguments[1].asNumber(),
|
|
40
|
-
arguments[2].asNumber(), arguments[3].asNumber());
|
|
41
|
-
return jsi::Value::undefined();
|
|
25
|
+
double getX() { return static_cast<double>(getObject()->x()); }
|
|
26
|
+
double getY() { return static_cast<double>(getObject()->y()); }
|
|
27
|
+
double getWidth() { return static_cast<double>(getObject()->width()); }
|
|
28
|
+
double getHeight() { return static_cast<double>(getObject()->height()); }
|
|
29
|
+
double getLeft() { return static_cast<double>(getObject()->left()); }
|
|
30
|
+
double getTop() { return static_cast<double>(getObject()->top()); }
|
|
31
|
+
double getRight() { return static_cast<double>(getObject()->right()); }
|
|
32
|
+
double getBottom() { return static_cast<double>(getObject()->bottom()); }
|
|
33
|
+
|
|
34
|
+
void setXYWH(double x, double y, double width, double height) {
|
|
35
|
+
getObject()->setXYWH(x, y, width, height);
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
getObject()->setLTRB(
|
|
46
|
-
arguments[2].asNumber(), arguments[3].asNumber());
|
|
47
|
-
return jsi::Value::undefined();
|
|
38
|
+
void setLTRB(double left, double top, double right, double bottom) {
|
|
39
|
+
getObject()->setLTRB(left, top, right, bottom);
|
|
48
40
|
}
|
|
49
41
|
|
|
50
42
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
51
43
|
installCommon(runtime, prototype);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
installGetter(runtime, prototype, "x", &JsiSkRect::getX);
|
|
45
|
+
installGetter(runtime, prototype, "y", &JsiSkRect::getY);
|
|
46
|
+
installGetter(runtime, prototype, "width", &JsiSkRect::getWidth);
|
|
47
|
+
installGetter(runtime, prototype, "height", &JsiSkRect::getHeight);
|
|
48
|
+
installGetter(runtime, prototype, "left", &JsiSkRect::getLeft);
|
|
49
|
+
installGetter(runtime, prototype, "top", &JsiSkRect::getTop);
|
|
50
|
+
installGetter(runtime, prototype, "right", &JsiSkRect::getRight);
|
|
51
|
+
installGetter(runtime, prototype, "bottom", &JsiSkRect::getBottom);
|
|
52
|
+
installMethod(runtime, prototype, "setXYWH", &JsiSkRect::setXYWH);
|
|
53
|
+
installMethod(runtime, prototype, "setLTRB", &JsiSkRect::setLTRB);
|
|
62
54
|
}
|
|
63
55
|
|
|
64
56
|
/**
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include <utility>
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
|
+
#include "JsiSkConverters.h"
|
|
8
9
|
#include "JsiSkMatrix.h"
|
|
9
10
|
#include "JsiSkNativeObjects.h"
|
|
10
11
|
#include "JsiSkShader.h"
|
|
@@ -36,108 +37,95 @@ struct RuntimeEffectUniform {
|
|
|
36
37
|
bool isInteger;
|
|
37
38
|
};
|
|
38
39
|
|
|
40
|
+
} // namespace RNSkia
|
|
41
|
+
|
|
42
|
+
namespace rnwgpu {
|
|
43
|
+
|
|
44
|
+
// RuntimeEffectUniform -> {columns, rows, slot, isInteger}
|
|
45
|
+
template <> struct JSIConverter<RNSkia::RuntimeEffectUniform> {
|
|
46
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
47
|
+
const RNSkia::RuntimeEffectUniform &u) {
|
|
48
|
+
jsi::Object result(runtime);
|
|
49
|
+
result.setProperty(runtime, "columns", u.columns);
|
|
50
|
+
result.setProperty(runtime, "rows", u.rows);
|
|
51
|
+
result.setProperty(runtime, "slot", u.slot);
|
|
52
|
+
result.setProperty(runtime, "isInteger", u.isInteger);
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace rnwgpu
|
|
58
|
+
|
|
59
|
+
namespace RNSkia {
|
|
60
|
+
|
|
39
61
|
class JsiSkRuntimeEffect
|
|
40
62
|
: public JsiSkWrappingSkPtrNativeObject<JsiSkRuntimeEffect,
|
|
41
63
|
SkRuntimeEffect> {
|
|
42
64
|
public:
|
|
43
65
|
static constexpr const char *CLASS_NAME = "RuntimeEffect";
|
|
44
66
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
auto
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// Create and return shader as host object
|
|
54
|
-
auto shader =
|
|
55
|
-
getObject()->makeShader(std::move(uniforms), nullptr, 0, matrix);
|
|
56
|
-
|
|
57
|
-
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
58
|
-
getContext(), std::move(shader)));
|
|
67
|
+
std::shared_ptr<JsiSkShader>
|
|
68
|
+
makeShader(std::vector<double> uniformValues,
|
|
69
|
+
JsiOptional<std::shared_ptr<SkMatrix>> matrix) {
|
|
70
|
+
auto uniforms = castUniforms(uniformValues);
|
|
71
|
+
auto shader = getObject()->makeShader(
|
|
72
|
+
std::move(uniforms), nullptr, 0,
|
|
73
|
+
matrix.has_value() ? matrix->get() : nullptr);
|
|
74
|
+
return std::make_shared<JsiSkShader>(getContext(), std::move(shader));
|
|
59
75
|
}
|
|
60
76
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
auto
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
auto shader = getJsiObject<JsiSkShader>(
|
|
71
|
-
runtime, jsiChildren.getValueAtIndex(runtime, i))
|
|
72
|
-
->getObject();
|
|
73
|
-
children.push_back(shader);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
auto matrix =
|
|
77
|
-
count >= 3 && !arguments[2].isUndefined() && !arguments[2].isNull()
|
|
78
|
-
? JsiSkMatrix::fromValue(runtime, arguments[2]).get()
|
|
79
|
-
: nullptr;
|
|
80
|
-
|
|
81
|
-
// Create and return shader as host object
|
|
82
|
-
auto shader = getObject()->makeShader(std::move(uniforms), children.data(),
|
|
83
|
-
children.size(), matrix);
|
|
84
|
-
|
|
85
|
-
return makeJsiObject(runtime, std::make_shared<JsiSkShader>(
|
|
86
|
-
getContext(), std::move(shader)));
|
|
77
|
+
std::shared_ptr<JsiSkShader>
|
|
78
|
+
makeShaderWithChildren(std::vector<double> uniformValues,
|
|
79
|
+
std::vector<sk_sp<SkShader>> children,
|
|
80
|
+
JsiOptional<std::shared_ptr<SkMatrix>> matrix) {
|
|
81
|
+
auto uniforms = castUniforms(uniformValues);
|
|
82
|
+
auto shader = getObject()->makeShader(
|
|
83
|
+
std::move(uniforms), children.data(), children.size(),
|
|
84
|
+
matrix.has_value() ? matrix->get() : nullptr);
|
|
85
|
+
return std::make_shared<JsiSkShader>(getContext(), std::move(shader));
|
|
87
86
|
}
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
int getUniformCount() {
|
|
90
89
|
return static_cast<int>(getObject()->uniforms().size());
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
|
|
92
|
+
int getUniformFloatCount() {
|
|
94
93
|
return static_cast<int>(getObject()->uniformSize() / sizeof(float));
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
auto i = static_cast<int>(arguments[0].asNumber());
|
|
96
|
+
std::string getUniformName(int i) {
|
|
99
97
|
if (i < 0 || i >= getObject()->uniforms().size()) {
|
|
100
|
-
throw
|
|
98
|
+
throw std::runtime_error("invalid uniform index");
|
|
101
99
|
}
|
|
102
100
|
auto it = getObject()->uniforms().begin() + i;
|
|
103
|
-
return
|
|
101
|
+
return std::string(it->name);
|
|
104
102
|
}
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
auto i = static_cast<int>(arguments[0].asNumber());
|
|
104
|
+
RuntimeEffectUniform getUniform(int i) {
|
|
108
105
|
if (i < 0 || i >= getObject()->uniforms().size()) {
|
|
109
|
-
throw
|
|
106
|
+
throw std::runtime_error("invalid uniform index");
|
|
110
107
|
}
|
|
111
108
|
auto it = getObject()->uniforms().begin() + i;
|
|
112
|
-
|
|
113
|
-
RuntimeEffectUniform su = fromUniform(*it);
|
|
114
|
-
result.setProperty(runtime, "columns", su.columns);
|
|
115
|
-
result.setProperty(runtime, "rows", su.rows);
|
|
116
|
-
result.setProperty(runtime, "slot", su.slot);
|
|
117
|
-
result.setProperty(runtime, "isInteger", su.isInteger);
|
|
118
|
-
return result;
|
|
109
|
+
return fromUniform(*it);
|
|
119
110
|
}
|
|
120
111
|
|
|
121
|
-
|
|
122
|
-
return jsi::String::createFromAscii(runtime, getObject()->source());
|
|
123
|
-
}
|
|
112
|
+
std::string source() { return std::string(getObject()->source()); }
|
|
124
113
|
|
|
125
114
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
126
115
|
installCommon(runtime, prototype);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
&JsiSkRuntimeEffect::source);
|
|
116
|
+
installMethod(runtime, prototype, "makeShader",
|
|
117
|
+
&JsiSkRuntimeEffect::makeShader);
|
|
118
|
+
installMethod(runtime, prototype, "makeShaderWithChildren",
|
|
119
|
+
&JsiSkRuntimeEffect::makeShaderWithChildren);
|
|
120
|
+
installMethod(runtime, prototype, "getUniformCount",
|
|
121
|
+
&JsiSkRuntimeEffect::getUniformCount);
|
|
122
|
+
installMethod(runtime, prototype, "getUniformFloatCount",
|
|
123
|
+
&JsiSkRuntimeEffect::getUniformFloatCount);
|
|
124
|
+
installMethod(runtime, prototype, "getUniformName",
|
|
125
|
+
&JsiSkRuntimeEffect::getUniformName);
|
|
126
|
+
installMethod(runtime, prototype, "getUniform",
|
|
127
|
+
&JsiSkRuntimeEffect::getUniform);
|
|
128
|
+
installMethod(runtime, prototype, "source", &JsiSkRuntimeEffect::source);
|
|
141
129
|
}
|
|
142
130
|
|
|
143
131
|
JsiSkRuntimeEffect(std::shared_ptr<RNSkPlatformContext> context,
|
|
@@ -206,17 +194,13 @@ public:
|
|
|
206
194
|
}
|
|
207
195
|
|
|
208
196
|
private:
|
|
209
|
-
sk_sp<SkData> castUniforms(
|
|
210
|
-
auto jsiUniforms = value.asObject(runtime).asArray(runtime);
|
|
211
|
-
auto jsiUniformsSize = jsiUniforms.size(runtime);
|
|
212
|
-
|
|
197
|
+
sk_sp<SkData> castUniforms(const std::vector<double> &values) {
|
|
213
198
|
// verify size of input uniforms
|
|
214
|
-
if (
|
|
215
|
-
std::
|
|
199
|
+
if (values.size() * sizeof(float) != getObject()->uniformSize()) {
|
|
200
|
+
throw std::runtime_error(
|
|
216
201
|
"Uniforms size differs from effect's uniform size. Received " +
|
|
217
|
-
std::to_string(
|
|
218
|
-
std::to_string(getObject()->uniformSize() / sizeof(float));
|
|
219
|
-
throw jsi::JSError(runtime, msg.c_str());
|
|
202
|
+
std::to_string(values.size()) + " expected " +
|
|
203
|
+
std::to_string(getObject()->uniformSize() / sizeof(float)));
|
|
220
204
|
}
|
|
221
205
|
|
|
222
206
|
auto uniforms = SkData::MakeUninitialized(getObject()->uniformSize());
|
|
@@ -228,7 +212,7 @@ private:
|
|
|
228
212
|
RuntimeEffectUniform reu = fromUniform(*it);
|
|
229
213
|
for (std::size_t j = 0; j < reu.columns * reu.rows; ++j) {
|
|
230
214
|
const std::size_t offset = reu.slot + j;
|
|
231
|
-
float fValue =
|
|
215
|
+
float fValue = static_cast<float>(values[offset]);
|
|
232
216
|
int iValue = static_cast<int>(fValue);
|
|
233
217
|
auto value = reu.isInteger ? SkBits2Float(iValue) : fValue;
|
|
234
218
|
memcpy(SkTAddOffset<void>(uniforms->writable_data(),
|
|
@@ -18,26 +18,22 @@ class JsiSkRuntimeEffectFactory
|
|
|
18
18
|
public:
|
|
19
19
|
static constexpr const char *CLASS_NAME = "RuntimeEffectFactory";
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
auto sksl = arguments[0].asString(runtime).utf8(runtime);
|
|
21
|
+
std::shared_ptr<JsiSkRuntimeEffect> Make(std::string sksl) {
|
|
23
22
|
auto result = SkRuntimeEffect::MakeForShader(SkString(sksl));
|
|
24
23
|
auto effect = result.effect;
|
|
25
24
|
auto errorText = result.errorText;
|
|
26
25
|
if (!effect) {
|
|
27
|
-
throw
|
|
28
|
-
|
|
29
|
-
.c_str());
|
|
30
|
-
return jsi::Value::null();
|
|
26
|
+
throw std::runtime_error("Error in sksl:\n" +
|
|
27
|
+
std::string(errorText.c_str()));
|
|
31
28
|
}
|
|
32
|
-
return
|
|
33
|
-
|
|
29
|
+
return std::make_shared<JsiSkRuntimeEffect>(getContext(),
|
|
30
|
+
std::move(effect));
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
size_t getMemoryPressure() override { return 1024; }
|
|
37
34
|
|
|
38
35
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
39
|
-
|
|
40
|
-
&JsiSkRuntimeEffectFactory::Make);
|
|
36
|
+
installMethod(runtime, prototype, "Make", &JsiSkRuntimeEffectFactory::Make);
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
explicit JsiSkRuntimeEffectFactory(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
+
#include <string>
|
|
4
5
|
#include <utility>
|
|
5
6
|
#include <vector>
|
|
6
7
|
|
|
@@ -35,26 +36,16 @@ public:
|
|
|
35
36
|
SkRuntimeShaderBuilder>(
|
|
36
37
|
std::move(context), std::make_shared<SkRuntimeShaderBuilder>(rt)) {}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
auto name = arguments[0].asString(runtime).utf8(runtime);
|
|
40
|
-
auto jsiValue = arguments[1].asObject(runtime).asArray(runtime);
|
|
41
|
-
auto size = jsiValue.size(runtime);
|
|
42
|
-
std::vector<SkScalar> value;
|
|
43
|
-
value.reserve(size);
|
|
44
|
-
for (int i = 0; i < size; i++) {
|
|
45
|
-
auto e = jsiValue.getValueAtIndex(runtime, i).asNumber();
|
|
46
|
-
value.push_back(e);
|
|
47
|
-
}
|
|
39
|
+
void setUniform(std::string name, std::vector<float> value) {
|
|
48
40
|
getObject()
|
|
49
41
|
->uniform(name.c_str())
|
|
50
|
-
.set(value.data(), static_cast<int>(size));
|
|
51
|
-
return jsi::Value::undefined();
|
|
42
|
+
.set(value.data(), static_cast<int>(value.size()));
|
|
52
43
|
}
|
|
53
44
|
|
|
54
45
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
55
46
|
installCommon(runtime, prototype);
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
installMethod(runtime, prototype, "setUniform",
|
|
48
|
+
&JsiSkRuntimeShaderBuilder::setUniform);
|
|
58
49
|
}
|
|
59
50
|
|
|
60
51
|
/**
|
package/cpp/api/JsiSkSVG.h
CHANGED
|
@@ -29,18 +29,18 @@ public:
|
|
|
29
29
|
|
|
30
30
|
~JsiSkSVG() = default;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
double width() {
|
|
33
33
|
return static_cast<double>(getObject()->containerSize().width());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
double height() {
|
|
37
37
|
return static_cast<double>(getObject()->containerSize().height());
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
41
41
|
installCommon(runtime, prototype);
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
installMethod(runtime, prototype, "width", &JsiSkSVG::width);
|
|
43
|
+
installMethod(runtime, prototype, "height", &JsiSkSVG::height);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|