@nativescript/canvas 2.0.0-webgpu.0 → 2.0.0-webgpu.10

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 (293) hide show
  1. package/Canvas/common.d.ts +3 -18
  2. package/Canvas/common.js +9 -72
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +6 -8
  5. package/Canvas/index.android.js +117 -62
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +7 -8
  8. package/Canvas/index.ios.d.ts +3 -2
  9. package/Canvas/index.ios.js +116 -74
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -0
  12. package/Canvas2D/CanvasRenderingContext2D/index.js +72 -72
  13. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  14. package/Canvas2D/DOMMatrix/index.js +1 -1
  15. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  16. package/Canvas2D/ImageData/index.js.map +1 -1
  17. package/Canvas2D/Path2D/index.js.map +1 -1
  18. package/Dom/Dom.js +8 -1
  19. package/Dom/Dom.js.map +1 -1
  20. package/Dom/Group.d.ts +1 -2
  21. package/Dom/Group.js.map +1 -1
  22. package/Dom/Image.d.ts +4 -1
  23. package/Dom/Image.js +15 -2
  24. package/Dom/Image.js.map +1 -1
  25. package/Dom/Paint.d.ts +1 -1
  26. package/Dom/Paint.js.map +1 -1
  27. package/Dom/Text.js.map +1 -1
  28. package/Dom/shaders/LinearGradient.js.map +1 -1
  29. package/Dom/shaders/TwoPointConicalGradient.js.map +1 -1
  30. package/Dom/shapes/Atlas.js.map +1 -1
  31. package/Dom/shapes/Circle.js.map +1 -1
  32. package/Dom/shapes/Line.js.map +1 -1
  33. package/Dom/shapes/Oval.js.map +1 -1
  34. package/Dom/shapes/Path.d.ts +1 -1
  35. package/Dom/shapes/Path.js.map +1 -1
  36. package/Dom/shapes/Rect.js.map +1 -1
  37. package/Dom/shapes/RoundedRect.js.map +1 -1
  38. package/Dom/shapes/index.js.map +1 -1
  39. package/ImageAsset/index.d.ts +3 -1
  40. package/ImageAsset/index.js +38 -6
  41. package/ImageAsset/index.js.map +1 -1
  42. package/ImageBitmap/index.js +3 -3
  43. package/ImageBitmap/index.js.map +1 -1
  44. package/README.md +62 -3
  45. package/TextDecoder/index.js +3 -3
  46. package/TextDecoder/index.js.map +1 -1
  47. package/TextEncoder/index.js +3 -3
  48. package/TextEncoder/index.js.map +1 -1
  49. package/WebGL/WebGLExtensions/index.js +5 -5
  50. package/WebGL/WebGLExtensions/index.js.map +1 -1
  51. package/WebGL/WebGLRenderingContext/common.js.map +1 -1
  52. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  53. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  54. package/WebGPU/Constants.js.map +1 -1
  55. package/WebGPU/GPU.js.map +1 -1
  56. package/WebGPU/GPUAdapter.d.ts +4 -2
  57. package/WebGPU/GPUAdapter.js +3 -0
  58. package/WebGPU/GPUAdapter.js.map +1 -1
  59. package/WebGPU/GPUAdapterInfo.js.map +1 -1
  60. package/WebGPU/GPUBindGroup.d.ts +1 -0
  61. package/WebGPU/GPUBindGroup.js +3 -0
  62. package/WebGPU/GPUBindGroup.js.map +1 -1
  63. package/WebGPU/GPUBindGroupLayout.d.ts +1 -0
  64. package/WebGPU/GPUBindGroupLayout.js +3 -0
  65. package/WebGPU/GPUBindGroupLayout.js.map +1 -1
  66. package/WebGPU/GPUBuffer.js +6 -2
  67. package/WebGPU/GPUBuffer.js.map +1 -1
  68. package/WebGPU/GPUCanvasContext.d.ts +4 -2
  69. package/WebGPU/GPUCanvasContext.js +16 -4
  70. package/WebGPU/GPUCanvasContext.js.map +1 -1
  71. package/WebGPU/GPUCommandBuffer.d.ts +1 -0
  72. package/WebGPU/GPUCommandBuffer.js +3 -0
  73. package/WebGPU/GPUCommandBuffer.js.map +1 -1
  74. package/WebGPU/GPUCommandEncoder.d.ts +1 -0
  75. package/WebGPU/GPUCommandEncoder.js +9 -1
  76. package/WebGPU/GPUCommandEncoder.js.map +1 -1
  77. package/WebGPU/GPUComputePassEncoder.d.ts +1 -0
  78. package/WebGPU/GPUComputePassEncoder.js +3 -0
  79. package/WebGPU/GPUComputePassEncoder.js.map +1 -1
  80. package/WebGPU/GPUComputePipeline.d.ts +1 -0
  81. package/WebGPU/GPUComputePipeline.js +3 -0
  82. package/WebGPU/GPUComputePipeline.js.map +1 -1
  83. package/WebGPU/GPUDevice.d.ts +4 -4
  84. package/WebGPU/GPUDevice.js +69 -71
  85. package/WebGPU/GPUDevice.js.map +1 -1
  86. package/WebGPU/GPUExternalTexture.d.ts +1 -0
  87. package/WebGPU/GPUExternalTexture.js +3 -0
  88. package/WebGPU/GPUExternalTexture.js.map +1 -1
  89. package/WebGPU/GPUPipelineLayout.d.ts +1 -0
  90. package/WebGPU/GPUPipelineLayout.js +3 -0
  91. package/WebGPU/GPUPipelineLayout.js.map +1 -1
  92. package/WebGPU/GPUQuerySet.d.ts +1 -0
  93. package/WebGPU/GPUQuerySet.js +3 -0
  94. package/WebGPU/GPUQuerySet.js.map +1 -1
  95. package/WebGPU/GPUQueue.d.ts +1 -0
  96. package/WebGPU/GPUQueue.js +3 -0
  97. package/WebGPU/GPUQueue.js.map +1 -1
  98. package/WebGPU/GPURenderBundle.d.ts +1 -0
  99. package/WebGPU/GPURenderBundle.js +3 -0
  100. package/WebGPU/GPURenderBundle.js.map +1 -1
  101. package/WebGPU/GPURenderBundleEncoder.d.ts +1 -0
  102. package/WebGPU/GPURenderBundleEncoder.js +3 -0
  103. package/WebGPU/GPURenderBundleEncoder.js.map +1 -1
  104. package/WebGPU/GPURenderPassEncoder.d.ts +2 -1
  105. package/WebGPU/GPURenderPassEncoder.js +5 -2
  106. package/WebGPU/GPURenderPassEncoder.js.map +1 -1
  107. package/WebGPU/GPURenderPipeline.d.ts +1 -0
  108. package/WebGPU/GPURenderPipeline.js +3 -0
  109. package/WebGPU/GPURenderPipeline.js.map +1 -1
  110. package/WebGPU/GPUSampler.d.ts +1 -0
  111. package/WebGPU/GPUSampler.js +3 -0
  112. package/WebGPU/GPUSampler.js.map +1 -1
  113. package/WebGPU/GPUShaderModule.d.ts +1 -1
  114. package/WebGPU/GPUShaderModule.js +2 -2
  115. package/WebGPU/GPUShaderModule.js.map +1 -1
  116. package/WebGPU/GPUTexture.d.ts +2 -0
  117. package/WebGPU/GPUTexture.js +6 -0
  118. package/WebGPU/GPUTexture.js.map +1 -1
  119. package/WebGPU/GPUTextureView.d.ts +1 -0
  120. package/WebGPU/GPUTextureView.js +3 -0
  121. package/WebGPU/GPUTextureView.js.map +1 -1
  122. package/WebGPU/Interfaces.d.ts +14 -4
  123. package/WebGPU/Types.d.ts +28 -27
  124. package/WebGPU/Utils.d.ts +1 -1
  125. package/WebGPU/Utils.js.map +1 -1
  126. package/angular/{esm2020 → esm2022}/index.mjs +5 -5
  127. package/angular/{fesm2015 → fesm2022}/nativescript-canvas-angular.mjs +4 -4
  128. package/angular/{fesm2020 → fesm2022}/nativescript-canvas-angular.mjs.map +1 -1
  129. package/angular/package.json +4 -10
  130. package/common.d.ts +0 -3
  131. package/common.js +1 -5
  132. package/common.js.map +1 -1
  133. package/helpers.js.map +1 -1
  134. package/package.json +2 -2
  135. package/platforms/android/canvas-release.aar +0 -0
  136. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +26 -9
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2159 -2085
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +971 -205
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +38 -9
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +38 -9
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +645 -602
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +52 -18
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2159 -2085
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +971 -205
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +38 -9
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +38 -9
  156. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +971 -205
  157. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +38 -9
  158. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +38 -9
  159. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +25 -25
  160. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  161. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +647 -604
  162. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +685 -638
  163. package/platforms/ios/src/NSOperationQueueWrapper.h +2 -0
  164. package/platforms/ios/src/cpp/AsyncCallback.h +206 -0
  165. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +13 -13
  166. package/platforms/ios/src/cpp/Helpers.h +2 -164
  167. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +13 -13
  168. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +1 -1
  169. package/platforms/ios/src/cpp/ImageBitmapImpl.h +2 -1
  170. package/platforms/ios/src/cpp/JSIReadFileCallback.h +4 -4
  171. package/platforms/ios/src/cpp/NativeType.h +87 -0
  172. package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
  173. package/platforms/ios/src/cpp/OneByteStringResource.cpp +2 -2
  174. package/platforms/ios/src/cpp/PromiseCallback.h +198 -0
  175. package/platforms/ios/src/cpp/RafImpl.h +2 -2
  176. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +0 -6
  177. package/platforms/ios/src/cpp/TextDecoderImpl.h +3 -3
  178. package/platforms/ios/src/cpp/TextEncoderImpl.cpp +1 -1
  179. package/platforms/ios/src/cpp/TextEncoderImpl.h +3 -3
  180. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +8 -7
  181. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
  182. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +3 -3
  183. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +146 -76
  184. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +74 -20
  185. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +5 -6
  186. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +4 -4
  187. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
  188. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +2 -2
  189. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
  190. package/platforms/ios/src/cpp/canvas2d/Path2D.h +7 -7
  191. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +3 -3
  192. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
  193. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
  194. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
  195. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
  196. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
  197. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +8 -8
  198. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
  199. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +1 -1
  200. package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
  201. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
  202. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
  203. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
  204. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
  205. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
  206. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
  207. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
  208. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
  209. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
  210. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
  211. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
  212. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
  213. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
  214. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
  215. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
  216. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
  217. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
  218. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
  219. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
  220. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
  221. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
  222. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
  223. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
  224. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
  225. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
  226. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
  227. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
  228. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
  229. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +722 -722
  230. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
  231. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
  232. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
  233. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
  234. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
  235. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
  236. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +137 -69
  237. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +1 -1
  238. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +1 -1
  239. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +1 -1
  240. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +32 -6
  241. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +5 -2
  242. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +27 -1
  243. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +4 -1
  244. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +80 -32
  245. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +8 -4
  246. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +19 -14
  247. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +1 -1
  248. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +29 -2
  249. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +4 -1
  250. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +583 -450
  251. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +5 -1
  252. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +42 -14
  253. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +4 -1
  254. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +26 -1
  255. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +3 -1
  256. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1709 -728
  257. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +4 -2
  258. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +54 -41
  259. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +2 -2
  260. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +27 -1
  261. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +8 -5
  262. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +2 -3
  263. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +2 -2
  264. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +65 -25
  265. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +4 -1
  266. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +30 -5
  267. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +4 -1
  268. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +26 -1
  269. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +4 -1
  270. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +51 -54
  271. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +6 -3
  272. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +26 -1
  273. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +4 -1
  274. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +27 -1
  275. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +5 -2
  276. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +25 -1
  277. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +5 -2
  278. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +2 -2
  279. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +2 -2
  280. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +33 -8
  281. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +6 -4
  282. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +27 -1
  283. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +5 -2
  284. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +580 -2
  285. package/react/index.d.ts +1 -1
  286. package/utils.d.ts +1 -1
  287. package/utils.js.map +1 -1
  288. package/angular/fesm2015/nativescript-canvas-angular.mjs.map +0 -1
  289. package/angular/fesm2020/nativescript-canvas-angular.mjs +0 -24
  290. package/typings/objc!CanvasNative.d.ts +0 -2038
  291. package/typings/objc!CanvasNative.js +0 -1
  292. package/typings/objc!CanvasNative.js.map +0 -1
  293. /package/angular/{esm2020 → esm2022}/nativescript-canvas-angular.mjs +0 -0
