@nativescript/canvas 2.0.0-beta.8 → 2.0.0-webgpu.0

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 (284) hide show
  1. package/Canvas/common.d.ts +23 -15
  2. package/Canvas/common.js +125 -56
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +5 -7
  5. package/Canvas/index.android.js +61 -133
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +4 -1
  8. package/Canvas/index.ios.d.ts +6 -6
  9. package/Canvas/index.ios.js +75 -85
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -1
  12. package/Canvas2D/CanvasRenderingContext2D/index.js +8 -11
  13. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  14. package/Canvas2D/DOMMatrix/index.d.ts +14 -0
  15. package/Canvas2D/DOMMatrix/index.js +62 -0
  16. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  17. package/Canvas2D/ImageData/index.js +4 -6
  18. package/Canvas2D/ImageData/index.js.map +1 -1
  19. package/ImageAsset/index.d.ts +1 -0
  20. package/ImageAsset/index.js +49 -0
  21. package/ImageAsset/index.js.map +1 -1
  22. package/WebGL/WebGLRenderingContext/index.d.ts +1 -0
  23. package/WebGL/WebGLRenderingContext/index.js +104 -14
  24. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  25. package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -0
  26. package/WebGL2/WebGL2RenderingContext/index.js +2 -3
  27. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  28. package/WebGPU/Constants.d.ts +36 -0
  29. package/WebGPU/Constants.js +42 -0
  30. package/WebGPU/Constants.js.map +1 -0
  31. package/WebGPU/Errors.d.ts +18 -0
  32. package/WebGPU/Errors.js +21 -0
  33. package/WebGPU/Errors.js.map +1 -0
  34. package/WebGPU/GPU.d.ts +13 -0
  35. package/WebGPU/GPU.js +35 -0
  36. package/WebGPU/GPU.js.map +1 -0
  37. package/WebGPU/GPUAdapter.d.ts +23 -0
  38. package/WebGPU/GPUAdapter.js +62 -0
  39. package/WebGPU/GPUAdapter.js.map +1 -0
  40. package/WebGPU/GPUAdapterInfo.d.ts +9 -0
  41. package/WebGPU/GPUAdapterInfo.js +24 -0
  42. package/WebGPU/GPUAdapterInfo.js.map +1 -0
  43. package/WebGPU/GPUBindGroup.d.ts +5 -0
  44. package/WebGPU/GPUBindGroup.js +12 -0
  45. package/WebGPU/GPUBindGroup.js.map +1 -0
  46. package/WebGPU/GPUBindGroupLayout.d.ts +5 -0
  47. package/WebGPU/GPUBindGroupLayout.js +12 -0
  48. package/WebGPU/GPUBindGroupLayout.js.map +1 -0
  49. package/WebGPU/GPUBuffer.d.ts +15 -0
  50. package/WebGPU/GPUBuffer.js +54 -0
  51. package/WebGPU/GPUBuffer.js.map +1 -0
  52. package/WebGPU/GPUCanvasContext.d.ts +33 -0
  53. package/WebGPU/GPUCanvasContext.js +67 -0
  54. package/WebGPU/GPUCanvasContext.js.map +1 -0
  55. package/WebGPU/GPUCommandBuffer.d.ts +5 -0
  56. package/WebGPU/GPUCommandBuffer.js +12 -0
  57. package/WebGPU/GPUCommandBuffer.js.map +1 -0
  58. package/WebGPU/GPUCommandEncoder.d.ts +41 -0
  59. package/WebGPU/GPUCommandEncoder.js +105 -0
  60. package/WebGPU/GPUCommandEncoder.js.map +1 -0
  61. package/WebGPU/GPUComputePassEncoder.d.ts +16 -0
  62. package/WebGPU/GPUComputePassEncoder.js +50 -0
  63. package/WebGPU/GPUComputePassEncoder.js.map +1 -0
  64. package/WebGPU/GPUComputePipeline.d.ts +7 -0
  65. package/WebGPU/GPUComputePipeline.js +16 -0
  66. package/WebGPU/GPUComputePipeline.js.map +1 -0
  67. package/WebGPU/GPUDevice.d.ts +173 -0
  68. package/WebGPU/GPUDevice.js +381 -0
  69. package/WebGPU/GPUDevice.js.map +1 -0
  70. package/WebGPU/GPUDeviceLostInfo.d.ts +1 -0
  71. package/WebGPU/GPUDeviceLostInfo.js +10 -0
  72. package/WebGPU/GPUDeviceLostInfo.js.map +1 -0
  73. package/WebGPU/GPUExternalTexture.d.ts +5 -0
  74. package/WebGPU/GPUExternalTexture.js +12 -0
  75. package/WebGPU/GPUExternalTexture.js.map +1 -0
  76. package/WebGPU/GPUPipelineLayout.d.ts +5 -0
  77. package/WebGPU/GPUPipelineLayout.js +12 -0
  78. package/WebGPU/GPUPipelineLayout.js.map +1 -0
  79. package/WebGPU/GPUQuerySet.d.ts +5 -0
  80. package/WebGPU/GPUQuerySet.js +12 -0
  81. package/WebGPU/GPUQuerySet.js.map +1 -0
  82. package/WebGPU/GPUQueue.d.ts +14 -0
  83. package/WebGPU/GPUQueue.js +77 -0
  84. package/WebGPU/GPUQueue.js.map +1 -0
  85. package/WebGPU/GPURenderBundle.d.ts +5 -0
  86. package/WebGPU/GPURenderBundle.js +12 -0
  87. package/WebGPU/GPURenderBundle.js.map +1 -0
  88. package/WebGPU/GPURenderBundleEncoder.d.ts +20 -0
  89. package/WebGPU/GPURenderBundleEncoder.js +61 -0
  90. package/WebGPU/GPURenderBundleEncoder.js.map +1 -0
  91. package/WebGPU/GPURenderPassEncoder.d.ts +29 -0
  92. package/WebGPU/GPURenderPassEncoder.js +94 -0
  93. package/WebGPU/GPURenderPassEncoder.js.map +1 -0
  94. package/WebGPU/GPURenderPipeline.d.ts +7 -0
  95. package/WebGPU/GPURenderPipeline.js +16 -0
  96. package/WebGPU/GPURenderPipeline.js.map +1 -0
  97. package/WebGPU/GPUSampler.d.ts +5 -0
  98. package/WebGPU/GPUSampler.js +12 -0
  99. package/WebGPU/GPUSampler.js.map +1 -0
  100. package/WebGPU/GPUShaderModule.d.ts +6 -0
  101. package/WebGPU/GPUShaderModule.js +15 -0
  102. package/WebGPU/GPUShaderModule.js.map +1 -0
  103. package/WebGPU/GPUTexture.d.ts +16 -0
  104. package/WebGPU/GPUTexture.js +41 -0
  105. package/WebGPU/GPUTexture.js.map +1 -0
  106. package/WebGPU/GPUTextureView.d.ts +5 -0
  107. package/WebGPU/GPUTextureView.js +12 -0
  108. package/WebGPU/GPUTextureView.js.map +1 -0
  109. package/WebGPU/Interfaces.d.ts +155 -0
  110. package/WebGPU/Interfaces.js +2 -0
  111. package/WebGPU/Interfaces.js.map +1 -0
  112. package/WebGPU/Types.d.ts +39 -0
  113. package/WebGPU/Types.js +2 -0
  114. package/WebGPU/Types.js.map +1 -0
  115. package/WebGPU/Utils.d.ts +1 -0
  116. package/WebGPU/Utils.js +75 -0
  117. package/WebGPU/Utils.js.map +1 -0
  118. package/WebGPU/index.d.ts +28 -0
  119. package/WebGPU/index.js +29 -0
  120. package/WebGPU/index.js.map +1 -0
  121. package/index.d.ts +1 -1
  122. package/index.js +22 -1
  123. package/index.js.map +1 -1
  124. package/package.json +1 -4
  125. package/platforms/android/canvas-release.aar +0 -0
  126. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  127. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +23 -23
  128. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +47 -8
  129. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2280 -103
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1564 -3814
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -34
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +27 -34
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +602 -664
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +46 -46
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +47 -8
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2280 -103
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1564 -3814
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -34
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +27 -34
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1564 -3814
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -34
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +27 -34
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +31 -31
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +604 -663
  156. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -642
  157. package/platforms/ios/build.xcconfig +3 -1
  158. package/platforms/ios/src/cpp/Caches.h +69 -1
  159. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +320 -395
  160. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -1
  161. package/platforms/ios/src/cpp/Helpers.h +43 -8
  162. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +35 -37
  163. package/platforms/ios/src/cpp/ImageAssetImpl.h +14 -10
  164. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +2 -2
  165. package/platforms/ios/src/cpp/ImageBitmapImpl.h +1 -1
  166. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +0 -10
  167. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +41 -4
  168. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
  169. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
  170. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +131 -149
  171. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
  172. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +302 -0
  173. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
  174. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
  175. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
  176. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +53 -0
  177. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +45 -0
  178. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +53 -0
  179. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +45 -0
  180. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +229 -0
  181. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +59 -0
  182. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +317 -0
  183. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +55 -0
  184. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +54 -0
  185. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +45 -0
  186. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1087 -0
  187. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +69 -0
  188. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +260 -0
  189. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +62 -0
  190. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +84 -0
  191. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +49 -0
  192. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +2741 -0
  193. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +95 -0
  194. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +186 -0
  195. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
  196. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +54 -0
  197. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +46 -0
  198. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +137 -0
  199. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
  200. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +521 -0
  201. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +56 -0
  202. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +469 -0
  203. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +71 -0
  204. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +53 -0
  205. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +45 -0
  206. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +653 -0
  207. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +85 -0
  208. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +84 -0
  209. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +49 -0
  210. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +53 -0
  211. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +45 -0
  212. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +56 -0
  213. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +45 -0
  214. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
  215. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
  216. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +360 -0
  217. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +75 -0
  218. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +53 -0
  219. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +45 -0
  220. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +178 -0
  221. package/SVG/Circle.d.ts +0 -11
  222. package/SVG/Circle.js +0 -21
  223. package/SVG/Circle.js.map +0 -1
  224. package/SVG/ClipPath.d.ts +0 -4
  225. package/SVG/ClipPath.js +0 -9
  226. package/SVG/ClipPath.js.map +0 -1
  227. package/SVG/Defs.d.ts +0 -4
  228. package/SVG/Defs.js +0 -9
  229. package/SVG/Defs.js.map +0 -1
  230. package/SVG/Ellipse.d.ts +0 -13
  231. package/SVG/Ellipse.js +0 -26
  232. package/SVG/Ellipse.js.map +0 -1
  233. package/SVG/G.d.ts +0 -7
  234. package/SVG/G.js +0 -9
  235. package/SVG/G.js.map +0 -1
  236. package/SVG/Image.d.ts +0 -11
  237. package/SVG/Image.js +0 -40
  238. package/SVG/Image.js.map +0 -1
  239. package/SVG/Line.d.ts +0 -13
  240. package/SVG/Line.js +0 -26
  241. package/SVG/Line.js.map +0 -1
  242. package/SVG/LinearGradient.d.ts +0 -10
  243. package/SVG/LinearGradient.js +0 -13
  244. package/SVG/LinearGradient.js.map +0 -1
  245. package/SVG/Path.d.ts +0 -7
  246. package/SVG/Path.js +0 -14
  247. package/SVG/Path.js.map +0 -1
  248. package/SVG/Pattern.d.ts +0 -4
  249. package/SVG/Pattern.js +0 -9
  250. package/SVG/Pattern.js.map +0 -1
  251. package/SVG/Polygon.d.ts +0 -7
  252. package/SVG/Polygon.js +0 -14
  253. package/SVG/Polygon.js.map +0 -1
  254. package/SVG/Polyline.d.ts +0 -7
  255. package/SVG/Polyline.js +0 -14
  256. package/SVG/Polyline.js.map +0 -1
  257. package/SVG/Rect.d.ts +0 -8
  258. package/SVG/Rect.js +0 -13
  259. package/SVG/Rect.js.map +0 -1
  260. package/SVG/SVG.d.ts +0 -32
  261. package/SVG/SVG.js +0 -204
  262. package/SVG/SVG.js.map +0 -1
  263. package/SVG/SVGItem.d.ts +0 -5
  264. package/SVG/SVGItem.js +0 -8
  265. package/SVG/SVGItem.js.map +0 -1
  266. package/SVG/Stop.d.ts +0 -5
  267. package/SVG/Stop.js +0 -9
  268. package/SVG/Stop.js.map +0 -1
  269. package/SVG/Symbol.d.ts +0 -4
  270. package/SVG/Symbol.js +0 -9
  271. package/SVG/Symbol.js.map +0 -1
  272. package/SVG/Text.d.ts +0 -14
  273. package/SVG/Text.js +0 -26
  274. package/SVG/Text.js.map +0 -1
  275. package/SVG/Use.d.ts +0 -4
  276. package/SVG/Use.js +0 -9
  277. package/SVG/Use.js.map +0 -1
  278. package/SVG/index.d.ts +0 -18
  279. package/SVG/index.js +0 -19
  280. package/SVG/index.js.map +0 -1
  281. package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
  282. package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
  283. package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
  284. package/platforms/ios/src/cpp/URLImpl.h +0 -121
