@shopify/react-native-skia 2.5.5 → 2.6.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.
Files changed (286) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniWebGPUView.cpp +3 -3
  3. package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
  5. package/apple/MetalContext.h +5 -6
  6. package/apple/MetalWindowContext.mm +3 -4
  7. package/apple/RNSkApplePlatformContext.h +1 -1
  8. package/apple/RNSkApplePlatformContext.mm +4 -3
  9. package/apple/SkiaCVPixelBufferUtils.h +1 -1
  10. package/apple/SkiaCVPixelBufferUtils.mm +31 -30
  11. package/apple/SkiaPlatformContext.mm +2 -2
  12. package/apple/SkiaUIView.mm +1 -1
  13. package/apple/SkiaWebGPUView.mm +8 -4
  14. package/apple/WebGPUMetalView.h +1 -1
  15. package/apple/WebGPUMetalView.mm +1 -1
  16. package/cpp/api/CustomBlendModes.h +1 -0
  17. package/cpp/api/JsiSkApi.h +4 -0
  18. package/cpp/api/JsiSkCanvas.h +2 -2
  19. package/cpp/api/JsiSkColor.h +8 -4
  20. package/cpp/api/JsiSkContourMeasure.h +4 -3
  21. package/cpp/api/JsiSkContourMeasureIter.h +1 -1
  22. package/cpp/api/JsiSkImage.h +17 -9
  23. package/cpp/api/JsiSkParagraphBuilder.h +14 -1
  24. package/cpp/api/JsiSkPath.h +475 -357
  25. package/cpp/api/JsiSkPathBuilder.h +415 -0
  26. package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
  27. package/cpp/api/JsiSkPathEffectFactory.h +3 -2
  28. package/cpp/api/JsiSkPathFactory.h +287 -20
  29. package/cpp/api/JsiSkShader.h +1 -1
  30. package/cpp/api/JsiSkShaderFactory.h +50 -26
  31. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  32. package/cpp/api/recorder/DataTypes.h +1 -1
  33. package/cpp/api/recorder/Drawings.h +11 -9
  34. package/cpp/api/recorder/Shaders.h +77 -22
  35. package/cpp/jsi2/JSIConverter.h +1 -1
  36. package/cpp/rnskia/RNDawnContext.h +29 -9
  37. package/cpp/rnskia/RNDawnUtils.h +112 -113
  38. package/cpp/rnskia/RNDawnWindowContext.h +1 -1
  39. package/cpp/rnskia/RNSkManager.cpp +5 -4
  40. package/cpp/rnskia/RNSkPlatformContext.h +2 -2
  41. package/cpp/rnwgpu/api/GPU.cpp +21 -0
  42. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
  43. package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
  44. package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
  45. package/cpp/rnwgpu/api/GPUTexture.h +14 -2
  46. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
  47. package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
  48. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
  49. package/cpp/skia/include/android/SkImageAndroid.h +7 -2
  50. package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
  51. package/cpp/skia/include/codec/SkCodec.h +42 -15
  52. package/cpp/skia/include/config/SkUserConfig.h +8 -0
  53. package/cpp/skia/include/core/SkBitmap.h +0 -5
  54. package/cpp/skia/include/core/SkCanvas.h +2 -39
  55. package/cpp/skia/include/core/SkColor.h +12 -0
  56. package/cpp/skia/include/core/SkColorSpace.h +9 -0
  57. package/cpp/skia/include/core/SkContourMeasure.h +1 -5
  58. package/cpp/skia/include/core/SkData.h +8 -0
  59. package/cpp/skia/include/core/SkFont.h +1 -55
  60. package/cpp/skia/include/core/SkFontArguments.h +15 -0
  61. package/cpp/skia/include/core/SkGraphics.h +0 -5
  62. package/cpp/skia/include/core/SkImage.h +0 -4
  63. package/cpp/skia/include/core/SkImageGenerator.h +1 -4
  64. package/cpp/skia/include/core/SkMatrix.h +0 -37
  65. package/cpp/skia/include/core/SkMilestone.h +1 -1
  66. package/cpp/skia/include/core/SkPath.h +11 -911
  67. package/cpp/skia/include/core/SkPathBuilder.h +42 -32
  68. package/cpp/skia/include/core/SkPathEffect.h +0 -9
  69. package/cpp/skia/include/core/SkPathMeasure.h +1 -4
  70. package/cpp/skia/include/core/SkPathUtils.h +0 -10
  71. package/cpp/skia/include/core/SkRect.h +0 -12
  72. package/cpp/skia/include/core/SkRegion.h +1 -6
  73. package/cpp/skia/include/core/SkSerialProcs.h +4 -5
  74. package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
  75. package/cpp/skia/include/core/SkTextBlob.h +0 -22
  76. package/cpp/skia/include/core/SkTypeface.h +14 -32
  77. package/cpp/skia/include/core/SkTypes.h +0 -8
  78. package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
  79. package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
  80. package/cpp/skia/include/effects/SkGradient.h +206 -0
  81. package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
  82. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  83. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
  84. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
  85. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
  86. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
  87. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
  88. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
  89. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
  90. package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
  91. package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
  92. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
  93. package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
  94. package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
  95. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
  96. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
  97. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
  98. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
  99. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
  100. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
  101. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  102. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
  103. package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
  104. package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
  105. package/cpp/skia/include/private/SkPathRef.h +0 -457
  106. package/cpp/skia/include/private/base/SkFeatures.h +4 -0
  107. package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
  108. package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
  109. package/cpp/skia/include/private/base/SkLog.h +68 -0
  110. package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
  111. package/cpp/skia/include/private/base/SkMacros.h +9 -0
  112. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  113. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
  114. package/cpp/skia/include/utils/SkEventTracer.h +5 -7
  115. package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
  116. package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
  117. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
  118. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
  119. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
  120. package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
  121. package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
  122. package/cpp/skia/src/base/SkMathPriv.h +27 -132
  123. package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  124. package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
  125. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  126. package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
  127. package/lib/commonjs/external/reanimated/interpolators.js +21 -4
  128. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  129. package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
  130. package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
  131. package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
  132. package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  133. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
  134. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
  135. package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
  136. package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
  137. package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
  138. package/lib/commonjs/skia/types/Path/index.js +22 -0
  139. package/lib/commonjs/skia/types/Path/index.js.map +1 -1
  140. package/lib/commonjs/skia/types/Skia.d.ts +2 -1
  141. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  142. package/lib/commonjs/skia/web/Host.js +1 -3
  143. package/lib/commonjs/skia/web/Host.js.map +1 -1
  144. package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
  145. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  146. package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
  147. package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
  148. package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
  149. package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
  150. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  151. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
  152. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
  153. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
  154. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  155. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
  156. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  157. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
  158. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  159. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
  160. package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
  161. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  162. package/lib/commonjs/skia/web/JsiSkia.js +8 -1
  163. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  164. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
  165. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  166. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  167. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
  168. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  169. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
  170. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
  171. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
  172. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
  173. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  174. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  175. package/lib/module/animation/functions/interpolatePaths.js +5 -4
  176. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  177. package/lib/module/external/reanimated/interpolators.d.ts +11 -2
  178. package/lib/module/external/reanimated/interpolators.js +21 -4
  179. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  180. package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
  181. package/lib/module/skia/types/Path/PathBuilder.js +2 -0
  182. package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
  183. package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  184. package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
  185. package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
  186. package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
  187. package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
  188. package/lib/module/skia/types/Path/index.d.ts +2 -0
  189. package/lib/module/skia/types/Path/index.js +2 -0
  190. package/lib/module/skia/types/Path/index.js.map +1 -1
  191. package/lib/module/skia/types/Skia.d.ts +2 -1
  192. package/lib/module/skia/types/Skia.js.map +1 -1
  193. package/lib/module/skia/web/Host.js +1 -3
  194. package/lib/module/skia/web/Host.js.map +1 -1
  195. package/lib/module/skia/web/JsiSkCanvas.js +6 -2
  196. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  197. package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
  198. package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
  199. package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
  200. package/lib/module/skia/web/JsiSkPath.js +300 -110
  201. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  202. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  203. package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
  204. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
  205. package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  206. package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
  207. package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  208. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
  209. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  210. package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
  211. package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
  212. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  213. package/lib/module/skia/web/JsiSkia.js +8 -1
  214. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  215. package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
  216. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  217. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  218. package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
  219. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  220. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
  221. package/lib/module/specs/WebGPUViewNativeComponent.js +1 -1
  222. package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
  223. package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
  224. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  225. package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  226. package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
  227. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
  228. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  229. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
  230. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
  231. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
  232. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
  233. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  234. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
  235. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
  236. package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  237. package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
  238. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  239. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  240. package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
  241. package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  242. package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
  243. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
  244. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  245. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
  246. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
  247. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  248. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
  249. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
  250. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  251. package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
  252. package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
  253. package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  254. package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
  255. package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
  256. package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
  257. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
  258. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
  259. package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  260. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
  261. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  262. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
  263. package/package.json +7 -6
  264. package/scripts/install-libs.js +16 -6
  265. package/src/animation/functions/interpolatePaths.ts +5 -6
  266. package/src/external/reanimated/interpolators.ts +25 -5
  267. package/src/skia/types/Path/PathBuilder.ts +303 -0
  268. package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
  269. package/src/skia/types/Path/PathFactory.ts +108 -1
  270. package/src/skia/types/Path/index.ts +2 -0
  271. package/src/skia/types/Skia.ts +2 -1
  272. package/src/skia/web/Host.ts +7 -1
  273. package/src/skia/web/JsiSkCanvas.ts +6 -6
  274. package/src/skia/web/JsiSkContourMeasure.ts +4 -4
  275. package/src/skia/web/JsiSkPath.ts +451 -168
  276. package/src/skia/web/JsiSkPathBuilder.ts +293 -0
  277. package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
  278. package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
  279. package/src/skia/web/JsiSkPathFactory.ts +231 -8
  280. package/src/skia/web/JsiSkia.ts +11 -8
  281. package/src/sksg/Recorder/commands/Drawing.ts +20 -7
  282. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
  283. package/src/specs/WebGPUViewNativeComponent.ts +2 -2
  284. package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
  285. package/cpp/skia/include/effects/SkGradientShader.h +0 -359
  286. package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
