@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.
Files changed (226) hide show
  1. package/android/CMakeLists.txt +69 -0
  2. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +19 -7
  3. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +7 -0
  4. package/apple/RNSkApplePlatformContext.mm +4 -0
  5. package/cpp/api/JsiSkApi.h +31 -0
  6. package/cpp/api/JsiSkImageFactory.h +69 -1
  7. package/cpp/api/JsiSkImageFilter.h +1 -0
  8. package/cpp/api/JsiSkPath.h +1 -1
  9. package/cpp/jsi/RuntimeAwareCache.h +0 -2
  10. package/cpp/jsi2/EnumMapper.h +45 -0
  11. package/cpp/jsi2/JSIConverter.h +468 -0
  12. package/cpp/jsi2/NativeObject.h +598 -0
  13. package/cpp/jsi2/Promise.cpp +44 -0
  14. package/cpp/jsi2/Promise.h +35 -0
  15. package/cpp/rnskia/RNDawnContext.h +114 -0
  16. package/cpp/rnskia/RNSkManager.cpp +41 -1
  17. package/cpp/rnwgpu/ArrayBuffer.h +68 -0
  18. package/cpp/rnwgpu/api/Convertors.h +761 -0
  19. package/cpp/rnwgpu/api/External.h +12 -0
  20. package/cpp/rnwgpu/api/GPU.cpp +129 -0
  21. package/cpp/rnwgpu/api/GPU.h +57 -0
  22. package/cpp/rnwgpu/api/GPUAdapter.cpp +178 -0
  23. package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
  24. package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
  25. package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
  26. package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
  27. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
  28. package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
  29. package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
  30. package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
  31. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
  32. package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
  33. package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
  34. package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
  35. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
  36. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
  37. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
  38. package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
  39. package/cpp/rnwgpu/api/GPUDevice.cpp +434 -0
  40. package/cpp/rnwgpu/api/GPUDevice.h +174 -0
  41. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
  42. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
  43. package/cpp/rnwgpu/api/GPUError.h +35 -0
  44. package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
  45. package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
  46. package/cpp/rnwgpu/api/GPUFeatures.h +212 -0
  47. package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
  48. package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
  49. package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
  50. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
  51. package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
  52. package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
  53. package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
  54. package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
  55. package/cpp/rnwgpu/api/GPUQueue.h +84 -0
  56. package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
  57. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
  58. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
  59. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
  60. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
  61. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
  62. package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
  63. package/cpp/rnwgpu/api/GPUSampler.h +44 -0
  64. package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
  65. package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
  66. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
  67. package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
  68. package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
  69. package/cpp/rnwgpu/api/GPUTexture.h +150 -0
  70. package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
  71. package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
  72. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +64 -0
  73. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +71 -0
  74. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +56 -0
  75. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +97 -0
  76. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +57 -0
  77. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +52 -0
  78. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +56 -0
  79. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +56 -0
  80. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +59 -0
  81. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
  82. package/cpp/rnwgpu/api/descriptors/GPUColor.h +66 -0
  83. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +58 -0
  84. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
  85. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +45 -0
  86. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +45 -0
  87. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +56 -0
  88. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +58 -0
  89. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +67 -0
  90. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +103 -0
  91. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +99 -0
  92. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +38 -0
  93. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +71 -0
  94. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +73 -0
  95. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +62 -0
  96. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +62 -0
  97. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +65 -0
  98. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +81 -0
  99. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +54 -0
  100. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
  101. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +54 -0
  102. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +57 -0
  103. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +69 -0
  104. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +61 -0
  105. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +55 -0
  106. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +43 -0
  107. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +45 -0
  108. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +80 -0
  109. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +81 -0
  110. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +101 -0
  111. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +92 -0
  112. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +58 -0
  113. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +103 -0
  114. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +51 -0
  115. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +45 -0
  116. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +110 -0
  117. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +60 -0
  118. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +62 -0
  119. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
  120. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +64 -0
  121. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +59 -0
  122. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +59 -0
  123. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +91 -0
  124. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
  125. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +91 -0
  126. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +64 -0
  127. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +53 -0
  128. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +62 -0
  129. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +73 -0
  130. package/cpp/rnwgpu/api/descriptors/Unions.h +1984 -0
  131. package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
  132. package/cpp/rnwgpu/async/AsyncRunner.cpp +181 -0
  133. package/cpp/rnwgpu/async/AsyncRunner.h +56 -0
  134. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
  135. package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
  136. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
  137. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
  138. package/lib/commonjs/Platform/Platform.web.js +1 -2
  139. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  140. package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
  141. package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -4
  142. package/lib/commonjs/renderer/Canvas.js +4 -3
  143. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  144. package/lib/commonjs/renderer/components/Group.js +1 -2
  145. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  146. package/lib/commonjs/renderer/components/shapes/FitBox.js +1 -2
  147. package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
  148. package/lib/commonjs/skia/types/ContourMeasure.js.map +1 -1
  149. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +20 -0
  150. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  151. package/lib/commonjs/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
  152. package/lib/commonjs/skia/types/Skia.d.ts +17 -0
  153. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  154. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
  155. package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -0
  156. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  157. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +2 -2
  158. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
  159. package/lib/commonjs/skia/web/JsiSkia.js +6 -0
  160. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  161. package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -1
  162. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  163. package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -1
  164. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  165. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
  166. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -0
  167. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  168. package/lib/commonjs/views/SkiaPictureView.web.js +4 -4
  169. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  170. package/lib/commonjs/web/WithSkiaWeb.js +1 -2
  171. package/lib/commonjs/web/WithSkiaWeb.js.map +1 -1
  172. package/lib/module/external/reanimated/buffers.js.map +1 -1
  173. package/lib/module/external/reanimated/interpolators.d.ts +1 -4
  174. package/lib/module/renderer/Canvas.js +3 -1
  175. package/lib/module/renderer/Canvas.js.map +1 -1
  176. package/lib/module/skia/types/ContourMeasure.js.map +1 -1
  177. package/lib/module/skia/types/Image/ImageFactory.d.ts +20 -0
  178. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  179. package/lib/module/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
  180. package/lib/module/skia/types/Skia.d.ts +17 -0
  181. package/lib/module/skia/types/Skia.js.map +1 -1
  182. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
  183. package/lib/module/skia/web/JsiSkImageFactory.js +6 -0
  184. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  185. package/lib/module/skia/web/JsiSkParagraphStyle.js +2 -2
  186. package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
  187. package/lib/module/skia/web/JsiSkia.js +6 -0
  188. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  189. package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -1
  190. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  191. package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -1
  192. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  193. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
  194. package/lib/module/specs/SkiaPictureViewNativeComponent.js +4 -0
  195. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  196. package/lib/module/views/SkiaPictureView.web.js +3 -2
  197. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  198. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
  199. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  200. package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -1
  201. package/lib/typescript/lib/module/skia/Skia.web.d.ts +2 -0
  202. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
  203. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  204. package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +1 -1
  205. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -4
  206. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +20 -0
  207. package/lib/typescript/src/skia/types/Skia.d.ts +17 -0
  208. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -0
  209. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
  210. package/package.json +20 -16
  211. package/react-native-skia.podspec +52 -13
  212. package/scripts/install-skia.mjs +99 -48
  213. package/src/external/reanimated/buffers.ts +1 -1
  214. package/src/renderer/Canvas.tsx +3 -2
  215. package/src/skia/types/ContourMeasure.tsx +1 -2
  216. package/src/skia/types/Image/ImageFactory.ts +22 -0
  217. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -2
  218. package/src/skia/types/Skia.ts +17 -0
  219. package/src/skia/web/JsiSkImageFactory.ts +8 -0
  220. package/src/skia/web/JsiSkia.ts +6 -0
  221. package/src/sksg/Recorder/commands/ColorFilters.ts +3 -2
  222. package/src/sksg/Recorder/commands/ImageFilters.ts +3 -2
  223. package/src/sksg/Recorder/commands/PathEffects.ts +3 -2
  224. package/src/sksg/Recorder/commands/Shaders.ts +3 -2
  225. package/src/specs/SkiaPictureViewNativeComponent.ts +7 -0
  226. package/src/views/SkiaPictureView.web.tsx +4 -1
@@ -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 SkiaTextureView(context, this, debug);
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
- if (value && mView instanceof SkiaTextureView) {
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);
@@ -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)) {}
@@ -30,6 +30,7 @@ public:
30
30
  std::string getObjectType() const override { return "JsiSkImageFilter"; }
31
31
 
32
32
  EXPORT_JSI_API_TYPENAME(JsiSkImageFilter, ImageFilter)
33
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkImageFilter, dispose))
33
34
  };
34
35
 
35
36
  } // namespace RNSkia
@@ -426,7 +426,7 @@ public:
426
426
  auto x2 = arguments[2].asNumber();
427
427
  auto y2 = arguments[3].asNumber();
428
428
  getObject()->quadTo(x1, y1, x2, y2);
429
- return jsi::Value::undefined();
429
+ return thisValue.getObject(runtime);
430
430
  }
431
431
 
432
432
  JSI_HOST_FUNCTION(rQuadTo) {
@@ -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