@@ -27,7 +27,8 @@ void GPURenderPassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isol
27
27
  auto context = isolate->GetCurrentContext();
28
28
  auto func = ctor->GetFunction(context).ToLocalChecked();
29
29
 
30
- canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPassEncoder"), func).FromJust();;
30
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPassEncoder"),
31
+ func).FromJust();
31
32
  }
32
33
 
33
34
  GPURenderPassEncoderImpl *
@@ -53,6 +54,10 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
53
54
  auto tmpl = ctorTmpl->InstanceTemplate();
54
55
  tmpl->SetInternalFieldCount(2);
55
56
 
57
+ tmpl->SetLazyDataProperty(
58
+ ConvertToV8String(isolate, "label"),
59
+ GetLabel
60
+ );
56
61
 
57
62
  tmpl->Set(
58
63
  ConvertToV8String(isolate, "beginOcclusionQuery"),
@@ -66,7 +71,6 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
66
71
  ConvertToV8String(isolate, "drawIndexed"),
67
72
  v8::FunctionTemplate::New(isolate, &DrawIndexed));
68
73
 
69
-
70
74
  tmpl->Set(
71
75
  ConvertToV8String(isolate, "drawIndexedIndirect"),
72
76
  v8::FunctionTemplate::New(isolate, &DrawIndexedIndirect));
