@nativescript/canvas 2.0.0-beta.9 → 2.0.0-webgpu.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 (288) hide show
  1. package/Canvas/common.d.ts +24 -17
  2. package/Canvas/common.js +133 -66
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +5 -7
  5. package/Canvas/index.android.js +62 -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 +4 -5
  9. package/Canvas/index.ios.js +73 -82
  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 +86 -32
  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 +35 -0
  53. package/WebGPU/GPUCanvasContext.js +76 -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 +110 -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 +356 -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 +17 -0
  104. package/WebGPU/GPUTexture.js +44 -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/common.d.ts +0 -3
  122. package/common.js +1 -5
  123. package/common.js.map +1 -1
  124. package/index.d.ts +1 -1
  125. package/index.js +22 -1
  126. package/index.js.map +1 -1
  127. package/package.json +1 -4
  128. package/platforms/android/canvas-release.aar +0 -0
  129. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +23 -23
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +41 -8
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2318 -103
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1563 -3729
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -34
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +27 -34
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +602 -663
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +46 -46
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +41 -8
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2318 -103
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1563 -3729
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -34
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +27 -34
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1563 -3729
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -34
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  156. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +27 -34
  157. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +31 -31
  158. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  159. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +604 -662
  160. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -641
  161. package/platforms/ios/build.xcconfig +3 -1
  162. package/platforms/ios/src/cpp/Caches.h +69 -1
  163. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +320 -395
  164. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -1
  165. package/platforms/ios/src/cpp/Helpers.h +43 -8
  166. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +35 -37
  167. package/platforms/ios/src/cpp/ImageAssetImpl.h +14 -10
  168. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +2 -2
  169. package/platforms/ios/src/cpp/ImageBitmapImpl.h +1 -1
  170. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +0 -10
  171. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +41 -4
  172. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
  173. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
  174. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +131 -149
  175. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
  176. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +302 -0
  177. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
  178. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
  179. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
  180. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +53 -0
  181. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +45 -0
  182. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +53 -0
  183. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +45 -0
  184. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +229 -0
  185. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +59 -0
  186. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +317 -0
  187. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +55 -0
  188. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +54 -0
  189. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +45 -0
  190. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1222 -0
  191. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +69 -0
  192. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +260 -0
  193. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +62 -0
  194. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +84 -0
  195. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +49 -0
  196. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +2750 -0
  197. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +95 -0
  198. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +186 -0
  199. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
  200. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +54 -0
  201. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +46 -0
  202. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +137 -0
  203. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
  204. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +521 -0
  205. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +56 -0
  206. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +469 -0
  207. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +71 -0
  208. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +53 -0
  209. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +45 -0
  210. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +623 -0
  211. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +85 -0
  212. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +84 -0
  213. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +49 -0
  214. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +53 -0
  215. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +45 -0
  216. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +56 -0
  217. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +45 -0
  218. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
  219. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
  220. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +360 -0
  221. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +75 -0
  222. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +53 -0
  223. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +45 -0
  224. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +245 -0
  225. package/SVG/Circle.d.ts +0 -11
  226. package/SVG/Circle.js +0 -21
  227. package/SVG/Circle.js.map +0 -1
  228. package/SVG/ClipPath.d.ts +0 -4
  229. package/SVG/ClipPath.js +0 -9
  230. package/SVG/ClipPath.js.map +0 -1
  231. package/SVG/Defs.d.ts +0 -4
  232. package/SVG/Defs.js +0 -9
  233. package/SVG/Defs.js.map +0 -1
  234. package/SVG/Ellipse.d.ts +0 -13
  235. package/SVG/Ellipse.js +0 -26
  236. package/SVG/Ellipse.js.map +0 -1
  237. package/SVG/G.d.ts +0 -7
  238. package/SVG/G.js +0 -9
  239. package/SVG/G.js.map +0 -1
  240. package/SVG/Image.d.ts +0 -11
  241. package/SVG/Image.js +0 -40
  242. package/SVG/Image.js.map +0 -1
  243. package/SVG/Line.d.ts +0 -13
  244. package/SVG/Line.js +0 -26
  245. package/SVG/Line.js.map +0 -1
  246. package/SVG/LinearGradient.d.ts +0 -10
  247. package/SVG/LinearGradient.js +0 -13
  248. package/SVG/LinearGradient.js.map +0 -1
  249. package/SVG/Path.d.ts +0 -7
  250. package/SVG/Path.js +0 -14
  251. package/SVG/Path.js.map +0 -1
  252. package/SVG/Pattern.d.ts +0 -4
  253. package/SVG/Pattern.js +0 -9
  254. package/SVG/Pattern.js.map +0 -1
  255. package/SVG/Polygon.d.ts +0 -7
  256. package/SVG/Polygon.js +0 -14
  257. package/SVG/Polygon.js.map +0 -1
  258. package/SVG/Polyline.d.ts +0 -7
  259. package/SVG/Polyline.js +0 -14
  260. package/SVG/Polyline.js.map +0 -1
  261. package/SVG/Rect.d.ts +0 -8
  262. package/SVG/Rect.js +0 -13
  263. package/SVG/Rect.js.map +0 -1
  264. package/SVG/SVG.d.ts +0 -32
  265. package/SVG/SVG.js +0 -204
  266. package/SVG/SVG.js.map +0 -1
  267. package/SVG/SVGItem.d.ts +0 -5
  268. package/SVG/SVGItem.js +0 -8
  269. package/SVG/SVGItem.js.map +0 -1
  270. package/SVG/Stop.d.ts +0 -5
  271. package/SVG/Stop.js +0 -9
  272. package/SVG/Stop.js.map +0 -1
  273. package/SVG/Symbol.d.ts +0 -4
  274. package/SVG/Symbol.js +0 -9
  275. package/SVG/Symbol.js.map +0 -1
  276. package/SVG/Text.d.ts +0 -14
  277. package/SVG/Text.js +0 -26
  278. package/SVG/Text.js.map +0 -1
  279. package/SVG/Use.d.ts +0 -4
  280. package/SVG/Use.js +0 -9
  281. package/SVG/Use.js.map +0 -1
  282. package/SVG/index.d.ts +0 -18
  283. package/SVG/index.js +0 -19
  284. package/SVG/index.js.map +0 -1
  285. package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
  286. package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
  287. package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
  288. package/platforms/ios/src/cpp/URLImpl.h +0 -121