@@ -0,0 +1,288 @@
1
+ //
2
+ // Created by Osei Fortune on 17/06/2024.
3
+ //
4
+
5
+ #ifndef CANVAS_ANDROID_GPUSUPPORTEDLIMITSIMPL_H
6
+ #define CANVAS_ANDROID_GPUSUPPORTEDLIMITSIMPL_H
7
+
8
+ #include "Helpers.h"
9
+ #include "ObjectWrapperImpl.h"
10
+
11
+ class GPUSupportedLimitsImpl : public ObjectWrapperImpl {
12
+ public:
13
+ GPUSupportedLimitsImpl(CanvasGPUSupportedLimits *limits);
14
+
15
+ ~GPUSupportedLimitsImpl() {
16
+ canvas_native_webgpu_limits_release(this->limits_);
17
+ }
18
+
19
+ CanvasGPUSupportedLimits *GetLimits();
20
+
21
+ static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUSupportedLimitsImpl *limits) {
22
+ auto context = isolate->GetCurrentContext();
23
+ v8::EscapableHandleScope scope(isolate);
24
+ auto object = GPUSupportedLimitsImpl::GetCtor(isolate)->GetFunction(
25
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
26
+ SetNativeType(object, NativeType::GPUSupportedLimits);
27
+ object->SetAlignedPointerInInternalField(0, limits);
28
+ limits->BindFinalizer(isolate, object);
29
+ return scope.Escape(object);
30
+ }
31
+
32
+ static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
33
+
34
+ static GPUSupportedLimitsImpl *GetPointer(v8::Local<v8::Object> object);
35
+
36
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
37
+
38
+ static void Ctor(const v8::FunctionCallbackInfo<v8::Value> &args);
39
+
40
+ static void GetMaxTextureDimension1D(v8::Local<v8::String> property,
41
+ const v8::PropertyCallbackInfo<v8::Value> &info);
42
+
43
+ static void SetMaxTextureDimension1D(v8::Local<v8::String> property,
44
+ v8::Local<v8::Value> value,
45
+ const v8::PropertyCallbackInfo<void> &info);
46
+
47
+ static void GetMaxTextureDimension2D(v8::Local<v8::String> property,
48
+ const v8::PropertyCallbackInfo<v8::Value> &info);
49
+
50
+ static void SetMaxTextureDimension2D(v8::Local<v8::String> property,
51
+ v8::Local<v8::Value> value,
52
+ const v8::PropertyCallbackInfo<void> &info);
53
+
54
+ static void GetMaxTextureDimension3D(v8::Local<v8::String> property,
55
+ const v8::PropertyCallbackInfo<v8::Value> &info);
56
+
57
+ static void SetMaxTextureDimension3D(v8::Local<v8::String> property,
58
+ v8::Local<v8::Value> value,
59
+ const v8::PropertyCallbackInfo<void> &info);
60
+
61
+ static void GetMaxTextureArrayLayers(v8::Local<v8::String> property,
62
+ const v8::PropertyCallbackInfo<v8::Value> &info);
63
+
64
+ static void SetMaxTextureArrayLayers(v8::Local<v8::String> property,
65
+ v8::Local<v8::Value> value,
66
+ const v8::PropertyCallbackInfo<void> &info);
67
+
68
+ static void GetMaxBindGroups(v8::Local<v8::String> property,
69
+ const v8::PropertyCallbackInfo<v8::Value> &info);
70
+
71
+ static void SetMaxBindGroups(v8::Local<v8::String> property,
72
+ v8::Local<v8::Value> value,
73
+ const v8::PropertyCallbackInfo<void> &info);
74
+
75
+ static void GetMaxBindingsPerBindGroup(v8::Local<v8::String> property,
76
+ const v8::PropertyCallbackInfo<v8::Value> &info);
77
+
78
+ static void SetMaxBindingsPerBindGroup(v8::Local<v8::String> property,
79
+ v8::Local<v8::Value> value,
80
+ const v8::PropertyCallbackInfo<void> &info);
81
+
82
+
83
+ static void GetMaxDynamicUniformBuffersPerPipelineLayout(v8::Local<v8::String> property,
84
+ const v8::PropertyCallbackInfo<v8::Value> &info);
85
+
86
+ static void SetMaxDynamicUniformBuffersPerPipelineLayout(v8::Local<v8::String> property,
87
+ v8::Local<v8::Value> value,
88
+ const v8::PropertyCallbackInfo<void> &info);
89
+
90
+ static void GetMaxDynamicStorageBuffersPerPipelineLayout(v8::Local<v8::String> property,
91
+ const v8::PropertyCallbackInfo<v8::Value> &info);
92
+
93
+ static void SetMaxDynamicStorageBuffersPerPipelineLayout(v8::Local<v8::String> property,
94
+ v8::Local<v8::Value> value,
95
+ const v8::PropertyCallbackInfo<void> &info);
96
+
97
+ static void GetMaxSampledTexturesPerShaderStage(v8::Local<v8::String> property,
98
+ const v8::PropertyCallbackInfo<v8::Value> &info);
99
+
100
+ static void SetMaxSampledTexturesPerShaderStage(v8::Local<v8::String> property,
101
+ v8::Local<v8::Value> value,
102
+ const v8::PropertyCallbackInfo<void> &info);
103
+
104
+ static void GetMaxSamplersPerShaderStage(v8::Local<v8::String> property,
105
+ const v8::PropertyCallbackInfo<v8::Value> &info);
106
+
107
+ static void SetMaxSamplersPerShaderStage(v8::Local<v8::String> property,
108
+ v8::Local<v8::Value> value,
109
+ const v8::PropertyCallbackInfo<void> &info);
110
+
111
+
112
+ static void GetMaxStorageBuffersPerShaderStage(v8::Local<v8::String> property,
113
+ const v8::PropertyCallbackInfo<v8::Value> &info);
114
+
115
+ static void SetMaxStorageBuffersPerShaderStage(v8::Local<v8::String> property,
116
+ v8::Local<v8::Value> value,
117
+ const v8::PropertyCallbackInfo<void> &info);
118
+
119
+ static void GetMaxStorageTexturesPerShaderStage(v8::Local<v8::String> property,
120
+ const v8::PropertyCallbackInfo<v8::Value> &info);
121
+
122
+ static void SetMaxStorageTexturesPerShaderStage(v8::Local<v8::String> property,
123
+ v8::Local<v8::Value> value,
124
+ const v8::PropertyCallbackInfo<void> &info);
125
+
126
+ static void GetMaxUniformBuffersPerShaderStage(v8::Local<v8::String> property,
127
+ const v8::PropertyCallbackInfo<v8::Value> &info);
128
+
129
+ static void SetMaxUniformBuffersPerShaderStage(v8::Local<v8::String> property,
130
+ v8::Local<v8::Value> value,
131
+ const v8::PropertyCallbackInfo<void> &info);
132
+
133
+ static void GetMaxUniformBufferBindingSize(v8::Local<v8::String> property,
134
+ const v8::PropertyCallbackInfo<v8::Value> &info);
135
+
136
+ static void SetMaxUniformBufferBindingSize(v8::Local<v8::String> property,
137
+ v8::Local<v8::Value> value,
138
+ const v8::PropertyCallbackInfo<void> &info);
139
+
140
+ static void GetMaxStorageBufferBindingSize(v8::Local<v8::String> property,
141
+ const v8::PropertyCallbackInfo<v8::Value> &info);
142
+
143
+ static void SetMaxStorageBufferBindingSize(v8::Local<v8::String> property,
144
+ v8::Local<v8::Value> value,
145
+ const v8::PropertyCallbackInfo<void> &info);
146
+
147
+ static void GetMaxVertexBuffers(v8::Local<v8::String> property,
148
+ const v8::PropertyCallbackInfo<v8::Value> &info);
149
+
150
+ static void SetMaxVertexBuffers(v8::Local<v8::String> property,
151
+ v8::Local<v8::Value> value,
152
+ const v8::PropertyCallbackInfo<void> &info);
153
+
154
+ static void GetMaxBufferSize(v8::Local<v8::String> property,
155
+ const v8::PropertyCallbackInfo<v8::Value> &info);
156
+
157
+ static void SetMaxBufferSize(v8::Local<v8::String> property,
158
+ v8::Local<v8::Value> value,
159
+ const v8::PropertyCallbackInfo<void> &info);
160
+
161
+ static void GetMaxVertexAttributes(v8::Local<v8::String> property,
162
+ const v8::PropertyCallbackInfo<v8::Value> &info);
163
+
164
+ static void SetMaxVertexAttributes(v8::Local<v8::String> property,
165
+ v8::Local<v8::Value> value,
166
+ const v8::PropertyCallbackInfo<void> &info);
167
+
168
+ static void GetMaxVertexBufferArrayStride(v8::Local<v8::String> property,
169
+ const v8::PropertyCallbackInfo<v8::Value> &info);
170
+
171
+ static void SetMaxVertexBufferArrayStride(v8::Local<v8::String> property,
172
+ v8::Local<v8::Value> value,
173
+ const v8::PropertyCallbackInfo<void> &info);
174
+
175
+ static void GetMinUniformBufferOffsetAlignment(v8::Local<v8::String> property,
176
+ const v8::PropertyCallbackInfo<v8::Value> &info);
177
+
178
+ static void SetMinUniformBufferOffsetAlignment(v8::Local<v8::String> property,
179
+ v8::Local<v8::Value> value,
180
+ const v8::PropertyCallbackInfo<void> &info);
181
+
182
+ static void GetMinStorageBufferOffsetAlignment(v8::Local<v8::String> property,
183
+ const v8::PropertyCallbackInfo<v8::Value> &info);
184
+
185
+ static void SetMinStorageBufferOffsetAlignment(v8::Local<v8::String> property,
186
+ v8::Local<v8::Value> value,
187
+ const v8::PropertyCallbackInfo<void> &info);
188
+
189
+ static void GetMaxInterStageShaderComponents(v8::Local<v8::String> property,
190
+ const v8::PropertyCallbackInfo<v8::Value> &info);
191
+
192
+ static void SetMaxInterStageShaderComponents(v8::Local<v8::String> property,
193
+ v8::Local<v8::Value> value,
194
+ const v8::PropertyCallbackInfo<void> &info);
195
+
196
+ static void GetMaxColorAttachments(v8::Local<v8::String> property,
197
+ const v8::PropertyCallbackInfo<v8::Value> &info);
198
+
199
+ static void SetMaxColorAttachments(v8::Local<v8::String> property,
200
+ v8::Local<v8::Value> value,
201
+ const v8::PropertyCallbackInfo<void> &info);
202
+
203
+ static void GetMaxColorAttachmentBytesPerSample(v8::Local<v8::String> property,
204
+ const v8::PropertyCallbackInfo<v8::Value> &info);
205
+
206
+ static void SetMaxColorAttachmentBytesPerSample(v8::Local<v8::String> property,
207
+ v8::Local<v8::Value> value,
208
+ const v8::PropertyCallbackInfo<void> &info);
209
+
210
+ static void GetMaxComputeWorkgroupStorageSize(v8::Local<v8::String> property,
211
+ const v8::PropertyCallbackInfo<v8::Value> &info);
212
+
213
+ static void SetMaxComputeWorkgroupStorageSize(v8::Local<v8::String> property,
214
+ v8::Local<v8::Value> value,
215
+ const v8::PropertyCallbackInfo<void> &info);
216
+
217
+ static void GetMaxComputeInvocationsPerWorkgroup(v8::Local<v8::String> property,
218
+ const v8::PropertyCallbackInfo<v8::Value> &info);
219
+
220
+
221
+ static void SetMaxComputeInvocationsPerWorkgroup(v8::Local<v8::String> property,
222
+ v8::Local<v8::Value> value,
223
+ const v8::PropertyCallbackInfo<void> &info);
224
+
225
+ static void GetMaxComputeWorkgroupSizeX(v8::Local<v8::String> property,
226
+ const v8::PropertyCallbackInfo<v8::Value> &info);
227
+
228
+ static void SetMaxComputeWorkgroupSizeX(v8::Local<v8::String> property,
229
+ v8::Local<v8::Value> value,
230
+ const v8::PropertyCallbackInfo<void> &info);
231
+
232
+ static void GetMaxComputeWorkgroupSizeY(v8::Local<v8::String> property,
233
+ const v8::PropertyCallbackInfo<v8::Value> &info);
234
+
235
+ static void SetMaxComputeWorkgroupSizeY(v8::Local<v8::String> property,
236
+ v8::Local<v8::Value> value,
237
+ const v8::PropertyCallbackInfo<void> &info);
238
+
239
+ static void GetMaxComputeWorkgroupSizeZ(v8::Local<v8::String> property,
240
+ const v8::PropertyCallbackInfo<v8::Value> &info);
241
+
242
+ static void SetMaxComputeWorkgroupSizeZ(v8::Local<v8::String> property,
243
+ v8::Local<v8::Value> value,
244
+ const v8::PropertyCallbackInfo<void> &info);
245
+
246
+ static void GetMaxComputeWorkgroupsPerDimension(v8::Local<v8::String> property,
247
+ const v8::PropertyCallbackInfo<v8::Value> &info);
248
+
249
+ static void SetMaxComputeWorkgroupsPerDimension(v8::Local<v8::String> property,
250
+ v8::Local<v8::Value> value,
251
+ const v8::PropertyCallbackInfo<void> &info);
252
+
253
+ static void GetMinSubgroupSize(v8::Local<v8::String> property,
254
+ const v8::PropertyCallbackInfo<v8::Value> &info);
255
+
256
+ static void SetMinSubgroupSize(v8::Local<v8::String> property,
257
+ v8::Local<v8::Value> value,
258
+ const v8::PropertyCallbackInfo<void> &info);
259
+
260
+ static void GetMaxSubgroupSize(v8::Local<v8::String> property,
261
+ const v8::PropertyCallbackInfo<v8::Value> &info);
262
+
263
+ static void SetMaxSubgroupSize(v8::Local<v8::String> property,
264
+ v8::Local<v8::Value> value,
265
+ const v8::PropertyCallbackInfo<void> &info);
266
+
267
+ static void GetMaxPushConstantSize(v8::Local<v8::String> property,
268
+ const v8::PropertyCallbackInfo<v8::Value> &info);
269
+
270
+
271
+ static void SetMaxPushConstantSize(v8::Local<v8::String> property,
272
+ v8::Local<v8::Value> value,
273
+ const v8::PropertyCallbackInfo<void> &info);
274
+
275
+ static void GetMaxNonSamplerBindings(v8::Local<v8::String> property,
276
+ const v8::PropertyCallbackInfo<v8::Value> &info);
277
+
278
+
279
+ static void SetMaxNonSamplerBindings(v8::Local<v8::String> property,
280
+ v8::Local<v8::Value> value,
281
+ const v8::PropertyCallbackInfo<void> &info);
282
+
283
+ private:
284
+ CanvasGPUSupportedLimits *limits_;
285
+ };
286
+
287
+
288
+ #endif //CANVAS_ANDROID_GPUSUPPORTEDLIMITSIMPL_H
@@ -0,0 +1,360 @@
1
+ //
2
+ // Created by Osei Fortune on 21/06/2024.
3
+ //
4
+
5
+ #include "GPUTextureImpl.h"
6
+ #include "Caches.h"
7
+ #include "GPUTextureViewImpl.h"
8
+
9
+ GPUTextureImpl::GPUTextureImpl(const CanvasGPUTexture *texture) : texture_(texture) {}
10
+
11
+ const CanvasGPUTexture *GPUTextureImpl::GetTexture() {
12
+ return this->texture_;
13
+ }
14
+
15
+
16
+ void GPUTextureImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
17
+ v8::Locker locker(isolate);
18
+ v8::Isolate::Scope isolate_scope(isolate);
19
+ v8::HandleScope handle_scope(isolate);
20
+
21
+ auto ctor = GetCtor(isolate);
22
+ auto context = isolate->GetCurrentContext();
23
+ auto func = ctor->GetFunction(context).ToLocalChecked();
24
+
25
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUTexture"), func).FromJust();
26
+ }
27
+
28
+ GPUTextureImpl *GPUTextureImpl::GetPointer(const v8::Local<v8::Object> &object) {
29
+ auto ptr = object->GetAlignedPointerFromInternalField(0);
30
+ if (ptr == nullptr) {
31
+ return nullptr;
32
+ }
33
+ return static_cast<GPUTextureImpl *>(ptr);
34
+ }
35
+
36
+ v8::Local<v8::FunctionTemplate> GPUTextureImpl::GetCtor(v8::Isolate *isolate) {
37
+ auto cache = Caches::Get(isolate);
38
+ auto ctor = cache->GPUTextureTmpl.get();
39
+ if (ctor != nullptr) {
40
+ return ctor->Get(isolate);
41
+ }
42
+
43
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
44
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
45
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUTexture"));
46
+
47
+ auto tmpl = ctorTmpl->InstanceTemplate();
48
+ tmpl->SetInternalFieldCount(2);
49
+
50
+
51
+ tmpl->Set(
52
+ ConvertToV8String(isolate, "destroy"),
53
+ v8::FunctionTemplate::New(isolate, &Destroy));
54
+
55
+
56
+ tmpl->SetLazyDataProperty(
57
+ ConvertToV8String(isolate, "width"),
58
+ GetWidth
59
+ );
60
+
61
+
62
+ tmpl->SetLazyDataProperty(
63
+ ConvertToV8String(isolate, "height"),
64
+ GetHeight
65
+ );
66
+
67
+ tmpl->SetLazyDataProperty(
68
+ ConvertToV8String(isolate, "format"),
69
+ GetFormat
70
+ );
71
+
72
+ tmpl->SetLazyDataProperty(
73
+ ConvertToV8String(isolate, "usage"),
74
+ GetUsage
75
+ );
76
+
77
+
78
+ tmpl->SetLazyDataProperty(
79
+ ConvertToV8String(isolate, "depthOrArrayLayers"),
80
+ GetDepthOrArrayLayers
81
+ );
82
+
83
+
84
+ tmpl->SetLazyDataProperty(
85
+ ConvertToV8String(isolate, "dimension"),
86
+ GetDimension
87
+ );
88
+
89
+
90
+ tmpl->SetLazyDataProperty(
91
+ ConvertToV8String(isolate, "sampleCount"),
92
+ GetSampleCount
93
+ );
94
+
95
+
96
+ tmpl->SetLazyDataProperty(
97
+ ConvertToV8String(isolate, "mipLevelCount"),
98
+ GetMipLevelCount
99
+ );
100
+
101
+ tmpl->Set(
102
+ ConvertToV8String(isolate, "createView"),
103
+ v8::FunctionTemplate::New(isolate, &CreateView));
104
+
105
+ cache->GPUTextureTmpl =
106
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
107
+ return ctorTmpl;
108
+ }
109
+
110
+ void
111
+ GPUTextureImpl::GetDimension(v8::Local<v8::Name> name,
112
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
113
+ auto ptr = GetPointer(info.This());
114
+ if (ptr != nullptr) {
115
+ auto width = canvas_native_webgpu_texture_get_dimension(ptr->GetTexture());
116
+ auto isolate = info.GetIsolate();
117
+ switch (width) {
118
+ case CanvasTextureDimensionD1:
119
+ info.GetReturnValue().Set(ConvertToV8String(isolate, "1d"));
120
+ break;
121
+ case CanvasTextureDimensionD2:
122
+ info.GetReturnValue().Set(ConvertToV8String(isolate, "2d"));
123
+ break;
124
+ case CanvasTextureDimensionD3:
125
+ info.GetReturnValue().Set(ConvertToV8String(isolate, "3d"));
126
+ break;
127
+ }
128
+
129
+ return;
130
+ }
131
+ }
132
+
133
+
134
+ void
135
+ GPUTextureImpl::GetWidth(v8::Local<v8::Name> name,
136
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
137
+ auto ptr = GetPointer(info.This());
138
+ if (ptr != nullptr) {
139
+ auto width = canvas_native_webgpu_texture_get_width(ptr->GetTexture());
140
+ info.GetReturnValue().Set(width);
141
+ return;
142
+ }
143
+ info.GetReturnValue().Set(0);
144
+ }
145
+
146
+
147
+ void
148
+ GPUTextureImpl::GetHeight(v8::Local<v8::Name> name,
149
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
150
+ auto ptr = GetPointer(info.This());
151
+ if (ptr != nullptr) {
152
+ auto value = canvas_native_webgpu_texture_get_height(ptr->GetTexture());
153
+ info.GetReturnValue().Set(value);
154
+ return;
155
+ }
156
+ info.GetReturnValue().Set(0);
157
+ }
158
+
159
+ void
160
+ GPUTextureImpl::GetDepthOrArrayLayers(v8::Local<v8::Name> name,
161
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
162
+ auto ptr = GetPointer(info.This());
163
+ if (ptr != nullptr) {
164
+ auto value = canvas_native_webgpu_texture_get_depth_or_array_layers(ptr->GetTexture());
165
+ info.GetReturnValue().Set(value);
166
+ return;
167
+ }
168
+ info.GetReturnValue().Set(0);
169
+ }
170
+
171
+
172
+ void
173
+ GPUTextureImpl::GetUsage(v8::Local<v8::Name> name,
174
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
175
+ auto ptr = GetPointer(info.This());
176
+ if (ptr != nullptr) {
177
+ auto value = canvas_native_webgpu_texture_get_usage(ptr->GetTexture());
178
+ info.GetReturnValue().Set(value);
179
+ return;
180
+ }
181
+ info.GetReturnValue().Set(0);
182
+ }
183
+
184
+
185
+ void
186
+ GPUTextureImpl::GetFormat(v8::Local<v8::Name> name,
187
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
188
+ auto ptr = GetPointer(info.This());
189
+ if (ptr != nullptr) {
190
+ auto isolate = info.GetIsolate();
191
+ auto value = canvas_native_webgpu_texture_get_format(ptr->GetTexture());
192
+ auto str = canvas_native_webgpu_enum_gpu_texture_to_string(value);
193
+ info.GetReturnValue().Set(ConvertToV8String(isolate, str));
194
+ return;
195
+ }
196
+ info.GetReturnValue().Set(0);
197
+ }
198
+
199
+ void
200
+ GPUTextureImpl::GetSampleCount(v8::Local<v8::Name> name,
201
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
202
+ auto ptr = GetPointer(info.This());
203
+ if (ptr != nullptr) {
204
+ auto value = canvas_native_webgpu_texture_get_sample_count(ptr->GetTexture());
205
+ info.GetReturnValue().Set(value);
206
+ return;
207
+ }
208
+ info.GetReturnValue().Set(0);
209
+ }
210
+
211
+ void
212
+ GPUTextureImpl::GetMipLevelCount(v8::Local<v8::Name> name,
213
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
214
+ auto ptr = GetPointer(info.This());
215
+ if (ptr != nullptr) {
216
+ auto value = canvas_native_webgpu_texture_get_mip_level_count(ptr->GetTexture());
217
+ info.GetReturnValue().Set(value);
218
+ return;
219
+ }
220
+ info.GetReturnValue().Set(0);
221
+ }
222
+
223
+
224
+ void GPUTextureImpl::Destroy(const v8::FunctionCallbackInfo<v8::Value> &args) {
225
+ GPUTextureImpl *ptr = GetPointer(args.This());
226
+ if (ptr == nullptr) {
227
+ return;
228
+ }
229
+ canvas_native_webgpu_texture_destroy(ptr->GetTexture());
230
+ }
231
+
232
+
233
+ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args) {
234
+ GPUTextureImpl *ptr = GetPointer(args.This());
235
+ if (ptr == nullptr) {
236
+ args.GetReturnValue().SetUndefined();
237
+ return;
238
+ }
239
+ auto isolate = args.GetIsolate();
240
+ auto context = isolate->GetCurrentContext();
241
+
242
+ auto descVal = args[0];
243
+
244
+ CanvasCreateTextureViewDescriptor *descriptor = nullptr;
245
+
246
+ CanvasTextureAspect aspect = CanvasTextureAspectAll;
247
+
248
+ CanvasImageSubresourceRange range = {
249
+ aspect, 0, -1, 0, -1
250
+ };
251
+
252
+
253
+ if (descVal->IsObject()) {
254
+ descriptor = new CanvasCreateTextureViewDescriptor{};
255
+ descriptor->label = nullptr;
256
+ auto descObj = descVal.As<v8::Object>();
257
+
258
+ v8::Local<v8::Value> aspectVal;
259
+
260
+ if (descObj->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal)) {
261
+ auto aspectStr = ConvertFromV8String(isolate, aspectVal);
262
+ if (aspectStr == "all") {
263
+ aspect = CanvasTextureAspectAll;
264
+ } else if (aspectStr == "stencil-only") {
265
+ aspect = CanvasTextureAspectStencilOnly;
266
+ } else if (aspectStr == "depth-only") {
267
+ aspect = CanvasTextureAspectDepthOnly;
268
+ }
269
+ }
270
+
271
+
272
+
273
+ v8::Local<v8::Value> arrayLayerCountVal;
274
+ if (descObj->Get(context, ConvertToV8String(isolate, "arrayLayerCount")).ToLocal(
275
+ &arrayLayerCountVal) && arrayLayerCountVal->IsInt32()) {
276
+ range.array_layer_count = arrayLayerCountVal->Int32Value(context).FromJust();
277
+ }
278
+
279
+ v8::Local<v8::Value> mipLevelCountVal;
280
+ if (descObj->Get(context, ConvertToV8String(isolate, "mipLevelCount")).ToLocal(
281
+ &mipLevelCountVal) && mipLevelCountVal->IsInt32()) {
282
+ range.mip_level_count = mipLevelCountVal->Int32Value(context).FromJust();
283
+ }
284
+
285
+ v8::Local<v8::Value> baseArrayLayerVal;
286
+ if (descObj->Get(context, ConvertToV8String(isolate, "baseArrayLayer")).ToLocal(
287
+ &baseArrayLayerVal) && baseArrayLayerVal->IsUint32()) {
288
+ range.base_array_layer = baseArrayLayerVal->Uint32Value(context).FromJust();
289
+ }
290
+
291
+ v8::Local<v8::Value> baseMipLevelVal;
292
+ if (descObj->Get(context, ConvertToV8String(isolate, "baseMipLevel")).ToLocal(
293
+ &baseMipLevelVal) && baseMipLevelVal->IsUint32()) {
294
+ range.base_mip_level = baseMipLevelVal->Uint32Value(context).FromJust();
295
+ }
296
+
297
+ descriptor->range = &range;
298
+
299
+
300
+
301
+ v8::Local<v8::Value> formatVal;
302
+ descObj->Get(context, ConvertToV8String(isolate, "format")).ToLocal(&formatVal);
303
+ auto formatStr = ConvertFromV8String(isolate, formatVal);
304
+
305
+ descriptor->format = CanvasOptionalGPUTextureFormat {
306
+ CanvasOptionalGPUTextureFormatNone
307
+ };
308
+
309
+ if (!formatStr.empty()){
310
+ auto format = canvas_native_webgpu_enum_string_to_gpu_texture(formatStr.c_str());
311
+ descriptor->format = format;
312
+ }
313
+
314
+ auto dimension = CanvasOptionalTextureViewDimensionNone;
315
+
316
+
317
+ v8::Local<v8::Value> labelVal;
318
+ descObj->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
319
+
320
+ if (!labelVal.IsEmpty() && labelVal->IsString()) {
321
+ descriptor->label = *v8::String::Utf8Value(isolate, labelVal);
322
+ }
323
+
324
+ v8::Local<v8::Value> dimensionVal;
325
+ if (descObj->Get(context, ConvertToV8String(isolate, "dimension")).ToLocal(&dimensionVal)) {
326
+ auto dimensionStr = ConvertFromV8String(isolate, dimensionVal);
327
+ if (dimensionStr == "1d") {
328
+ dimension = CanvasOptionalTextureViewDimensionD1;
329
+ } else if (dimensionStr == "2d") {
330
+ dimension = CanvasOptionalTextureViewDimensionD2;
331
+ } else if (dimensionStr == "2d-array") {
332
+ dimension = CanvasOptionalTextureViewDimensionD2Array;
333
+ } else if (dimensionStr == "cube") {
334
+ dimension = CanvasOptionalTextureViewDimensionCube;
335
+ } else if (dimensionStr == "cube-array") {
336
+ dimension = CanvasOptionalTextureViewDimensionCubeArray;
337
+ } else if (dimensionStr == "3d") {
338
+ dimension = CanvasOptionalTextureViewDimensionD3;
339
+ }
340
+ }
341
+
342
+ descriptor->dimension = dimension;
343
+
344
+
345
+ }
346
+ auto view = canvas_native_webgpu_texture_create_texture_view(ptr->GetTexture(), descriptor);
347
+
348
+ if (descriptor != nullptr) {
349
+ delete descriptor;
350
+ }
351
+
352
+ if (view != nullptr) {
353
+ auto ret = GPUTextureViewImpl::NewInstance(isolate, new GPUTextureViewImpl(view));
354
+ args.GetReturnValue().Set(ret);
355
+ return;
356
+ }
357
+
358
+ args.GetReturnValue().SetUndefined();
359
+
360
+ }