@@ -75,12 +79,10 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
75
79
  ConvertToV8String(isolate, "drawIndirect"),
76
80
  v8::FunctionTemplate::New(isolate, &DrawIndirect));
77
81
 
78
-
79
82
  tmpl->Set(
80
83
  ConvertToV8String(isolate, "end"),
81
84
  v8::FunctionTemplate::New(isolate, &End));
82
85
 
83
-
84
86
  tmpl->Set(
85
87
  ConvertToV8String(isolate, "endOcclusionQuery"),
86
88
  v8::FunctionTemplate::New(isolate, &EndOcclusionQuery));
@@ -139,6 +141,27 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
139
141
  }
140
142
 
141
143
 
144
+ void
145
+ GPURenderPassEncoderImpl::GetLabel(v8::Local<v8::Name> name,
146
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
147
+ auto ptr = GetPointer(info.This());
148
+ if (ptr != nullptr) {
149
+ auto label = canvas_native_webgpu_render_pass_encoder_get_label(ptr->pass_);
150
+ if (label == nullptr) {
151
+ info.GetReturnValue().SetEmptyString();
152
+ return;
153
+ }
154
+ info.GetReturnValue().Set(
155
+ ConvertToV8String(info.GetIsolate(), label)
156
+ );
157
+ canvas_native_string_destroy(label);
158
+ return;
159
+ }
160
+
161
+ info.GetReturnValue().SetEmptyString();
162
+ }
163
+
164
+
142
165
  void
143
166
  GPURenderPassEncoderImpl::BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
144
167
  auto *ptr = GetPointer(args.This());
