@shopify/react-native-skia 2.4.15 → 2.4.17
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 +69 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +19 -7
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +7 -0
- package/apple/RNSkApplePlatformContext.mm +4 -0
- package/cpp/api/JsiSkApi.h +31 -0
- package/cpp/api/JsiSkImageFactory.h +69 -1
- package/cpp/api/JsiSkImageFilter.h +1 -0
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/jsi/RuntimeAwareCache.h +0 -2
- package/cpp/jsi2/EnumMapper.h +45 -0
- package/cpp/jsi2/JSIConverter.h +468 -0
- package/cpp/jsi2/NativeObject.h +598 -0
- package/cpp/jsi2/Promise.cpp +44 -0
- package/cpp/jsi2/Promise.h +35 -0
- package/cpp/rnskia/RNDawnContext.h +114 -0
- package/cpp/rnskia/RNSkManager.cpp +41 -1
- package/cpp/rnwgpu/ArrayBuffer.h +68 -0
- package/cpp/rnwgpu/api/Convertors.h +761 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +129 -0
- package/cpp/rnwgpu/api/GPU.h +57 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +178 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +434 -0
- package/cpp/rnwgpu/api/GPUDevice.h +174 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
- package/cpp/rnwgpu/api/GPUError.h +35 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
- package/cpp/rnwgpu/api/GPUFeatures.h +212 -0
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
- package/cpp/rnwgpu/api/GPUQueue.h +84 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
- package/cpp/rnwgpu/api/GPUSampler.h +44 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +150 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +97 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +52 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +99 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +38 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +43 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +101 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +110 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +53 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1984 -0
- package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
- package/cpp/rnwgpu/async/AsyncRunner.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncRunner.h +56 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
- package/lib/commonjs/Platform/Platform.web.js +1 -2
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -4
- package/lib/commonjs/renderer/Canvas.js +4 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +1 -2
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/FitBox.js +1 -2
- package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/commonjs/skia/types/ContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +17 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +6 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +4 -4
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/web/WithSkiaWeb.js +1 -2
- package/lib/commonjs/web/WithSkiaWeb.js.map +1 -1
- package/lib/module/external/reanimated/buffers.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +1 -4
- package/lib/module/renderer/Canvas.js +3 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/ContourMeasure.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +17 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/module/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +6 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js +4 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +3 -2
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -4
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +17 -0
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/package.json +20 -16
- package/react-native-skia.podspec +52 -13
- package/scripts/install-skia.mjs +99 -48
- package/src/external/reanimated/buffers.ts +1 -1
- package/src/renderer/Canvas.tsx +3 -2
- package/src/skia/types/ContourMeasure.tsx +1 -2
- package/src/skia/types/Image/ImageFactory.ts +22 -0
- package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -2
- package/src/skia/types/Skia.ts +17 -0
- package/src/skia/web/JsiSkImageFactory.ts +8 -0
- package/src/skia/web/JsiSkia.ts +6 -0
- package/src/sksg/Recorder/commands/ColorFilters.ts +3 -2
- package/src/sksg/Recorder/commands/ImageFilters.ts +3 -2
- package/src/sksg/Recorder/commands/PathEffects.ts +3 -2
- package/src/sksg/Recorder/commands/Shaders.ts +3 -2
- package/src/specs/SkiaPictureViewNativeComponent.ts +7 -0
- package/src/views/SkiaPictureView.web.tsx +4 -1
package/android/CMakeLists.txt
CHANGED
|
@@ -7,6 +7,36 @@ set (CMAKE_CXX_STANDARD 20)
|
|
|
7
7
|
# Import prebuilt SKIA libraries path
|
|
8
8
|
set (SKIA_LIBS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../libs/android/${ANDROID_ABI}")
|
|
9
9
|
|
|
10
|
+
# Check if Skia prebuilt binaries are installed
|
|
11
|
+
# The postinstall script downloads these - if missing, the user needs to run it
|
|
12
|
+
if(NOT EXISTS "${SKIA_LIBS_PATH}/libskia.a")
|
|
13
|
+
message("")
|
|
14
|
+
message("┌─────────────────────────────────────────────────────────────────────────────┐")
|
|
15
|
+
message("│ │")
|
|
16
|
+
message("│ ERROR: Skia prebuilt binaries not found! │")
|
|
17
|
+
message("│ │")
|
|
18
|
+
message("│ The postinstall script has not run. This is required to download the │")
|
|
19
|
+
message("│ Skia binaries. Some package managers (pnpm, bun, yarn berry) require │")
|
|
20
|
+
message("│ explicit trust for packages with postinstall scripts. │")
|
|
21
|
+
message("│ │")
|
|
22
|
+
message("│ To fix this: │")
|
|
23
|
+
message("│ │")
|
|
24
|
+
message("│ • npm/yarn classic: Run 'npm rebuild @shopify/react-native-skia' or │")
|
|
25
|
+
message("│ reinstall the package │")
|
|
26
|
+
message("│ │")
|
|
27
|
+
message("│ • bun: Run 'bun add --trust @shopify/react-native-skia' │")
|
|
28
|
+
message("│ │")
|
|
29
|
+
message("│ • pnpm: Add to package.json: │")
|
|
30
|
+
message("│ \"pnpm\": { \"onlyBuiltDependencies\": [\"@shopify/react-native-skia\"] }│")
|
|
31
|
+
message("│ Then reinstall the package │")
|
|
32
|
+
message("│ │")
|
|
33
|
+
message("│ See: https://shopify.github.io/react-native-skia/docs/getting-started/installation │")
|
|
34
|
+
message("│ │")
|
|
35
|
+
message("└─────────────────────────────────────────────────────────────────────────────┘")
|
|
36
|
+
message("")
|
|
37
|
+
message(FATAL_ERROR "Skia prebuilt binaries not found at ${SKIA_LIBS_PATH}. Please run the postinstall script.")
|
|
38
|
+
endif()
|
|
39
|
+
|
|
10
40
|
# Import libskia first so we can check for symbols
|
|
11
41
|
add_library(skia STATIC IMPORTED)
|
|
12
42
|
set_property(TARGET skia PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libskia.a")
|
|
@@ -122,6 +152,37 @@ add_library(
|
|
|
122
152
|
${BACKEND_SOURCES}
|
|
123
153
|
)
|
|
124
154
|
|
|
155
|
+
if(SK_GRAPHITE)
|
|
156
|
+
# WebGPU JSI infrastructure (jsi2)
|
|
157
|
+
target_sources(${PACKAGE_NAME} PRIVATE
|
|
158
|
+
"${PROJECT_SOURCE_DIR}/../cpp/jsi2/Promise.cpp"
|
|
159
|
+
|
|
160
|
+
# WebGPU async system
|
|
161
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/async/AsyncRunner.cpp"
|
|
162
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/async/AsyncTaskHandle.cpp"
|
|
163
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp"
|
|
164
|
+
|
|
165
|
+
# WebGPU API
|
|
166
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPU.cpp"
|
|
167
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUAdapter.cpp"
|
|
168
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUBindGroup.cpp"
|
|
169
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUBuffer.cpp"
|
|
170
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUCommandEncoder.cpp"
|
|
171
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUComputePassEncoder.cpp"
|
|
172
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUComputePipeline.cpp"
|
|
173
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUDevice.cpp"
|
|
174
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUDeviceLostInfo.cpp"
|
|
175
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUQuerySet.cpp"
|
|
176
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUQueue.cpp"
|
|
177
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPURenderBundleEncoder.cpp"
|
|
178
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPURenderPassEncoder.cpp"
|
|
179
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPURenderPipeline.cpp"
|
|
180
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUShaderModule.cpp"
|
|
181
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUSupportedLimits.cpp"
|
|
182
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUTexture.cpp"
|
|
183
|
+
)
|
|
184
|
+
endif()
|
|
185
|
+
|
|
125
186
|
|
|
126
187
|
target_include_directories(
|
|
127
188
|
${PACKAGE_NAME}
|
|
@@ -150,6 +211,14 @@ target_include_directories(
|
|
|
150
211
|
../cpp/rnskia/values
|
|
151
212
|
../cpp/utils
|
|
152
213
|
|
|
214
|
+
# WebGPU bindings
|
|
215
|
+
../cpp
|
|
216
|
+
../cpp/jsi2
|
|
217
|
+
../cpp/rnwgpu
|
|
218
|
+
../cpp/rnwgpu/api
|
|
219
|
+
../cpp/rnwgpu/api/descriptors
|
|
220
|
+
../cpp/rnwgpu/async
|
|
221
|
+
|
|
153
222
|
${libfbjni_include_DIRS}
|
|
154
223
|
)
|
|
155
224
|
|
|
@@ -3,9 +3,11 @@ package com.shopify.reactnative.skia;
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.graphics.SurfaceTexture;
|
|
5
5
|
import android.util.Log;
|
|
6
|
+
import android.view.MotionEvent;
|
|
6
7
|
import android.view.Surface;
|
|
7
8
|
import android.view.View;
|
|
8
9
|
|
|
10
|
+
import com.facebook.react.uimanager.PointerEvents;
|
|
9
11
|
import com.facebook.react.views.view.ReactViewGroup;
|
|
10
12
|
|
|
11
13
|
public abstract class SkiaBaseView extends ReactViewGroup implements SkiaViewAPI {
|
|
@@ -16,20 +18,30 @@ public abstract class SkiaBaseView extends ReactViewGroup implements SkiaViewAPI
|
|
|
16
18
|
|
|
17
19
|
public SkiaBaseView(Context context) {
|
|
18
20
|
super(context);
|
|
19
|
-
mView = new
|
|
21
|
+
mView = new SkiaSurfaceView(context, this, debug);
|
|
20
22
|
addView(mView);
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
@Override
|
|
26
|
+
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
27
|
+
// When pointerEvents is "none" or "box-none", make this view completely
|
|
28
|
+
// transparent to touch dispatch so events pass through to views behind it
|
|
29
|
+
if (!PointerEvents.canBeTouchTarget(getPointerEvents())) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return super.dispatchTouchEvent(ev);
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
public void setOpaque(boolean value) {
|
|
24
|
-
|
|
36
|
+
// if (value && mView instanceof SkiaTextureView) {
|
|
25
37
|
removeView(mView);
|
|
26
38
|
mView = new SkiaSurfaceView(getContext(), this, debug);
|
|
27
39
|
addView(mView);
|
|
28
|
-
} else if (!value && mView instanceof SkiaSurfaceView) {
|
|
29
|
-
removeView(mView);
|
|
30
|
-
mView = new SkiaTextureView(getContext(), this, debug);
|
|
31
|
-
addView(mView);
|
|
32
|
-
}
|
|
40
|
+
// } else if (!value && mView instanceof SkiaSurfaceView) {
|
|
41
|
+
// removeView(mView);
|
|
42
|
+
// mView = new SkiaTextureView(getContext(), this, debug);
|
|
43
|
+
// addView(mView);
|
|
44
|
+
// }
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
void dropInstance() {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.shopify.reactnative.skia;
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.uimanager.PointerEvents;
|
|
4
|
+
import com.facebook.react.uimanager.ViewProps;
|
|
3
5
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
4
6
|
import com.facebook.react.views.view.ReactViewGroup;
|
|
5
7
|
import com.facebook.react.views.view.ReactViewManager;
|
|
@@ -26,6 +28,11 @@ public abstract class SkiaBaseViewManager<T extends SkiaBaseView> extends ReactV
|
|
|
26
28
|
((SkiaBaseView)view).setOpaque(value);
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
@ReactProp(name = ViewProps.POINTER_EVENTS)
|
|
32
|
+
public void setPointerEvents(T view, @Nullable String pointerEventsStr) {
|
|
33
|
+
view.setPointerEvents(PointerEvents.parsePointerEvents(pointerEventsStr));
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
@Override
|
|
30
37
|
public void onDropViewInstance(@NonNull ReactViewGroup view) {
|
|
31
38
|
super.onDropViewInstance(view);
|
|
@@ -50,7 +50,11 @@ void RNSkApplePlatformContext::performStreamOperation(
|
|
|
50
50
|
// load from the embedded iOS app bundle and will try to load image
|
|
51
51
|
// and get data from the image directly. imageNamed will return the
|
|
52
52
|
// best version of the requested image:
|
|
53
|
+
#if !TARGET_OS_OSX
|
|
53
54
|
auto image = [UIImage imageNamed:[url absoluteString]];
|
|
55
|
+
#else
|
|
56
|
+
auto image = [NSImage imageNamed:[url absoluteString]];
|
|
57
|
+
#endif // !TARGET_OS_OSX
|
|
54
58
|
// We don't know the image format (png, jpg, etc) but
|
|
55
59
|
// UIImagePNGRepresentation will support all of them
|
|
56
60
|
data = UIImagePNGRepresentation(image);
|
package/cpp/api/JsiSkApi.h
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
#include "JsiSkHostObjects.h"
|
|
8
8
|
|
|
9
|
+
#ifdef SK_GRAPHITE
|
|
10
|
+
#include "RNDawnContext.h"
|
|
11
|
+
#include "rnwgpu/api/GPUDevice.h"
|
|
12
|
+
#include "rnwgpu/async/AsyncRunner.h"
|
|
13
|
+
#endif
|
|
14
|
+
|
|
9
15
|
#include "JsiNativeBuffer.h"
|
|
10
16
|
#include "JsiSkAnimatedImage.h"
|
|
11
17
|
#include "JsiSkAnimatedImageFactory.h"
|
|
@@ -140,6 +146,31 @@ public:
|
|
|
140
146
|
std::make_shared<JsiNativeBufferFactory>(context));
|
|
141
147
|
|
|
142
148
|
installFunction("Recorder", JsiRecorder::createCtor(context));
|
|
149
|
+
|
|
150
|
+
installFunction("hasDevice", JSI_HOST_FUNCTION_LAMBDA {
|
|
151
|
+
#ifdef SK_GRAPHITE
|
|
152
|
+
return jsi::Value(true);
|
|
153
|
+
#else
|
|
154
|
+
return jsi::Value(false);
|
|
155
|
+
#endif
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
installFunction("getDevice", JSI_HOST_FUNCTION_LAMBDA {
|
|
159
|
+
#ifdef SK_GRAPHITE
|
|
160
|
+
auto &dawnContext = DawnContext::getInstance();
|
|
161
|
+
auto asyncRunner = rnwgpu::async::AsyncRunner::get(runtime);
|
|
162
|
+
if (!asyncRunner) {
|
|
163
|
+
throw jsi::JSError(runtime, "AsyncRunner not initialized");
|
|
164
|
+
}
|
|
165
|
+
auto device = std::make_shared<rnwgpu::GPUDevice>(
|
|
166
|
+
dawnContext.getWGPUDevice(), asyncRunner, "Skia Device");
|
|
167
|
+
return rnwgpu::GPUDevice::create(runtime, device);
|
|
168
|
+
#else
|
|
169
|
+
throw jsi::JSError(runtime,
|
|
170
|
+
"getDevice() is only available with the Graphite "
|
|
171
|
+
"backend. Rebuild with SK_GRAPHITE enabled.");
|
|
172
|
+
#endif
|
|
173
|
+
});
|
|
143
174
|
}
|
|
144
175
|
};
|
|
145
176
|
} // namespace RNSkia
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
#include "JsiSkImage.h"
|
|
12
12
|
#include "JsiSkImageInfo.h"
|
|
13
13
|
|
|
14
|
+
#ifdef SK_GRAPHITE
|
|
15
|
+
#include "RNDawnContext.h"
|
|
16
|
+
#include "rnwgpu/api/GPUTexture.h"
|
|
17
|
+
#endif
|
|
18
|
+
|
|
14
19
|
namespace RNSkia {
|
|
15
20
|
|
|
16
21
|
namespace jsi = facebook::jsi;
|
|
@@ -113,6 +118,67 @@ public:
|
|
|
113
118
|
runtime, hostObjectInstance, getContext());
|
|
114
119
|
}
|
|
115
120
|
|
|
121
|
+
JSI_HOST_FUNCTION(MakeImageFromTexture) {
|
|
122
|
+
#ifdef SK_GRAPHITE
|
|
123
|
+
if (count < 1 || !arguments[0].isObject()) {
|
|
124
|
+
throw std::runtime_error(
|
|
125
|
+
"MakeImageFromTexture requires a GPUTexture argument");
|
|
126
|
+
}
|
|
127
|
+
auto obj = arguments[0].asObject(runtime);
|
|
128
|
+
auto gpuTexture = obj.getNativeState<rnwgpu::GPUTexture>(runtime);
|
|
129
|
+
if (!gpuTexture) {
|
|
130
|
+
throw std::runtime_error("Invalid GPUTexture object");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
wgpu::Texture texture = gpuTexture->get();
|
|
134
|
+
int width = static_cast<int>(gpuTexture->getWidth());
|
|
135
|
+
int height = static_cast<int>(gpuTexture->getHeight());
|
|
136
|
+
wgpu::TextureFormat format = gpuTexture->getFormat();
|
|
137
|
+
|
|
138
|
+
auto &dawnContext = DawnContext::getInstance();
|
|
139
|
+
auto image =
|
|
140
|
+
dawnContext.MakeImageFromTexture(texture, width, height, format);
|
|
141
|
+
if (image == nullptr) {
|
|
142
|
+
throw std::runtime_error("Failed to create SkImage from GPUTexture!");
|
|
143
|
+
}
|
|
144
|
+
auto hostObjectInstance =
|
|
145
|
+
std::make_shared<JsiSkImage>(getContext(), std::move(image));
|
|
146
|
+
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
|
|
147
|
+
runtime, hostObjectInstance, getContext());
|
|
148
|
+
#else
|
|
149
|
+
throw std::runtime_error(
|
|
150
|
+
"MakeImageFromTexture is only available with the Graphite backend. "
|
|
151
|
+
"Rebuild with SK_GRAPHITE enabled.");
|
|
152
|
+
#endif
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
JSI_HOST_FUNCTION(MakeTextureFromImage) {
|
|
156
|
+
#ifdef SK_GRAPHITE
|
|
157
|
+
if (count < 1) {
|
|
158
|
+
throw std::runtime_error(
|
|
159
|
+
"MakeTextureFromImage requires an SkImage argument");
|
|
160
|
+
}
|
|
161
|
+
auto image = JsiSkImage::fromValue(runtime, arguments[0]);
|
|
162
|
+
if (!image) {
|
|
163
|
+
throw std::runtime_error("Invalid SkImage object");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
auto &dawnContext = DawnContext::getInstance();
|
|
167
|
+
wgpu::Texture texture = dawnContext.MakeTextureFromImage(image);
|
|
168
|
+
if (!texture) {
|
|
169
|
+
throw std::runtime_error("Failed to create GPUTexture from SkImage!");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
auto gpuTexture =
|
|
173
|
+
std::make_shared<rnwgpu::GPUTexture>(texture, "SkImage Texture");
|
|
174
|
+
return rnwgpu::GPUTexture::create(runtime, gpuTexture);
|
|
175
|
+
#else
|
|
176
|
+
throw std::runtime_error(
|
|
177
|
+
"MakeTextureFromImage is only available with the Graphite backend. "
|
|
178
|
+
"Rebuild with SK_GRAPHITE enabled.");
|
|
179
|
+
#endif
|
|
180
|
+
}
|
|
181
|
+
|
|
116
182
|
size_t getMemoryPressure() const override { return 1024; }
|
|
117
183
|
|
|
118
184
|
std::string getObjectType() const override { return "JsiSkImageFactory"; }
|
|
@@ -124,7 +190,9 @@ public:
|
|
|
124
190
|
JSI_EXPORT_FUNC(JsiSkImageFactory,
|
|
125
191
|
MakeImageFromNativeTextureUnstable),
|
|
126
192
|
JSI_EXPORT_FUNC(JsiSkImageFactory, MakeImage),
|
|
127
|
-
JSI_EXPORT_FUNC(JsiSkImageFactory, MakeNull)
|
|
193
|
+
JSI_EXPORT_FUNC(JsiSkImageFactory, MakeNull),
|
|
194
|
+
JSI_EXPORT_FUNC(JsiSkImageFactory, MakeImageFromTexture),
|
|
195
|
+
JSI_EXPORT_FUNC(JsiSkImageFactory, MakeTextureFromImage))
|
|
128
196
|
|
|
129
197
|
explicit JsiSkImageFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
130
198
|
: JsiSkHostObject(std::move(context)) {}
|
package/cpp/api/JsiSkPath.h
CHANGED
|
@@ -15,8 +15,6 @@ namespace jsi = facebook::jsi;
|
|
|
15
15
|
class BaseRuntimeAwareCache {
|
|
16
16
|
public:
|
|
17
17
|
static void setMainJsRuntime(jsi::Runtime *rt) { _mainRuntime = rt; }
|
|
18
|
-
|
|
19
|
-
protected:
|
|
20
18
|
static jsi::Runtime *getMainJsRuntime() {
|
|
21
19
|
assert(_mainRuntime != nullptr &&
|
|
22
20
|
"Expected main Javascript runtime to be set in the "
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
namespace rnwgpu {
|
|
7
|
+
|
|
8
|
+
namespace EnumMapper {
|
|
9
|
+
// Add these two methods in namespace "EnumMapper" to allow parsing a custom enum:
|
|
10
|
+
// 1. `static void convertJSUnionToEnum(const std::string& inUnion, Enum* outEnum)`
|
|
11
|
+
// 2. `static void convertEnumToJSUnion(Enum inEnum, std::string* outUnion)`
|
|
12
|
+
|
|
13
|
+
static std::runtime_error invalidUnion(const std::string& passedUnion) {
|
|
14
|
+
return std::runtime_error("Cannot convert JS Value to Enum: Invalid Union value passed! (\"" + std::string(passedUnion) + "\")");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
template <typename T> static std::runtime_error invalidEnum(T passedEnum) {
|
|
18
|
+
return std::runtime_error("Cannot convert Enum to JS Value: Invalid Enum passed! (Value #" +
|
|
19
|
+
std::to_string(static_cast<int>(passedEnum)) + ")");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Trait to check if a convertJSUnionToEnum function for enum type T exists
|
|
23
|
+
template <typename T, typename = void> struct has_js_union_to_enum : std::false_type {};
|
|
24
|
+
template <typename T>
|
|
25
|
+
struct has_js_union_to_enum<T, std::void_t<decltype(convertJSUnionToEnum(std::declval<std::string>(), std::declval<T*>()))>>
|
|
26
|
+
: std::true_type {};
|
|
27
|
+
|
|
28
|
+
// Trait to check if a convertEnumToJSUnion function for enum type T exists
|
|
29
|
+
template <typename T, typename = void> struct has_enum_to_js_union : std::false_type {};
|
|
30
|
+
template <typename T>
|
|
31
|
+
struct has_enum_to_js_union<T, std::void_t<decltype(convertEnumToJSUnion(std::declval<T>(), std::declval<std::string*>()))>>
|
|
32
|
+
: std::true_type {};
|
|
33
|
+
|
|
34
|
+
template <typename TEnum> static void convertJSUnionToEnum(const std::string&, TEnum*) {
|
|
35
|
+
static_assert(has_js_union_to_enum<TEnum>::value,
|
|
36
|
+
"Cannot convert a JS union to this enum type. Did you implement EnumMapper::convertJSUnionToEnum(...)?");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
template <typename TEnum> static void convertEnumToJSUnion(TEnum, std::string*) {
|
|
40
|
+
static_assert(has_enum_to_js_union<TEnum>::value,
|
|
41
|
+
"Cannot convert this enum type to a JS union. Did you implement EnumMapper::convertEnumToJSUnion(...)?");
|
|
42
|
+
}
|
|
43
|
+
} // namespace EnumMapper
|
|
44
|
+
|
|
45
|
+
} // namespace rnwgpu
|