@@ -5,6 +5,7 @@
5
5
  #include <variant>
6
6
 
7
7
  #include <include/core/SkSamplingOptions.h>
8
+ #include <include/effects/SkGradient.h>
8
9
 
9
10
  #include "Command.h"
10
11
  #include "Convertor.h"
@@ -250,11 +251,24 @@ public:
250
251
 
251
252
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
252
253
  const SkPoint pts[2] = {props.start, props.end};
253
- auto shader = SkGradientShader::MakeLinear(
254
- pts, props.colors.data(),
255
- props.positions ? props.positions->data() : nullptr,
256
- props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
257
- props.flags.value_or(0), &m3);
254
+
255
+ // Convert SkColor to SkColor4f
256
+ std::vector<SkColor4f> colors4f;
257
+ colors4f.reserve(props.colors.size());
258
+ for (const auto &c : props.colors) {
259
+ colors4f.push_back(SkColor4f::FromColor(c));
260
+ }
261
+
262
+ auto tileMode = props.mode.value_or(SkTileMode::kClamp);
263
+ SkGradient::Colors gradColors(
264
+ SkSpan(colors4f),
265
+ props.positions ? SkSpan<const float>(props.positions->data(),
266
+ props.positions->size())
267
+ : SkSpan<const float>(),
268
+ tileMode);
269
+ SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(
270
+ props.flags.value_or(0)));
271
+ auto shader = SkShaders::LinearGradient(pts, grad, &m3);
258
272
  ctx->shaders.push_back(shader);