@@ -0,0 +1,623 @@
1
+ //
2
+ // Created by Osei Fortune on 01/07/2024.
3
+ //
4
+
5
+ #include "GPURenderPassEncoderImpl.h"
6
+ #include "Caches.h"
7
+ #include "GPURenderPipelineImpl.h"
8
+ #include "GPUBufferImpl.h"
9
+ #include "GPURenderBundleImpl.h"
10
+ #include "GPUQuerySetImpl.h"
11
+ #include "GPUBindGroupImpl.h"
12
+
13
+ GPURenderPassEncoderImpl::GPURenderPassEncoderImpl(const CanvasGPURenderPassEncoder *pass) : pass_(
14
+ pass) {}
15
+
16
+ const CanvasGPURenderPassEncoder *GPURenderPassEncoderImpl::GetPass() {
17
+ return this->pass_;
18
+ }
19
+
20
+
21
+ void GPURenderPassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
22
+ v8::Locker locker(isolate);
23
+ v8::Isolate::Scope isolate_scope(isolate);
24
+ v8::HandleScope handle_scope(isolate);
25
+
26
+ auto ctor = GetCtor(isolate);
27
+ auto context = isolate->GetCurrentContext();
28
+ auto func = ctor->GetFunction(context).ToLocalChecked();
29
+
30
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPassEncoder"),
31
+ func).FromJust();;
32
+ }
33
+
34
+ GPURenderPassEncoderImpl *
35
+ GPURenderPassEncoderImpl::GetPointer(const v8::Local<v8::Object> &object) {
36
+ auto ptr = object->GetAlignedPointerFromInternalField(0);
37
+ if (ptr == nullptr) {
38
+ return nullptr;
39
+ }
40
+ return static_cast<GPURenderPassEncoderImpl *>(ptr);
41
+ }
42
+
43
+ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *isolate) {
44
+ auto cache = Caches::Get(isolate);
45
+ auto ctor = cache->GPURenderPassEncoderTmpl.get();
46
+ if (ctor != nullptr) {
47
+ return ctor->Get(isolate);
48
+ }
49
+
50
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
51
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
52
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPURenderPassEncoder"));
53
+
54
+ auto tmpl = ctorTmpl->InstanceTemplate();
55
+ tmpl->SetInternalFieldCount(2);
56
+
57
+ tmpl->Set(
58
+ ConvertToV8String(isolate, "beginOcclusionQuery"),
59
+ v8::FunctionTemplate::New(isolate, &BeginOcclusionQuery));
60
+
61
+ tmpl->Set(
62
+ ConvertToV8String(isolate, "draw"),
63
+ v8::FunctionTemplate::New(isolate, &Draw));
64
+
65
+ tmpl->Set(
66
+ ConvertToV8String(isolate, "drawIndexed"),
67
+ v8::FunctionTemplate::New(isolate, &DrawIndexed));
68
+
69
+ tmpl->Set(
70
+ ConvertToV8String(isolate, "drawIndexedIndirect"),
71
+ v8::FunctionTemplate::New(isolate, &DrawIndexedIndirect));
72
+
73
+ tmpl->Set(
74
+ ConvertToV8String(isolate, "drawIndirect"),
75
+ v8::FunctionTemplate::New(isolate, &DrawIndirect));
76
+
77
+ tmpl->Set(
78
+ ConvertToV8String(isolate, "end"),
79
+ v8::FunctionTemplate::New(isolate, &End));
80
+
81
+ tmpl->Set(
82
+ ConvertToV8String(isolate, "endOcclusionQuery"),
83
+ v8::FunctionTemplate::New(isolate, &EndOcclusionQuery));
84
+
85
+ tmpl->Set(
86
+ ConvertToV8String(isolate, "executeBundles"),
87
+ v8::FunctionTemplate::New(isolate, &ExecuteBundles));
88
+
89
+ tmpl->Set(
90
+ ConvertToV8String(isolate, "insertDebugMarker"),
91
+ v8::FunctionTemplate::New(isolate, &InsertDebugMarker));
92
+
93
+ tmpl->Set(
94
+ ConvertToV8String(isolate, "popDebugGroup"),
95
+ v8::FunctionTemplate::New(isolate, &PopDebugGroup));
96
+
97
+ tmpl->Set(
98
+ ConvertToV8String(isolate, "pushDebugGroup"),
99
+ v8::FunctionTemplate::New(isolate, &PushDebugGroup));
100
+
101
+ tmpl->Set(
102
+ ConvertToV8String(isolate, "setBindGroup"),
103
+ v8::FunctionTemplate::New(isolate, &SetBindGroup));
104
+
105
+ tmpl->Set(
106
+ ConvertToV8String(isolate, "setBlendConstant"),
107
+ v8::FunctionTemplate::New(isolate, &SetBlendConstant));
108
+
109
+ tmpl->Set(
110
+ ConvertToV8String(isolate, "setIndexBuffer"),
111
+ v8::FunctionTemplate::New(isolate, &SetIndexBuffer));
112
+
113
+ tmpl->Set(
114
+ ConvertToV8String(isolate, "setPipeline"),
115
+ v8::FunctionTemplate::New(isolate, &SetPipeline));
116
+
117
+ tmpl->Set(
118
+ ConvertToV8String(isolate, "setScissorRect"),
119
+ v8::FunctionTemplate::New(isolate, &SetScissorRect));
120
+
121
+ tmpl->Set(
122
+ ConvertToV8String(isolate, "setStencilReference"),
123
+ v8::FunctionTemplate::New(isolate, &SetStencilReference));
124
+
125
+ tmpl->Set(
126
+ ConvertToV8String(isolate, "setVertexBuffer"),
127
+ v8::FunctionTemplate::New(isolate, &SetVertexBuffer));
128
+
129
+ tmpl->Set(
130
+ ConvertToV8String(isolate, "setViewport"),
131
+ v8::FunctionTemplate::New(isolate, &SetViewport));
132
+
133
+ cache->GPURenderPassEncoderTmpl =
134
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
135
+ return ctorTmpl;
136
+ }
137
+
138
+
139
+ void
140
+ GPURenderPassEncoderImpl::BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
141
+ auto *ptr = GetPointer(args.This());
142
+ if (ptr == nullptr) {
143
+ return;
144
+ }
145
+ auto isolate = args.GetIsolate();
146
+ auto context = isolate->GetCurrentContext();
147
+
148
+ auto queryIndexVal = args[0];
149
+ if (queryIndexVal->IsUint32()) {
150
+ auto queryIndex = queryIndexVal->Uint32Value(context).FromJust();
151
+ canvas_native_webgpu_render_pass_encoder_begin_occlusion_query(ptr->GetPass(), queryIndex);
152
+ }
153
+ }
154
+
155
+
156
+ void GPURenderPassEncoderImpl::Draw(const v8::FunctionCallbackInfo<v8::Value> &args) {
157
+ auto *ptr = GetPointer(args.This());
158
+ if (ptr == nullptr) {
159
+ return;
160
+ }
161
+
162
+ auto vertexCountVal = args[0];
163
+ auto instanceCountVal = args[1];
164
+ uint32_t instanceCount = 1;
165
+ uint32_t firstVertex = 0;
166
+ uint32_t firstInstance = 0;
167
+ auto firstVertexVal = args[2];
168
+ auto firstInstanceVal = args[3];
169
+
170
+ if (vertexCountVal->IsUint32()) {
171
+ auto vertexCount = vertexCountVal.As<v8::Uint32>()->Value();
172
+
173
+ if (instanceCountVal->IsUint32()) {
174
+ instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
175
+ }
176
+
177
+ if (firstVertexVal->IsUint32()) {
178
+ firstVertex = firstVertexVal.As<v8::Uint32>()->Value();
179
+ }
180
+
181
+ if (firstInstanceVal->IsUint32()) {
182
+ firstInstance = firstInstanceVal.As<v8::Uint32>()->Value();
183
+ }
184
+
185
+ canvas_native_webgpu_render_pass_encoder_draw(ptr->GetPass(), vertexCount, instanceCount,
186
+ firstVertex, firstInstance);
187
+
188
+ }
189
+ }
190
+
191
+ void GPURenderPassEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::Value> &args) {
192
+ auto *ptr = GetPointer(args.This());
193
+ if (ptr == nullptr) {
194
+ return;
195
+ }
196
+
197
+ auto isolate = args.GetIsolate();
198
+ auto context = isolate->GetCurrentContext();
199
+
200
+
201
+ uint32_t instanceCount = 1;
202
+ uint32_t firstIndex = 0;
203
+ int32_t baseVertex = 0;
204
+ uint32_t firstInstance = 0;
205
+
206
+
207
+ auto indexCountVal = args[0];
208
+ auto instanceCountVal = args[1];
209
+ auto firstIndexVal = args[2];
210
+ auto baseVertexVal = args[3];
211
+ auto firstInstanceVal = args[4];
212
+
213
+ if (indexCountVal->IsUint32()) {
214
+
215
+ if (instanceCountVal->IsUint32()) {
216
+ instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
217
+ }
218
+
219
+ if (firstIndexVal->IsUint32()) {
220
+ firstIndex = firstIndexVal.As<v8::Uint32>()->Value();
221
+ }
222
+
223
+ if (baseVertexVal->IsInt32()) {
224
+ baseVertex = baseVertexVal.As<v8::Int32>()->Value();
225
+ }
226
+
227
+ if (firstInstanceVal->IsUint32()) {
228
+ firstInstance = firstInstanceVal.As<v8::Uint32>()->Value();
229
+ }
230
+
231
+ canvas_native_webgpu_render_pass_encoder_draw_indexed(ptr->GetPass(),
232
+ indexCountVal->Uint32Value(
233
+ context).FromJust(),
234
+ instanceCount, firstIndex,
235
+ baseVertex,
236
+ firstInstance);
237
+ }
238
+
239
+
240
+ }
241
+
242
+ void
243
+ GPURenderPassEncoderImpl::DrawIndexedIndirect(const v8::FunctionCallbackInfo<v8::Value> &args) {
244
+ auto *ptr = GetPointer(args.This());
245
+ if (ptr == nullptr) {
246
+ return;
247
+ }
248
+
249
+ auto isolate = args.GetIsolate();
250
+ auto context = isolate->GetCurrentContext();
251
+
252
+ auto indirectBufferVal = args[0];
253
+ auto indirectOffsetVal = args[1];
254
+
255
+
256
+ auto indirectBufferType = GetNativeType(indirectBufferVal);
257
+
258
+ if (indirectBufferType == NativeType::GPUBuffer) {
259
+ auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
260
+ uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
261
+ canvas_native_webgpu_render_pass_encoder_draw_indexed_indirect(ptr->GetPass(),
262
+ indirectBuffer->GetGPUBuffer(),
263
+ offset);
264
+ }
265
+
266
+
267
+ }
268
+
269
+ void
270
+ GPURenderPassEncoderImpl::DrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args) {
271
+ auto *ptr = GetPointer(args.This());
272
+ if (ptr == nullptr) {
273
+ return;
274
+ }
275
+
276
+ auto isolate = args.GetIsolate();
277
+ auto context = isolate->GetCurrentContext();
278
+
279
+ auto indirectBufferVal = args[0];
280
+ auto indirectOffsetVal = args[1];
281
+
282
+
283
+ auto indirectBufferType = GetNativeType(indirectBufferVal);
284
+
285
+ if (indirectBufferType == NativeType::GPUBuffer) {
286
+ auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
287
+ uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
288
+ canvas_native_webgpu_render_pass_encoder_draw_indirect(ptr->GetPass(),
289
+ indirectBuffer->GetGPUBuffer(),
290
+ offset);
291
+ }
292
+
293
+
294
+ }
295
+
296
+ void GPURenderPassEncoderImpl::End(const v8::FunctionCallbackInfo<v8::Value> &args) {
297
+ auto *ptr = GetPointer(args.This());
298
+ if (ptr == nullptr) {
299
+ return;
300
+ }
301
+
302
+ canvas_native_webgpu_render_pass_encoder_end(ptr->GetPass());
303
+ }
304
+
305
+ void GPURenderPassEncoderImpl::EndOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
306
+ auto *ptr = GetPointer(args.This());
307
+ if (ptr == nullptr) {
308
+ return;
309
+ }
310
+
311
+ canvas_native_webgpu_render_pass_encoder_end_occlusion_query(ptr->GetPass());
312
+ }
313
+
314
+ void GPURenderPassEncoderImpl::ExecuteBundles(const v8::FunctionCallbackInfo<v8::Value> &args) {
315
+ auto *ptr = GetPointer(args.This());
316
+ if (ptr == nullptr) {
317
+ return;
318
+ }
319
+
320
+ auto isolate = args.GetIsolate();
321
+ auto context = isolate->GetCurrentContext();
322
+
323
+ auto bundlesVal = args[0];
324
+ if (bundlesVal->IsArray()) {
325
+ auto bundlesArray = bundlesVal.As<v8::Array>();
326
+ auto len = bundlesArray->Length();
327
+ std::vector<const CanvasGPURenderBundle *> bundles;
328
+ for (int i = 0; i < len; i++) {
329
+ v8::Local<v8::Value> bundleVal;
330
+ bundlesArray->Get(context, i).ToLocal(&bundlesVal);
331
+ auto type = GetNativeType(bundleVal);
332
+ if (type == NativeType::GPURenderBundle) {
333
+ auto bundle = GPURenderBundleImpl::GetPointer(bundleVal.As<v8::Object>());
334
+ bundles.emplace_back(bundle->GetBundle());
335
+ }
336
+ }
337
+
338
+ if (!bundles.empty()) {
339
+ canvas_native_webgpu_render_pass_encoder_execute_bundles(ptr->GetPass(), bundles.data(),
340
+ bundles.size());
341
+ }
342
+
343
+
344
+ }
345
+ }
346
+
347
+ void
348
+ GPURenderPassEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args) {
349
+ auto *ptr = GetPointer(args.This());
350
+ if (ptr == nullptr) {
351
+ return;
352
+ }
353
+
354
+ auto isolate = args.GetIsolate();
355
+
356
+ auto markerLabelVal = args[0];
357
+ if (markerLabelVal->IsString()) {
358
+ auto markerLabel = ConvertFromV8String(isolate, markerLabelVal);
359
+ canvas_native_webgpu_render_pass_encoder_insert_debug_marker(ptr->GetPass(),
360
+ markerLabel.c_str());
361
+ }
362
+ }
363
+
364
+ void GPURenderPassEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
365
+ auto *ptr = GetPointer(args.This());
366
+ if (ptr == nullptr) {
367
+ return;
368
+ }
369
+
370
+ canvas_native_webgpu_render_pass_encoder_pop_debug_group(ptr->GetPass());
371
+ }
372
+
373
+ void GPURenderPassEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
374
+ auto *ptr = GetPointer(args.This());
375
+ if (ptr == nullptr) {
376
+ return;
377
+ }
378
+
379
+ auto isolate = args.GetIsolate();
380
+
381
+ auto groupLabelVal = args[0];
382
+ if (groupLabelVal->IsString()) {
383
+ auto groupLabel = ConvertFromV8String(isolate, groupLabelVal);
384
+ canvas_native_webgpu_render_pass_encoder_push_debug_group(ptr->GetPass(),
385
+ groupLabel.c_str());
386
+ }
387
+ }
388
+
389
+ void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
390
+ auto *ptr = GetPointer(args.This());
391
+ if (ptr == nullptr) {
392
+ return;
393
+ }
394
+
395
+ auto isolate = args.GetIsolate();
396
+ auto context = isolate->GetCurrentContext();
397
+
398
+ auto indexVal = args[0];
399
+ auto bindGroupVal = args[1];
400
+ auto dynamicOffsets = args[2];
401
+ auto dynamicOffsetsStart = args[3];
402
+ auto dynamicOffsetsLength = args[4];
403
+
404
+ auto type = GetNativeType(bindGroupVal);
405
+
406
+ if (type == NativeType::GPUBindGroup) {
407
+ auto index = indexVal->Uint32Value(context).FromJust();
408
+ auto bindgroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
409
+
410
+ if (dynamicOffsets->IsUint8Array()) {
411
+ auto buf = dynamicOffsets.As<v8::Uint32Array>();
412
+ auto buffer = buf->Buffer();
413
+ auto store = buffer->GetBackingStore();
414
+ auto offset = buf->ByteOffset();
415
+ auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
416
+ auto size = buf->Length();
417
+ auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
418
+ auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
419
+ canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
420
+ bindgroup->GetBindGroup(),
421
+ static_cast<const uint32_t *>(static_cast<void *>(data)),
422
+ size, start, offset_length);
423
+ } else {
424
+ canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
425
+ bindgroup->GetBindGroup(),
426
+ nullptr, 0, 0, 0);
427
+ }
428
+ }
429
+ }
430
+
431
+ void GPURenderPassEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
432
+ auto *ptr = GetPointer(args.This());
433
+ if (ptr == nullptr) {
434
+ return;
435
+ }
436
+
437
+ auto isolate = args.GetIsolate();
438
+
439
+ auto bufferVal = args[0];
440
+ auto indexFormatVal = args[1];
441
+ int64_t offset = -1;
442
+ int64_t size = -1;
443
+ auto offsetVal = args[2];
444
+ auto sizeVal = args[3];
445
+
446
+ auto type = GetNativeType(bufferVal);
447
+
448
+ if (type == NativeType::GPURenderBundleEncoder) {
449
+ auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
450
+ auto indexFormat = ConvertFromV8String(isolate, indexFormatVal);
451
+ if (offsetVal->IsNumber()) {
452
+ offset = (int64_t) offsetVal.As<v8::Number>()->Value();
453
+ }
454
+
455
+ if (sizeVal->IsNumber()) {
456
+ size = (int64_t) sizeVal.As<v8::Number>()->Value();
457
+ }
458
+
459
+ if (indexFormat == "uint16") {
460
+ canvas_native_webgpu_render_pass_encoder_set_index_buffer(ptr->GetPass(),
461
+ buffer->GetGPUBuffer(),
462
+ CanvasIndexFormatUint16,
463
+ offset,
464
+ size);
465
+ } else if (indexFormat == "uint32") {
466
+ canvas_native_webgpu_render_pass_encoder_set_index_buffer(ptr->GetPass(),
467
+ buffer->GetGPUBuffer(),
468
+ CanvasIndexFormatUint32,
469
+ offset,
470
+ size);
471
+ }
472
+
473
+
474
+ }
475
+ }
476
+
477
+ void GPURenderPassEncoderImpl::SetBlendConstant(const v8::FunctionCallbackInfo<v8::Value> &args) {
478
+ auto *ptr = GetPointer(args.This());
479
+ if (ptr == nullptr) {
480
+ return;
481
+ }
482
+
483
+ auto isolate = args.GetIsolate();
484
+
485
+ auto colorVal = args[0];
486
+
487
+ if (colorVal->IsObject() || colorVal->IsArray()) {
488
+
489
+ auto color = ParseColor(isolate, colorVal);
490
+
491
+
492
+ canvas_native_webgpu_render_pass_encoder_set_blend_constant(ptr->GetPass(), &color);
493
+ }
494
+
495
+ }
496
+
497
+ void GPURenderPassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Value> &args) {
498
+ auto *ptr = GetPointer(args.This());
499
+ if (ptr == nullptr) {
500
+ return;
501
+ }
502
+
503
+ auto pipelineVal = args[0];
504
+ if(GetNativeType(pipelineVal) == NativeType::GPURenderPipeline){
505
+ auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
506
+ canvas_native_webgpu_render_pass_encoder_set_pipeline(ptr->GetPass(),
507
+ pipeline->GetGPUPipeline());
508
+ }
509
+ }
510
+
511
+ void GPURenderPassEncoderImpl::SetScissorRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
512
+ auto *ptr = GetPointer(args.This());
513
+ if (ptr == nullptr) {
514
+ return;
515
+ }
516
+
517
+ auto x = args[0];
518
+ auto y = args[1];
519
+ auto width = args[2];
520
+ auto height = args[3];
521
+
522
+ auto isolate = args.GetIsolate();
523
+ auto context = isolate->GetCurrentContext();
524
+
525
+ canvas_native_webgpu_render_pass_encoder_set_scissor_rect(ptr->GetPass(),
526
+ x->Uint32Value(context).FromJust(),
527
+ y->Uint32Value(context).FromJust(),
528
+ width->Uint32Value(
529
+ context).FromJust(),
530
+ height->Uint32Value(
531
+ context).FromJust());
532
+ }
533
+
534
+ void
535
+ GPURenderPassEncoderImpl::SetStencilReference(const v8::FunctionCallbackInfo<v8::Value> &args) {
536
+ auto *ptr = GetPointer(args.This());
537
+ if (ptr == nullptr) {
538
+ return;
539
+ }
540
+ auto isolate = args.GetIsolate();
541
+ auto context = isolate->GetCurrentContext();
542
+
543
+ auto reference = args[0];
544
+
545
+ if (reference->IsUint32()) {
546
+ canvas_native_webgpu_render_pass_encoder_set_stencil_reference(ptr->GetPass(),
547
+ reference->Uint32Value(
548
+ context).FromJust());
549
+ }
550
+
551
+
552
+ }
553
+
554
+
555
+ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
556
+ auto *ptr = GetPointer(args.This());
557
+ if (ptr == nullptr) {
558
+ return;
559
+ }
560
+
561
+ auto slotVal = args[0];
562
+ auto bufferVal = args[1];
563
+ int64_t offset = -1;
564
+ int64_t size = -1;
565
+ auto offsetVal = args[2];
566
+ auto sizeVal = args[3];
567
+
568
+ if (slotVal->IsUint32() && bufferVal->IsObject()) {
569
+ auto slot = slotVal.As<v8::Uint32>()->Value();
570
+ if (GetNativeType(bufferVal) != NativeType::GPUBuffer) {
571
+ // todo throw ??
572
+ return;
573
+ }
574
+
575
+ auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
576
+
577
+ if (offsetVal->IsNumber()) {
578
+ offset = (int64_t) offsetVal.As<v8::Number>()->Value();
579
+ }
580
+
581
+ if (sizeVal->IsNumber()) {
582
+ size = (int64_t) sizeVal.As<v8::Number>()->Value();
583
+ }
584
+
585
+ canvas_native_webgpu_render_pass_encoder_set_vertex_buffer(ptr->GetPass(), slot,
586
+ buffer->GetGPUBuffer(), offset,
587
+ size);
588
+
589
+ }
590
+ }
591
+
592
+ void GPURenderPassEncoderImpl::SetViewport(const v8::FunctionCallbackInfo<v8::Value> &args) {
593
+ auto *ptr = GetPointer(args.This());
594
+ if (ptr == nullptr) {
595
+ return;
596
+ }
597
+
598
+ auto x = args[0];
599
+ auto y = args[1];
600
+ auto width = args[2];
601
+ auto height = args[3];
602
+
603
+ auto minDepth = args[4];
604
+ auto maxDepth = args[5];
605
+
606
+ auto isolate = args.GetIsolate();
607
+ auto context = isolate->GetCurrentContext();
608
+
609
+ canvas_native_webgpu_render_pass_encoder_set_viewport(ptr->GetPass(),
610
+ (float) x->NumberValue(
611
+ context).FromJust(),
612
+ (float) y->NumberValue(
613
+ context).FromJust(),
614
+ (float) width->NumberValue(
615
+ context).FromJust(),
616
+ (float) height->NumberValue(
617
+ context).FromJust(),
618
+ (float) minDepth->NumberValue(
619
+ context).FromJust(),
620
+ (float) maxDepth->NumberValue(
621
+ context).FromJust());
622
+
623
+ }
@@ -0,0 +1,85 @@
1
+ //
2
+ // Created by Osei Fortune on 01/07/2024.
3
+ //
4
+
5
+ #ifndef CANVAS_ANDROID_GPURENDERPASSENCODERIMPL_H
6
+ #define CANVAS_ANDROID_GPURENDERPASSENCODERIMPL_H
7
+
8
+ #include "Common.h"
9
+ #include "Helpers.h"
10
+ #include "ObjectWrapperImpl.h"
11
+ #include "GPUUtils.h"
12
+
13
+ class GPURenderPassEncoderImpl : ObjectWrapperImpl {
14
+ public:
15
+ explicit GPURenderPassEncoderImpl(const CanvasGPURenderPassEncoder *pass);
16
+
17
+ ~GPURenderPassEncoderImpl() {
18
+ canvas_native_webgpu_render_pass_encoder_release(this->GetPass());
19
+ }
20
+
21
+ const CanvasGPURenderPassEncoder *GetPass();
22
+
23
+ static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
24
+
25
+ static GPURenderPassEncoderImpl *GetPointer(const v8::Local<v8::Object> &object);
26
+
27
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
28
+
29
+ static v8::Local<v8::Object>
30
+ NewInstance(v8::Isolate *isolate, GPURenderPassEncoderImpl *encoder) {
31
+ auto context = isolate->GetCurrentContext();
32
+ v8::EscapableHandleScope scope(isolate);
33
+ auto object = GPURenderPassEncoderImpl::GetCtor(isolate)->GetFunction(
34
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
35
+ SetNativeType(object, NativeType::GPURenderPassEncoder);
36
+ object->SetAlignedPointerInInternalField(0, encoder);
37
+ encoder->BindFinalizer(isolate, object);
38
+ return scope.Escape(object);
39
+ }
40
+
41
+ static void BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args);
42
+
43
+ static void Draw(const v8::FunctionCallbackInfo<v8::Value> &args);
44
+
45
+ static void DrawIndexed(const v8::FunctionCallbackInfo<v8::Value> &args);
46
+
47
+ static void DrawIndexedIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
48
+
49
+ static void DrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
50
+
51
+ static void End(const v8::FunctionCallbackInfo<v8::Value> &args);
52
+
53
+ static void EndOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args);
54
+
55
+ static void ExecuteBundles(const v8::FunctionCallbackInfo<v8::Value> &args);
56
+
57
+ static void InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args);
58
+
59
+ static void PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
60
+
61
+ static void PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
62
+
63
+ static void SetBindGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
64
+
65
+ static void SetBlendConstant(const v8::FunctionCallbackInfo<v8::Value> &args);
66
+
67
+ static void SetIndexBuffer(const v8::FunctionCallbackInfo<v8::Value> &args);
68
+
69
+ static void SetPipeline(const v8::FunctionCallbackInfo<v8::Value> &args);
70
+
71
+ static void SetScissorRect(const v8::FunctionCallbackInfo<v8::Value> &args);
72
+
73
+ static void SetStencilReference(const v8::FunctionCallbackInfo<v8::Value> &args);
74
+
75
+ static void SetVertexBuffer(const v8::FunctionCallbackInfo<v8::Value> &args);
76
+
77
+ static void SetViewport(const v8::FunctionCallbackInfo<v8::Value> &args);
78
+
79
+
80
+ private:
81
+ const CanvasGPURenderPassEncoder *pass_;
82
+ };
83
+
84
+
85
+ #endif //CANVAS_ANDROID_GPURENDERPASSENCODERIMPL_H