@shopify/react-native-skia 2.10.0 → 2.10.2
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 +64 -96
- 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/EnumMapper.h +2 -2
- package/cpp/jsi/JSIConverter.h +2 -33
- package/cpp/jsi/NativeObject.h +24 -19
- package/cpp/jsi/Promise.cpp +2 -2
- package/cpp/jsi/Promise.h +2 -2
- 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/JsiSkSkottie.h
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <utility>
|
|
7
|
+
#include <variant>
|
|
8
|
+
|
|
3
9
|
#include <jsi/jsi.h>
|
|
4
10
|
|
|
5
11
|
#include "JsiSkCanvas.h"
|
|
6
12
|
#include "JsiSkColor.h"
|
|
13
|
+
#include "JsiSkConverters.h"
|
|
7
14
|
#include "JsiSkNativeObjects.h"
|
|
8
15
|
#include "JsiSkPoint.h"
|
|
9
16
|
#include "JsiSkRect.h"
|
|
@@ -153,84 +160,64 @@ public:
|
|
|
153
160
|
static constexpr const char *CLASS_NAME = "Skottie";
|
|
154
161
|
|
|
155
162
|
// #region Properties
|
|
156
|
-
|
|
163
|
+
double duration() {
|
|
157
164
|
return static_cast<double>(getObject()->_animation->duration());
|
|
158
165
|
}
|
|
159
|
-
|
|
160
|
-
return static_cast<double>(getObject()->_animation->fps());
|
|
161
|
-
}
|
|
166
|
+
double fps() { return static_cast<double>(getObject()->_animation->fps()); }
|
|
162
167
|
// #endregion
|
|
163
168
|
|
|
164
169
|
// #region Methods
|
|
165
|
-
|
|
170
|
+
void seekFrame(double frame,
|
|
171
|
+
std::optional<std::shared_ptr<SkRect>> rectParam) {
|
|
166
172
|
sksg::InvalidationController ic;
|
|
167
|
-
getObject()->_animation->seekFrame(
|
|
173
|
+
getObject()->_animation->seekFrame(frame, &ic);
|
|
168
174
|
auto bounds = ic.bounds();
|
|
169
|
-
if (
|
|
170
|
-
auto rect =
|
|
171
|
-
|
|
172
|
-
rect->setXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
|
|
173
|
-
}
|
|
175
|
+
if (rectParam.has_value() && *rectParam != nullptr) {
|
|
176
|
+
auto rect = *rectParam;
|
|
177
|
+
rect->setXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
|
|
174
178
|
}
|
|
175
|
-
return jsi::Value::undefined();
|
|
176
179
|
}
|
|
177
180
|
|
|
178
|
-
|
|
179
|
-
auto size = getObject()->_animation->size();
|
|
180
|
-
jsi::Object jsiSize(runtime);
|
|
181
|
-
jsiSize.setProperty(runtime, "width", size.width());
|
|
182
|
-
jsiSize.setProperty(runtime, "height", size.height());
|
|
183
|
-
return jsiSize;
|
|
184
|
-
}
|
|
181
|
+
SkSize size() { return getObject()->_animation->size(); }
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
getObject()->_animation->render(canvas, rect
|
|
183
|
+
void render(std::shared_ptr<JsiSkCanvas> jsiCanvas,
|
|
184
|
+
std::optional<std::shared_ptr<SkRect>> rect) {
|
|
185
|
+
auto canvas = jsiCanvas->getCanvas();
|
|
186
|
+
if (rect.has_value()) {
|
|
187
|
+
getObject()->_animation->render(canvas, rect->get());
|
|
191
188
|
} else {
|
|
192
189
|
getObject()->_animation->render(canvas);
|
|
193
190
|
}
|
|
194
|
-
|
|
195
|
-
return jsi::Value::undefined();
|
|
196
191
|
}
|
|
197
192
|
|
|
198
|
-
|
|
199
|
-
return
|
|
200
|
-
runtime, getObject()->_animation->version().c_str());
|
|
193
|
+
std::string version() {
|
|
194
|
+
return std::string(getObject()->_animation->version().c_str());
|
|
201
195
|
}
|
|
202
196
|
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
return
|
|
197
|
+
bool setColor(JsiOptional<std::string> key, JsiOptional<JsiColor> color) {
|
|
198
|
+
if (!key.has_value() || !color.has_value()) {
|
|
199
|
+
return false;
|
|
206
200
|
}
|
|
207
|
-
|
|
208
|
-
auto color = JsiSkColor::fromValue(runtime, arguments[1]);
|
|
209
|
-
return getObject()->_propManager->setColor(key, color);
|
|
201
|
+
return getObject()->_propManager->setColor(*key, *color);
|
|
210
202
|
}
|
|
211
203
|
|
|
212
|
-
|
|
213
|
-
if (
|
|
214
|
-
return
|
|
204
|
+
bool setOpacity(JsiOptional<std::string> key, JsiOptional<double> opacity) {
|
|
205
|
+
if (!key.has_value() || !opacity.has_value()) {
|
|
206
|
+
return false;
|
|
215
207
|
}
|
|
216
|
-
|
|
217
|
-
auto key = arguments[0].asString(runtime).utf8(runtime);
|
|
218
|
-
auto opacity = arguments[1].asNumber();
|
|
219
|
-
return getObject()->_propManager->setOpacity(key, opacity);
|
|
208
|
+
return getObject()->_propManager->setOpacity(*key, *opacity);
|
|
220
209
|
}
|
|
221
210
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
211
|
+
bool setText(JsiOptional<std::string> key, JsiOptional<std::string> text,
|
|
212
|
+
JsiOptional<double> size) {
|
|
213
|
+
if (!key.has_value() || !text.has_value() || !size.has_value()) {
|
|
214
|
+
return false;
|
|
225
215
|
}
|
|
226
|
-
auto key = arguments[0].asString(runtime).utf8(runtime);
|
|
227
|
-
auto text = arguments[1].asString(runtime).utf8(runtime);
|
|
228
|
-
auto size = arguments[2].asNumber();
|
|
229
216
|
// preserve all other text fields
|
|
230
|
-
auto t = getObject()->_propManager->getText(key);
|
|
231
|
-
t.fText = SkString(text);
|
|
232
|
-
t.fTextSize = size;
|
|
233
|
-
return getObject()->_propManager->setText(key, t);
|
|
217
|
+
auto t = getObject()->_propManager->getText(*key);
|
|
218
|
+
t.fText = SkString(*text);
|
|
219
|
+
t.fTextSize = *size;
|
|
220
|
+
return getObject()->_propManager->setText(*key, t);
|
|
234
221
|
}
|
|
235
222
|
|
|
236
223
|
JSI_HOST_FUNCTION(getTextProps) {
|
|
@@ -251,27 +238,24 @@ public:
|
|
|
251
238
|
return props;
|
|
252
239
|
}
|
|
253
240
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
241
|
+
bool setTransform(JsiOptional<std::string> key, JsiOptional<SkPoint> anchor,
|
|
242
|
+
JsiOptional<SkPoint> position, JsiOptional<SkPoint> scale,
|
|
243
|
+
JsiOptional<double> rotation, JsiOptional<double> skew,
|
|
244
|
+
JsiOptional<double> skewAxis) {
|
|
245
|
+
if (!key.has_value() || !anchor.has_value() || !position.has_value() ||
|
|
246
|
+
!scale.has_value() || !rotation.has_value() || !skew.has_value() ||
|
|
247
|
+
!skewAxis.has_value()) {
|
|
248
|
+
return false;
|
|
257
249
|
}
|
|
258
250
|
|
|
259
|
-
auto key = arguments[0].asString(runtime).utf8(runtime);
|
|
260
|
-
auto anchor = JsiSkPoint::fromValue(runtime, arguments[1]);
|
|
261
|
-
auto position = JsiSkPoint::fromValue(runtime, arguments[2]);
|
|
262
|
-
auto scale = JsiSkPoint::fromValue(runtime, arguments[3]);
|
|
263
|
-
auto rotation = arguments[4].asNumber();
|
|
264
|
-
auto skew = arguments[5].asNumber();
|
|
265
|
-
auto skewAxis = arguments[6].asNumber();
|
|
266
|
-
|
|
267
251
|
skottie::TransformPropertyValue transform;
|
|
268
252
|
transform.fAnchorPoint = {anchor->x(), anchor->y()};
|
|
269
253
|
transform.fPosition = {position->x(), position->y()};
|
|
270
254
|
transform.fScale = {scale->x(), scale->y()};
|
|
271
|
-
transform.fRotation = rotation;
|
|
272
|
-
transform.fSkew = skew;
|
|
273
|
-
transform.fSkewAxis = skewAxis;
|
|
274
|
-
return getObject()->_propManager->setTransform(key, transform);
|
|
255
|
+
transform.fRotation = *rotation;
|
|
256
|
+
transform.fSkew = *skew;
|
|
257
|
+
transform.fSkewAxis = *skewAxis;
|
|
258
|
+
return getObject()->_propManager->setTransform(*key, transform);
|
|
275
259
|
}
|
|
276
260
|
|
|
277
261
|
JSI_HOST_FUNCTION(getSlotInfo) {
|
|
@@ -325,52 +309,47 @@ public:
|
|
|
325
309
|
return slotInfoJS;
|
|
326
310
|
}
|
|
327
311
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
312
|
+
bool setColorSlot(JsiOptional<std::string> slotID,
|
|
313
|
+
JsiOptional<JsiColor> color) {
|
|
314
|
+
if (!slotID.has_value() || !color.has_value()) {
|
|
315
|
+
return false;
|
|
331
316
|
}
|
|
332
|
-
|
|
333
|
-
auto color = JsiSkColor::fromValue(runtime, arguments[1]);
|
|
334
|
-
return getObject()->_slotManager->setColorSlot(SkString(slotID), color);
|
|
317
|
+
return getObject()->_slotManager->setColorSlot(SkString(*slotID), *color);
|
|
335
318
|
}
|
|
336
319
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
320
|
+
bool setScalarSlot(JsiOptional<std::string> slotID,
|
|
321
|
+
JsiOptional<double> scalar) {
|
|
322
|
+
if (!slotID.has_value() || !scalar.has_value()) {
|
|
323
|
+
return false;
|
|
340
324
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
return getObject()->_slotManager->setScalarSlot(SkString(slotID), scalar);
|
|
325
|
+
return getObject()->_slotManager->setScalarSlot(SkString(*slotID),
|
|
326
|
+
*scalar);
|
|
344
327
|
}
|
|
345
328
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
329
|
+
bool setVec2Slot(JsiOptional<std::string> slotID,
|
|
330
|
+
JsiOptional<SkPoint> point) {
|
|
331
|
+
if (!slotID.has_value() || !point.has_value()) {
|
|
332
|
+
return false;
|
|
349
333
|
}
|
|
350
|
-
auto slotID = arguments[0].asString(runtime).utf8(runtime);
|
|
351
|
-
auto point = JsiSkPoint::fromValue(runtime, arguments[1]);
|
|
352
334
|
SkV2 vec2{point->x(), point->y()};
|
|
353
|
-
return getObject()->_slotManager->setVec2Slot(SkString(slotID), vec2);
|
|
335
|
+
return getObject()->_slotManager->setVec2Slot(SkString(*slotID), vec2);
|
|
354
336
|
}
|
|
355
337
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
auto key = arguments[0].asString(runtime).utf8(runtime);
|
|
338
|
+
// The text value argument is intentionally not declared: the raw binding
|
|
339
|
+
// never read it (the method is not implemented yet).
|
|
340
|
+
bool setTextSlot(JsiOptional<std::string> key) {
|
|
361
341
|
// TODO: Implement proper text slot setting
|
|
362
|
-
return
|
|
342
|
+
return false;
|
|
363
343
|
}
|
|
364
344
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
345
|
+
bool setImageSlot(JsiOptional<std::string> slotID,
|
|
346
|
+
JsiOptional<std::string> assetName) {
|
|
347
|
+
if (!slotID.has_value() || !assetName.has_value()) {
|
|
348
|
+
return false;
|
|
368
349
|
}
|
|
369
|
-
auto slotID = arguments[0].asString(runtime).utf8(runtime);
|
|
370
|
-
auto assetName = arguments[1].asString(runtime).utf8(runtime);
|
|
371
350
|
return getObject()->_slotManager->setImageSlot(
|
|
372
|
-
SkString(slotID), getObject()->_resourceProvider->loadImageAsset(
|
|
373
|
-
|
|
351
|
+
SkString(*slotID), getObject()->_resourceProvider->loadImageAsset(
|
|
352
|
+
nullptr, assetName->data(), nullptr));
|
|
374
353
|
}
|
|
375
354
|
|
|
376
355
|
JSI_HOST_FUNCTION(getColorSlot) {
|
|
@@ -384,15 +363,15 @@ public:
|
|
|
384
363
|
return jsi::Value::null();
|
|
385
364
|
}
|
|
386
365
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
366
|
+
std::variant<double, std::nullptr_t>
|
|
367
|
+
getScalarSlot(JsiOptional<std::string> slotID) {
|
|
368
|
+
if (!slotID.has_value()) {
|
|
369
|
+
return nullptr;
|
|
390
370
|
}
|
|
391
|
-
auto
|
|
392
|
-
|
|
393
|
-
return jsi::Value(v.value());
|
|
371
|
+
if (auto v = getObject()->_slotManager->getScalarSlot(SkString(*slotID))) {
|
|
372
|
+
return static_cast<double>(v.value());
|
|
394
373
|
}
|
|
395
|
-
return
|
|
374
|
+
return nullptr;
|
|
396
375
|
}
|
|
397
376
|
|
|
398
377
|
JSI_HOST_FUNCTION(getVec2Slot) {
|
|
@@ -551,29 +530,28 @@ public:
|
|
|
551
530
|
|
|
552
531
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
553
532
|
installCommon(runtime, prototype);
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
installHostMethod(runtime, prototype, "version", &JsiSkSkottie::version);
|
|
533
|
+
installMethod(runtime, prototype, "duration", &JsiSkSkottie::duration);
|
|
534
|
+
installMethod(runtime, prototype, "fps", &JsiSkSkottie::fps);
|
|
535
|
+
installMethod(runtime, prototype, "seekFrame", &JsiSkSkottie::seekFrame);
|
|
536
|
+
installMethod(runtime, prototype, "render", &JsiSkSkottie::render);
|
|
537
|
+
installMethod(runtime, prototype, "size", &JsiSkSkottie::size);
|
|
538
|
+
installMethod(runtime, prototype, "version", &JsiSkSkottie::version);
|
|
561
539
|
installHostMethod(runtime, prototype, "getSlotInfo",
|
|
562
540
|
&JsiSkSkottie::getSlotInfo);
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
541
|
+
installMethod(runtime, prototype, "setColorSlot",
|
|
542
|
+
&JsiSkSkottie::setColorSlot);
|
|
543
|
+
installMethod(runtime, prototype, "setScalarSlot",
|
|
544
|
+
&JsiSkSkottie::setScalarSlot);
|
|
545
|
+
installMethod(runtime, prototype, "setVec2Slot",
|
|
546
|
+
&JsiSkSkottie::setVec2Slot);
|
|
547
|
+
installMethod(runtime, prototype, "setTextSlot",
|
|
548
|
+
&JsiSkSkottie::setTextSlot);
|
|
549
|
+
installMethod(runtime, prototype, "setImageSlot",
|
|
550
|
+
&JsiSkSkottie::setImageSlot);
|
|
573
551
|
installHostMethod(runtime, prototype, "getColorSlot",
|
|
574
552
|
&JsiSkSkottie::getColorSlot);
|
|
575
|
-
|
|
576
|
-
|
|
553
|
+
installMethod(runtime, prototype, "getScalarSlot",
|
|
554
|
+
&JsiSkSkottie::getScalarSlot);
|
|
577
555
|
installHostMethod(runtime, prototype, "getVec2Slot",
|
|
578
556
|
&JsiSkSkottie::getVec2Slot);
|
|
579
557
|
installHostMethod(runtime, prototype, "getTextSlot",
|
|
@@ -586,8 +564,8 @@ public:
|
|
|
586
564
|
&JsiSkSkottie::getTransformProps);
|
|
587
565
|
installHostMethod(runtime, prototype, "getTextProps",
|
|
588
566
|
&JsiSkSkottie::getTextProps);
|
|
589
|
-
|
|
590
|
-
|
|
567
|
+
installMethod(runtime, prototype, "setColor", &JsiSkSkottie::setColor);
|
|
568
|
+
installMethod(runtime, prototype, "setText", &JsiSkSkottie::setText);
|
|
591
569
|
}
|
|
592
570
|
// #endregion
|
|
593
571
|
|
package/cpp/api/JsiSkSurface.h
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#include <jsi/jsi.h>
|
|
9
9
|
|
|
10
|
+
#include "JsiSkConverters.h"
|
|
10
11
|
#include "JsiSkDispatcher.h"
|
|
11
12
|
#include "JsiSkNativeObjects.h"
|
|
12
13
|
#include "JsiTextureInfo.h"
|
|
@@ -67,27 +68,25 @@ public:
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
// TODO-API: Properties?
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return static_cast<double>(getObject()->height());
|
|
73
|
-
}
|
|
71
|
+
double width() { return static_cast<double>(getObject()->width()); }
|
|
72
|
+
double height() { return static_cast<double>(getObject()->height()); }
|
|
74
73
|
|
|
75
|
-
|
|
74
|
+
std::shared_ptr<JsiSkCanvas> getCanvas() {
|
|
76
75
|
auto surface = getObject();
|
|
77
76
|
auto canvas =
|
|
78
77
|
std::make_shared<JsiSkCanvas>(getContext(), surface->getCanvas());
|
|
79
78
|
// Keep a reference to the owning surface so the canvas can read pixels back
|
|
80
79
|
// through a snapshot on Graphite (which lacks synchronous canvas readback).
|
|
81
80
|
canvas->setSurface(surface);
|
|
82
|
-
return
|
|
81
|
+
return canvas;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
|
|
84
|
+
void flush(JsiOptional<bool> syncParam) {
|
|
86
85
|
auto surface = getObject();
|
|
87
86
|
// When `sync` is true, block until the GPU has finished executing the
|
|
88
87
|
// submitted work. Required before a native consumer on a different command
|
|
89
88
|
// queue reads this surface's texture via getNativeTextureUnstable(). #3916
|
|
90
|
-
bool sync =
|
|
89
|
+
bool sync = syncParam.has_value() && *syncParam;
|
|
91
90
|
#if defined(SK_GRAPHITE)
|
|
92
91
|
// A raster surface (e.g. Skia.Surface.Make) has no Graphite recorder;
|
|
93
92
|
// only Graphite-backed surfaces need to snap and submit a recording.
|
|
@@ -102,7 +101,6 @@ public:
|
|
|
102
101
|
dContext->flushAndSubmit(sync ? GrSyncCpu::kYes : GrSyncCpu::kNo);
|
|
103
102
|
}
|
|
104
103
|
#endif
|
|
105
|
-
return jsi::Value::undefined();
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
JSI_HOST_FUNCTION(makeImageSnapshot) {
|
|
@@ -195,13 +193,12 @@ public:
|
|
|
195
193
|
|
|
196
194
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
197
195
|
installCommon(runtime, prototype);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
&JsiSkSurface::getCanvas);
|
|
196
|
+
installMethod(runtime, prototype, "width", &JsiSkSurface::width);
|
|
197
|
+
installMethod(runtime, prototype, "height", &JsiSkSurface::height);
|
|
198
|
+
installMethod(runtime, prototype, "getCanvas", &JsiSkSurface::getCanvas);
|
|
202
199
|
installHostMethod(runtime, prototype, "makeImageSnapshot",
|
|
203
200
|
&JsiSkSurface::makeImageSnapshot);
|
|
204
|
-
|
|
201
|
+
installMethod(runtime, prototype, "flush", &JsiSkSurface::flush);
|
|
205
202
|
installHostMethod(runtime, prototype, "getNativeTextureUnstable",
|
|
206
203
|
&JsiSkSurface::getNativeTextureUnstable);
|
|
207
204
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
#include <utility>
|
|
5
|
+
#include <variant>
|
|
5
6
|
|
|
6
7
|
#include <jsi/jsi.h>
|
|
7
8
|
|
|
@@ -24,16 +25,14 @@ class JsiSkSurfaceFactory : public JsiSkNativeObject<JsiSkSurfaceFactory> {
|
|
|
24
25
|
public:
|
|
25
26
|
static constexpr const char *CLASS_NAME = "SurfaceFactory";
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
auto height = static_cast<int>(arguments[1].asNumber());
|
|
28
|
+
std::variant<std::nullptr_t, std::shared_ptr<JsiSkSurface>> Make(int width,
|
|
29
|
+
int height) {
|
|
30
30
|
auto imageInfo = SkImageInfo::MakeN32Premul(width, height);
|
|
31
31
|
auto surface = SkSurfaces::Raster(imageInfo);
|
|
32
32
|
if (surface == nullptr) {
|
|
33
|
-
return
|
|
33
|
+
return nullptr;
|
|
34
34
|
}
|
|
35
|
-
return
|
|
36
|
-
getContext(), std::move(surface)));
|
|
35
|
+
return std::make_shared<JsiSkSurface>(getContext(), std::move(surface));
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
JSI_HOST_FUNCTION(MakeOffscreen) {
|
|
@@ -63,7 +62,7 @@ public:
|
|
|
63
62
|
size_t getMemoryPressure() override { return 2048; }
|
|
64
63
|
|
|
65
64
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
66
|
-
|
|
65
|
+
installMethod(runtime, prototype, "Make", &JsiSkSurfaceFactory::Make);
|
|
67
66
|
installHostMethod(runtime, prototype, "MakeOffscreen",
|
|
68
67
|
&JsiSkSurfaceFactory::MakeOffscreen);
|
|
69
68
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
+
#include <string>
|
|
4
5
|
#include <utility>
|
|
5
6
|
#include <vector>
|
|
6
7
|
|
|
7
8
|
#include <jsi/jsi.h>
|
|
8
9
|
|
|
10
|
+
#include "JsiSkConverters.h"
|
|
9
11
|
#include "JsiSkFont.h"
|
|
10
12
|
#include "JsiSkNativeObjects.h"
|
|
11
13
|
#include "JsiSkRSXform.h"
|
|
@@ -26,88 +28,63 @@ class JsiSkTextBlobFactory : public JsiSkNativeObject<JsiSkTextBlobFactory> {
|
|
|
26
28
|
public:
|
|
27
29
|
static constexpr const char *CLASS_NAME = "TextBlobFactory";
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
auto font = JsiSkFont::fromValue(runtime, arguments[1]);
|
|
31
|
+
std::shared_ptr<JsiSkTextBlob> MakeFromText(std::string str,
|
|
32
|
+
std::shared_ptr<SkFont> font) {
|
|
32
33
|
auto textBlob = SkTextBlob::MakeFromString(str.c_str(), *font);
|
|
33
|
-
return
|
|
34
|
-
getContext(), std::move(textBlob)));
|
|
34
|
+
return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
auto font = JsiSkFont::fromValue(runtime, arguments[1]);
|
|
37
|
+
std::shared_ptr<JsiSkTextBlob> MakeFromGlyphs(std::vector<int> glyphIds,
|
|
38
|
+
std::shared_ptr<SkFont> font) {
|
|
40
39
|
int bytesPerGlyph = 2;
|
|
41
40
|
std::vector<SkGlyphID> glyphs;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
|
|
41
|
+
glyphs.reserve(glyphIds.size());
|
|
42
|
+
for (auto glyph : glyphIds) {
|
|
43
|
+
glyphs.push_back(static_cast<SkGlyphID>(glyph));
|
|
46
44
|
}
|
|
47
45
|
auto textBlob =
|
|
48
46
|
SkTextBlob::MakeFromText(glyphs.data(), glyphs.size() * bytesPerGlyph,
|
|
49
47
|
*font, SkTextEncoding::kGlyphID);
|
|
50
|
-
return
|
|
51
|
-
getContext(), std::move(textBlob)));
|
|
48
|
+
return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
auto font = JsiSkFont::fromValue(runtime, arguments[2]);
|
|
58
|
-
std::vector<SkRSXform> rsxforms;
|
|
59
|
-
int rsxformsSize = static_cast<int>(jsiRsxforms.size(runtime));
|
|
60
|
-
rsxforms.reserve(rsxformsSize);
|
|
61
|
-
for (int i = 0; i < rsxformsSize; i++) {
|
|
62
|
-
auto rsxform = JsiSkRSXform::fromValue(
|
|
63
|
-
runtime, jsiRsxforms.getValueAtIndex(runtime, i));
|
|
64
|
-
rsxforms.push_back(*rsxform);
|
|
65
|
-
}
|
|
51
|
+
std::shared_ptr<JsiSkTextBlob>
|
|
52
|
+
MakeFromRSXform(std::string str, std::vector<SkRSXform> rsxforms,
|
|
53
|
+
std::shared_ptr<SkFont> font) {
|
|
66
54
|
auto x = SkSpan(rsxforms.data(), rsxforms.size());
|
|
67
55
|
auto textBlob =
|
|
68
56
|
SkTextBlob::MakeFromRSXform(str.c_str(), str.length(), x, *font);
|
|
69
|
-
return
|
|
70
|
-
getContext(), std::move(textBlob)));
|
|
57
|
+
return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
|
|
71
58
|
}
|
|
72
59
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
std::shared_ptr<JsiSkTextBlob>
|
|
61
|
+
MakeFromRSXformGlyphs(std::vector<int> glyphIds,
|
|
62
|
+
std::vector<SkRSXform> rsxforms,
|
|
63
|
+
std::shared_ptr<SkFont> font) {
|
|
77
64
|
int bytesPerGlyph = 2;
|
|
78
65
|
std::vector<SkGlyphID> glyphs;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
|
|
83
|
-
}
|
|
84
|
-
std::vector<SkRSXform> rsxforms;
|
|
85
|
-
int rsxformsSize = static_cast<int>(jsiRsxforms.size(runtime));
|
|
86
|
-
rsxforms.reserve(rsxformsSize);
|
|
87
|
-
for (int i = 0; i < rsxformsSize; i++) {
|
|
88
|
-
auto rsxform = JsiSkRSXform::fromValue(
|
|
89
|
-
runtime, jsiRsxforms.getValueAtIndex(runtime, i));
|
|
90
|
-
rsxforms.push_back(*rsxform);
|
|
66
|
+
glyphs.reserve(glyphIds.size());
|
|
67
|
+
for (auto glyph : glyphIds) {
|
|
68
|
+
glyphs.push_back(static_cast<SkGlyphID>(glyph));
|
|
91
69
|
}
|
|
92
70
|
auto x = SkSpan(rsxforms.data(), rsxforms.size());
|
|
93
71
|
auto textBlob = SkTextBlob::MakeFromRSXform(
|
|
94
72
|
glyphs.data(), glyphs.size() * bytesPerGlyph, x, *font,
|
|
95
73
|
SkTextEncoding::kGlyphID);
|
|
96
|
-
return
|
|
97
|
-
getContext(), std::move(textBlob)));
|
|
74
|
+
return std::make_shared<JsiSkTextBlob>(getContext(), std::move(textBlob));
|
|
98
75
|
}
|
|
99
76
|
|
|
100
77
|
size_t getMemoryPressure() override { return 2048; }
|
|
101
78
|
|
|
102
79
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
80
|
+
installMethod(runtime, prototype, "MakeFromText",
|
|
81
|
+
&JsiSkTextBlobFactory::MakeFromText);
|
|
82
|
+
installMethod(runtime, prototype, "MakeFromGlyphs",
|
|
83
|
+
&JsiSkTextBlobFactory::MakeFromGlyphs);
|
|
84
|
+
installMethod(runtime, prototype, "MakeFromRSXform",
|
|
85
|
+
&JsiSkTextBlobFactory::MakeFromRSXform);
|
|
86
|
+
installMethod(runtime, prototype, "MakeFromRSXformGlyphs",
|
|
87
|
+
&JsiSkTextBlobFactory::MakeFromRSXformGlyphs);
|
|
111
88
|
}
|
|
112
89
|
|
|
113
90
|
explicit JsiSkTextBlobFactory(std::shared_ptr<RNSkPlatformContext> context)
|
package/cpp/api/JsiSkTypeface.h
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
+
#include <string>
|
|
4
5
|
#include <utility>
|
|
5
6
|
#include <vector>
|
|
6
7
|
|
|
7
8
|
#include <jsi/jsi.h>
|
|
8
9
|
|
|
10
|
+
#include "JsiSkConverters.h"
|
|
9
11
|
#include "JsiSkNativeObjects.h"
|
|
10
12
|
#include "utils/RNSkLog.h"
|
|
11
13
|
|
|
@@ -32,11 +34,10 @@ public:
|
|
|
32
34
|
: JsiSkWrappingSkPtrNativeObject<JsiSkTypeface, SkTypeface>(
|
|
33
35
|
std::move(context), std::move(typeface)) {}
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
auto str = arguments[0].asString(runtime).utf8(runtime);
|
|
37
|
+
std::vector<int> getGlyphIDs(std::string str, JsiOptional<int> numGlyphs) {
|
|
37
38
|
int numGlyphIDs =
|
|
38
|
-
|
|
39
|
-
?
|
|
39
|
+
numGlyphs.has_value()
|
|
40
|
+
? *numGlyphs
|
|
40
41
|
: getObject()->textToGlyphs(str.c_str(), str.length(),
|
|
41
42
|
SkTextEncoding::kUTF8,
|
|
42
43
|
SkSpan<SkGlyphID>(nullptr, 0));
|
|
@@ -45,12 +46,7 @@ public:
|
|
|
45
46
|
getObject()->textToGlyphs(
|
|
46
47
|
str.c_str(), str.length(), SkTextEncoding::kUTF8,
|
|
47
48
|
SkSpan(static_cast<SkGlyphID *>(glyphIDs.data()), numGlyphIDs));
|
|
48
|
-
|
|
49
|
-
for (int i = 0; i < numGlyphIDs; i++) {
|
|
50
|
-
jsiGlyphIDs.setValueAtIndex(runtime, i,
|
|
51
|
-
jsi::Value(static_cast<int>(glyphIDs[i])));
|
|
52
|
-
}
|
|
53
|
-
return jsiGlyphIDs;
|
|
49
|
+
return std::vector<int>(glyphIDs.begin(), glyphIDs.end());
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
size_t getMemoryPressure() override {
|
|
@@ -85,8 +81,8 @@ public:
|
|
|
85
81
|
|
|
86
82
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
87
83
|
installCommon(runtime, prototype);
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
installMethod(runtime, prototype, "getGlyphIDs",
|
|
85
|
+
&JsiSkTypeface::getGlyphIDs);
|
|
90
86
|
}
|
|
91
87
|
};
|
|
92
88
|
|