@@ -173,7 +196,6 @@ void GPURenderPassEncoderImpl::Draw(const v8::FunctionCallbackInfo<v8::Value> &a
173
196
  if (vertexCountVal->IsUint32()) {
174
197
  auto vertexCount = vertexCountVal.As<v8::Uint32>()->Value();
175
198
 
176
-
177
199
  if (instanceCountVal->IsUint32()) {
178
200
  instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
179
201
  }
@@ -209,12 +231,16 @@ void GPURenderPassEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::Va
209
231
 
210
232
 
211
233
  auto indexCountVal = args[0];
212
- auto firstIndexVal = args[1];
213
- auto baseVertexVal = args[2];
214
- auto firstInstanceVal = args[3];
234
+ auto instanceCountVal = args[1];
235
+ auto firstIndexVal = args[2];
236
+ auto baseVertexVal = args[3];
237
+ auto firstInstanceVal = args[4];
215
238
 
216
239
  if (indexCountVal->IsUint32()) {
217
240
 
241
+ if (instanceCountVal->IsUint32()) {
242
+ instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
243
+ }
218
244
 
219
245
  if (firstIndexVal->IsUint32()) {
220
246
  firstIndex = firstIndexVal.As<v8::Uint32>()->Value();
@@ -228,9 +254,10 @@ void GPURenderPassEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::Va
228
254
  firstInstance = firstInstanceVal.As<v8::Uint32>()->Value();
229
255
  }
230
256
 
257
+ auto indexCount = indexCountVal->Uint32Value(
258
+ context).FromJust();
231
259
  canvas_native_webgpu_render_pass_encoder_draw_indexed(ptr->GetPass(),
232
- indexCountVal->Uint32Value(
233
- context).FromJust(),
260
+ indexCount,
234
261
  instanceCount, firstIndex,
235
262
  baseVertex,
236
263
  firstInstance);
@@ -407,7 +434,7 @@ void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::V
407
434
  auto index = indexVal->Uint32Value(context).FromJust();
408
435
  auto bindgroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
409
436
 
410
- if (dynamicOffsets->IsUint8Array()) {
437
+ if (dynamicOffsets->IsUint32Array()) {
411
438
  auto buf = dynamicOffsets.As<v8::Uint32Array>();
412
439
  auto buffer = buf->Buffer();
413
440
  auto store = buffer->GetBackingStore();
@@ -415,11 +442,11 @@ void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::V
415
442
  auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
416
443
  auto size = buf->Length();
417
444
  auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
418
- auto offset_length = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
445
+ auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
419
446
  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);
447
+ bindgroup->GetBindGroup(),
448
+ static_cast<const uint32_t *>(static_cast<void *>(data)),
449
+ size, start, offset_length);
423
450
  } else {
424
451
  canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
425
452
  bindgroup->GetBindGroup(),
@@ -435,7 +462,6 @@ void GPURenderPassEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v8:
435
462
  }
436
463
 
437
464
  auto isolate = args.GetIsolate();
438
- auto context = isolate->GetCurrentContext();
439
465
 
440
466
  auto bufferVal = args[0];
441
467
  auto indexFormatVal = args[1];
@@ -446,7 +472,7 @@ void GPURenderPassEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v8:
446
472
 
447
473
  auto type = GetNativeType(bufferVal);
448
474
 
449
- if (type == NativeType::GPURenderBundleEncoder) {
475
+ if (type == NativeType::GPUBuffer) {
450
476
  auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
451
477
  auto indexFormat = ConvertFromV8String(isolate, indexFormatVal);
452
478
  if (offsetVal->IsNumber()) {
@@ -482,41 +508,13 @@ void GPURenderPassEncoderImpl::SetBlendConstant(const v8::FunctionCallbackInfo<v
482
508
  }
483
509
 
484
510
  auto isolate = args.GetIsolate();
485
- auto context = isolate->GetCurrentContext();
486
511
 
487
512
  auto colorVal = args[0];
488
513
 
489
- if (colorVal->IsObject()) {
490
-
491
- auto color = CanvasColor{0, 0, 0, 0};
492
- auto colorObj = colorVal.As<v8::Object>();
493
-
494
- v8::Local<v8::Value> r;
495
- v8::Local<v8::Value> g;
496
- v8::Local<v8::Value> b;
497
- v8::Local<v8::Value> a;
498
-
499
- colorObj->Get(context, ConvertToV8String(isolate, "r")).ToLocal(&r);
500
- colorObj->Get(context, ConvertToV8String(isolate, "g")).ToLocal(&g);
501
- colorObj->Get(context, ConvertToV8String(isolate, "b")).ToLocal(&b);
502
- colorObj->Get(context, ConvertToV8String(isolate, "a")).ToLocal(&a);
503
-
504
- if (!r.IsEmpty() && r->IsNumber()) {
505
- color.r = r.As<v8::Number>()->Value();
506
- }
507
-
508
- if (!g.IsEmpty() && g->IsNumber()) {
509
- color.g = g.As<v8::Number>()->Value();
510
- }
514
+ if (colorVal->IsObject() || colorVal->IsArray()) {
511
515
 
516
+ auto color = ParseColor(isolate, colorVal);
512
517
 
513
- if (!b.IsEmpty() && b->IsNumber()) {
514
- color.b = b.As<v8::Number>()->Value();
515
- }
516
-
517
- if (!a.IsEmpty() && a->IsNumber()) {
518
- color.a = a.As<v8::Number>()->Value();
519
- }
520
518
 
521
519
  canvas_native_webgpu_render_pass_encoder_set_blend_constant(ptr->GetPass(), &color);
522
520
  }
@@ -530,12 +528,10 @@ void GPURenderPassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Va
530
528
  }
531
529
 
532
530
  auto pipelineVal = args[0];
533
- if (pipelineVal->IsObject()) {
531
+ if (GetNativeType(pipelineVal) == NativeType::GPURenderPipeline) {
534
532
  auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
535
- if (pipeline != nullptr) {
536
- canvas_native_webgpu_render_pass_encoder_set_pipeline(ptr->GetPass(),
537
- pipeline->GetGPUPipeline());
538
- }
533
+ canvas_native_webgpu_render_pass_encoder_set_pipeline(ptr->GetPass(),
534
+ pipeline->GetGPUPipeline());
539
535
  }
540
536
  }
541
537
 
@@ -598,12 +594,13 @@ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8
598
594
 
599
595
  if (slotVal->IsUint32() && bufferVal->IsObject()) {
600
596
  auto slot = slotVal.As<v8::Uint32>()->Value();
601
- auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
602
- if (buffer == nullptr) {
597
+ if (GetNativeType(bufferVal) != NativeType::GPUBuffer) {
603
598
  // todo throw ??
604
599
  return;
605
600
  }
606
601
 
602
+ auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
603
+
607
604
  if (offsetVal->IsNumber()) {
608
605
  offset = (int64_t) offsetVal.As<v8::Number>()->Value();
609
606
  }
@@ -8,10 +8,11 @@
8
8
  #include "Common.h"
9
9
  #include "Helpers.h"
10
10
  #include "ObjectWrapperImpl.h"
11
+ #include "GPUUtils.h"
11
12
 
12
13
  class GPURenderPassEncoderImpl : ObjectWrapperImpl {
13
14
  public:
14
- GPURenderPassEncoderImpl(const CanvasGPURenderPassEncoder *pass);
15
+ explicit GPURenderPassEncoderImpl(const CanvasGPURenderPassEncoder *pass);
15
16
 
16
17
  ~GPURenderPassEncoderImpl() {
17
18
  canvas_native_webgpu_render_pass_encoder_release(this->GetPass());
@@ -31,12 +32,15 @@ public:
31
32
  v8::EscapableHandleScope scope(isolate);
32
33
  auto object = GPURenderPassEncoderImpl::GetCtor(isolate)->GetFunction(
33
34
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
34
- SetNativeType(object, NativeType::GPURenderPassEncoder);
35
+ SetNativeType(encoder, NativeType::GPURenderPassEncoder);
35
36
  object->SetAlignedPointerInInternalField(0, encoder);
36
37
  encoder->BindFinalizer(isolate, object);
37
38
  return scope.Escape(object);
38
39
  }
39
40
 
41
+ static void GetLabel(v8::Local<v8::Name> name,
42
+ const v8::PropertyCallbackInfo<v8::Value> &info);
43
+
40
44
  static void BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args);
41
45
 
42
46
  static void Draw(const v8::FunctionCallbackInfo<v8::Value> &args);
@@ -78,7 +82,6 @@ public:
78
82
 
79
83
  private:
80
84
  const CanvasGPURenderPassEncoder *pass_;
81
- bool ended_ = false;
82
85
  };
83
86
 
84
87
 
@@ -23,7 +23,7 @@ void GPURenderPipelineImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate
23
23
  auto context = isolate->GetCurrentContext();
24
24
  auto func = ctor->GetFunction(context).ToLocalChecked();
25
25
 
26
- canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPipeline"), func).FromJust();;
26
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPipeline"), func).FromJust();
27
27
  }
28
28
 
29
29
  GPURenderPipelineImpl *GPURenderPipelineImpl::GetPointer(const v8::Local<v8::Object> &object) {
@@ -48,6 +48,10 @@ v8::Local<v8::FunctionTemplate> GPURenderPipelineImpl::GetCtor(v8::Isolate *isol
48
48
  auto tmpl = ctorTmpl->InstanceTemplate();
49
49
  tmpl->SetInternalFieldCount(2);
50
50
 
51
+ tmpl->SetLazyDataProperty(
52
+ ConvertToV8String(isolate, "label"),
53
+ GetLabel
54
+ );
51
55
 
52
56
  tmpl->Set(
53
57
  ConvertToV8String(isolate, "getBindGroupLayout"),
@@ -82,3 +86,24 @@ void GPURenderPipelineImpl::GetBindGroupLayout(const v8::FunctionCallbackInfo<v8
82
86
  args.GetReturnValue().SetUndefined();
83
87
  }
84
88
 
89
+
90
+ void
91
+ GPURenderPipelineImpl::GetLabel(v8::Local<v8::Name> name,
92
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
93
+ auto ptr = GetPointer(info.This());
94
+ if (ptr != nullptr) {
95
+ auto label = canvas_native_webgpu_render_pipeline_get_label(ptr->pipeline_);
96
+ if (label == nullptr) {
97
+ info.GetReturnValue().SetEmptyString();
98
+ return;
99
+ }
100
+ info.GetReturnValue().Set(
101
+ ConvertToV8String(info.GetIsolate(), label)
102
+ );
103
+ canvas_native_string_destroy(label);
104
+ return;
105
+ }
106
+
107
+ info.GetReturnValue().SetEmptyString();
108
+ }
109
+
@@ -31,12 +31,15 @@ public:
31
31
  v8::EscapableHandleScope scope(isolate);
32
32
  auto object = GPURenderPipelineImpl::GetCtor(isolate)->GetFunction(
33
33
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
34
- SetNativeType(object, NativeType::GPURenderPipeline);
34
+ SetNativeType(pipeline, NativeType::GPURenderPipeline);
35
35
  object->SetAlignedPointerInInternalField(0, pipeline);
36
36
  pipeline->BindFinalizer(isolate, object);
37
37
  return scope.Escape(object);
38
38
  }
39
39
 
40
+ static void GetLabel(v8::Local<v8::Name> name,
41
+ const v8::PropertyCallbackInfo<v8::Value> &info);
42
+
40
43
 
41
44
  static void GetBindGroupLayout(const v8::FunctionCallbackInfo <v8::Value> &args);
42
45
 
@@ -22,7 +22,7 @@ void GPUSamplerImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isola
22
22
  auto context = isolate->GetCurrentContext();
23
23
  auto func = ctor->GetFunction(context).ToLocalChecked();
24
24
 
25
- canvasModule->Set(context, ConvertToV8String(isolate, "GPUSampler"), func).FromJust();;
25
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUSampler"), func).FromJust();
26
26
  }
27
27
 
28
28
  GPUSamplerImpl *GPUSamplerImpl::GetPointer(const v8::Local<v8::Object> &object) {
@@ -47,7 +47,33 @@ v8::Local<v8::FunctionTemplate> GPUSamplerImpl::GetCtor(v8::Isolate *isolate) {
47
47
  auto tmpl = ctorTmpl->InstanceTemplate();
48
48
  tmpl->SetInternalFieldCount(2);
49
49
 
50
+ tmpl->SetLazyDataProperty(
51
+ ConvertToV8String(isolate, "label"),
52
+ GetLabel
53
+ );
54
+
50
55
  cache->GPUSamplerTmpl =
51
56
  std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
52
57
  return ctorTmpl;
53
58
  }
59
+
60
+
61
+ void
62
+ GPUSamplerImpl::GetLabel(v8::Local<v8::Name> name,
63
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
64
+ auto ptr = GetPointer(info.This());
65
+ if (ptr != nullptr) {
66
+ auto label = canvas_native_webgpu_sampler_get_label(ptr->sampler_);
67
+ if (label == nullptr) {
68
+ info.GetReturnValue().SetEmptyString();
69
+ return;
70
+ }
71
+ info.GetReturnValue().Set(
72
+ ConvertToV8String(info.GetIsolate(), label)
73
+ );
74
+ canvas_native_string_destroy(label);
75
+ return;
76
+ }
77
+
78
+ info.GetReturnValue().SetEmptyString();
79
+ }
@@ -9,7 +9,7 @@
9
9
  #include "Helpers.h"
10
10
  #include "ObjectWrapperImpl.h"
11
11
 
12
- class GPUSamplerImpl: ObjectWrapperImpl {
12
+ class GPUSamplerImpl : ObjectWrapperImpl {
13
13
  public:
14
14
  explicit GPUSamplerImpl(const CanvasGPUSampler *sampler);
15
15
 
@@ -30,12 +30,15 @@ public:
30
30
  v8::EscapableHandleScope scope(isolate);
31
31
  auto object = GPUSamplerImpl::GetCtor(isolate)->GetFunction(
32
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
- SetNativeType(object, NativeType::GPUSampler);
33
+ SetNativeType(sampler, NativeType::GPUSampler);
34
34
  object->SetAlignedPointerInInternalField(0, sampler);
35
35
  sampler->BindFinalizer(isolate, object);
36
36
  return scope.Escape(object);
37
37
  }
38
38
 
39
+ static void GetLabel(v8::Local<v8::Name> name,
40
+ const v8::PropertyCallbackInfo<v8::Value> &info);
41
+
39
42
 
40
43
  private:
41
44
  const CanvasGPUSampler *sampler_;
@@ -22,7 +22,7 @@ void GPUShaderModuleImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *
22
22
  auto context = isolate->GetCurrentContext();
23
23
  auto func = ctor->GetFunction(context).ToLocalChecked();
24
24
 
25
- canvasModule->Set(context, ConvertToV8String(isolate, "GPUShaderModule"), func).FromJust();;
25
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUShaderModule"), func).FromJust();
26
26
  }
27
27
 
28
28
  GPUShaderModuleImpl *GPUShaderModuleImpl::GetPointer(const v8::Local<v8::Object> &object) {
@@ -47,10 +47,34 @@ v8::Local<v8::FunctionTemplate> GPUShaderModuleImpl::GetCtor(v8::Isolate *isolat
47
47
  auto tmpl = ctorTmpl->InstanceTemplate();
48
48
  tmpl->SetInternalFieldCount(2);
49
49
 
50
+ tmpl->SetLazyDataProperty(
51
+ ConvertToV8String(isolate, "label"),
52
+ GetLabel
53
+ );
50
54
 
51
55
  cache->GPUShaderModuleTmpl =
52
56
  std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
53
57
  return ctorTmpl;
54
58
  }
55
59
 
60
+ void
61
+ GPUShaderModuleImpl::GetLabel(v8::Local<v8::Name> name,
62
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
63
+ auto ptr = GetPointer(info.This());
64
+ if (ptr != nullptr) {
65
+ auto label = canvas_native_webgpu_shader_module_get_label(ptr->shaderModule_);
66
+ if (label == nullptr) {
67
+ info.GetReturnValue().SetEmptyString();
68
+ return;
69
+ }
70
+ info.GetReturnValue().Set(
71
+ ConvertToV8String(info.GetIsolate(), label)
72
+ );
73
+ canvas_native_string_destroy(label);
74
+ return;
75
+ }
76
+
77
+ info.GetReturnValue().SetEmptyString();
78
+ }
79
+
56
80
 
@@ -11,7 +11,7 @@
11
11
 
12
12
  class GPUShaderModuleImpl : ObjectWrapperImpl {
13
13
  public:
14
- GPUShaderModuleImpl(const CanvasGPUShaderModule *shaderModule);
14
+ explicit GPUShaderModuleImpl(const CanvasGPUShaderModule *shaderModule);
15
15
 
16
16
  ~GPUShaderModuleImpl() {
17
17
  canvas_native_webgpu_shader_module_release(this->GetShaderModule());
@@ -31,12 +31,15 @@ public:
31
31
  v8::EscapableHandleScope scope(isolate);
32
32
  auto object = GPUShaderModuleImpl::GetCtor(isolate)->GetFunction(
33
33
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
34
- SetNativeType(object, NativeType::GPUShaderModule);
34
+ SetNativeType(shaderModule, NativeType::GPUShaderModule);
35
35
  object->SetAlignedPointerInInternalField(0, shaderModule);
36
36
  shaderModule->BindFinalizer(isolate, object);
37
37
  return scope.Escape(object);
38
38
  }
39
39
 
40
+ static void GetLabel(v8::Local<v8::Name> name,
41
+ const v8::PropertyCallbackInfo<v8::Value> &info);
42
+
40
43
  private:
41
44
  const CanvasGPUShaderModule *shaderModule_;
42
45
  };
@@ -22,7 +22,7 @@ void GPUSupportedLimitsImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolat
22
22
  auto context = isolate->GetCurrentContext();
23
23
  auto func = ctor->GetFunction(context).ToLocalChecked();
24
24
 
25
- canvasModule->Set(context, ConvertToV8String(isolate, "GPUSupportedLimits"), func).FromJust();;
25
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUSupportedLimits"), func).FromJust();
26
26
  }
27
27
 
28
28
  GPUSupportedLimitsImpl *GPUSupportedLimitsImpl::GetPointer(v8::Local<v8::Object> object) {
@@ -281,7 +281,7 @@ void GPUSupportedLimitsImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &arg
281
281
 
282
282
  ret->SetAlignedPointerInInternalField(0, object);
283
283
 
284
- SetNativeType(ret, NativeType::GPUSupportedLimits);
284
+ SetNativeType(object, NativeType::GPUSupportedLimits);
285
285
 
286
286
  object->BindFinalizer(isolate, ret);
287
287
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  class GPUSupportedLimitsImpl : public ObjectWrapperImpl {
12
12
  public:
13
- GPUSupportedLimitsImpl(CanvasGPUSupportedLimits *limits);
13
+ explicit GPUSupportedLimitsImpl(CanvasGPUSupportedLimits *limits);
14
14
 
15
15
  ~GPUSupportedLimitsImpl() {
16
16
  canvas_native_webgpu_limits_release(this->limits_);
@@ -23,7 +23,7 @@ public:
23
23
  v8::EscapableHandleScope scope(isolate);
24
24
  auto object = GPUSupportedLimitsImpl::GetCtor(isolate)->GetFunction(
25
25
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
26
- SetNativeType(object, NativeType::GPUSupportedLimits);
26
+ SetNativeType(limits, NativeType::GPUSupportedLimits);
27
27
  object->SetAlignedPointerInInternalField(0, limits);
28
28
  limits->BindFinalizer(isolate, object);
29
29
  return scope.Escape(object);
@@ -47,6 +47,10 @@ v8::Local<v8::FunctionTemplate> GPUTextureImpl::GetCtor(v8::Isolate *isolate) {
47
47
  auto tmpl = ctorTmpl->InstanceTemplate();
48
48
  tmpl->SetInternalFieldCount(2);
49
49
 
50
+ tmpl->SetLazyDataProperty(
51
+ ConvertToV8String(isolate, "label"),
52
+ GetLabel
53
+ );
50
54
 
51
55
  tmpl->Set(
52
56
  ConvertToV8String(isolate, "destroy"),
@@ -107,6 +111,27 @@ v8::Local<v8::FunctionTemplate> GPUTextureImpl::GetCtor(v8::Isolate *isolate) {
107
111
  return ctorTmpl;
108
112
  }
109
113
 
114
+
115
+ void
116
+ GPUTextureImpl::GetLabel(v8::Local<v8::Name> name,
117
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
118
+ auto ptr = GetPointer(info.This());
119
+ if (ptr != nullptr) {
120
+ auto label = canvas_native_webgpu_texture_get_label(ptr->texture_);
121
+ if (label == nullptr) {
122
+ info.GetReturnValue().SetEmptyString();
123
+ return;
124
+ }
125
+ info.GetReturnValue().Set(
126
+ ConvertToV8String(info.GetIsolate(), label)
127
+ );
128
+ canvas_native_string_destroy(label);
129
+ return;
130
+ }
131
+
132
+ info.GetReturnValue().SetEmptyString();
133
+ }
134
+
110
135
  void
111
136
  GPUTextureImpl::GetDimension(v8::Local<v8::Name> name,
112
137
  const v8::PropertyCallbackInfo<v8::Value> &info) {
@@ -249,6 +274,7 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
249
274
  aspect, 0, -1, 0, -1
250
275
  };
251
276
 
277
+ std::string label;
252
278
 
253
279
  if (descVal->IsObject()) {
254
280
  descriptor = new CanvasCreateTextureViewDescriptor{};
@@ -269,7 +295,6 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
269
295
  }
270
296
 
271
297
 
272
-
273
298
  v8::Local<v8::Value> arrayLayerCountVal;
274
299
  if (descObj->Get(context, ConvertToV8String(isolate, "arrayLayerCount")).ToLocal(
275
300
  &arrayLayerCountVal) && arrayLayerCountVal->IsInt32()) {
@@ -297,16 +322,15 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
297
322
  descriptor->range = &range;
298
323
 
299
324
 
300
-
301
325
  v8::Local<v8::Value> formatVal;
302
326
  descObj->Get(context, ConvertToV8String(isolate, "format")).ToLocal(&formatVal);
303
327
  auto formatStr = ConvertFromV8String(isolate, formatVal);
304
328
 
305
- descriptor->format = CanvasOptionalGPUTextureFormat {
306
- CanvasOptionalGPUTextureFormatNone
329
+ descriptor->format = CanvasOptionalGPUTextureFormat{
330
+ CanvasOptionalGPUTextureFormatNone
307
331
  };
308
332
 
309
- if (!formatStr.empty()){
333
+ if (!formatStr.empty()) {
310
334
  auto format = canvas_native_webgpu_enum_string_to_gpu_texture(formatStr.c_str());
311
335
  descriptor->format = format;
312
336
  }
@@ -317,9 +341,9 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
317
341
  v8::Local<v8::Value> labelVal;
318
342
  descObj->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
319
343
 
320
- if (!labelVal.IsEmpty() && labelVal->IsString()) {
321
- descriptor->label = *v8::String::Utf8Value(isolate, labelVal);
322
- }
344
+ label = ConvertFromV8String(isolate, labelVal);
345
+
346
+ descriptor->label = label.c_str();
323
347
 
324
348
  v8::Local<v8::Value> dimensionVal;
325
349
  if (descObj->Get(context, ConvertToV8String(isolate, "dimension")).ToLocal(&dimensionVal)) {
@@ -347,6 +371,7 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
347
371
 
348
372
  if (descriptor != nullptr) {
349
373
  delete descriptor;
374
+ descriptor = nullptr;
350
375
  }
351
376
 
352
377
  if (view != nullptr) {
@@ -25,17 +25,19 @@ public:
25
25
 
26
26
  static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
27
27
 
28
- static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUTextureImpl *queue) {
28
+ static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUTextureImpl *texture) {
29
29
  auto context = isolate->GetCurrentContext();
30
30
  v8::EscapableHandleScope scope(isolate);
31
31
  auto object = GPUTextureImpl::GetCtor(isolate)->GetFunction(
32
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
- SetNativeType(object, NativeType::GPUTexture);
34
- object->SetAlignedPointerInInternalField(0, queue);
35
- queue->BindFinalizer(isolate, object);
33
+ SetNativeType(texture, NativeType::GPUTexture);
34
+ object->SetAlignedPointerInInternalField(0, texture);
35
+ texture->BindFinalizer(isolate, object);
36
36
  return scope.Escape(object);
37
37
  }
38
38
 
39
+ static void GetLabel(v8::Local<v8::Name> name,
40
+ const v8::PropertyCallbackInfo<v8::Value> &info);
39
41
 
40
42
 
41
43
  static void GetWidth(v8::Local<v8::Name> name,
@@ -21,7 +21,7 @@ void GPUTextureViewImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *i
21
21
  auto context = isolate->GetCurrentContext();
22
22
  auto func = ctor->GetFunction(context).ToLocalChecked();
23
23
 
24
- canvasModule->Set(context, ConvertToV8String(isolate, "GPUTextureView"), func).FromJust();;
24
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUTextureView"), func).FromJust();
25
25
  }
26
26
 
27
27
  GPUTextureViewImpl *GPUTextureViewImpl::GetPointer(const v8::Local<v8::Object> &object) {
@@ -46,8 +46,34 @@ v8::Local<v8::FunctionTemplate> GPUTextureViewImpl::GetCtor(v8::Isolate *isolate
46
46
  auto tmpl = ctorTmpl->InstanceTemplate();
47
47
  tmpl->SetInternalFieldCount(2);
48
48
 
49
+ tmpl->SetLazyDataProperty(
50
+ ConvertToV8String(isolate, "label"),
51
+ GetLabel
52
+ );
53
+
49
54
 
50
55
  cache->GPUTextureViewTmpl =
51
56
  std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
52
57
  return ctorTmpl;
53
58
  }
59
+
60
+
61
+ void
62
+ GPUTextureViewImpl::GetLabel(v8::Local<v8::Name> name,
63
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
64
+ auto ptr = GetPointer(info.This());
65
+ if (ptr != nullptr) {
66
+ auto label = canvas_native_webgpu_texture_view_get_label(ptr->view_);
67
+ if (label == nullptr) {
68
+ info.GetReturnValue().SetEmptyString();
69
+ return;
70
+ }
71
+ info.GetReturnValue().Set(
72
+ ConvertToV8String(info.GetIsolate(), label)
73
+ );
74
+ canvas_native_string_destroy(label);
75
+ return;
76
+ }
77
+
78
+ info.GetReturnValue().SetEmptyString();
79
+ }