@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
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
+
#include <string>
|
|
4
5
|
#include <utility>
|
|
6
|
+
#include <variant>
|
|
7
|
+
#include <vector>
|
|
5
8
|
|
|
6
9
|
#include <jsi/jsi.h>
|
|
7
10
|
|
|
8
|
-
#include "
|
|
11
|
+
#include "JsiSkColor.h"
|
|
12
|
+
#include "JsiSkColorFilter.h"
|
|
13
|
+
#include "JsiSkConverters.h"
|
|
14
|
+
#include "JsiSkImage.h"
|
|
9
15
|
#include "JsiSkImageFilter.h"
|
|
16
|
+
#include "JsiSkMatrix.h"
|
|
17
|
+
#include "JsiSkNativeObjects.h"
|
|
10
18
|
#include "JsiSkPicture.h"
|
|
19
|
+
#include "JsiSkRect.h"
|
|
11
20
|
#include "JsiSkRuntimeShaderBuilder.h"
|
|
21
|
+
#include "JsiSkShader.h"
|
|
12
22
|
|
|
13
23
|
#pragma clang diagnostic push
|
|
14
24
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -22,681 +32,417 @@ namespace RNSkia {
|
|
|
22
32
|
|
|
23
33
|
namespace jsi = facebook::jsi;
|
|
24
34
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return (index < count && !arguments[index].isNull() &&
|
|
28
|
-
!arguments[index].isUndefined());
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class JsiSkImageFilterFactory : public JsiSkHostObject {
|
|
35
|
+
class JsiSkImageFilterFactory
|
|
36
|
+
: public JsiSkNativeObject<JsiSkImageFilterFactory> {
|
|
32
37
|
public:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
SkImageFilters::CropRect cropRect = {};
|
|
42
|
-
if (hasOptionalArgument(arguments, count, 4)) {
|
|
43
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[4]);
|
|
44
|
-
}
|
|
45
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
46
|
-
getContext(), SkImageFilters::Blur(sigmaX, sigmaY, (SkTileMode)tileMode,
|
|
47
|
-
imageFilter, cropRect));
|
|
48
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
49
|
-
getContext());
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
JSI_HOST_FUNCTION(MakeColorFilter) {
|
|
53
|
-
auto cf = JsiSkColorFilter::fromValue(runtime, arguments[0]);
|
|
54
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
55
|
-
if (hasOptionalArgument(arguments, count, 1)) {
|
|
56
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[1]);
|
|
57
|
-
}
|
|
58
|
-
SkImageFilters::CropRect cropRect = {};
|
|
59
|
-
if (hasOptionalArgument(arguments, count, 2)) {
|
|
60
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[2]);
|
|
61
|
-
}
|
|
62
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
38
|
+
static constexpr const char *CLASS_NAME = "ImageFilterFactory";
|
|
39
|
+
|
|
40
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
41
|
+
MakeBlur(float sigmaX, float sigmaY, int tileMode,
|
|
42
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
43
|
+
JsiOptional<SkRect> crop) {
|
|
44
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
63
45
|
getContext(),
|
|
64
|
-
SkImageFilters::
|
|
65
|
-
|
|
66
|
-
getContext());
|
|
46
|
+
SkImageFilters::Blur(sigmaX, sigmaY, static_cast<SkTileMode>(tileMode),
|
|
47
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
67
48
|
}
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[2]);
|
|
75
|
-
}
|
|
76
|
-
SkImageFilters::CropRect cropRect = {};
|
|
77
|
-
if (hasOptionalArgument(arguments, count, 3)) {
|
|
78
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[3]);
|
|
79
|
-
}
|
|
80
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
81
|
-
getContext(), SkImageFilters::Offset(x, y, std::move(input), cropRect));
|
|
82
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
83
|
-
getContext());
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
JSI_HOST_FUNCTION(MakeDisplacementMap) {
|
|
87
|
-
auto fXChannelSelector =
|
|
88
|
-
static_cast<SkColorChannel>(arguments[0].asNumber());
|
|
89
|
-
auto fYChannelSelector =
|
|
90
|
-
static_cast<SkColorChannel>(arguments[1].asNumber());
|
|
91
|
-
auto scale = arguments[2].asNumber();
|
|
92
|
-
auto in2 = JsiSkImageFilter::fromValue(runtime, arguments[3]);
|
|
93
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
94
|
-
if (hasOptionalArgument(arguments, count, 4)) {
|
|
95
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[4]);
|
|
96
|
-
}
|
|
97
|
-
SkImageFilters::CropRect cropRect = {};
|
|
98
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
99
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[5]);
|
|
100
|
-
}
|
|
101
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
102
|
-
getContext(), SkImageFilters::DisplacementMap(
|
|
103
|
-
fXChannelSelector, fYChannelSelector, scale,
|
|
104
|
-
std::move(in2), std::move(input), cropRect));
|
|
105
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
106
|
-
getContext());
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
JSI_HOST_FUNCTION(MakeShader) {
|
|
110
|
-
auto shader = JsiSkShader::fromValue(runtime, arguments[0]);
|
|
111
|
-
SkImageFilters::Dither dither = SkImageFilters::Dither::kNo;
|
|
112
|
-
if (hasOptionalArgument(arguments, count, 1)) {
|
|
113
|
-
dither = arguments[1].asBool() ? SkImageFilters::Dither::kYes
|
|
114
|
-
: SkImageFilters::Dither::kNo;
|
|
115
|
-
}
|
|
116
|
-
SkImageFilters::CropRect cropRect = {};
|
|
117
|
-
if (hasOptionalArgument(arguments, count, 2)) {
|
|
118
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[2]);
|
|
119
|
-
}
|
|
120
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
50
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
51
|
+
MakeColorFilter(sk_sp<SkColorFilter> cf,
|
|
52
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
53
|
+
JsiOptional<SkRect> crop) {
|
|
54
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
121
55
|
getContext(),
|
|
122
|
-
SkImageFilters::
|
|
123
|
-
|
|
124
|
-
getContext());
|
|
56
|
+
SkImageFilters::ColorFilter(std::move(cf), orNull(std::move(input)),
|
|
57
|
+
toCropRect(crop)));
|
|
125
58
|
}
|
|
126
59
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (hasOptionalArgument(arguments, count, 1)) {
|
|
134
|
-
inner = JsiSkImageFilter::fromValue(runtime, arguments[1]);
|
|
135
|
-
}
|
|
136
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
137
|
-
getContext(),
|
|
138
|
-
SkImageFilters::Compose(std::move(outer), std::move(inner)));
|
|
139
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
140
|
-
getContext());
|
|
60
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
61
|
+
MakeOffset(double x, double y, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
62
|
+
JsiOptional<SkRect> crop) {
|
|
63
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
64
|
+
getContext(), SkImageFilters::Offset(x, y, orNull(std::move(input)),
|
|
65
|
+
toCropRect(crop)));
|
|
141
66
|
}
|
|
142
67
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
68
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
69
|
+
MakeDisplacementMap(double xChannelSelector, double yChannelSelector,
|
|
70
|
+
double scale, sk_sp<SkImageFilter> in2,
|
|
71
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
72
|
+
JsiOptional<SkRect> crop) {
|
|
73
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
74
|
+
getContext(),
|
|
75
|
+
SkImageFilters::DisplacementMap(
|
|
76
|
+
static_cast<SkColorChannel>(xChannelSelector),
|
|
77
|
+
static_cast<SkColorChannel>(yChannelSelector), scale,
|
|
78
|
+
std::move(in2), orNull(std::move(input)), toCropRect(crop)));
|
|
79
|
+
}
|
|
148
80
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
81
|
+
std::shared_ptr<JsiSkImageFilter> MakeShader(sk_sp<SkShader> shader,
|
|
82
|
+
JsiOptional<bool> dither,
|
|
83
|
+
JsiOptional<SkRect> crop) {
|
|
84
|
+
auto ditherMode = dither.has_value() && *dither
|
|
85
|
+
? SkImageFilters::Dither::kYes
|
|
86
|
+
: SkImageFilters::Dither::kNo;
|
|
87
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
88
|
+
getContext(),
|
|
89
|
+
SkImageFilters::Shader(std::move(shader), ditherMode, toCropRect(crop)));
|
|
90
|
+
}
|
|
152
91
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
92
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
93
|
+
MakeCompose(JsiOptional<sk_sp<SkImageFilter>> outer,
|
|
94
|
+
JsiOptional<sk_sp<SkImageFilter>> inner) {
|
|
95
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
96
|
+
getContext(), SkImageFilters::Compose(orNull(std::move(outer)),
|
|
97
|
+
orNull(std::move(inner))));
|
|
98
|
+
}
|
|
157
99
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return
|
|
163
|
-
getContext());
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
JSI_HOST_FUNCTION(MakeDropShadow) {
|
|
167
|
-
auto dx = arguments[0].asNumber();
|
|
168
|
-
auto dy = arguments[1].asNumber();
|
|
169
|
-
auto sigmaX = arguments[2].asNumber();
|
|
170
|
-
auto sigmaY = arguments[3].asNumber();
|
|
171
|
-
auto color = JsiSkColor::fromValue(runtime, arguments[4]);
|
|
172
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
173
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
174
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[5]);
|
|
175
|
-
}
|
|
176
|
-
SkImageFilters::CropRect cropRect = {};
|
|
177
|
-
if (hasOptionalArgument(arguments, count, 6)) {
|
|
178
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
|
|
179
|
-
}
|
|
180
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
181
|
-
getContext(), SkImageFilters::DropShadow(dx, dy, sigmaX, sigmaY, color,
|
|
182
|
-
std::move(input), cropRect));
|
|
183
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
184
|
-
getContext());
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
JSI_HOST_FUNCTION(MakeDropShadowOnly) {
|
|
188
|
-
auto dx = arguments[0].asNumber();
|
|
189
|
-
auto dy = arguments[1].asNumber();
|
|
190
|
-
auto sigmaX = arguments[2].asNumber();
|
|
191
|
-
auto sigmaY = arguments[3].asNumber();
|
|
192
|
-
auto color = JsiSkColor::fromValue(runtime, arguments[4]);
|
|
193
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
194
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
195
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[5]);
|
|
196
|
-
}
|
|
197
|
-
SkImageFilters::CropRect cropRect = {};
|
|
198
|
-
if (hasOptionalArgument(arguments, count, 6)) {
|
|
199
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
|
|
200
|
-
}
|
|
201
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
202
|
-
getContext(),
|
|
203
|
-
SkImageFilters::DropShadowOnly(dx, dy, sigmaX, sigmaY, color,
|
|
204
|
-
std::move(input), cropRect));
|
|
205
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
206
|
-
getContext());
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
JSI_HOST_FUNCTION(MakeErode) {
|
|
210
|
-
auto rx = arguments[0].asNumber();
|
|
211
|
-
auto ry = arguments[1].asNumber();
|
|
212
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
213
|
-
if (hasOptionalArgument(arguments, count, 2)) {
|
|
214
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[2]);
|
|
215
|
-
}
|
|
216
|
-
SkImageFilters::CropRect cropRect = {};
|
|
217
|
-
if (hasOptionalArgument(arguments, count, 3)) {
|
|
218
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[3]);
|
|
219
|
-
}
|
|
220
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
100
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
101
|
+
MakeBlend(double mode, sk_sp<SkImageFilter> background,
|
|
102
|
+
JsiOptional<sk_sp<SkImageFilter>> foreground,
|
|
103
|
+
JsiOptional<SkRect> crop) {
|
|
104
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
221
105
|
getContext(),
|
|
222
|
-
SkImageFilters::
|
|
223
|
-
|
|
224
|
-
|
|
106
|
+
SkImageFilters::Blend(static_cast<SkBlendMode>(mode),
|
|
107
|
+
std::move(background),
|
|
108
|
+
orNull(std::move(foreground)), toCropRect(crop)));
|
|
225
109
|
}
|
|
226
110
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[2]);
|
|
233
|
-
}
|
|
234
|
-
SkImageFilters::CropRect cropRect = {};
|
|
235
|
-
if (hasOptionalArgument(arguments, count, 3)) {
|
|
236
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[3]);
|
|
237
|
-
}
|
|
238
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
111
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
112
|
+
MakeDropShadow(double dx, double dy, double sigmaX, double sigmaY,
|
|
113
|
+
JsiColor color, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
114
|
+
JsiOptional<SkRect> crop) {
|
|
115
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
239
116
|
getContext(),
|
|
240
|
-
SkImageFilters::
|
|
241
|
-
|
|
242
|
-
getContext());
|
|
117
|
+
SkImageFilters::DropShadow(dx, dy, sigmaX, sigmaY, color,
|
|
118
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
243
119
|
}
|
|
244
120
|
|
|
245
|
-
|
|
246
|
-
|
|
121
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
122
|
+
MakeDropShadowOnly(double dx, double dy, double sigmaX, double sigmaY,
|
|
123
|
+
JsiColor color, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
124
|
+
JsiOptional<SkRect> crop) {
|
|
125
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
126
|
+
getContext(), SkImageFilters::DropShadowOnly(
|
|
127
|
+
dx, dy, sigmaX, sigmaY, color,
|
|
128
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
129
|
+
}
|
|
247
130
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
131
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
132
|
+
MakeErode(double rx, double ry, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
133
|
+
JsiOptional<SkRect> crop) {
|
|
134
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
135
|
+
getContext(), SkImageFilters::Erode(rx, ry, orNull(std::move(input)),
|
|
136
|
+
toCropRect(crop)));
|
|
137
|
+
}
|
|
254
138
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
float k3 = arguments[2].asNumber();
|
|
270
|
-
float k4 = arguments[3].asNumber();
|
|
271
|
-
bool enforcePMColor = arguments[4].asBool();
|
|
272
|
-
sk_sp<SkImageFilter> background = nullptr;
|
|
273
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
274
|
-
background = JsiSkImageFilter::fromValue(runtime, arguments[5]);
|
|
275
|
-
}
|
|
276
|
-
sk_sp<SkImageFilter> foreground = nullptr;
|
|
277
|
-
if (hasOptionalArgument(arguments, count, 6)) {
|
|
278
|
-
foreground = JsiSkImageFilter::fromValue(runtime, arguments[6]);
|
|
279
|
-
}
|
|
280
|
-
SkImageFilters::CropRect cropRect = {};
|
|
281
|
-
if (hasOptionalArgument(arguments, count, 7)) {
|
|
282
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[7]);
|
|
283
|
-
}
|
|
284
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
285
|
-
getContext(), SkImageFilters::Arithmetic(
|
|
286
|
-
k1, k2, k3, k4, enforcePMColor, std::move(background),
|
|
287
|
-
std::move(foreground), cropRect));
|
|
288
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
289
|
-
getContext());
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
JSI_HOST_FUNCTION(MakeCrop) {
|
|
293
|
-
SkRect rect = *JsiSkRect::fromValue(runtime, arguments[0]);
|
|
294
|
-
SkTileMode tileMode = SkTileMode::kDecal;
|
|
295
|
-
if (hasOptionalArgument(arguments, count, 1)) {
|
|
296
|
-
tileMode = (SkTileMode)arguments[1].asNumber();
|
|
297
|
-
}
|
|
298
|
-
sk_sp<SkImageFilter> imageFilter = nullptr;
|
|
299
|
-
if (hasOptionalArgument(arguments, count, 2)) {
|
|
300
|
-
imageFilter = JsiSkImageFilter::fromValue(runtime, arguments[2]);
|
|
301
|
-
}
|
|
302
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
303
|
-
getContext(),
|
|
304
|
-
SkImageFilters::Crop(rect, tileMode, std::move(imageFilter)));
|
|
305
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
306
|
-
getContext());
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
JSI_HOST_FUNCTION(MakeEmpty) {
|
|
310
|
-
auto filter = std::make_shared<JsiSkImageFilter>(getContext(),
|
|
311
|
-
SkImageFilters::Empty());
|
|
312
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
313
|
-
getContext());
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
inline SkPoint3 SkPoint3FromValue(jsi::Runtime &runtime,
|
|
317
|
-
const jsi::Value &obj) {
|
|
318
|
-
const auto &object = obj.asObject(runtime);
|
|
319
|
-
auto x = object.getProperty(runtime, "x").asNumber();
|
|
320
|
-
auto y = object.getProperty(runtime, "y").asNumber();
|
|
321
|
-
auto z = object.getProperty(runtime, "z").asNumber();
|
|
322
|
-
return SkPoint3::Make(x, y, z);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
JSI_HOST_FUNCTION(MakeDistantLitDiffuse) {
|
|
326
|
-
SkPoint3 direction = SkPoint3FromValue(runtime, arguments[0]);
|
|
327
|
-
SkColor lightColor = JsiSkColor::fromValue(runtime, arguments[1]);
|
|
328
|
-
float surfaceScale = arguments[2].asNumber();
|
|
329
|
-
float kd = arguments[3].asNumber();
|
|
330
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
331
|
-
if (hasOptionalArgument(arguments, count, 4)) {
|
|
332
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[4]);
|
|
333
|
-
}
|
|
334
|
-
SkImageFilters::CropRect cropRect = {};
|
|
335
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
336
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[5]);
|
|
337
|
-
}
|
|
338
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
139
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
140
|
+
MakeDilate(double rx, double ry, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
141
|
+
JsiOptional<SkRect> crop) {
|
|
142
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
143
|
+
getContext(), SkImageFilters::Dilate(rx, ry, orNull(std::move(input)),
|
|
144
|
+
toCropRect(crop)));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
148
|
+
MakeRuntimeShader(std::shared_ptr<SkRuntimeShaderBuilder> rtb,
|
|
149
|
+
JsiOptional<std::string> childName,
|
|
150
|
+
JsiOptional<sk_sp<SkImageFilter>> input) {
|
|
151
|
+
std::string childNameStr = childName.value_or("");
|
|
152
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
339
153
|
getContext(),
|
|
340
|
-
SkImageFilters::
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
float kd = arguments[3].asNumber();
|
|
351
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
352
|
-
if (hasOptionalArgument(arguments, count, 4)) {
|
|
353
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[4]);
|
|
354
|
-
}
|
|
355
|
-
SkImageFilters::CropRect cropRect = {};
|
|
356
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
357
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[5]);
|
|
358
|
-
}
|
|
359
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
154
|
+
SkImageFilters::RuntimeShader(*rtb, childNameStr.c_str(),
|
|
155
|
+
orNull(std::move(input))));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
159
|
+
MakeArithmetic(float k1, float k2, float k3, float k4, bool enforcePMColor,
|
|
160
|
+
JsiOptional<sk_sp<SkImageFilter>> background,
|
|
161
|
+
JsiOptional<sk_sp<SkImageFilter>> foreground,
|
|
162
|
+
JsiOptional<SkRect> crop) {
|
|
163
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
360
164
|
getContext(),
|
|
361
|
-
SkImageFilters::
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
float surfaceScale = arguments[5].asNumber();
|
|
374
|
-
float kd = arguments[6].asNumber();
|
|
375
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
376
|
-
if (hasOptionalArgument(arguments, count, 7)) {
|
|
377
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[7]);
|
|
378
|
-
}
|
|
379
|
-
SkImageFilters::CropRect cropRect = {};
|
|
380
|
-
if (hasOptionalArgument(arguments, count, 8)) {
|
|
381
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[8]);
|
|
382
|
-
}
|
|
383
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
165
|
+
SkImageFilters::Arithmetic(k1, k2, k3, k4, enforcePMColor,
|
|
166
|
+
orNull(std::move(background)),
|
|
167
|
+
orNull(std::move(foreground)),
|
|
168
|
+
toCropRect(crop)));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
172
|
+
MakeCrop(SkRect rect, JsiOptional<double> tileMode,
|
|
173
|
+
JsiOptional<sk_sp<SkImageFilter>> imageFilter) {
|
|
174
|
+
auto mode = tileMode.has_value() ? static_cast<SkTileMode>(*tileMode)
|
|
175
|
+
: SkTileMode::kDecal;
|
|
176
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
384
177
|
getContext(),
|
|
385
|
-
SkImageFilters::
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
178
|
+
SkImageFilters::Crop(rect, mode, orNull(std::move(imageFilter))));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
std::shared_ptr<JsiSkImageFilter> MakeEmpty() {
|
|
182
|
+
return std::make_shared<JsiSkImageFilter>(getContext(),
|
|
183
|
+
SkImageFilters::Empty());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
187
|
+
MakeDistantLitDiffuse(SkPoint3 direction, JsiColor lightColor,
|
|
188
|
+
float surfaceScale, float kd,
|
|
189
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
190
|
+
JsiOptional<SkRect> crop) {
|
|
191
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
192
|
+
getContext(), SkImageFilters::DistantLitDiffuse(
|
|
193
|
+
direction, lightColor, surfaceScale, kd,
|
|
194
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
198
|
+
MakePointLitDiffuse(SkPoint3 location, JsiColor lightColor,
|
|
199
|
+
float surfaceScale, float kd,
|
|
200
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
201
|
+
JsiOptional<SkRect> crop) {
|
|
202
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
203
|
+
getContext(), SkImageFilters::PointLitDiffuse(
|
|
204
|
+
location, lightColor, surfaceScale, kd,
|
|
205
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
209
|
+
MakeSpotLitDiffuse(SkPoint3 location, SkPoint3 target, float falloffExponent,
|
|
210
|
+
float cutoffAngle, JsiColor lightColor, float surfaceScale,
|
|
211
|
+
float kd, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
212
|
+
JsiOptional<SkRect> crop) {
|
|
213
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
214
|
+
getContext(), SkImageFilters::SpotLitDiffuse(
|
|
215
|
+
location, target, falloffExponent, cutoffAngle,
|
|
216
|
+
lightColor, surfaceScale, kd,
|
|
217
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
221
|
+
MakeDistantLitSpecular(SkPoint3 direction, JsiColor lightColor,
|
|
222
|
+
float surfaceScale, float ks, float shininess,
|
|
223
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
224
|
+
JsiOptional<SkRect> crop) {
|
|
225
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
407
226
|
getContext(), SkImageFilters::DistantLitSpecular(
|
|
408
227
|
direction, lightColor, surfaceScale, ks, shininess,
|
|
409
|
-
std::move(input),
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
float ks = arguments[3].asNumber();
|
|
419
|
-
float shininess = arguments[4].asNumber();
|
|
420
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
421
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
422
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[5]);
|
|
423
|
-
}
|
|
424
|
-
SkImageFilters::CropRect cropRect = {};
|
|
425
|
-
if (hasOptionalArgument(arguments, count, 6)) {
|
|
426
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
|
|
427
|
-
}
|
|
428
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
228
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
232
|
+
MakePointLitSpecular(SkPoint3 location, JsiColor lightColor,
|
|
233
|
+
float surfaceScale, float ks, float shininess,
|
|
234
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
235
|
+
JsiOptional<SkRect> crop) {
|
|
236
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
429
237
|
getContext(), SkImageFilters::PointLitSpecular(
|
|
430
238
|
location, lightColor, surfaceScale, ks, shininess,
|
|
431
|
-
std::move(input),
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
SkColor lightColor = JsiSkColor::fromValue(runtime, arguments[4]);
|
|
442
|
-
float surfaceScale = arguments[5].asNumber();
|
|
443
|
-
float ks = arguments[6].asNumber();
|
|
444
|
-
float shininess = arguments[7].asNumber();
|
|
445
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
446
|
-
if (hasOptionalArgument(arguments, count, 8)) {
|
|
447
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[8]);
|
|
448
|
-
}
|
|
449
|
-
SkImageFilters::CropRect cropRect = {};
|
|
450
|
-
if (hasOptionalArgument(arguments, count, 9)) {
|
|
451
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[9]);
|
|
452
|
-
}
|
|
453
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
239
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
243
|
+
MakeSpotLitSpecular(SkPoint3 location, SkPoint3 target,
|
|
244
|
+
float falloffExponent, float cutoffAngle,
|
|
245
|
+
JsiColor lightColor, float surfaceScale, float ks,
|
|
246
|
+
float shininess, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
247
|
+
JsiOptional<SkRect> crop) {
|
|
248
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
454
249
|
getContext(),
|
|
455
|
-
SkImageFilters::SpotLitSpecular(
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
SkRect dstRect;
|
|
471
|
-
if (hasOptionalArgument(arguments, count, 2)) {
|
|
472
|
-
dstRect = *JsiSkRect::fromValue(runtime, arguments[2]);
|
|
473
|
-
} else {
|
|
474
|
-
dstRect = srcRect;
|
|
475
|
-
}
|
|
476
|
-
SkFilterMode filterMode = SkFilterMode::kNearest;
|
|
477
|
-
if (hasOptionalArgument(arguments, count, 3)) {
|
|
478
|
-
filterMode = (SkFilterMode)arguments[3].asNumber();
|
|
479
|
-
}
|
|
480
|
-
SkMipmapMode mipmap = SkMipmapMode::kNone;
|
|
481
|
-
if (hasOptionalArgument(arguments, count, 4)) {
|
|
482
|
-
mipmap = (SkMipmapMode)arguments[4].asNumber();
|
|
483
|
-
}
|
|
484
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
250
|
+
SkImageFilters::SpotLitSpecular(location, target, falloffExponent,
|
|
251
|
+
cutoffAngle, lightColor, surfaceScale,
|
|
252
|
+
ks, shininess, orNull(std::move(input)),
|
|
253
|
+
toCropRect(crop)));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
257
|
+
MakeImage(sk_sp<SkImage> image, JsiOptional<SkRect> src,
|
|
258
|
+
JsiOptional<SkRect> dst, JsiOptional<double> filterMode,
|
|
259
|
+
JsiOptional<double> mipmap) {
|
|
260
|
+
SkRect srcRect = src.has_value() ? *src : SkRect::Make(image->bounds());
|
|
261
|
+
SkRect dstRect = dst.has_value() ? *dst : srcRect;
|
|
262
|
+
auto sampling = SkSamplingOptions(toFilterMode(filterMode),
|
|
263
|
+
toMipmapMode(mipmap));
|
|
264
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
485
265
|
getContext(),
|
|
486
|
-
SkImageFilters::Image(std::move(image), srcRect, dstRect,
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
if (hasOptionalArgument(arguments, count, 3)) {
|
|
498
|
-
filterMode = (SkFilterMode)arguments[3].asNumber();
|
|
499
|
-
}
|
|
500
|
-
SkMipmapMode mipmap = SkMipmapMode::kNone;
|
|
501
|
-
if (hasOptionalArgument(arguments, count, 4)) {
|
|
502
|
-
mipmap = (SkMipmapMode)arguments[4].asNumber();
|
|
503
|
-
}
|
|
504
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
505
|
-
if (hasOptionalArgument(arguments, count, 5)) {
|
|
506
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[5]);
|
|
507
|
-
}
|
|
508
|
-
SkImageFilters::CropRect cropRect = {};
|
|
509
|
-
if (hasOptionalArgument(arguments, count, 6)) {
|
|
510
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
|
|
511
|
-
}
|
|
512
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
266
|
+
SkImageFilters::Image(std::move(image), srcRect, dstRect, sampling));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
270
|
+
MakeMagnifier(SkRect lensBounds, float zoomAmount, float inset,
|
|
271
|
+
JsiOptional<double> filterMode, JsiOptional<double> mipmap,
|
|
272
|
+
JsiOptional<sk_sp<SkImageFilter>> input,
|
|
273
|
+
JsiOptional<SkRect> crop) {
|
|
274
|
+
auto sampling = SkSamplingOptions(toFilterMode(filterMode),
|
|
275
|
+
toMipmapMode(mipmap));
|
|
276
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
513
277
|
getContext(),
|
|
514
|
-
SkImageFilters::Magnifier(lensBounds, zoomAmount, inset,
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
auto size = kernelArray.size(runtime);
|
|
527
|
-
for (size_t i = 0; i < size; i++) {
|
|
528
|
-
kernel.push_back(kernelArray.getValueAtIndex(runtime, i).asNumber());
|
|
529
|
-
}
|
|
530
|
-
auto gain = arguments[3].asNumber();
|
|
531
|
-
auto bias = arguments[4].asNumber();
|
|
532
|
-
SkIPoint kernelOffset =
|
|
533
|
-
SkIPoint::Make(arguments[5].asNumber(), arguments[6].asNumber());
|
|
534
|
-
auto tileMode = static_cast<SkTileMode>(arguments[7].asNumber());
|
|
535
|
-
bool convolveAlpha = arguments[8].asBool();
|
|
536
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
537
|
-
if (hasOptionalArgument(arguments, count, 9)) {
|
|
538
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[9]);
|
|
539
|
-
}
|
|
540
|
-
SkImageFilters::CropRect cropRect = {};
|
|
541
|
-
if (hasOptionalArgument(arguments, count, 10)) {
|
|
542
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[10]);
|
|
543
|
-
}
|
|
544
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
545
|
-
getContext(), SkImageFilters::MatrixConvolution(
|
|
546
|
-
kernelSize, kernel.data(), gain, bias, kernelOffset,
|
|
547
|
-
tileMode, convolveAlpha, std::move(input), cropRect));
|
|
548
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
549
|
-
getContext());
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
JSI_HOST_FUNCTION(MakeMatrixTransform) {
|
|
553
|
-
SkMatrix matrix = *JsiSkMatrix::fromValue(runtime, arguments[0]);
|
|
554
|
-
SkFilterMode filterMode = SkFilterMode::kNearest;
|
|
555
|
-
if (hasOptionalArgument(arguments, count, 1)) {
|
|
556
|
-
filterMode = (SkFilterMode)arguments[1].asNumber();
|
|
557
|
-
}
|
|
558
|
-
SkMipmapMode mipmap = SkMipmapMode::kNone;
|
|
559
|
-
if (hasOptionalArgument(arguments, count, 2)) {
|
|
560
|
-
mipmap = (SkMipmapMode)arguments[2].asNumber();
|
|
561
|
-
}
|
|
562
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
563
|
-
if (hasOptionalArgument(arguments, count, 3)) {
|
|
564
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[3]);
|
|
565
|
-
}
|
|
566
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
278
|
+
SkImageFilters::Magnifier(lensBounds, zoomAmount, inset, sampling,
|
|
279
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
std::shared_ptr<JsiSkImageFilter> MakeMatrixConvolution(
|
|
283
|
+
int kernelSizeX, int kernelSizeY, std::vector<float> kernel, double gain,
|
|
284
|
+
double bias, int kernelOffsetX, int kernelOffsetY, double tileMode,
|
|
285
|
+
bool convolveAlpha, JsiOptional<sk_sp<SkImageFilter>> input,
|
|
286
|
+
JsiOptional<SkRect> crop) {
|
|
287
|
+
auto kernelSize = SkISize::Make(kernelSizeX, kernelSizeY);
|
|
288
|
+
auto kernelOffset = SkIPoint::Make(kernelOffsetX, kernelOffsetY);
|
|
289
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
567
290
|
getContext(),
|
|
568
|
-
SkImageFilters::
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
291
|
+
SkImageFilters::MatrixConvolution(
|
|
292
|
+
kernelSize, kernel.data(), gain, bias, kernelOffset,
|
|
293
|
+
static_cast<SkTileMode>(tileMode), convolveAlpha,
|
|
294
|
+
orNull(std::move(input)), toCropRect(crop)));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
298
|
+
MakeMatrixTransform(SkMatrix matrix, JsiOptional<double> filterMode,
|
|
299
|
+
JsiOptional<double> mipmap,
|
|
300
|
+
JsiOptional<sk_sp<SkImageFilter>> input) {
|
|
301
|
+
auto sampling = SkSamplingOptions(toFilterMode(filterMode),
|
|
302
|
+
toMipmapMode(mipmap));
|
|
303
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
304
|
+
getContext(), SkImageFilters::MatrixTransform(
|
|
305
|
+
matrix, sampling, orNull(std::move(input))));
|
|
572
306
|
}
|
|
573
307
|
|
|
574
|
-
|
|
308
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
309
|
+
MakeMerge(std::vector<JsiOptional<sk_sp<SkImageFilter>>> jsiFilters,
|
|
310
|
+
JsiOptional<SkRect> crop) {
|
|
575
311
|
std::vector<sk_sp<SkImageFilter>> filters;
|
|
576
|
-
|
|
577
|
-
auto
|
|
578
|
-
|
|
579
|
-
auto element = filtersArray.getValueAtIndex(runtime, i);
|
|
580
|
-
if (element.isNull()) {
|
|
581
|
-
filters.push_back(nullptr);
|
|
582
|
-
} else {
|
|
583
|
-
filters.push_back(JsiSkImageFilter::fromValue(runtime, element));
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
SkImageFilters::CropRect cropRect = {};
|
|
587
|
-
if (hasOptionalArgument(arguments, count, 1)) {
|
|
588
|
-
cropRect = *JsiSkRect::fromValue(runtime, arguments[1]);
|
|
312
|
+
filters.reserve(jsiFilters.size());
|
|
313
|
+
for (auto &filter : jsiFilters) {
|
|
314
|
+
filters.push_back(orNull(std::move(filter)));
|
|
589
315
|
}
|
|
590
|
-
|
|
316
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
591
317
|
getContext(),
|
|
592
|
-
SkImageFilters::Merge(filters.data(),
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
} else {
|
|
603
|
-
targetRect = picture ? picture->cullRect() : SkRect::MakeEmpty();
|
|
604
|
-
}
|
|
605
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
318
|
+
SkImageFilters::Merge(filters.data(), filters.size(), toCropRect(crop)));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
std::shared_ptr<JsiSkImageFilter> MakePicture(sk_sp<SkPicture> picture,
|
|
322
|
+
JsiOptional<SkRect> target) {
|
|
323
|
+
SkRect targetRect = target.has_value()
|
|
324
|
+
? *target
|
|
325
|
+
: (picture ? picture->cullRect()
|
|
326
|
+
: SkRect::MakeEmpty());
|
|
327
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
606
328
|
getContext(), SkImageFilters::Picture(std::move(picture), targetRect));
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
size_t length = childNamesJS.size(runtime);
|
|
617
|
-
for (size_t i = 0; i < length; ++i) {
|
|
618
|
-
auto element = childNamesJS.getValueAtIndex(runtime, i);
|
|
619
|
-
childNames.push_back(element.asString(runtime).utf8(runtime).c_str());
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
std::variant<std::nullptr_t, std::shared_ptr<JsiSkImageFilter>>
|
|
332
|
+
MakeRuntimeShaderWithChildren(
|
|
333
|
+
std::shared_ptr<SkRuntimeShaderBuilder> rtb, float maxSampleRadius,
|
|
334
|
+
std::vector<std::string> childNames,
|
|
335
|
+
std::vector<JsiOptional<sk_sp<SkImageFilter>>> jsiInputs) {
|
|
336
|
+
if (jsiInputs.size() != childNames.size()) {
|
|
337
|
+
return nullptr;
|
|
620
338
|
}
|
|
621
339
|
std::vector<std::string_view> childNamesStringView;
|
|
622
340
|
childNamesStringView.reserve(childNames.size());
|
|
623
341
|
for (const auto &name : childNames) {
|
|
624
342
|
childNamesStringView.push_back(std::string_view(name));
|
|
625
343
|
}
|
|
626
|
-
|
|
627
344
|
std::vector<sk_sp<SkImageFilter>> inputs;
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
getContext(), SkImageFilters::
|
|
642
|
-
childNamesStringView.data(),
|
|
643
|
-
inputs.data(), length));
|
|
644
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
645
|
-
getContext());
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
JSI_HOST_FUNCTION(MakeTile) {
|
|
649
|
-
SkRect src = *JsiSkRect::fromValue(runtime, arguments[0]);
|
|
650
|
-
SkRect dst = *JsiSkRect::fromValue(runtime, arguments[1]);
|
|
651
|
-
sk_sp<SkImageFilter> input = nullptr;
|
|
652
|
-
if (hasOptionalArgument(arguments, count, 2)) {
|
|
653
|
-
input = JsiSkImageFilter::fromValue(runtime, arguments[2]);
|
|
654
|
-
}
|
|
655
|
-
auto filter = std::make_shared<JsiSkImageFilter>(
|
|
656
|
-
getContext(), SkImageFilters::Tile(src, dst, std::move(input)));
|
|
657
|
-
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
|
|
658
|
-
getContext());
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
JSI_EXPORT_FUNCTIONS(
|
|
662
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeBlur),
|
|
663
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeOffset),
|
|
664
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeColorFilter),
|
|
665
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeShader),
|
|
666
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeDisplacementMap),
|
|
667
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeCompose),
|
|
668
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeErode),
|
|
669
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeDilate),
|
|
670
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeBlend),
|
|
671
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeDropShadow),
|
|
672
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeDropShadowOnly),
|
|
673
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeRuntimeShader),
|
|
674
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeArithmetic),
|
|
675
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeCrop),
|
|
676
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeEmpty),
|
|
677
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeImage),
|
|
678
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeMagnifier),
|
|
679
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeMatrixConvolution),
|
|
680
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeMatrixTransform),
|
|
681
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeMerge),
|
|
682
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakePicture),
|
|
683
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeRuntimeShaderWithChildren),
|
|
684
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeTile),
|
|
685
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeDistantLitDiffuse),
|
|
686
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakePointLitDiffuse),
|
|
687
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeSpotLitDiffuse),
|
|
688
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeDistantLitSpecular),
|
|
689
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakePointLitSpecular),
|
|
690
|
-
JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeSpotLitSpecular))
|
|
691
|
-
|
|
692
|
-
size_t getMemoryPressure() const override { return 2048; }
|
|
693
|
-
|
|
694
|
-
std::string getObjectType() const override {
|
|
695
|
-
return "JsiSkImageFilterFactory";
|
|
345
|
+
inputs.reserve(jsiInputs.size());
|
|
346
|
+
for (auto &input : jsiInputs) {
|
|
347
|
+
inputs.push_back(orNull(std::move(input)));
|
|
348
|
+
}
|
|
349
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
350
|
+
getContext(), SkImageFilters::RuntimeShader(
|
|
351
|
+
*rtb, maxSampleRadius, childNamesStringView.data(),
|
|
352
|
+
inputs.data(), inputs.size()));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
std::shared_ptr<JsiSkImageFilter>
|
|
356
|
+
MakeTile(SkRect src, SkRect dst, JsiOptional<sk_sp<SkImageFilter>> input) {
|
|
357
|
+
return std::make_shared<JsiSkImageFilter>(
|
|
358
|
+
getContext(), SkImageFilters::Tile(src, dst, orNull(std::move(input))));
|
|
696
359
|
}
|
|
697
360
|
|
|
361
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
362
|
+
installMethod(runtime, prototype, "MakeBlur",
|
|
363
|
+
&JsiSkImageFilterFactory::MakeBlur);
|
|
364
|
+
installMethod(runtime, prototype, "MakeOffset",
|
|
365
|
+
&JsiSkImageFilterFactory::MakeOffset);
|
|
366
|
+
installMethod(runtime, prototype, "MakeColorFilter",
|
|
367
|
+
&JsiSkImageFilterFactory::MakeColorFilter);
|
|
368
|
+
installMethod(runtime, prototype, "MakeShader",
|
|
369
|
+
&JsiSkImageFilterFactory::MakeShader);
|
|
370
|
+
installMethod(runtime, prototype, "MakeDisplacementMap",
|
|
371
|
+
&JsiSkImageFilterFactory::MakeDisplacementMap);
|
|
372
|
+
installMethod(runtime, prototype, "MakeCompose",
|
|
373
|
+
&JsiSkImageFilterFactory::MakeCompose);
|
|
374
|
+
installMethod(runtime, prototype, "MakeErode",
|
|
375
|
+
&JsiSkImageFilterFactory::MakeErode);
|
|
376
|
+
installMethod(runtime, prototype, "MakeDilate",
|
|
377
|
+
&JsiSkImageFilterFactory::MakeDilate);
|
|
378
|
+
installMethod(runtime, prototype, "MakeBlend",
|
|
379
|
+
&JsiSkImageFilterFactory::MakeBlend);
|
|
380
|
+
installMethod(runtime, prototype, "MakeDropShadow",
|
|
381
|
+
&JsiSkImageFilterFactory::MakeDropShadow);
|
|
382
|
+
installMethod(runtime, prototype, "MakeDropShadowOnly",
|
|
383
|
+
&JsiSkImageFilterFactory::MakeDropShadowOnly);
|
|
384
|
+
installMethod(runtime, prototype, "MakeRuntimeShader",
|
|
385
|
+
&JsiSkImageFilterFactory::MakeRuntimeShader);
|
|
386
|
+
installMethod(runtime, prototype, "MakeArithmetic",
|
|
387
|
+
&JsiSkImageFilterFactory::MakeArithmetic);
|
|
388
|
+
installMethod(runtime, prototype, "MakeCrop",
|
|
389
|
+
&JsiSkImageFilterFactory::MakeCrop);
|
|
390
|
+
installMethod(runtime, prototype, "MakeEmpty",
|
|
391
|
+
&JsiSkImageFilterFactory::MakeEmpty);
|
|
392
|
+
installMethod(runtime, prototype, "MakeImage",
|
|
393
|
+
&JsiSkImageFilterFactory::MakeImage);
|
|
394
|
+
installMethod(runtime, prototype, "MakeMagnifier",
|
|
395
|
+
&JsiSkImageFilterFactory::MakeMagnifier);
|
|
396
|
+
installMethod(runtime, prototype, "MakeMatrixConvolution",
|
|
397
|
+
&JsiSkImageFilterFactory::MakeMatrixConvolution);
|
|
398
|
+
installMethod(runtime, prototype, "MakeMatrixTransform",
|
|
399
|
+
&JsiSkImageFilterFactory::MakeMatrixTransform);
|
|
400
|
+
installMethod(runtime, prototype, "MakeMerge",
|
|
401
|
+
&JsiSkImageFilterFactory::MakeMerge);
|
|
402
|
+
installMethod(runtime, prototype, "MakePicture",
|
|
403
|
+
&JsiSkImageFilterFactory::MakePicture);
|
|
404
|
+
installMethod(runtime, prototype, "MakeRuntimeShaderWithChildren",
|
|
405
|
+
&JsiSkImageFilterFactory::MakeRuntimeShaderWithChildren);
|
|
406
|
+
installMethod(runtime, prototype, "MakeTile",
|
|
407
|
+
&JsiSkImageFilterFactory::MakeTile);
|
|
408
|
+
installMethod(runtime, prototype, "MakeDistantLitDiffuse",
|
|
409
|
+
&JsiSkImageFilterFactory::MakeDistantLitDiffuse);
|
|
410
|
+
installMethod(runtime, prototype, "MakePointLitDiffuse",
|
|
411
|
+
&JsiSkImageFilterFactory::MakePointLitDiffuse);
|
|
412
|
+
installMethod(runtime, prototype, "MakeSpotLitDiffuse",
|
|
413
|
+
&JsiSkImageFilterFactory::MakeSpotLitDiffuse);
|
|
414
|
+
installMethod(runtime, prototype, "MakeDistantLitSpecular",
|
|
415
|
+
&JsiSkImageFilterFactory::MakeDistantLitSpecular);
|
|
416
|
+
installMethod(runtime, prototype, "MakePointLitSpecular",
|
|
417
|
+
&JsiSkImageFilterFactory::MakePointLitSpecular);
|
|
418
|
+
installMethod(runtime, prototype, "MakeSpotLitSpecular",
|
|
419
|
+
&JsiSkImageFilterFactory::MakeSpotLitSpecular);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
size_t getMemoryPressure() override { return 2048; }
|
|
423
|
+
|
|
698
424
|
explicit JsiSkImageFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
699
|
-
:
|
|
425
|
+
: JsiSkNativeObject<JsiSkImageFilterFactory>(std::move(context)) {}
|
|
426
|
+
|
|
427
|
+
private:
|
|
428
|
+
static sk_sp<SkImageFilter> orNull(JsiOptional<sk_sp<SkImageFilter>> filter) {
|
|
429
|
+
return filter.has_value() ? std::move(*filter) : nullptr;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
static SkImageFilters::CropRect toCropRect(const JsiOptional<SkRect> &rect) {
|
|
433
|
+
return rect.has_value() ? SkImageFilters::CropRect(*rect)
|
|
434
|
+
: SkImageFilters::CropRect{};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
static SkFilterMode toFilterMode(const JsiOptional<double> &mode) {
|
|
438
|
+
return mode.has_value() ? static_cast<SkFilterMode>(*mode)
|
|
439
|
+
: SkFilterMode::kNearest;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
static SkMipmapMode toMipmapMode(const JsiOptional<double> &mode) {
|
|
443
|
+
return mode.has_value() ? static_cast<SkMipmapMode>(*mode)
|
|
444
|
+
: SkMipmapMode::kNone;
|
|
445
|
+
}
|
|
700
446
|
};
|
|
701
447
|
|
|
702
448
|
} // namespace RNSkia
|