259
273
  }
260
274
  };
@@ -293,11 +307,25 @@ public:
293
307
  }
294
308
 
295
309
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
296
- auto shader = SkGradientShader::MakeRadial(
297
- props.center, props.radius, props.colors.data(),
298
- props.positions ? props.positions->data() : nullptr,
299
- props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
300
- props.flags.value_or(0), &m3);
310
+
311
+ // Convert SkColor to SkColor4f
312
+ std::vector<SkColor4f> colors4f;
313
+ colors4f.reserve(props.colors.size());
314
+ for (const auto &c : props.colors) {
315
+ colors4f.push_back(SkColor4f::FromColor(c));
316
+ }
317
+
318
+ auto tileMode = props.mode.value_or(SkTileMode::kClamp);
319
+ SkGradient::Colors gradColors(
320
+ SkSpan(colors4f),
321
+ props.positions ? SkSpan<const float>(props.positions->data(),
322
+ props.positions->size())
323
+ : SkSpan<const float>(),
324
+ tileMode);
325
+ SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(
326
+ props.flags.value_or(0)));
327
+ auto shader =
328
+ SkShaders::RadialGradient(props.center, props.radius, grad, &m3);
301
329
  ctx->shaders.push_back(shader);
302
330
  }
303
331
  };
@@ -338,12 +366,26 @@ public:
338
366
  }
339
367
 
340
368
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
341
- auto shader = SkGradientShader::MakeSweep(
342
- props.center.x(), props.center.y(), props.colors.data(),
343
- props.positions ? props.positions->data() : nullptr,
344
- props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
345
- props.start.value_or(0), props.end.value_or(360),
346
- props.flags.value_or(0), &m3);
369
+
370
+ // Convert SkColor to SkColor4f
371
+ std::vector<SkColor4f> colors4f;
372
+ colors4f.reserve(props.colors.size());
373
+ for (const auto &c : props.colors) {
374
+ colors4f.push_back(SkColor4f::FromColor(c));
375
+ }
376
+
377
+ auto tileMode = props.mode.value_or(SkTileMode::kClamp);
378
+ SkGradient::Colors gradColors(
379
+ SkSpan(colors4f),
380
+ props.positions ? SkSpan<const float>(props.positions->data(),
381
+ props.positions->size())
382
+ : SkSpan<const float>(),
383
+ tileMode);
384
+ SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(
385
+ props.flags.value_or(0)));
386
+ auto shader =
387
+ SkShaders::SweepGradient(props.center, props.start.value_or(0),
388
+ props.end.value_or(360), grad, &m3);
347
389
  ctx->shaders.push_back(shader);
348
390
  }
349
391
  };
@@ -387,12 +429,25 @@ public:
387
429
  }
388
430
 
389
431
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
390
- auto shader = SkGradientShader::MakeTwoPointConical(
391
- props.start, props.startRadius, props.end, props.endRadius,
392
- props.colors.data(),
393
- props.positions ? props.positions->data() : nullptr,
394
- props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
395
- props.flags.value_or(0), &m3);
432
+
433
+ // Convert SkColor to SkColor4f
434
+ std::vector<SkColor4f> colors4f;
435
+ colors4f.reserve(props.colors.size());
436
+ for (const auto &c : props.colors) {
437
+ colors4f.push_back(SkColor4f::FromColor(c));
438
+ }
439
+
440
+ auto tileMode = props.mode.value_or(SkTileMode::kClamp);
441
+ SkGradient::Colors gradColors(
442
+ SkSpan(colors4f),
443
+ props.positions ? SkSpan<const float>(props.positions->data(),
444
+ props.positions->size())
445
+ : SkSpan<const float>(),
446
+ tileMode);
447
+ SkGradient grad(gradColors, SkGradient::Interpolation::FromFlags(
448
+ props.flags.value_or(0)));
449
+ auto shader = SkShaders::TwoPointConicalGradient(
450
+ props.start, props.startRadius, props.end, props.endRadius, grad, &m3);
396
451
  ctx->shaders.push_back(shader);
397
452
  }
398
453
  };
