@nativescript/canvas 2.0.0-beta.9 → 2.0.0-rc.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 (454) hide show
  1. package/Canvas/common.d.ts +15 -24
  2. package/Canvas/common.js +147 -203
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +13 -15
  5. package/Canvas/index.android.js +152 -151
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +23 -11
  8. package/Canvas/index.ios.d.ts +14 -6
  9. package/Canvas/index.ios.js +213 -124
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas/utils.d.ts +3 -0
  12. package/Canvas/utils.js +85 -0
  13. package/Canvas/utils.js.map +1 -0
  14. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +4 -2
  15. package/Canvas2D/CanvasRenderingContext2D/index.js +79 -85
  16. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  17. package/Canvas2D/DOMMatrix/index.d.ts +14 -0
  18. package/Canvas2D/DOMMatrix/index.js +62 -0
  19. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  20. package/Canvas2D/ImageData/index.js +4 -6
  21. package/Canvas2D/ImageData/index.js.map +1 -1
  22. package/Canvas2D/Path2D/index.js.map +1 -1
  23. package/Dom/Dom.js +8 -1
  24. package/Dom/Dom.js.map +1 -1
  25. package/Dom/Group.d.ts +1 -2
  26. package/Dom/Group.js.map +1 -1
  27. package/Dom/Image.d.ts +4 -1
  28. package/Dom/Image.js +15 -2
  29. package/Dom/Image.js.map +1 -1
  30. package/Dom/Paint.d.ts +1 -1
  31. package/Dom/Paint.js.map +1 -1
  32. package/Dom/Text.js.map +1 -1
  33. package/Dom/shaders/LinearGradient.js.map +1 -1
  34. package/Dom/shaders/TwoPointConicalGradient.js.map +1 -1
  35. package/Dom/shapes/Atlas.js.map +1 -1
  36. package/Dom/shapes/Circle.js.map +1 -1
  37. package/Dom/shapes/Line.js.map +1 -1
  38. package/Dom/shapes/Oval.js.map +1 -1
  39. package/Dom/shapes/Path.d.ts +1 -1
  40. package/Dom/shapes/Path.js.map +1 -1
  41. package/Dom/shapes/Rect.js.map +1 -1
  42. package/Dom/shapes/RoundedRect.js.map +1 -1
  43. package/Dom/shapes/index.js.map +1 -1
  44. package/Fonts/FontFace.android.d.ts +46 -0
  45. package/Fonts/FontFace.android.js +197 -0
  46. package/Fonts/FontFace.android.js.map +1 -0
  47. package/Fonts/FontFace.ios.d.ts +45 -0
  48. package/Fonts/FontFace.ios.js +169 -0
  49. package/Fonts/FontFace.ios.js.map +1 -0
  50. package/Fonts/FontFaceSet.android.d.ts +31 -0
  51. package/Fonts/FontFaceSet.android.js +119 -0
  52. package/Fonts/FontFaceSet.android.js.map +1 -0
  53. package/Fonts/FontFaceSet.ios.d.ts +31 -0
  54. package/Fonts/FontFaceSet.ios.js +109 -0
  55. package/Fonts/FontFaceSet.ios.js.map +1 -0
  56. package/Fonts/index.d.ts +2 -0
  57. package/Fonts/index.js +3 -0
  58. package/Fonts/index.js.map +1 -0
  59. package/ImageAsset/index.d.ts +8 -3
  60. package/ImageAsset/index.js +206 -11
  61. package/ImageAsset/index.js.map +1 -1
  62. package/ImageBitmap/index.js +110 -23
  63. package/ImageBitmap/index.js.map +1 -1
  64. package/README.md +62 -3
  65. package/TextDecoder/index.js +3 -3
  66. package/TextDecoder/index.js.map +1 -1
  67. package/TextEncoder/index.js +3 -3
  68. package/TextEncoder/index.js.map +1 -1
  69. package/WebGL/WebGLExtensions/index.js +5 -5
  70. package/WebGL/WebGLExtensions/index.js.map +1 -1
  71. package/WebGL/WebGLRenderingContext/common.d.ts +1 -1
  72. package/WebGL/WebGLRenderingContext/common.js.map +1 -1
  73. package/WebGL/WebGLRenderingContext/index.d.ts +1 -0
  74. package/WebGL/WebGLRenderingContext/index.js +144 -46
  75. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  76. package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -0
  77. package/WebGL2/WebGL2RenderingContext/index.js +7 -8
  78. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  79. package/WebGPU/Constants.d.ts +36 -0
  80. package/WebGPU/Constants.js +42 -0
  81. package/WebGPU/Constants.js.map +1 -0
  82. package/WebGPU/Errors.d.ts +18 -0
  83. package/WebGPU/Errors.js +21 -0
  84. package/WebGPU/Errors.js.map +1 -0
  85. package/WebGPU/GPU.d.ts +13 -0
  86. package/WebGPU/GPU.js +36 -0
  87. package/WebGPU/GPU.js.map +1 -0
  88. package/WebGPU/GPUAdapter.d.ts +26 -0
  89. package/WebGPU/GPUAdapter.js +93 -0
  90. package/WebGPU/GPUAdapter.js.map +1 -0
  91. package/WebGPU/GPUAdapterInfo.d.ts +9 -0
  92. package/WebGPU/GPUAdapterInfo.js +24 -0
  93. package/WebGPU/GPUAdapterInfo.js.map +1 -0
  94. package/WebGPU/GPUBindGroup.d.ts +6 -0
  95. package/WebGPU/GPUBindGroup.js +15 -0
  96. package/WebGPU/GPUBindGroup.js.map +1 -0
  97. package/WebGPU/GPUBindGroupLayout.d.ts +6 -0
  98. package/WebGPU/GPUBindGroupLayout.js +15 -0
  99. package/WebGPU/GPUBindGroupLayout.js.map +1 -0
  100. package/WebGPU/GPUBuffer.d.ts +15 -0
  101. package/WebGPU/GPUBuffer.js +66 -0
  102. package/WebGPU/GPUBuffer.js.map +1 -0
  103. package/WebGPU/GPUCanvasContext.d.ts +42 -0
  104. package/WebGPU/GPUCanvasContext.js +149 -0
  105. package/WebGPU/GPUCanvasContext.js.map +1 -0
  106. package/WebGPU/GPUCommandBuffer.d.ts +6 -0
  107. package/WebGPU/GPUCommandBuffer.js +15 -0
  108. package/WebGPU/GPUCommandBuffer.js.map +1 -0
  109. package/WebGPU/GPUCommandEncoder.d.ts +35 -0
  110. package/WebGPU/GPUCommandEncoder.js +163 -0
  111. package/WebGPU/GPUCommandEncoder.js.map +1 -0
  112. package/WebGPU/GPUComputePassEncoder.d.ts +17 -0
  113. package/WebGPU/GPUComputePassEncoder.js +53 -0
  114. package/WebGPU/GPUComputePassEncoder.js.map +1 -0
  115. package/WebGPU/GPUComputePipeline.d.ts +8 -0
  116. package/WebGPU/GPUComputePipeline.js +19 -0
  117. package/WebGPU/GPUComputePipeline.js.map +1 -0
  118. package/WebGPU/GPUDevice.d.ts +111 -0
  119. package/WebGPU/GPUDevice.js +341 -0
  120. package/WebGPU/GPUDevice.js.map +1 -0
  121. package/WebGPU/GPUDeviceLostInfo.d.ts +1 -0
  122. package/WebGPU/GPUDeviceLostInfo.js +10 -0
  123. package/WebGPU/GPUDeviceLostInfo.js.map +1 -0
  124. package/WebGPU/GPUExternalTexture.d.ts +6 -0
  125. package/WebGPU/GPUExternalTexture.js +15 -0
  126. package/WebGPU/GPUExternalTexture.js.map +1 -0
  127. package/WebGPU/GPUPipelineLayout.d.ts +6 -0
  128. package/WebGPU/GPUPipelineLayout.js +15 -0
  129. package/WebGPU/GPUPipelineLayout.js.map +1 -0
  130. package/WebGPU/GPUQuerySet.d.ts +6 -0
  131. package/WebGPU/GPUQuerySet.js +15 -0
  132. package/WebGPU/GPUQuerySet.js.map +1 -0
  133. package/WebGPU/GPUQueue.d.ts +15 -0
  134. package/WebGPU/GPUQueue.js +128 -0
  135. package/WebGPU/GPUQueue.js.map +1 -0
  136. package/WebGPU/GPURenderBundle.d.ts +6 -0
  137. package/WebGPU/GPURenderBundle.js +15 -0
  138. package/WebGPU/GPURenderBundle.js.map +1 -0
  139. package/WebGPU/GPURenderBundleEncoder.d.ts +22 -0
  140. package/WebGPU/GPURenderBundleEncoder.js +65 -0
  141. package/WebGPU/GPURenderBundleEncoder.js.map +1 -0
  142. package/WebGPU/GPURenderPassEncoder.d.ts +33 -0
  143. package/WebGPU/GPURenderPassEncoder.js +106 -0
  144. package/WebGPU/GPURenderPassEncoder.js.map +1 -0
  145. package/WebGPU/GPURenderPipeline.d.ts +8 -0
  146. package/WebGPU/GPURenderPipeline.js +19 -0
  147. package/WebGPU/GPURenderPipeline.js.map +1 -0
  148. package/WebGPU/GPUSampler.d.ts +6 -0
  149. package/WebGPU/GPUSampler.js +15 -0
  150. package/WebGPU/GPUSampler.js.map +1 -0
  151. package/WebGPU/GPUShaderModule.d.ts +6 -0
  152. package/WebGPU/GPUShaderModule.js +15 -0
  153. package/WebGPU/GPUShaderModule.js.map +1 -0
  154. package/WebGPU/GPUTexture.d.ts +18 -0
  155. package/WebGPU/GPUTexture.js +47 -0
  156. package/WebGPU/GPUTexture.js.map +1 -0
  157. package/WebGPU/GPUTextureView.d.ts +6 -0
  158. package/WebGPU/GPUTextureView.js +15 -0
  159. package/WebGPU/GPUTextureView.js.map +1 -0
  160. package/WebGPU/Interfaces.d.ts +246 -0
  161. package/WebGPU/Interfaces.js +2 -0
  162. package/WebGPU/Interfaces.js.map +1 -0
  163. package/WebGPU/Types.d.ts +47 -0
  164. package/WebGPU/Types.js +2 -0
  165. package/WebGPU/Types.js.map +1 -0
  166. package/WebGPU/Utils.d.ts +7 -0
  167. package/WebGPU/Utils.js +301 -0
  168. package/WebGPU/Utils.js.map +1 -0
  169. package/WebGPU/index.d.ts +28 -0
  170. package/WebGPU/index.js +29 -0
  171. package/WebGPU/index.js.map +1 -0
  172. package/angular/{esm2020 → esm2022}/index.mjs +5 -5
  173. package/angular/{fesm2015 → fesm2022}/nativescript-canvas-angular.mjs +4 -4
  174. package/angular/{fesm2015 → fesm2022}/nativescript-canvas-angular.mjs.map +1 -1
  175. package/angular/package.json +4 -10
  176. package/common.d.ts +0 -3
  177. package/common.js +1 -5
  178. package/common.js.map +1 -1
  179. package/helpers.js.map +1 -1
  180. package/index.d.ts +4 -2
  181. package/index.js +37 -3
  182. package/index.js.map +1 -1
  183. package/package.json +2 -5
  184. package/platforms/android/canvas-release.aar +0 -0
  185. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  186. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +194 -56
  187. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +1 -0
  188. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
  189. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +152 -151
  190. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2901 -411
  191. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  192. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  193. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +10901 -8099
  194. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +259 -52
  195. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  196. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +259 -52
  197. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Black.ttf +0 -0
  198. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Bold.ttf +0 -0
  199. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-ExtraBold.ttf +0 -0
  200. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-ExtraLight.ttf +0 -0
  201. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Light.ttf +0 -0
  202. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Medium.ttf +0 -0
  203. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Regular.ttf +0 -0
  204. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-SemiBold.ttf +0 -0
  205. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoMath-Regular.ttf +0 -0
  206. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Bold.ttf +0 -0
  207. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-BoldItalic.ttf +0 -0
  208. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Italic.ttf +0 -0
  209. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Medium.ttf +0 -0
  210. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-MediumItalic.ttf +0 -0
  211. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Regular.ttf +0 -0
  212. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-SemiBold.ttf +0 -0
  213. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-SemiBoldItalic.ttf +0 -0
  214. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  215. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +994 -663
  216. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  217. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +388 -112
  218. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +1 -0
  219. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
  220. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +152 -151
  221. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2901 -411
  222. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  223. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  224. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  225. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +10901 -8099
  226. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +259 -52
  227. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  228. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +259 -52
  229. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +10901 -8099
  230. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +259 -52
  231. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  232. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +259 -52
  233. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +143 -33
  234. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Black.ttf +0 -0
  235. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Bold.ttf +0 -0
  236. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-ExtraBold.ttf +0 -0
  237. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-ExtraLight.ttf +0 -0
  238. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Light.ttf +0 -0
  239. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Medium.ttf +0 -0
  240. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-Regular.ttf +0 -0
  241. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/Noto_Serif_CJK/NotoSerifTC-SemiBold.ttf +0 -0
  242. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoMath-Regular.ttf +0 -0
  243. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Bold.ttf +0 -0
  244. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-BoldItalic.ttf +0 -0
  245. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Italic.ttf +0 -0
  246. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Medium.ttf +0 -0
  247. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-MediumItalic.ttf +0 -0
  248. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-Regular.ttf +0 -0
  249. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-SemiBold.ttf +0 -0
  250. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/fonts/STIXTwoMath/STIXTwoText-SemiBoldItalic.ttf +0 -0
  251. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  252. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +993 -662
  253. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +1037 -641
  254. package/platforms/ios/build.xcconfig +3 -1
  255. package/platforms/ios/src/NSOperationQueueWrapper.h +3 -1
  256. package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
  257. package/platforms/ios/src/cpp/AsyncCallback.h +214 -0
  258. package/platforms/ios/src/cpp/Caches.h +69 -1
  259. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +647 -1166
  260. package/platforms/ios/src/cpp/CanvasJSIModule.h +11 -1
  261. package/platforms/ios/src/cpp/Helpers.h +2 -129
  262. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +600 -437
  263. package/platforms/ios/src/cpp/ImageAssetImpl.h +18 -10
  264. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +63 -6
  265. package/platforms/ios/src/cpp/ImageBitmapImpl.h +12 -4
  266. package/platforms/ios/src/cpp/JSIReadFileCallback.h +4 -4
  267. package/platforms/ios/src/cpp/NativeType.h +87 -0
  268. package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
  269. package/platforms/ios/src/cpp/OneByteStringResource.cpp +2 -2
  270. package/platforms/ios/src/cpp/PromiseCallback.h +197 -0
  271. package/platforms/ios/src/cpp/RafImpl.h +2 -2
  272. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +0 -6
  273. package/platforms/ios/src/cpp/TextDecoderImpl.h +3 -3
  274. package/platforms/ios/src/cpp/TextEncoderImpl.cpp +1 -1
  275. package/platforms/ios/src/cpp/TextEncoderImpl.h +3 -3
  276. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +8 -7
  277. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -11
  278. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +3 -3
  279. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +193 -90
  280. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +77 -23
  281. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +5 -6
  282. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +4 -4
  283. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
  284. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +29 -2
  285. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
  286. package/platforms/ios/src/cpp/canvas2d/Path2D.h +7 -7
  287. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +3 -3
  288. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
  289. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
  290. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
  291. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
  292. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
  293. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +247 -160
  294. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
  295. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +6 -6
  296. package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
  297. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
  298. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
  299. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
  300. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
  301. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
  302. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
  303. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
  304. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
  305. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
  306. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
  307. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
  308. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
  309. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
  310. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
  311. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
  312. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
  313. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
  314. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
  315. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
  316. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
  317. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
  318. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
  319. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
  320. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
  321. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
  322. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
  323. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
  324. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
  325. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1067 -960
  326. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
  327. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
  328. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
  329. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
  330. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
  331. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
  332. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +371 -0
  333. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
  334. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
  335. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
  336. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +79 -0
  337. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +48 -0
  338. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +79 -0
  339. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +48 -0
  340. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +277 -0
  341. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +63 -0
  342. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +379 -0
  343. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +57 -0
  344. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +81 -0
  345. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +48 -0
  346. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1217 -0
  347. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +73 -0
  348. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +293 -0
  349. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +65 -0
  350. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +109 -0
  351. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +51 -0
  352. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +3701 -0
  353. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +97 -0
  354. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +200 -0
  355. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
  356. package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
  357. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +80 -0
  358. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +49 -0
  359. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +136 -0
  360. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
  361. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +605 -0
  362. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +59 -0
  363. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +501 -0
  364. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +74 -0
  365. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +78 -0
  366. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +48 -0
  367. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +723 -0
  368. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +92 -0
  369. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +109 -0
  370. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +52 -0
  371. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +79 -0
  372. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +48 -0
  373. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +80 -0
  374. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +48 -0
  375. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
  376. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
  377. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +386 -0
  378. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +77 -0
  379. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +79 -0
  380. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +48 -0
  381. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +756 -0
  382. package/react/index.d.ts +1 -1
  383. package/utils.d.ts +1 -1
  384. package/utils.js.map +1 -1
  385. package/SVG/Circle.d.ts +0 -11
  386. package/SVG/Circle.js +0 -21
  387. package/SVG/Circle.js.map +0 -1
  388. package/SVG/ClipPath.d.ts +0 -4
  389. package/SVG/ClipPath.js +0 -9
  390. package/SVG/ClipPath.js.map +0 -1
  391. package/SVG/Defs.d.ts +0 -4
  392. package/SVG/Defs.js +0 -9
  393. package/SVG/Defs.js.map +0 -1
  394. package/SVG/Ellipse.d.ts +0 -13
  395. package/SVG/Ellipse.js +0 -26
  396. package/SVG/Ellipse.js.map +0 -1
  397. package/SVG/G.d.ts +0 -7
  398. package/SVG/G.js +0 -9
  399. package/SVG/G.js.map +0 -1
  400. package/SVG/Image.d.ts +0 -11
  401. package/SVG/Image.js +0 -40
  402. package/SVG/Image.js.map +0 -1
  403. package/SVG/Line.d.ts +0 -13
  404. package/SVG/Line.js +0 -26
  405. package/SVG/Line.js.map +0 -1
  406. package/SVG/LinearGradient.d.ts +0 -10
  407. package/SVG/LinearGradient.js +0 -13
  408. package/SVG/LinearGradient.js.map +0 -1
  409. package/SVG/Path.d.ts +0 -7
  410. package/SVG/Path.js +0 -14
  411. package/SVG/Path.js.map +0 -1
  412. package/SVG/Pattern.d.ts +0 -4
  413. package/SVG/Pattern.js +0 -9
  414. package/SVG/Pattern.js.map +0 -1
  415. package/SVG/Polygon.d.ts +0 -7
  416. package/SVG/Polygon.js +0 -14
  417. package/SVG/Polygon.js.map +0 -1
  418. package/SVG/Polyline.d.ts +0 -7
  419. package/SVG/Polyline.js +0 -14
  420. package/SVG/Polyline.js.map +0 -1
  421. package/SVG/Rect.d.ts +0 -8
  422. package/SVG/Rect.js +0 -13
  423. package/SVG/Rect.js.map +0 -1
  424. package/SVG/SVG.d.ts +0 -32
  425. package/SVG/SVG.js +0 -204
  426. package/SVG/SVG.js.map +0 -1
  427. package/SVG/SVGItem.d.ts +0 -5
  428. package/SVG/SVGItem.js +0 -8
  429. package/SVG/SVGItem.js.map +0 -1
  430. package/SVG/Stop.d.ts +0 -5
  431. package/SVG/Stop.js +0 -9
  432. package/SVG/Stop.js.map +0 -1
  433. package/SVG/Symbol.d.ts +0 -4
  434. package/SVG/Symbol.js +0 -9
  435. package/SVG/Symbol.js.map +0 -1
  436. package/SVG/Text.d.ts +0 -14
  437. package/SVG/Text.js +0 -26
  438. package/SVG/Text.js.map +0 -1
  439. package/SVG/Use.d.ts +0 -4
  440. package/SVG/Use.js +0 -9
  441. package/SVG/Use.js.map +0 -1
  442. package/SVG/index.d.ts +0 -18
  443. package/SVG/index.js +0 -19
  444. package/SVG/index.js.map +0 -1
  445. package/angular/fesm2020/nativescript-canvas-angular.mjs +0 -24
  446. package/angular/fesm2020/nativescript-canvas-angular.mjs.map +0 -1
  447. package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
  448. package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
  449. package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
  450. package/platforms/ios/src/cpp/URLImpl.h +0 -121
  451. package/typings/objc!CanvasNative.d.ts +0 -2038
  452. package/typings/objc!CanvasNative.js +0 -1
  453. package/typings/objc!CanvasNative.js.map +0 -1
  454. /package/angular/{esm2020 → esm2022}/nativescript-canvas-angular.mjs +0 -0