@@ -241,7 +241,7 @@ template <> struct JSIConverter<rnwgpu::async::AsyncTaskHandle> {
241
241
  // jsi::Function <> Function
242
242
  template <> struct JSIConverter<jsi::Function> {
243
243
  static jsi::Function fromJSI(jsi::Runtime &runtime, const jsi::Value &arg,
244
- bool outOfBound) {
244
+ bool outOfBound) {
245
245
  return arg.asObject(runtime).asFunction(runtime);
246
246
  }
247
247
  static jsi::Value toJSI(jsi::Runtime &runtime, jsi::Function &&arg) {
@@ -114,7 +114,6 @@ public:
114
114
  wgpu::SharedTextureMemoryAHardwareBufferDescriptor platformDesc;
115
115
  auto ahb = (AHardwareBuffer *)buffer;
116
116
  platformDesc.handle = ahb;
117
- platformDesc.useExternalFormat = true;
118
117
  AHardwareBuffer_Desc adesc;
119
118
  AHardwareBuffer_describe(ahb, &adesc);
120
119
  int width = adesc.width;
@@ -164,15 +163,14 @@ public:
164
163
 
165
164
  // Create offscreen surface
166
165
  sk_sp<SkSurface> MakeOffscreen(int width, int height,
167
- bool useP3ColorSpace = false) {
166
+ bool useP3ColorSpace = false) {
168
167
  sk_sp<SkColorSpace> colorSpace =
169
- useP3ColorSpace
170
- ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
171
- SkNamedGamut::kDisplayP3)
172
- : nullptr;
173
- SkImageInfo info = SkImageInfo::Make(
174
- width, height, DawnUtils::PreferedColorType, kPremul_SkAlphaType,
175
- colorSpace);
168
+ useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
169
+ SkNamedGamut::kDisplayP3)
170
+ : nullptr;
171
+ SkImageInfo info =
172
+ SkImageInfo::Make(width, height, DawnUtils::PreferedColorType,
173
+ kPremul_SkAlphaType, colorSpace);
176
174
  sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(getRecorder(), info);
177
175
 
178
176
  if (!surface) {
@@ -188,6 +186,28 @@ public:
188
186
  // Get the wgpu::Device for WebGPU bindings
189
187
  wgpu::Device getWGPUDevice() { return backendContext.fDevice; }
190
188
 
189
+ // Create a secondary Dawn device from the same adapter.
190
+ // Has its own command queue and does NOT enable
191
+ // ImplicitDeviceSynchronization, so it won't contend with the primary
192
+ // rendering device's mutex. Safe for concurrent GPU work (e.g. ML inference)
193
+ // alongside Skia rendering.
194
+ wgpu::Device createSecondaryDevice() {
195
+ auto adapter = DawnUtils::getMatchedAdapter(instance.get());
196
+
197
+ std::vector<wgpu::FeatureName> features = {
198
+ wgpu::FeatureName::BufferMapExtendedUsages,
199
+ #ifdef __APPLE__
200
+ wgpu::FeatureName::SharedTextureMemoryIOSurface,
201
+ wgpu::FeatureName::DawnMultiPlanarFormats,
202
+ // Note: SharedFenceMTLSharedEvent intentionally NOT enabled — it causes
203
+ // EndAccess to encode fence signals that crash with "uncommitted encoder".
204
+ // IOSurface data is already written by the camera before we read it.
205
+ #endif
206
+ };
207
+
208
+ return DawnUtils::requestDevice(adapter, features, false);
209
+ }
210
+
191
211
  // Create an SkImage from a WebGPU texture
192
212
  // The texture must have TextureBinding usage
193
213
  sk_sp<SkImage> MakeImageFromTexture(wgpu::Texture texture, int width,
@@ -21,35 +21,21 @@ static const wgpu::TextureFormat PreferredTextureFormat =
21
21
  wgpu::TextureFormat::RGBA8Unorm;
22
22
  #endif
23
23
 
24
- inline skgpu::graphite::DawnBackendContext
25
- createDawnBackendContext(dawn::native::Instance *instance) {
26
-
27
- auto useTintIR = false;
28
- static constexpr const char *kToggles[] = {
29
- #if !defined(SK_DEBUG)
30
- "skip_validation",
31
- #endif
32
- "disable_lazy_clear_for_mapped_at_creation_buffer",
33
- "allow_unsafe_apis",
34
- "use_user_defined_labels_in_backend",
35
- "disable_robustness",
36
- "use_tint_ir",
37
- };
38
- wgpu::DawnTogglesDescriptor togglesDesc;
39
- togglesDesc.enabledToggleCount = std::size(kToggles) - (useTintIR ? 0 : 1);
40
- togglesDesc.enabledToggles = kToggles;
41
-
42
- dawn::native::Adapter matchedAdaptor;
43
-
44
- wgpu::RequestAdapterOptions options;
24
+ // Find the best matching GPU adapter for the current platform.
25
+ // Sorts by adapter type (DiscreteGPU > IntegratedGPU > CPU) and selects the
26
+ // first adapter matching the platform backend (Metal on Apple, Vulkan on
27
+ // Android).
28
+ inline dawn::native::Adapter
29
+ getMatchedAdapter(dawn::native::Instance *instance) {
45
30
  #ifdef __APPLE__
46
31
  constexpr auto kDefaultBackendType = wgpu::BackendType::Metal;
47
32
  #elif __ANDROID__
48
33
  constexpr auto kDefaultBackendType = wgpu::BackendType::Vulkan;
49
34
  #endif
35
+
36
+ wgpu::RequestAdapterOptions options;
50
37
  options.backendType = kDefaultBackendType;
51
38
  options.featureLevel = wgpu::FeatureLevel::Core;
52
- options.nextInChain = &togglesDesc;
53
39
 
54
40
  std::vector<dawn::native::Adapter> adapters =
55
41
  instance->EnumerateAdapters(&options);
@@ -57,8 +43,6 @@ createDawnBackendContext(dawn::native::Instance *instance) {
57
43
  throw std::runtime_error("No matching adapter found");
58
44
  }
59
45
 
60
- // Sort adapters by adapterType(DiscreteGPU, IntegratedGPU, CPU) and
61
- // backendType(Metal, Vulkan, OpenGL, OpenGLES, WebGPU).
62
46
  std::sort(adapters.begin(), adapters.end(),
63
47
  [](dawn::native::Adapter a, dawn::native::Adapter b) {
64
48
  wgpu::Adapter wgpuA = a.Get();
@@ -76,16 +60,90 @@ createDawnBackendContext(dawn::native::Instance *instance) {
76
60
  wgpu::AdapterInfo props;
77
61
  wgpuAdapter.GetInfo(&props);
78
62
  if (kDefaultBackendType == props.backendType) {
79
- matchedAdaptor = adapter;
80
- break;
63
+ return adapter;
81
64
  }
82
65
  }
83
66
 
84
- if (!matchedAdaptor) {
85
- throw std::runtime_error("No matching adapter found");
67
+ throw std::runtime_error("No matching adapter found");
68
+ }
69
+
70
+ // Create a Dawn device from the given adapter with the requested features.
71
+ // Features not supported by the adapter are silently skipped.
72
+ // Set fatalOnDeviceLost=true for primary rendering devices (SK_ABORT on loss),
73
+ // false for secondary/compute devices (log only).
74
+ inline wgpu::Device
75
+ requestDevice(dawn::native::Adapter &nativeAdapter,
76
+ const std::vector<wgpu::FeatureName> &requestedFeatures,
77
+ bool fatalOnDeviceLost = true) {
78
+ wgpu::Adapter adapter = nativeAdapter.Get();
79
+
80
+ // Filter to only features the adapter supports
81
+ std::vector<wgpu::FeatureName> features;
82
+ for (auto feature : requestedFeatures) {
83
+ if (adapter.HasFeature(feature)) {
84
+ features.push_back(feature);
85
+ }
86
86
  }
87
87
 
88
- wgpu::Adapter adapter = matchedAdaptor.Get();
88
+ static constexpr const char *kToggles[] = {
89
+ #if !defined(SK_DEBUG)
90
+ "skip_validation",
91
+ #endif
92
+ "disable_lazy_clear_for_mapped_at_creation_buffer",
93
+ "allow_unsafe_apis",
94
+ "use_user_defined_labels_in_backend",
95
+ "disable_robustness",
96
+ };
97
+ wgpu::DawnTogglesDescriptor togglesDesc;
98
+ togglesDesc.enabledToggleCount = std::size(kToggles);
99
+ togglesDesc.enabledToggles = kToggles;
100
+
101
+ wgpu::DeviceDescriptor desc;
102
+ desc.requiredFeatureCount = features.size();
103
+ desc.requiredFeatures = features.data();
104
+ desc.nextInChain = &togglesDesc;
105
+
106
+ if (fatalOnDeviceLost) {
107
+ desc.SetDeviceLostCallback(
108
+ wgpu::CallbackMode::AllowSpontaneous,
109
+ [](const wgpu::Device &, wgpu::DeviceLostReason reason,
110
+ wgpu::StringView message) {
111
+ if (reason != wgpu::DeviceLostReason::Destroyed) {
112
+ SK_ABORT("Device lost: %.*s\n", static_cast<int>(message.length),
113
+ message.data);
114
+ }
115
+ });
116
+ desc.SetUncapturedErrorCallback(
117
+ [](const wgpu::Device &, wgpu::ErrorType, wgpu::StringView message) {
118
+ SkDebugf("Device error: %.*s\n", static_cast<int>(message.length),
119
+ message.data);
120
+ });
121
+ } else {
122
+ desc.SetDeviceLostCallback(
123
+ wgpu::CallbackMode::AllowSpontaneous,
124
+ [](const wgpu::Device &, wgpu::DeviceLostReason reason,
125
+ wgpu::StringView message) {
126
+ if (reason != wgpu::DeviceLostReason::Destroyed) {
127
+ RNSkia::RNSkLogger::logToConsole("Device lost: %.*s",
128
+ static_cast<int>(message.length),
129
+ message.data);
130
+ }
131
+ });
132
+ desc.SetUncapturedErrorCallback([](const wgpu::Device &, wgpu::ErrorType,
133
+ wgpu::StringView message) {
134
+ RNSkia::RNSkLogger::logToConsole(
135
+ "Device error: %.*s", static_cast<int>(message.length), message.data);
136
+ });
137
+ }
138
+
139
+ return wgpu::Device::Acquire(nativeAdapter.CreateDevice(&desc));
140
+ }
141
+
142
+ inline skgpu::graphite::DawnBackendContext
143
+ createDawnBackendContext(dawn::native::Instance *instance) {
144
+
145
+ auto matchedAdapter = getMatchedAdapter(instance);
146
+ wgpu::Adapter adapter = matchedAdapter.Get();
89
147
 
90
148
  // Log selected adapter info
91
149
  wgpu::AdapterInfo adapterInfo;
@@ -130,93 +188,34 @@ createDawnBackendContext(dawn::native::Instance *instance) {
130
188
  "Selected Dawn adapter - Backend: %s, Device: %s, Description: %s",
131
189
  backendName.c_str(), deviceName.c_str(), description.c_str());
132
190
 
133
- std::vector<wgpu::FeatureName> features;
134
- if (adapter.HasFeature(wgpu::FeatureName::MSAARenderToSingleSampled)) {
135
- features.push_back(wgpu::FeatureName::MSAARenderToSingleSampled);
136
- }
137
- if (adapter.HasFeature(wgpu::FeatureName::TransientAttachments)) {
138
- features.push_back(wgpu::FeatureName::TransientAttachments);
139
- }
140
- if (adapter.HasFeature(wgpu::FeatureName::Unorm16TextureFormats)) {
141
- features.push_back(wgpu::FeatureName::Unorm16TextureFormats);
142
- }
143
- if (adapter.HasFeature(wgpu::FeatureName::DualSourceBlending)) {
144
- features.push_back(wgpu::FeatureName::DualSourceBlending);
145
- }
146
- if (adapter.HasFeature(wgpu::FeatureName::FramebufferFetch)) {
147
- features.push_back(wgpu::FeatureName::FramebufferFetch);
148
- }
149
- if (adapter.HasFeature(wgpu::FeatureName::BufferMapExtendedUsages)) {
150
- features.push_back(wgpu::FeatureName::BufferMapExtendedUsages);
151
- }
152
- if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionETC2)) {
153
- features.push_back(wgpu::FeatureName::TextureCompressionETC2);
154
- }
155
- if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionBC)) {
156
- features.push_back(wgpu::FeatureName::TextureCompressionBC);
157
- }
158
- if (adapter.HasFeature(wgpu::FeatureName::R8UnormStorage)) {
159
- features.push_back(wgpu::FeatureName::R8UnormStorage);
160
- }
161
- if (adapter.HasFeature(wgpu::FeatureName::DawnLoadResolveTexture)) {
162
- features.push_back(wgpu::FeatureName::DawnLoadResolveTexture);
163
- }
164
- if (adapter.HasFeature(wgpu::FeatureName::DawnPartialLoadResolveTexture)) {
165
- features.push_back(wgpu::FeatureName::DawnPartialLoadResolveTexture);
166
- }
167
- if (adapter.HasFeature(wgpu::FeatureName::TimestampQuery)) {
168
- features.push_back(wgpu::FeatureName::TimestampQuery);
169
- }
170
- if (adapter.HasFeature(wgpu::FeatureName::DawnTexelCopyBufferRowAlignment)) {
171
- features.push_back(wgpu::FeatureName::DawnTexelCopyBufferRowAlignment);
172
- }
173
- if (adapter.HasFeature(wgpu::FeatureName::ImplicitDeviceSynchronization)) {
174
- features.push_back(wgpu::FeatureName::ImplicitDeviceSynchronization);
175
- }
191
+ // Primary device features — request everything Skia/Graphite can use
192
+ std::vector<wgpu::FeatureName> features = {
193
+ wgpu::FeatureName::MSAARenderToSingleSampled,
194
+ wgpu::FeatureName::TransientAttachments,
195
+ wgpu::FeatureName::Unorm16TextureFormats,
196
+ wgpu::FeatureName::DualSourceBlending,
197
+ wgpu::FeatureName::FramebufferFetch,
198
+ wgpu::FeatureName::BufferMapExtendedUsages,
199
+ wgpu::FeatureName::TextureCompressionETC2,
200
+ wgpu::FeatureName::TextureCompressionBC,
201
+ wgpu::FeatureName::BGRA8UnormStorage,
202
+ wgpu::FeatureName::DawnLoadResolveTexture,
203
+ wgpu::FeatureName::DawnPartialLoadResolveTexture,
204
+ wgpu::FeatureName::TimestampQuery,
205
+ wgpu::FeatureName::DawnTexelCopyBufferRowAlignment,
206
+ wgpu::FeatureName::ImplicitDeviceSynchronization,
176
207
  #ifdef __APPLE__
177
- if (adapter.HasFeature(wgpu::FeatureName::SharedTextureMemoryIOSurface)) {
178
- features.push_back(wgpu::FeatureName::SharedTextureMemoryIOSurface);
179
- }
180
- if (adapter.HasFeature(wgpu::FeatureName::DawnMultiPlanarFormats)) {
181
- features.push_back(wgpu::FeatureName::DawnMultiPlanarFormats);
182
- }
183
- if (adapter.HasFeature(wgpu::FeatureName::MultiPlanarFormatP010)) {
184
- features.push_back(wgpu::FeatureName::MultiPlanarFormatP010);
185
- }
186
- if (adapter.HasFeature(wgpu::FeatureName::MultiPlanarFormatP210)) {
187
- features.push_back(wgpu::FeatureName::MultiPlanarFormatP210);
188
- }
189
- if (adapter.HasFeature(wgpu::FeatureName::MultiPlanarFormatExtendedUsages)) {
190
- features.push_back(wgpu::FeatureName::MultiPlanarFormatExtendedUsages);
191
- }
208
+ wgpu::FeatureName::SharedTextureMemoryIOSurface,
209
+ wgpu::FeatureName::DawnMultiPlanarFormats,
210
+ wgpu::FeatureName::MultiPlanarFormatP010,
211
+ wgpu::FeatureName::MultiPlanarFormatP210,
212
+ wgpu::FeatureName::MultiPlanarFormatExtendedUsages,
192
213
  #else
193
- if (adapter.HasFeature(
194
- wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer)) {
195
- features.push_back(wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer);
196
- }
214
+ wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer,
197
215
  #endif
216
+ };
198
217
 
199
- wgpu::DeviceDescriptor desc;
200
- desc.requiredFeatureCount = features.size();
201
- desc.requiredFeatures = features.data();
202
- desc.nextInChain = &togglesDesc;
203
- desc.SetDeviceLostCallback(
204
- wgpu::CallbackMode::AllowSpontaneous,
205
- [](const wgpu::Device &, wgpu::DeviceLostReason reason,
206
- wgpu::StringView message) {
207
- if (reason != wgpu::DeviceLostReason::Destroyed) {
208
- SK_ABORT("Device lost: %.*s\n", static_cast<int>(message.length),
209
- message.data);
210
- }
211
- });
212
- desc.SetUncapturedErrorCallback(
213
- [](const wgpu::Device &, wgpu::ErrorType, wgpu::StringView message) {
214
- SkDebugf("Device error: %.*s\n", static_cast<int>(message.length),
215
- message.data);
216
- });
217
-
218
- wgpu::Device device =
219
- wgpu::Device::Acquire(matchedAdaptor.CreateDevice(&desc));
218
+ wgpu::Device device = requestDevice(matchedAdapter, features, true);
220
219
  SkASSERT(device);
221
220
 
222
221
  skgpu::graphite::DawnBackendContext backendContext;
@@ -227,4 +226,4 @@ createDawnBackendContext(dawn::native::Instance *instance) {
227
226
  return backendContext;
228
227
  }
229
228
 
230
- } // namespace DawnUtils
229
+ } // namespace DawnUtils
@@ -38,7 +38,7 @@ public:
38
38
  return nullptr;
39
39
  }
40
40
  skgpu::graphite::DawnTextureInfo info(
41
- /*sampleCount=*/1, skgpu::Mipmapped::kNo,
41
+ skgpu::graphite::SampleCount::k1, skgpu::Mipmapped::kNo,
42
42
  DawnUtils::PreferredTextureFormat, texture.GetUsage(),
43
43
  wgpu::TextureAspect::All);
44
44
  auto backendTex = skgpu::graphite::BackendTextures::MakeDawn(texture.Get());
@@ -106,13 +106,14 @@ void RNSkManager::installBindings() {
106
106
  rnwgpu::GPUMapMode::create(*_jsRuntime));
107
107
  _jsRuntime->global().setProperty(*_jsRuntime, "GPUShaderStage",
108
108
  rnwgpu::GPUShaderStage::create(*_jsRuntime));
109
- _jsRuntime->global().setProperty(*_jsRuntime, "GPUTextureUsage",
110
- rnwgpu::GPUTextureUsage::create(*_jsRuntime));
109
+ _jsRuntime->global().setProperty(
110
+ *_jsRuntime, "GPUTextureUsage",
111
+ rnwgpu::GPUTextureUsage::create(*_jsRuntime));
111
112
 
112
113
  // Install RNWebGPU global object for WebGPU Canvas support
113
114
  auto rnWebGPU = std::make_shared<rnwgpu::RNWebGPU>(gpu, nullptr);
114
- _jsRuntime->global().setProperty(*_jsRuntime, "RNWebGPU",
115
- rnwgpu::RNWebGPU::create(*_jsRuntime, rnWebGPU));
115
+ _jsRuntime->global().setProperty(
116
+ *_jsRuntime, "RNWebGPU", rnwgpu::RNWebGPU::create(*_jsRuntime, rnWebGPU));
116
117
  #endif
117
118
  }
118
119
  } // namespace RNSkia
@@ -93,8 +93,8 @@ public:
93
93
  * @param useP3ColorSpace If true, surface will use Display P3 color space
94
94
  * @return sk_sp<SkSurface>
95
95
  */
96
- virtual sk_sp<SkSurface> makeOffscreenSurface(int width, int height,
97
- bool useP3ColorSpace = false) = 0;
96
+ virtual sk_sp<SkSurface>
97
+ makeOffscreenSurface(int width, int height, bool useP3ColorSpace = false) = 0;
98
98
 
99
99
  virtual std::shared_ptr<WindowContext>
100
100
  makeContextFromNativeSurface(void *surface, int width, int height) = 0;
@@ -124,6 +124,27 @@ std::unordered_set<std::string> GPU::getWgslLanguageFeatures() {
124
124
  case wgpu::WGSLLanguageFeatureName::ChromiumPrint:
125
125
  name = "chromium_print";
126
126
  break;
127
+ case wgpu::WGSLLanguageFeatureName::TextureAndSamplerLet:
128
+ name = "texture_and_sampler_let";
129
+ break;
130
+ case wgpu::WGSLLanguageFeatureName::SubgroupUniformity:
131
+ name = "subgroup_uniformity";
132
+ break;
133
+ case wgpu::WGSLLanguageFeatureName::TextureFormatsTier1:
134
+ name = "texture_formats_tier1";
135
+ break;
136
+ case wgpu::WGSLLanguageFeatureName::BufferView:
137
+ name = "buffer_view";
138
+ break;
139
+ case wgpu::WGSLLanguageFeatureName::FilteringParameters:
140
+ name = "filtering_parameters";
141
+ break;
142
+ case wgpu::WGSLLanguageFeatureName::SwizzleAssignment:
143
+ name = "swizzle_assignment";
144
+ break;
145
+ case wgpu::WGSLLanguageFeatureName::LinearIndexing:
146
+ name = "linear_indexing";
147
+ break;
127
148
  }