@@ -0,0 +1,1217 @@
1
+ //
2
+ // Created by Osei Fortune on 23/06/2024.
3
+ //
4
+
5
+ #include "GPUCommandEncoderImpl.h"
6
+ #include "Caches.h"
7
+ #include "GPUComputePassEncoderImpl.h"
8
+ #include "GPUQuerySetImpl.h"
9
+ #include "GPUBufferImpl.h"
10
+ #include "GPUTextureViewImpl.h"
11
+ #include "GPURenderPassEncoderImpl.h"
12
+ #include "GPUCommandBufferImpl.h"
13
+ #include "GPUTextureImpl.h"
14
+ #include "GPULabel.h"
15
+
16
+ GPUCommandEncoderImpl::GPUCommandEncoderImpl(const CanvasGPUCommandEncoder *encoder) : encoder_(
17
+ encoder) {}
18
+
19
+ const CanvasGPUCommandEncoder *GPUCommandEncoderImpl::GetEncoder() {
20
+ return this->encoder_;
21
+ }
22
+
23
+ void GPUCommandEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
24
+ v8::Locker locker(isolate);
25
+ v8::Isolate::Scope isolate_scope(isolate);
26
+ v8::HandleScope handle_scope(isolate);
27
+
28
+ auto ctor = GetCtor(isolate);
29
+ auto context = isolate->GetCurrentContext();
30
+ auto func = ctor->GetFunction(context).ToLocalChecked();
31
+
32
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandEncoder"), func).FromJust();
33
+ }
34
+
35
+ GPUCommandEncoderImpl *GPUCommandEncoderImpl::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<GPUCommandEncoderImpl *>(ptr);
41
+ }
42
+
43
+ v8::Local<v8::FunctionTemplate> GPUCommandEncoderImpl::GetCtor(v8::Isolate *isolate) {
44
+ auto cache = Caches::Get(isolate);
45
+ auto ctor = cache->GPUCommandEncoderTmpl.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, "GPUCommandEncoder"));
53
+
54
+ auto tmpl = ctorTmpl->InstanceTemplate();
55
+ tmpl->SetInternalFieldCount(2);
56
+
57
+ tmpl->SetLazyDataProperty(
58
+ ConvertToV8String(isolate, "label"),
59
+ GetLabel
60
+ );
61
+
62
+ tmpl->Set(
63
+ ConvertToV8String(isolate, "beginComputePass"),
64
+ v8::FunctionTemplate::New(isolate, &BeginComputePass));
65
+
66
+ tmpl->Set(
67
+ ConvertToV8String(isolate, "beginRenderPass"),
68
+ v8::FunctionTemplate::New(isolate, &BeginRenderPass));
69
+
70
+ tmpl->Set(
71
+ ConvertToV8String(isolate, "clearBuffer"),
72
+ v8::FunctionTemplate::New(isolate, &ClearBuffer));
73
+
74
+ tmpl->Set(
75
+ ConvertToV8String(isolate, "copyBufferToBuffer"),
76
+ v8::FunctionTemplate::New(isolate, &CopyBufferToBuffer));
77
+
78
+ tmpl->Set(
79
+ ConvertToV8String(isolate, "copyBufferToTexture"),
80
+ v8::FunctionTemplate::New(isolate, &CopyBufferToTexture));
81
+
82
+ tmpl->Set(
83
+ ConvertToV8String(isolate, "copyTextureToBuffer"),
84
+ v8::FunctionTemplate::New(isolate, &CopyTextureToBuffer));
85
+
86
+ tmpl->Set(
87
+ ConvertToV8String(isolate, "copyTextureToTexture"),
88
+ v8::FunctionTemplate::New(isolate, &CopyTextureToTexture));
89
+
90
+ tmpl->Set(
91
+ ConvertToV8String(isolate, "finish"),
92
+ v8::FunctionTemplate::New(isolate, &Finish));
93
+
94
+ tmpl->Set(
95
+ ConvertToV8String(isolate, "insertDebugMarker"),
96
+ v8::FunctionTemplate::New(isolate, &InsertDebugMarker));
97
+
98
+ tmpl->Set(
99
+ ConvertToV8String(isolate, "popDebugGroup"),
100
+ v8::FunctionTemplate::New(isolate, &PopDebugGroup));
101
+
102
+ tmpl->Set(
103
+ ConvertToV8String(isolate, "pushDebugGroup"),
104
+ v8::FunctionTemplate::New(isolate, &PushDebugGroup));
105
+
106
+ tmpl->Set(
107
+ ConvertToV8String(isolate, "resolveQuerySet"),
108
+ v8::FunctionTemplate::New(isolate, &ResolveQuerySet));
109
+
110
+ tmpl->Set(
111
+ ConvertToV8String(isolate, "writeTimestamp"),
112
+ v8::FunctionTemplate::New(isolate, &WriteTimestamp));
113
+
114
+
115
+ cache->GPUCommandEncoderTmpl =
116
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
117
+ return ctorTmpl;
118
+ }
119
+
120
+ void
121
+ GPUCommandEncoderImpl::GetLabel(v8::Local<v8::Name> name,
122
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
123
+ auto ptr = GetPointer(info.This());
124
+ if (ptr != nullptr) {
125
+ auto label = canvas_native_webgpu_command_encoder_get_label(ptr->encoder_);
126
+ if (label == nullptr) {
127
+ info.GetReturnValue().SetEmptyString();
128
+ return;
129
+ }
130
+ info.GetReturnValue().Set(
131
+ ConvertToV8String(info.GetIsolate(), label)
132
+ );
133
+ canvas_native_string_destroy(label);
134
+ return;
135
+ }
136
+
137
+ info.GetReturnValue().SetEmptyString();
138
+ }
139
+
140
+
141
+ void GPUCommandEncoderImpl::BeginComputePass(const v8::FunctionCallbackInfo<v8::Value> &args) {
142
+ auto ptr = GetPointer(args.This());
143
+ if (ptr == nullptr) {
144
+ return;
145
+ }
146
+
147
+ auto isolate = args.GetIsolate();
148
+ auto context = isolate->GetCurrentContext();
149
+
150
+ auto descVal = args[0];
151
+
152
+ const CanvasGPUComputePassEncoder *pass;
153
+
154
+ if (!descVal->IsNullOrUndefined() && descVal->IsObject()) {
155
+ auto desc = descVal.As<v8::Object>();
156
+
157
+
158
+ v8::Local<v8::Value> labelVal;
159
+ desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
160
+
161
+ auto label = GPULabel(isolate, labelVal);
162
+
163
+ const CanvasGPUQuerySet *querySet = nullptr;
164
+
165
+ int32_t beginningOfPassWriteIndex = -1;
166
+
167
+ int32_t endOfPassWriteIndex = -1;
168
+
169
+
170
+ v8::Local<v8::Value> timestampWritesVal;
171
+
172
+ auto success = desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
173
+ &timestampWritesVal);
174
+ if (success && timestampWritesVal->IsObject()) {
175
+ auto timestampWrites = timestampWritesVal.As<v8::Object>();
176
+
177
+ v8::Local<v8::Value> querySetVal;
178
+ success = timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
179
+ &querySetVal);
180
+
181
+
182
+ if (success && querySetVal->IsObject()) {
183
+ auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
184
+ if (queryPtr != nullptr) {
185
+ querySet = queryPtr->GetQuerySet();
186
+ }
187
+ }
188
+
189
+ v8::Local<v8::Value> beginningOfPassWriteIndexVal;
190
+
191
+
192
+ v8::Local<v8::Value> endOfPassWriteIndexVal;
193
+
194
+
195
+ success = timestampWrites->Get(context,
196
+ ConvertToV8String(isolate,
197
+ "beginningOfPassWriteIndex")).ToLocal(
198
+ &beginningOfPassWriteIndexVal);
199
+
200
+ if (success && beginningOfPassWriteIndexVal->IsInt32()) {
201
+ beginningOfPassWriteIndex = beginningOfPassWriteIndexVal.As<v8::Int32>()->Value();
202
+ }
203
+
204
+ success = timestampWrites->Get(context,
205
+ ConvertToV8String(isolate,
206
+ "endOfPassWriteIndex")).ToLocal(
207
+ &endOfPassWriteIndexVal);
208
+
209
+
210
+ if (success && endOfPassWriteIndexVal->IsInt32()) {
211
+ endOfPassWriteIndex = endOfPassWriteIndexVal.As<v8::Int32>()->Value();
212
+ }
213
+ }
214
+
215
+
216
+ pass = canvas_native_webgpu_command_encoder_begin_compute_pass(ptr->GetEncoder(),
217
+ querySet, *label,
218
+ beginningOfPassWriteIndex,
219
+ endOfPassWriteIndex);
220
+
221
+
222
+ } else {
223
+ pass = canvas_native_webgpu_command_encoder_begin_compute_pass(ptr->GetEncoder(),
224
+ nullptr, nullptr, -1,
225
+ -1);
226
+
227
+ }
228
+
229
+
230
+ if (pass != nullptr) {
231
+ auto value = new GPUComputePassEncoderImpl(pass);
232
+ auto ret = GPUComputePassEncoderImpl::NewInstance(isolate, value);
233
+ args.GetReturnValue().Set(ret);
234
+ } else {
235
+ args.GetReturnValue().SetUndefined();
236
+ }
237
+
238
+ }
239
+
240
+ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::Value> &args) {
241
+ auto ptr = GetPointer(args.This());
242
+ if (ptr == nullptr) {
243
+ return;
244
+ }
245
+
246
+ auto isolate = args.GetIsolate();
247
+ auto context = isolate->GetCurrentContext();
248
+
249
+ auto descVal = args[0];
250
+
251
+ const CanvasGPURenderPassEncoder *pass = nullptr;
252
+
253
+ std::vector<CanvasRenderPassColorAttachment> colorAttachments_;
254
+
255
+ if (!descVal->IsNullOrUndefined() && descVal->IsObject()) {
256
+ auto desc = descVal.As<v8::Object>();
257
+
258
+ v8::Local<v8::Value> labelVal;
259
+ desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
260
+
261
+ auto label = GPULabel(isolate, labelVal);
262
+
263
+
264
+ v8::Local<v8::Value> colorAttachmentsVal;
265
+ desc->Get(context, ConvertToV8String(isolate, "colorAttachments")).ToLocal(
266
+ &colorAttachmentsVal);
267
+
268
+ auto colorAttachments = colorAttachmentsVal.As<v8::Array>();
269
+ auto colorAttachmentsLength = colorAttachments->Length();
270
+
271
+ for (int i = 0; i < colorAttachmentsLength; i++) {
272
+ auto colorAttachment = colorAttachments->Get(context,
273
+ i).ToLocalChecked().As<v8::Object>();
274
+
275
+ v8::Local<v8::Value> clearValueVal;
276
+ colorAttachment->Get(context, ConvertToV8String(isolate, "clearValue")).ToLocal(
277
+ &clearValueVal);
278
+
279
+ auto clearValue = ParseColor(isolate, clearValueVal);
280
+
281
+ const CanvasGPUTextureView *view = nullptr;
282
+
283
+ v8::Local<v8::Value> viewVal;
284
+
285
+ if (colorAttachment->Get(context, ConvertToV8String(isolate,
286
+ "view")).ToLocal(&viewVal)) {
287
+ auto type = GetNativeType(viewVal);
288
+ if (type == NativeType::GPUTextureView) {
289
+ auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
290
+ view = viewPtr->GetTextureView();
291
+ }
292
+ }
293
+
294
+
295
+ const CanvasGPUTextureView *resolveTarget = nullptr;
296
+
297
+ v8::Local<v8::Value> resolveTargetVal;
298
+
299
+ colorAttachment->Get(context, ConvertToV8String(isolate, "resolveTarget")).ToLocal(
300
+ &resolveTargetVal);
301
+
302
+ auto resolve_target_type = GetNativeType(resolveTargetVal);
303
+
304
+ if (resolve_target_type == NativeType::GPUTextureView) {
305
+ auto res = GPUTextureViewImpl::GetPointer(resolveTargetVal.As<v8::Object>());
306
+ resolveTarget = res->GetTextureView();
307
+ }
308
+
309
+ v8::Local<v8::Value> loadVal;
310
+ v8::Local<v8::Value> storeVal;
311
+ colorAttachment->Get(context, ConvertToV8String(isolate,
312
+ "loadOp")).ToLocal(&loadVal);
313
+
314
+ colorAttachment->Get(context, ConvertToV8String(isolate,
315
+ "storeOp")).ToLocal(&storeVal);
316
+
317
+
318
+ CanvasLoadOp load = ParseCanvasLoadOp(isolate, loadVal);
319
+ CanvasStoreOp store = ParseCanvasStoreOp(isolate, storeVal);
320
+
321
+
322
+ CanvasPassChannelColor channel{
323
+ load,
324
+ store,
325
+ clearValue,
326
+ false
327
+ };
328
+
329
+ auto attachment = CanvasRenderPassColorAttachment{
330
+ view,
331
+ resolveTarget,
332
+ channel
333
+ };
334
+
335
+ colorAttachments_.push_back(attachment);
336
+
337
+ }
338
+
339
+
340
+ // todo add when supported
341
+ v8::Local<v8::Value> maxDrawCountVal;
342
+ desc->Get(context, ConvertToV8String(isolate, "maxDrawCount")).ToLocal(&maxDrawCountVal);
343
+
344
+
345
+ CanvasRenderPassDepthStencilAttachment *depthStencilAttachment = nullptr;
346
+ v8::Local<v8::Value> depthStencilAttachmentVal;
347
+
348
+ desc->Get(context, ConvertToV8String(isolate, "depthStencilAttachment")).ToLocal(
349
+ &depthStencilAttachmentVal);
350
+
351
+
352
+ if (!depthStencilAttachmentVal.IsEmpty() && depthStencilAttachmentVal->IsObject()) {
353
+ auto depthStencilAttachmentObj = depthStencilAttachmentVal.As<v8::Object>();
354
+ depthStencilAttachment = new CanvasRenderPassDepthStencilAttachment{};
355
+
356
+
357
+ v8::Local<v8::Value> viewVal;
358
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
359
+ "view")).ToLocal(&viewVal);
360
+
361
+ auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
362
+ depthStencilAttachment->view = viewPtr->GetTextureView();
363
+
364
+
365
+ v8::Local<v8::Value> depthClearValue;
366
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
367
+ "depthClearValue")).ToLocal(
368
+ &depthClearValue);
369
+
370
+ depthStencilAttachment->depth_clear_value = 0;
371
+
372
+ if (!depthClearValue.IsEmpty() && depthClearValue->IsNumber()) {
373
+ depthStencilAttachment->depth_clear_value = (float) depthClearValue->NumberValue(
374
+ context).FromJust();
375
+ }
376
+
377
+ v8::Local<v8::Value> depthLoadOp;
378
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
379
+ "depthLoadOp")).ToLocal(
380
+ &depthLoadOp);
381
+
382
+ depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
383
+ CanvasOptionalLoadOpNone
384
+ };
385
+
386
+ if (!depthLoadOp.IsEmpty() && depthLoadOp->IsString()) {
387
+ auto value = ConvertFromV8String(isolate, depthLoadOp);
388
+ if (value == "load") {
389
+ depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
390
+ CanvasOptionalLoadOpSome,
391
+ CanvasLoadOpLoad
392
+ };
393
+ } else if (value == "clear") {
394
+ depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
395
+ CanvasOptionalLoadOpSome,
396
+ CanvasLoadOpClear
397
+ };
398
+ }
399
+ }
400
+
401
+
402
+ v8::Local<v8::Value> depthStoreOp;
403
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
404
+ "depthStoreOp")).ToLocal(
405
+ &depthStoreOp);
406
+
407
+ depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
408
+ CanvasOptionalStoreOpNone
409
+ };
410
+
411
+ if (!depthStoreOp.IsEmpty() && depthStoreOp->IsString()) {
412
+ auto value = ConvertFromV8String(isolate, depthStoreOp);
413
+ if (value == "store") {
414
+ depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
415
+ CanvasOptionalStoreOpSome,
416
+ CanvasStoreOpStore
417
+ };
418
+ } else if (value == "discard") {
419
+ depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
420
+ CanvasOptionalStoreOpSome,
421
+ CanvasStoreOpDiscard
422
+ };
423
+ }
424
+ }
425
+
426
+
427
+ v8::Local<v8::Value> depthReadOnly;
428
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
429
+ "depthReadOnly")).ToLocal(
430
+ &depthReadOnly);
431
+
432
+ depthStencilAttachment->depth_read_only = false;
433
+ if (!depthReadOnly.IsEmpty() && depthReadOnly->IsBoolean()) {
434
+ depthStencilAttachment->depth_read_only = depthReadOnly->BooleanValue(isolate);
435
+ }
436
+
437
+
438
+ v8::Local<v8::Value> stencilClearValue;
439
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
440
+ "stencilClearValue")).ToLocal(
441
+ &stencilClearValue);
442
+
443
+ depthStencilAttachment->stencil_clear_value = 0;
444
+
445
+ if (!stencilClearValue.IsEmpty() && stencilClearValue->IsUint32()) {
446
+ depthStencilAttachment->stencil_clear_value = stencilClearValue->Uint32Value(
447
+ context).FromJust();
448
+ }
449
+
450
+
451
+ v8::Local<v8::Value> stencilLoadOp;
452
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
453
+ "stencilLoadOp")).ToLocal(
454
+ &stencilLoadOp);
455
+
456
+ depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
457
+ CanvasOptionalLoadOpNone
458
+ };
459
+
460
+ if (!stencilLoadOp.IsEmpty() && stencilLoadOp->IsString()) {
461
+ auto value = ConvertFromV8String(isolate, stencilLoadOp);
462
+ if (value == "load") {
463
+ depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
464
+ CanvasOptionalLoadOpSome,
465
+ CanvasLoadOpLoad
466
+ };
467
+ } else if (value == "clear") {
468
+ depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
469
+ CanvasOptionalLoadOpSome,
470
+ CanvasLoadOpClear
471
+ };
472
+ }
473
+ }
474
+
475
+
476
+ v8::Local<v8::Value> stencilStoreOp;
477
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
478
+ "stencilStoreOp")).ToLocal(
479
+ &stencilStoreOp);
480
+
481
+ depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
482
+ CanvasOptionalStoreOpNone
483
+ };
484
+
485
+ if (!stencilStoreOp.IsEmpty() && stencilStoreOp->IsString()) {
486
+ auto value = ConvertFromV8String(isolate, stencilStoreOp);
487
+ if (value == "store") {
488
+ depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
489
+ CanvasOptionalStoreOpSome,
490
+ CanvasStoreOpStore
491
+ };
492
+ } else if (value == "discard") {
493
+ depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
494
+ CanvasOptionalStoreOpSome,
495
+ CanvasStoreOpDiscard
496
+ };
497
+ }
498
+ }
499
+
500
+
501
+ v8::Local<v8::Value> stencilReadOnly;
502
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
503
+ "stencilReadOnly")).ToLocal(
504
+ &stencilReadOnly);
505
+
506
+ depthStencilAttachment->stencil_read_only = false;
507
+ if (!stencilReadOnly.IsEmpty() && stencilReadOnly->IsBoolean()) {
508
+ depthStencilAttachment->stencil_read_only = stencilReadOnly->BooleanValue(isolate);
509
+ }
510
+
511
+ }
512
+
513
+ const CanvasGPUQuerySet *occlusion_query_set = nullptr;
514
+ v8::Local<v8::Value> occlusionQuerySetVal;
515
+
516
+
517
+ desc->Get(context, ConvertToV8String(isolate, "occlusionQuerySet")).ToLocal(
518
+ &occlusionQuerySetVal);
519
+
520
+
521
+ if (GetNativeType(occlusionQuerySetVal) == NativeType::GPUQuerySet) {
522
+ auto occlusionQuerySet = GPUQuerySetImpl::GetPointer(
523
+ occlusionQuerySetVal.As<v8::Object>());
524
+ occlusion_query_set = occlusionQuerySet->GetQuerySet();
525
+ }
526
+
527
+
528
+ v8::Local<v8::Value> timestampWritesVal;
529
+ desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
530
+ &timestampWritesVal);
531
+
532
+
533
+ const CanvasGPUQuerySet *querySet = nullptr;
534
+ int32_t beginningOfPassWriteIndex = -1;
535
+ int32_t endOfPassWriteIndex = -1;
536
+
537
+ if (!timestampWritesVal.IsEmpty() && timestampWritesVal->IsObject()) {
538
+ auto timestampWrites = timestampWritesVal.As<v8::Object>();
539
+ v8::Local<v8::Value> querySetVal;
540
+ timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
541
+ &querySetVal);
542
+
543
+
544
+ if (GetNativeType(querySetVal) == NativeType::GPUQuerySet) {
545
+ auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
546
+ if (queryPtr != nullptr) {
547
+ querySet = queryPtr->GetQuerySet();
548
+ }
549
+ }
550
+
551
+ v8::Local<v8::Value> beginningOfPassWriteIndexVal;
552
+
553
+ v8::Local<v8::Value> endOfPassWriteIndexVal;
554
+
555
+
556
+ auto beginningOfPassWriteIndexValSuccess = timestampWrites->Get(context,
557
+ ConvertToV8String(
558
+ isolate,
559
+ "beginningOfPassWriteIndex")).ToLocal(
560
+ &beginningOfPassWriteIndexVal);
561
+
562
+ auto endOfPassWriteIndexValSuccess = timestampWrites->Get(context,
563
+ ConvertToV8String(isolate,
564
+ "endOfPassWriteIndex")).ToLocal(
565
+ &endOfPassWriteIndexVal);
566
+
567
+
568
+ if (beginningOfPassWriteIndexValSuccess && beginningOfPassWriteIndexVal->IsInt32()) {
569
+ beginningOfPassWriteIndex = beginningOfPassWriteIndexVal.As<v8::Int32>()->Value();
570
+ }
571
+
572
+ if (endOfPassWriteIndexValSuccess && endOfPassWriteIndexVal->IsInt32()) {
573
+ endOfPassWriteIndex = endOfPassWriteIndexVal.As<v8::Int32>()->Value();
574
+ }
575
+
576
+ }
577
+
578
+
579
+ pass = canvas_native_webgpu_command_encoder_begin_render_pass(
580
+ ptr->GetEncoder(), *label, colorAttachments_.data(), colorAttachments_.size(),
581
+ depthStencilAttachment, occlusion_query_set,
582
+ querySet, beginningOfPassWriteIndex, endOfPassWriteIndex
583
+ );
584
+
585
+ if (depthStencilAttachment != nullptr) {
586
+ delete depthStencilAttachment;
587
+ depthStencilAttachment = nullptr;
588
+ }
589
+
590
+
591
+ }
592
+
593
+
594
+ if (pass != nullptr) {
595
+ auto value = new GPURenderPassEncoderImpl(pass);
596
+ auto ret = GPURenderPassEncoderImpl::NewInstance(isolate, value);
597
+ args.GetReturnValue().Set(ret);
598
+ } else {
599
+ args.GetReturnValue().SetUndefined();
600
+ }
601
+
602
+ }
603
+
604
+ void GPUCommandEncoderImpl::ClearBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
605
+ auto ptr = GetPointer(args.This());
606
+ if (ptr == nullptr) {
607
+ return;
608
+ }
609
+
610
+ auto bufferVal = args[0];
611
+ const CanvasGPUBuffer *buffer = nullptr;
612
+
613
+ if (bufferVal->IsObject()) {
614
+ auto bufferPtr = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
615
+ if (bufferPtr != nullptr) {
616
+ buffer = bufferPtr->GetGPUBuffer();
617
+ }
618
+ }
619
+
620
+ if (buffer == nullptr) {
621
+ return;
622
+ }
623
+
624
+ int64_t offset = -1;
625
+ auto offsetVal = args[1];
626
+
627
+ if (offsetVal->IsNumber()) {
628
+ offset = (int64_t) offsetVal.As<v8::Number>()->Value();
629
+ }
630
+
631
+ int64_t size = -1;
632
+ auto sizeVal = args[2];
633
+
634
+ if (sizeVal->IsNumber()) {
635
+ size = (int64_t) sizeVal.As<v8::Number>()->Value();
636
+ }
637
+
638
+ canvas_native_webgpu_command_encoder_clear_buffer(ptr->GetEncoder(), buffer, offset, size);
639
+
640
+ }
641
+
642
+ void GPUCommandEncoderImpl::CopyBufferToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
643
+ auto ptr = GetPointer(args.This());
644
+ if (ptr == nullptr) {
645
+ return;
646
+ }
647
+ auto isolate = args.GetIsolate();
648
+ auto context = isolate->GetCurrentContext();
649
+
650
+ auto source = args[0];
651
+ auto sourceType = GetNativeType(source);
652
+ auto sourceOffset = args[1];
653
+ auto destination = args[2];
654
+ auto destinationType = GetNativeType(destination);
655
+ auto destinationOffset = args[3];
656
+ auto size = args[4];
657
+
658
+ if (sourceType == NativeType::GPUBuffer && destinationType == NativeType::GPUBuffer) {
659
+ auto src = GPUBufferImpl::GetPointer(source.As<v8::Object>());
660
+ auto dst = GPUBufferImpl::GetPointer(destination.As<v8::Object>());
661
+ canvas_native_webgpu_command_encoder_copy_buffer_to_buffer(ptr->GetEncoder(),
662
+ src->GetGPUBuffer(),
663
+ (int64_t) sourceOffset->NumberValue(
664
+ context).FromJust(),
665
+ dst->GetGPUBuffer(),
666
+ (int64_t) destinationOffset->NumberValue(
667
+ context).FromJust(),
668
+ (uint64_t) size->NumberValue(
669
+ context).FromJust()
670
+ );
671
+ }
672
+
673
+ }
674
+
675
+ void GPUCommandEncoderImpl::CopyBufferToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
676
+ auto ptr = GetPointer(args.This());
677
+ if (ptr == nullptr) {
678
+ return;
679
+ }
680
+
681
+
682
+ auto isolate = args.GetIsolate();
683
+ auto context = isolate->GetCurrentContext();
684
+
685
+ auto source = args[0];
686
+ auto destination = args[1];
687
+ auto copySize = args[2];
688
+
689
+ if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
690
+ const CanvasGPUBuffer *buffer = nullptr;
691
+ auto src = source.As<v8::Object>();
692
+ v8::Local<v8::Value> bufferVal;
693
+ src->Get(context, ConvertToV8String(isolate, "buffer")).ToLocal(&bufferVal);
694
+ if (GetNativeType(bufferVal) == NativeType::GPUBuffer) {
695
+ buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>())->GetGPUBuffer();
696
+ }
697
+ uint64_t offset = 0;
698
+ int32_t rowsPerImage = -1;
699
+
700
+ v8::Local<v8::Value> rowsPerImageVal;
701
+
702
+ src->Get(context, ConvertToV8String(isolate, "rowsPerImage")).ToLocal(&rowsPerImageVal);
703
+
704
+ if (!rowsPerImageVal.IsEmpty() && rowsPerImageVal->IsInt32()) {
705
+ rowsPerImage = rowsPerImageVal->Int32Value(context).FromJust();
706
+ }
707
+
708
+
709
+ v8::Local<v8::Value> offsetVal;
710
+
711
+ src->Get(context, ConvertToV8String(isolate, "offset")).ToLocal(&offsetVal);
712
+
713
+ if (!offsetVal.IsEmpty() && offsetVal->IsNumber()) {
714
+ offset = (int64_t) offsetVal->NumberValue(context).FromJust();
715
+ }
716
+
717
+ v8::Local<v8::Value> bytesPerRowVal;
718
+
719
+ src->Get(context, ConvertToV8String(isolate, "bytesPerRow")).ToLocal(&bytesPerRowVal);
720
+
721
+ CanvasImageCopyBuffer copy{
722
+ buffer,
723
+ offset,
724
+ bytesPerRowVal->Int32Value(context).FromJust(),
725
+ rowsPerImage
726
+ };
727
+
728
+
729
+ uint32_t mipLevel = 0;
730
+ CanvasOrigin3d origin{0, 0, 0};
731
+ CanvasTextureAspect aspect = CanvasTextureAspectAll;
732
+
733
+ const CanvasGPUTexture *texture = nullptr;
734
+ auto dst = destination.As<v8::Object>();
735
+
736
+
737
+ v8::Local<v8::Value> textureVal;
738
+ dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
739
+ if (GetNativeType(textureVal) == NativeType::GPUTexture) {
740
+ texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
741
+ }
742
+
743
+
744
+ v8::Local<v8::Value> mipLevelVal;
745
+ dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
746
+
747
+ if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
748
+ mipLevel = mipLevelVal->Uint32Value(context).FromJust();
749
+ }
750
+
751
+ v8::Local<v8::Value> originVal;
752
+ dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
753
+
754
+
755
+ if (!originVal.IsEmpty() && originVal->IsObject()) {
756
+ auto originObj = originVal.As<v8::Object>();
757
+
758
+
759
+ v8::Local<v8::Value> xVal;
760
+ v8::Local<v8::Value> yVal;
761
+ v8::Local<v8::Value> zVal;
762
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
763
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
764
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
765
+
766
+ if (xVal->IsUint32()) {
767
+ origin.x = xVal->Uint32Value(context).FromJust();
768
+ }
769
+ if (yVal->IsUint32()) {
770
+ origin.y = yVal->Uint32Value(context).FromJust();
771
+ }
772
+ if (zVal->IsUint32()) {
773
+ origin.z = zVal->Uint32Value(context).FromJust();
774
+ }
775
+
776
+ }
777
+
778
+
779
+ v8::Local<v8::Value> aspectVal;
780
+ dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
781
+
782
+
783
+ auto aspectStr = ConvertFromV8String(isolate, aspectVal);
784
+
785
+ if (aspectStr == "stencil-only") {
786
+ aspect = CanvasTextureAspectStencilOnly;
787
+ } else if (aspectStr == "depth-only") {
788
+ aspect = CanvasTextureAspectDepthOnly;
789
+ }
790
+
791
+ CanvasImageCopyTexture ct{
792
+ texture, mipLevel, origin, aspect
793
+ };
794
+
795
+ CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
796
+ canvas_native_webgpu_command_encoder_copy_buffer_to_texture(
797
+ ptr->GetEncoder(),
798
+ &copy,
799
+ &ct,
800
+ &cz
801
+ );
802
+ }
803
+
804
+
805
+ }
806
+
807
+ void GPUCommandEncoderImpl::CopyTextureToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
808
+ auto ptr = GetPointer(args.This());
809
+ if (ptr == nullptr) {
810
+ return;
811
+ }
812
+
813
+
814
+ auto isolate = args.GetIsolate();
815
+ auto context = isolate->GetCurrentContext();
816
+
817
+ // copying texture to buffer swapped the real source and dst
818
+ auto source = args[1];
819
+ auto destination = args[0];
820
+ auto copySize = args[2];
821
+
822
+ if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
823
+ const CanvasGPUBuffer *buffer = nullptr;
824
+ auto src = source.As<v8::Object>();
825
+
826
+ v8::Local<v8::Value> bufferVal;
827
+ src->Get(context, ConvertToV8String(isolate, "buffer")).ToLocal(&bufferVal);
828
+ if (GetNativeType(bufferVal) == NativeType::GPUBuffer) {
829
+ buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>())->GetGPUBuffer();
830
+ }
831
+ uint64_t offset = 0;
832
+ int32_t rowsPerImage = -1;
833
+
834
+ v8::Local<v8::Value> rowsPerImageVal;
835
+
836
+ src->Get(context, ConvertToV8String(isolate, "rowsPerImage")).ToLocal(&rowsPerImageVal);
837
+
838
+ if (!rowsPerImageVal.IsEmpty() && rowsPerImageVal->IsInt32()) {
839
+ rowsPerImage = rowsPerImageVal->Int32Value(context).FromJust();
840
+ }
841
+
842
+
843
+ v8::Local<v8::Value> offsetVal;
844
+
845
+ src->Get(context, ConvertToV8String(isolate, "offset")).ToLocal(&offsetVal);
846
+
847
+ if (!offsetVal.IsEmpty() && offsetVal->IsNumber()) {
848
+ offset = (int64_t) offsetVal->NumberValue(context).FromJust();
849
+ }
850
+
851
+ v8::Local<v8::Value> bytesPerRowVal;
852
+
853
+ src->Get(context, ConvertToV8String(isolate, "bytesPerRow")).ToLocal(&bytesPerRowVal);
854
+
855
+ CanvasImageCopyBuffer copy{
856
+ buffer,
857
+ offset,
858
+ bytesPerRowVal->Int32Value(context).FromJust(),
859
+ rowsPerImage
860
+ };
861
+
862
+
863
+ uint32_t mipLevel = 0;
864
+ CanvasOrigin3d origin{0, 0, 0};
865
+ CanvasTextureAspect aspect = CanvasTextureAspectAll;
866
+
867
+ const CanvasGPUTexture *texture = nullptr;
868
+ auto dst = destination.As<v8::Object>();
869
+
870
+
871
+ v8::Local<v8::Value> textureVal;
872
+ dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
873
+ if (GetNativeType(textureVal) == NativeType::GPUTexture) {
874
+ texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
875
+ }
876
+
877
+
878
+ v8::Local<v8::Value> mipLevelVal;
879
+ dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
880
+
881
+ if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
882
+ mipLevel = mipLevelVal->Uint32Value(context).FromJust();
883
+ }
884
+
885
+ v8::Local<v8::Value> originVal;
886
+ dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
887
+
888
+
889
+ if (!originVal.IsEmpty() && originVal->IsObject()) {
890
+ auto originObj = originVal.As<v8::Object>();
891
+
892
+
893
+ v8::Local<v8::Value> xVal;
894
+ v8::Local<v8::Value> yVal;
895
+ v8::Local<v8::Value> zVal;
896
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
897
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
898
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
899
+
900
+ if (xVal->IsUint32()) {
901
+ origin.x = xVal->Uint32Value(context).FromJust();
902
+ }
903
+ if (yVal->IsUint32()) {
904
+ origin.y = yVal->Uint32Value(context).FromJust();
905
+ }
906
+ if (zVal->IsUint32()) {
907
+ origin.z = zVal->Uint32Value(context).FromJust();
908
+ }
909
+
910
+ }
911
+
912
+
913
+ v8::Local<v8::Value> aspectVal;
914
+ dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
915
+
916
+
917
+ auto aspectStr = ConvertFromV8String(isolate, aspectVal);
918
+
919
+ if (aspectStr == "stencil-only") {
920
+ aspect = CanvasTextureAspectStencilOnly;
921
+ } else if (aspectStr == "depth-only") {
922
+ aspect = CanvasTextureAspectDepthOnly;
923
+ }
924
+
925
+ CanvasImageCopyTexture ct{
926
+ texture, mipLevel, origin, aspect
927
+ };
928
+
929
+ CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
930
+ canvas_native_webgpu_command_encoder_copy_texture_to_buffer(
931
+ ptr->GetEncoder(),
932
+ &ct,
933
+ &copy,
934
+ &cz
935
+ );
936
+ }
937
+
938
+
939
+ }
940
+
941
+ void GPUCommandEncoderImpl::CopyTextureToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
942
+ auto ptr = GetPointer(args.This());
943
+ if (ptr == nullptr) {
944
+ return;
945
+ }
946
+
947
+ auto isolate = args.GetIsolate();
948
+ auto context = isolate->GetCurrentContext();
949
+
950
+ // copying texture to buffer swapped the real source and dst
951
+ auto source = args[0];
952
+ auto destination = args[1];
953
+ auto copySize = args[2];
954
+
955
+ if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
956
+ auto src = source.As<v8::Object>();
957
+
958
+ uint32_t mipLevelA = 0;
959
+ CanvasOrigin3d originA{0, 0, 0};
960
+ CanvasTextureAspect aspectA = CanvasTextureAspectAll;
961
+
962
+ const CanvasGPUTexture *textureA = nullptr;
963
+
964
+ v8::Local<v8::Value> srcTextureVal;
965
+ src->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&srcTextureVal);
966
+ if (GetNativeType(srcTextureVal) == NativeType::GPUTexture) {
967
+ textureA = GPUTextureImpl::GetPointer(srcTextureVal.As<v8::Object>())->GetTexture();
968
+ }
969
+
970
+ v8::Local<v8::Value> mipLevelAVal;
971
+ src->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelAVal);
972
+
973
+ if (!mipLevelAVal.IsEmpty() && mipLevelAVal->IsUint32()) {
974
+ mipLevelA = mipLevelAVal->Uint32Value(context).FromJust();
975
+ }
976
+
977
+ v8::Local<v8::Value> originAVal;
978
+ src->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originAVal);
979
+
980
+
981
+ if (!originAVal.IsEmpty() && originAVal->IsObject()) {
982
+ auto originObj = originAVal.As<v8::Object>();
983
+
984
+ v8::Local<v8::Value> xVal;
985
+ v8::Local<v8::Value> yVal;
986
+ v8::Local<v8::Value> zVal;
987
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
988
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
989
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
990
+
991
+ if (xVal->IsUint32()) {
992
+ originA.x = xVal->Uint32Value(context).FromJust();
993
+ }
994
+ if (yVal->IsUint32()) {
995
+ originA.y = yVal->Uint32Value(context).FromJust();
996
+ }
997
+ if (zVal->IsUint32()) {
998
+ originA.z = zVal->Uint32Value(context).FromJust();
999
+ }
1000
+
1001
+ }
1002
+
1003
+ v8::Local<v8::Value> aspectAVal;
1004
+ src->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectAVal);
1005
+
1006
+ auto aspectAStr = ConvertFromV8String(isolate, aspectAVal);
1007
+
1008
+ if (aspectAStr == "stencil-only") {
1009
+ aspectA = CanvasTextureAspectStencilOnly;
1010
+ } else if (aspectAStr == "depth-only") {
1011
+ aspectA = CanvasTextureAspectDepthOnly;
1012
+ }
1013
+ CanvasImageCopyTexture copy{
1014
+ textureA, mipLevelA, originA, aspectA
1015
+ };
1016
+
1017
+ uint32_t mipLevel = 0;
1018
+ CanvasOrigin3d origin{0, 0, 0};
1019
+ CanvasTextureAspect aspect = CanvasTextureAspectAll;
1020
+
1021
+ const CanvasGPUTexture *texture = nullptr;
1022
+ auto dst = destination.As<v8::Object>();
1023
+
1024
+
1025
+ v8::Local<v8::Value> textureVal;
1026
+ dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
1027
+ if (GetNativeType(textureVal) == NativeType::GPUTexture) {
1028
+ texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
1029
+ }
1030
+
1031
+
1032
+ v8::Local<v8::Value> mipLevelVal;
1033
+ dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
1034
+
1035
+ if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
1036
+ mipLevel = mipLevelVal->Uint32Value(context).FromJust();
1037
+ }
1038
+
1039
+ v8::Local<v8::Value> originVal;
1040
+ dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
1041
+
1042
+ if (!originVal.IsEmpty() && originVal->IsObject()) {
1043
+ auto originObj = originVal.As<v8::Object>();
1044
+
1045
+ v8::Local<v8::Value> xVal;
1046
+ v8::Local<v8::Value> yVal;
1047
+ v8::Local<v8::Value> zVal;
1048
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
1049
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
1050
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
1051
+
1052
+ if (xVal->IsUint32()) {
1053
+ origin.x = xVal->Uint32Value(context).FromJust();
1054
+ }
1055
+ if (yVal->IsUint32()) {
1056
+ origin.y = yVal->Uint32Value(context).FromJust();
1057
+ }
1058
+ if (zVal->IsUint32()) {
1059
+ origin.z = zVal->Uint32Value(context).FromJust();
1060
+ }
1061
+
1062
+ }
1063
+
1064
+
1065
+ v8::Local<v8::Value> aspectVal;
1066
+ dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
1067
+
1068
+ auto aspectStr = ConvertFromV8String(isolate, aspectVal);
1069
+
1070
+ if (aspectStr == "stencil-only") {
1071
+ aspect = CanvasTextureAspectStencilOnly;
1072
+ } else if (aspectStr == "depth-only") {
1073
+ aspect = CanvasTextureAspectDepthOnly;
1074
+ }
1075
+
1076
+ CanvasImageCopyTexture ct{
1077
+ texture, mipLevel, origin, aspect
1078
+ };
1079
+
1080
+ CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
1081
+
1082
+ canvas_native_webgpu_command_encoder_copy_texture_to_texture(
1083
+ ptr->GetEncoder(),
1084
+ &copy,
1085
+ &ct,
1086
+ &cz
1087
+ );
1088
+ }
1089
+
1090
+
1091
+ }
1092
+
1093
+ void GPUCommandEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value> &args) {
1094
+ auto ptr = GetPointer(args.This());
1095
+ if (ptr == nullptr) {
1096
+ return;
1097
+ }
1098
+
1099
+ auto isolate = args.GetIsolate();
1100
+ auto context = isolate->GetCurrentContext();
1101
+
1102
+ auto descVal = args[0];
1103
+ GPULabel label;
1104
+ if (descVal->IsObject()) {
1105
+ auto desc = descVal.As<v8::Object>();
1106
+ v8::Local<v8::Value> labelVal;
1107
+ desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
1108
+ label = GPULabel(isolate, labelVal);
1109
+ }
1110
+
1111
+ auto value = canvas_native_webgpu_command_encoder_finish(ptr->GetEncoder(), *label);
1112
+
1113
+ if (value != nullptr) {
1114
+ auto ret = GPUCommandBufferImpl::NewInstance(isolate, new GPUCommandBufferImpl(value));
1115
+ args.GetReturnValue().Set(ret);
1116
+ return;
1117
+ }
1118
+
1119
+ args.GetReturnValue().SetUndefined();
1120
+ }
1121
+
1122
+ void
1123
+ GPUCommandEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args) {
1124
+ auto *ptr = GetPointer(args.This());
1125
+ if (ptr == nullptr) {
1126
+ return;
1127
+ }
1128
+
1129
+ auto isolate = args.GetIsolate();
1130
+
1131
+ auto markerLabelVal = args[0];
1132
+ if (markerLabelVal->IsString()) {
1133
+ auto markerLabel = ConvertFromV8String(isolate, markerLabelVal);
1134
+ canvas_native_webgpu_command_encoder_insert_debug_marker(ptr->GetEncoder(),
1135
+ markerLabel.c_str());
1136
+ }
1137
+ }
1138
+
1139
+ void GPUCommandEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
1140
+ auto *ptr = GetPointer(args.This());
1141
+ if (ptr == nullptr) {
1142
+ return;
1143
+ }
1144
+
1145
+ canvas_native_webgpu_command_encoder_pop_debug_group(ptr->GetEncoder());
1146
+ }
1147
+
1148
+ void GPUCommandEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
1149
+ auto *ptr = GetPointer(args.This());
1150
+ if (ptr == nullptr) {
1151
+ return;
1152
+ }
1153
+
1154
+ auto isolate = args.GetIsolate();
1155
+
1156
+ auto groupLabelVal = args[0];
1157
+ if (groupLabelVal->IsString()) {
1158
+ auto groupLabel = ConvertFromV8String(isolate, groupLabelVal);
1159
+ canvas_native_webgpu_command_encoder_push_debug_group(ptr->GetEncoder(),
1160
+ groupLabel.c_str());
1161
+ }
1162
+ }
1163
+
1164
+ void GPUCommandEncoderImpl::ResolveQuerySet(const v8::FunctionCallbackInfo<v8::Value> &args) {
1165
+ auto *ptr = GetPointer(args.This());
1166
+ if (ptr == nullptr) {
1167
+ return;
1168
+ }
1169
+
1170
+ auto isolate = args.GetIsolate();
1171
+ auto context = isolate->GetCurrentContext();
1172
+
1173
+ auto querySet = args[0];
1174
+ auto queryType = GetNativeType(querySet);
1175
+ auto firstQuery = args[1];
1176
+ auto queryCount = args[2];
1177
+ auto destination = args[3];
1178
+ auto destinationType = GetNativeType(destination);
1179
+ auto destinationOffset = args[4];
1180
+
1181
+
1182
+ if (queryType == NativeType::GPUQuerySet && destinationType == NativeType::GPUBuffer) {
1183
+ auto qs = GPUQuerySetImpl::GetPointer(querySet.As<v8::Object>());
1184
+ auto dest = GPUBufferImpl::GetPointer(destination.As<v8::Object>());
1185
+ canvas_native_webgpu_command_encoder_resolve_query_set(ptr->GetEncoder(), qs->GetQuerySet(),
1186
+ firstQuery->Uint32Value(
1187
+ context).FromJust(),
1188
+ queryCount->Uint32Value(
1189
+ context).FromJust(),
1190
+ dest->GetGPUBuffer(),
1191
+ (uint64_t) destinationOffset->NumberValue(
1192
+ context).FromJust());
1193
+ }
1194
+ }
1195
+
1196
+ void GPUCommandEncoderImpl::WriteTimestamp(const v8::FunctionCallbackInfo<v8::Value> &args) {
1197
+ auto *ptr = GetPointer(args.This());
1198
+ if (ptr == nullptr) {
1199
+ return;
1200
+ }
1201
+
1202
+ auto isolate = args.GetIsolate();
1203
+ auto context = isolate->GetCurrentContext();
1204
+
1205
+ auto querySet = args[0];
1206
+ auto queryType = GetNativeType(querySet);
1207
+ auto queryIndex = args[1];
1208
+
1209
+ if (queryType == NativeType::GPUQuerySet) {
1210
+ auto qs = GPUQuerySetImpl::GetPointer(querySet.As<v8::Object>());
1211
+ canvas_native_webgpu_command_encoder_write_timestamp(ptr->GetEncoder(), qs->GetQuerySet(),
1212
+ queryIndex->Uint32Value(
1213
+ context).FromJust());
1214
+ }
1215
+
1216
+
1217
+ }