128
149
  result.insert(name);
129
150
  }
@@ -47,7 +47,7 @@ std::shared_ptr<GPUTexture> GPUCanvasContext::getCurrentTexture() {
47
47
  _surfaceInfo->reconfigure(width, height);
48
48
  }
49
49
  auto texture = _surfaceInfo->getCurrentTexture();
50
- return std::make_shared<GPUTexture>(texture, "");
50
+ return std::make_shared<GPUTexture>(texture, "", false);
51
51
  }
52
52
 
53
53
  void GPUCanvasContext::present() {
@@ -10,10 +10,10 @@
10
10
 
11
11
  #include "jsi2/NativeObject.h"
12
12
 
13
- #include "rnwgpu/Canvas.h"
14
13
  #include "GPU.h"
15
- #include "descriptors/GPUCanvasConfiguration.h"
16
14
  #include "GPUTexture.h"
15
+ #include "descriptors/GPUCanvasConfiguration.h"
16
+ #include "rnwgpu/Canvas.h"
17
17
  #include "rnwgpu/SurfaceRegistry.h"
18
18
 
19
19
  namespace rnwgpu {
@@ -89,9 +89,6 @@ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
89
89
  case wgpu::FeatureName::Unorm16TextureFormats:
90
90
  *outUnion = "unorm16-texture-formats";
91
91
  break;
92
- case wgpu::FeatureName::Snorm16TextureFormats:
93
- *outUnion = "snorm16-texture-formats";
94
- break;
95
92
  case wgpu::FeatureName::MultiPlanarFormatExtendedUsages:
96
93
  *outUnion = "multi-planar-format-extended-usages";
97
94
  break;
@@ -122,18 +119,12 @@ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
122
119
  case wgpu::FeatureName::AdapterPropertiesVk:
123
120
  *outUnion = "adapter-properties-vk";
124
121
  break;
125
- case wgpu::FeatureName::R8UnormStorage:
126
- *outUnion = "r8unorm-storage";
127
- break;
128
122
  case wgpu::FeatureName::DawnFormatCapabilities:
129
123
  *outUnion = "format-capabilities";
130
124
  break;
131
125
  case wgpu::FeatureName::DawnDrmFormatCapabilities:
132
126
  *outUnion = "drm-format-capabilities";
133
127
  break;
134
- case wgpu::FeatureName::Norm16TextureFormats:
135
- *outUnion = "norm16-texture-formats";
136
- break;
137
128
  case wgpu::FeatureName::MultiPlanarFormatNv16:
138
129
  *outUnion = "multi-planar-format-nv16";
139
130
  break;
@@ -21,8 +21,10 @@ class GPUTexture : public NativeObject<GPUTexture> {
21
21
  public:
22
22
  static constexpr const char *CLASS_NAME = "GPUTexture";
23
23
 
24
- explicit GPUTexture(wgpu::Texture instance, std::string label)
25
- : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
24
+ explicit GPUTexture(wgpu::Texture instance, std::string label,
25
+ bool reportsMemoryPressure = true)
26
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label),
27
+ _reportsMemoryPressure(reportsMemoryPressure) {}
26
28
 
27
29
  public:
28
30
  std::string getBrand() { return CLASS_NAME; }
@@ -68,6 +70,9 @@ public:
68
70
  inline const wgpu::Texture get() { return _instance; }
69
71
 
70
72
  size_t getMemoryPressure() override {
73
+ if (!_reportsMemoryPressure) {
74
+ return sizeof(GPUTexture);
75
+ }
71
76
  // Calculate approximate memory usage based on texture properties
72
77
  uint32_t width = getWidth();
73
78
  uint32_t height = getHeight();
@@ -85,6 +90,7 @@ public:
85
90
  case wgpu::TextureFormat::R8Snorm:
86
91
  case wgpu::TextureFormat::R8Uint:
87
92
  case wgpu::TextureFormat::R8Sint:
93
+ case wgpu::TextureFormat::Stencil8:
88
94
  bytesPerPixel = 1;
89
95
  break;
90
96
  case wgpu::TextureFormat::R16Uint:
@@ -94,6 +100,7 @@ public:
94
100
  case wgpu::TextureFormat::RG8Snorm:
95
101
  case wgpu::TextureFormat::RG8Uint:
96
102
  case wgpu::TextureFormat::RG8Sint:
103
+ case wgpu::TextureFormat::Depth16Unorm:
97
104
  bytesPerPixel = 2;
98
105
  break;
99
106
  case wgpu::TextureFormat::RGBA8Unorm:
@@ -110,6 +117,9 @@ public:
110
117
  case wgpu::TextureFormat::RG16Uint:
111
118
  case wgpu::TextureFormat::RG16Sint:
112
119
  case wgpu::TextureFormat::RG16Float:
120
+ case wgpu::TextureFormat::Depth24Plus:
121
+ case wgpu::TextureFormat::Depth24PlusStencil8:
122
+ case wgpu::TextureFormat::Depth32Float:
113
123
  bytesPerPixel = 4;
114
124
  break;
115
125
  case wgpu::TextureFormat::RG32Float:
@@ -118,6 +128,7 @@ public:
118
128
  case wgpu::TextureFormat::RGBA16Uint:
119
129
  case wgpu::TextureFormat::RGBA16Sint:
120
130
  case wgpu::TextureFormat::RGBA16Float:
131
+ case wgpu::TextureFormat::Depth32FloatStencil8:
121
132
  bytesPerPixel = 8;
122
133
  break;
123
134
  case wgpu::TextureFormat::RGBA32Float:
@@ -145,6 +156,7 @@ public:
145
156
  private:
146
157
  wgpu::Texture _instance;
147
158
  std::string _label;
159
+ bool _reportsMemoryPressure = true;
148
160
  };
149
161
 
150
162
  } // namespace rnwgpu