@nativescript/canvas 2.0.0-webgpu.2 → 2.0.0-webgpu.21

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 (251) hide show
  1. package/Canvas/common.d.ts +3 -4
  2. package/Canvas/common.js +35 -125
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +0 -1
  5. package/Canvas/index.android.js +45 -38
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +11 -3
  8. package/Canvas/index.ios.js +49 -40
  9. package/Canvas/index.ios.js.map +1 -1
  10. package/Canvas/utils.d.ts +3 -0
  11. package/Canvas/utils.js +85 -0
  12. package/Canvas/utils.js.map +1 -0
  13. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -0
  14. package/Canvas2D/CanvasRenderingContext2D/index.js +1 -0
  15. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  16. package/Dom/Group.d.ts +1 -2
  17. package/Dom/Group.js.map +1 -1
  18. package/Dom/Image.js +0 -1
  19. package/Dom/Image.js.map +1 -1
  20. package/Dom/Paint.d.ts +1 -1
  21. package/Dom/shapes/Path.d.ts +1 -1
  22. package/ImageAsset/index.js +77 -33
  23. package/ImageAsset/index.js.map +1 -1
  24. package/ImageBitmap/index.js +107 -20
  25. package/ImageBitmap/index.js.map +1 -1
  26. package/README.md +2 -4
  27. package/WebGL/WebGLRenderingContext/index.js +73 -31
  28. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  29. package/WebGL2/WebGL2RenderingContext/index.js +4 -4
  30. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  31. package/WebGPU/GPU.js +4 -3
  32. package/WebGPU/GPU.js.map +1 -1
  33. package/WebGPU/GPUAdapter.d.ts +6 -3
  34. package/WebGPU/GPUAdapter.js +31 -0
  35. package/WebGPU/GPUAdapter.js.map +1 -1
  36. package/WebGPU/GPUBindGroup.d.ts +1 -0
  37. package/WebGPU/GPUBindGroup.js +3 -0
  38. package/WebGPU/GPUBindGroup.js.map +1 -1
  39. package/WebGPU/GPUBindGroupLayout.d.ts +1 -0
  40. package/WebGPU/GPUBindGroupLayout.js +3 -0
  41. package/WebGPU/GPUBindGroupLayout.js.map +1 -1
  42. package/WebGPU/GPUBuffer.js +10 -2
  43. package/WebGPU/GPUBuffer.js.map +1 -1
  44. package/WebGPU/GPUCanvasContext.d.ts +3 -2
  45. package/WebGPU/GPUCanvasContext.js +52 -10
  46. package/WebGPU/GPUCanvasContext.js.map +1 -1
  47. package/WebGPU/GPUCommandBuffer.d.ts +1 -0
  48. package/WebGPU/GPUCommandBuffer.js +3 -0
  49. package/WebGPU/GPUCommandBuffer.js.map +1 -1
  50. package/WebGPU/GPUCommandEncoder.d.ts +3 -9
  51. package/WebGPU/GPUCommandEncoder.js +94 -41
  52. package/WebGPU/GPUCommandEncoder.js.map +1 -1
  53. package/WebGPU/GPUComputePassEncoder.d.ts +1 -0
  54. package/WebGPU/GPUComputePassEncoder.js +3 -0
  55. package/WebGPU/GPUComputePassEncoder.js.map +1 -1
  56. package/WebGPU/GPUComputePipeline.d.ts +1 -0
  57. package/WebGPU/GPUComputePipeline.js +3 -0
  58. package/WebGPU/GPUComputePipeline.js.map +1 -1
  59. package/WebGPU/GPUDevice.d.ts +17 -79
  60. package/WebGPU/GPUDevice.js +72 -91
  61. package/WebGPU/GPUDevice.js.map +1 -1
  62. package/WebGPU/GPUExternalTexture.d.ts +1 -0
  63. package/WebGPU/GPUExternalTexture.js +3 -0
  64. package/WebGPU/GPUExternalTexture.js.map +1 -1
  65. package/WebGPU/GPUPipelineLayout.d.ts +1 -0
  66. package/WebGPU/GPUPipelineLayout.js +3 -0
  67. package/WebGPU/GPUPipelineLayout.js.map +1 -1
  68. package/WebGPU/GPUQuerySet.d.ts +1 -0
  69. package/WebGPU/GPUQuerySet.js +3 -0
  70. package/WebGPU/GPUQuerySet.js.map +1 -1
  71. package/WebGPU/GPUQueue.d.ts +1 -0
  72. package/WebGPU/GPUQueue.js +45 -7
  73. package/WebGPU/GPUQueue.js.map +1 -1
  74. package/WebGPU/GPURenderBundle.d.ts +1 -0
  75. package/WebGPU/GPURenderBundle.js +3 -0
  76. package/WebGPU/GPURenderBundle.js.map +1 -1
  77. package/WebGPU/GPURenderBundleEncoder.d.ts +4 -2
  78. package/WebGPU/GPURenderBundleEncoder.js +7 -3
  79. package/WebGPU/GPURenderBundleEncoder.js.map +1 -1
  80. package/WebGPU/GPURenderPassEncoder.d.ts +2 -1
  81. package/WebGPU/GPURenderPassEncoder.js +5 -2
  82. package/WebGPU/GPURenderPassEncoder.js.map +1 -1
  83. package/WebGPU/GPURenderPipeline.d.ts +1 -0
  84. package/WebGPU/GPURenderPipeline.js +3 -0
  85. package/WebGPU/GPURenderPipeline.js.map +1 -1
  86. package/WebGPU/GPUSampler.d.ts +1 -0
  87. package/WebGPU/GPUSampler.js +3 -0
  88. package/WebGPU/GPUSampler.js.map +1 -1
  89. package/WebGPU/GPUShaderModule.d.ts +1 -1
  90. package/WebGPU/GPUShaderModule.js +2 -2
  91. package/WebGPU/GPUShaderModule.js.map +1 -1
  92. package/WebGPU/GPUTexture.d.ts +1 -0
  93. package/WebGPU/GPUTexture.js +3 -0
  94. package/WebGPU/GPUTexture.js.map +1 -1
  95. package/WebGPU/GPUTextureView.d.ts +1 -0
  96. package/WebGPU/GPUTextureView.js +3 -0
  97. package/WebGPU/GPUTextureView.js.map +1 -1
  98. package/WebGPU/Interfaces.d.ts +95 -4
  99. package/WebGPU/Types.d.ts +9 -1
  100. package/WebGPU/Utils.d.ts +6 -0
  101. package/WebGPU/Utils.js +221 -0
  102. package/WebGPU/Utils.js.map +1 -1
  103. package/angular/esm2022/index.mjs +4 -4
  104. package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
  105. package/angular/package.json +20 -0
  106. package/package.json +1 -3
  107. package/platforms/android/canvas-release.aar +0 -0
  108. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  109. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  110. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +9 -0
  111. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +7 -0
  112. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +226 -61
  113. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  114. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  115. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +6871 -5995
  116. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +7 -0
  117. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +7 -0
  118. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  119. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +656 -644
  120. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  121. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +18 -0
  122. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +7 -0
  123. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +226 -61
  124. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  125. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  126. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  127. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +6871 -5995
  128. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +7 -0
  129. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -0
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +6871 -5995
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +7 -0
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +7 -0
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +27 -27
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +658 -646
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +696 -684
  137. package/platforms/ios/src/NSOperationQueueWrapper.h +3 -1
  138. package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
  139. package/platforms/ios/src/cpp/AsyncCallback.h +214 -0
  140. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +123 -47
  141. package/platforms/ios/src/cpp/Helpers.h +2 -164
  142. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +18 -26
  143. package/platforms/ios/src/cpp/ImageAssetImpl.h +3 -3
  144. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +60 -3
  145. package/platforms/ios/src/cpp/ImageBitmapImpl.h +12 -4
  146. package/platforms/ios/src/cpp/NativeType.h +87 -0
  147. package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
  148. package/platforms/ios/src/cpp/PromiseCallback.h +197 -0
  149. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +7 -6
  150. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
  151. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +1 -1
  152. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +6 -6
  153. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +18 -13
  154. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +2 -2
  155. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +1 -1
  156. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
  157. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
  158. package/platforms/ios/src/cpp/canvas2d/Path2D.h +5 -5
  159. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
  160. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
  161. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
  162. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
  163. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
  164. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
  165. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
  166. package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
  167. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
  168. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
  169. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
  170. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
  171. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
  172. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
  173. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
  174. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
  175. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
  176. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
  177. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
  178. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
  179. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
  180. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
  181. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
  182. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
  183. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
  184. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
  185. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
  186. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
  187. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
  188. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
  189. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
  190. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
  191. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
  192. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
  193. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
  194. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
  195. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
  196. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
  197. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
  198. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
  199. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
  200. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
  201. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +142 -73
  202. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +1 -1
  203. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +1 -1
  204. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +1 -1
  205. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +32 -6
  206. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +5 -2
  207. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +27 -1
  208. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +4 -1
  209. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +80 -32
  210. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +8 -4
  211. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +11 -5
  212. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +1 -1
  213. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +29 -2
  214. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +4 -1
  215. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +101 -106
  216. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +5 -1
  217. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +42 -14
  218. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +4 -1
  219. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +26 -1
  220. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +3 -1
  221. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1683 -733
  222. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +3 -1
  223. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +53 -39
  224. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +2 -2
  225. package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
  226. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +27 -1
  227. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +8 -5
  228. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +2 -3
  229. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +2 -2
  230. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +88 -36
  231. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +4 -1
  232. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +43 -14
  233. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +4 -1
  234. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +26 -1
  235. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +4 -1
  236. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +40 -14
  237. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +4 -1
  238. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +26 -1
  239. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +4 -1
  240. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +27 -1
  241. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +5 -2
  242. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +25 -1
  243. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +5 -2
  244. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +2 -2
  245. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +2 -2
  246. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +34 -8
  247. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +6 -4
  248. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +27 -1
  249. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +5 -2
  250. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +511 -0
  251. package/utils.d.ts +1 -1
@@ -32,12 +32,15 @@ public:
32
32
  v8::EscapableHandleScope scope(isolate);
33
33
  auto object = GPURenderBundleEncoderImpl::GetCtor(isolate)->GetFunction(
34
34
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
35
- SetNativeType(object, NativeType::GPURenderBundleEncoder);
35
+ SetNativeType(encoder, NativeType::GPURenderBundleEncoder);
36
36
  object->SetAlignedPointerInInternalField(0, encoder);
37
37
  encoder->BindFinalizer(isolate, object);
38
38
  return scope.Escape(object);
39
39
  }
40
40
 
41
+ static void GetLabel(v8::Local<v8::Name> name,
42
+ const v8::PropertyCallbackInfo<v8::Value> &info);
43
+
41
44
  static void Draw(const v8::FunctionCallbackInfo<v8::Value> &args);
42
45
 
43
46
  static void DrawIndexed(const v8::FunctionCallbackInfo<v8::Value> &args);
@@ -22,7 +22,7 @@ void GPURenderBundleImpl::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, "GPURenderBundle"), func).FromJust();;
25
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderBundle"), func).FromJust();
26
26
  }
27
27
 
28
28
  GPURenderBundleImpl *GPURenderBundleImpl::GetPointer(const v8::Local<v8::Object> &object) {
@@ -47,7 +47,32 @@ v8::Local<v8::FunctionTemplate> GPURenderBundleImpl::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
+ );
54
+
50
55
  cache->GPURenderBundleTmpl =
51
56
  std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
52
57
  return ctorTmpl;
53
58
  }
59
+
60
+ void
61
+ GPURenderBundleImpl::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_render_bundle_get_label(ptr->bundle_);
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
+ }
@@ -30,12 +30,15 @@ public:
30
30
  v8::EscapableHandleScope scope(isolate);
31
31
  auto object = GPURenderBundleImpl::GetCtor(isolate)->GetFunction(
32
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
- SetNativeType(object, NativeType::GPURenderBundle);
33
+ SetNativeType(bundle, NativeType::GPURenderBundle);
34
34
  object->SetAlignedPointerInInternalField(0, bundle);
35
35
  bundle->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 CanvasGPURenderBundle *bundle_;
@@ -28,7 +28,7 @@ void GPURenderPassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isol
28
28
  auto func = ctor->GetFunction(context).ToLocalChecked();
29
29
 
30
30
  canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPassEncoder"),
31
- func).FromJust();;
31
+ func).FromJust();
32
32
  }
33
33
 
34
34
  GPURenderPassEncoderImpl *
@@ -54,6 +54,11 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
54
54
  auto tmpl = ctorTmpl->InstanceTemplate();
55
55
  tmpl->SetInternalFieldCount(2);
56
56
 
57
+ tmpl->SetLazyDataProperty(
58
+ ConvertToV8String(isolate, "label"),
59
+ GetLabel
60
+ );
61
+
57
62
  tmpl->Set(
58
63
  ConvertToV8String(isolate, "beginOcclusionQuery"),
59
64
  v8::FunctionTemplate::New(isolate, &BeginOcclusionQuery));
@@ -136,6 +141,27 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
136
141
  }
137
142
 
138
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
+
139
165
  void
140
166
  GPURenderPassEncoderImpl::BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
141
167
  auto *ptr = GetPointer(args.This());
@@ -229,7 +255,7 @@ void GPURenderPassEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::Va
229
255
  }
230
256
 
231
257
  auto indexCount = indexCountVal->Uint32Value(
232
- context).FromJust();
258
+ context).FromJust();
233
259
  canvas_native_webgpu_render_pass_encoder_draw_indexed(ptr->GetPass(),
234
260
  indexCount,
235
261
  instanceCount, firstIndex,
@@ -328,7 +354,7 @@ void GPURenderPassEncoderImpl::ExecuteBundles(const v8::FunctionCallbackInfo<v8:
328
354
  std::vector<const CanvasGPURenderBundle *> bundles;
329
355
  for (int i = 0; i < len; i++) {
330
356
  v8::Local<v8::Value> bundleVal;
331
- bundlesArray->Get(context, i).ToLocal(&bundlesVal);
357
+ bundlesArray->Get(context, i).ToLocal(&bundleVal);
332
358
  auto type = GetNativeType(bundleVal);
333
359
  if (type == NativeType::GPURenderBundle) {
334
360
  auto bundle = GPURenderBundleImpl::GetPointer(bundleVal.As<v8::Object>());
@@ -408,7 +434,7 @@ void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::V
408
434
  auto index = indexVal->Uint32Value(context).FromJust();
409
435
  auto bindgroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
410
436
 
411
- if (dynamicOffsets->IsUint8Array()) {
437
+ if (dynamicOffsets->IsUint32Array()) {
412
438
  auto buf = dynamicOffsets.As<v8::Uint32Array>();
413
439
  auto buffer = buf->Buffer();
414
440
  auto store = buffer->GetBackingStore();
@@ -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()) {
@@ -502,7 +528,7 @@ void GPURenderPassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Va
502
528
  }
503
529
 
504
530
  auto pipelineVal = args[0];
505
- if(GetNativeType(pipelineVal) == NativeType::GPURenderPipeline){
531
+ if (GetNativeType(pipelineVal) == NativeType::GPURenderPipeline) {
506
532
  auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
507
533
  canvas_native_webgpu_render_pass_encoder_set_pipeline(ptr->GetPass(),
508
534
  pipeline->GetGPUPipeline());
@@ -565,13 +591,13 @@ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8
565
591
  int64_t size = -1;
566
592
  auto offsetVal = args[2];
567
593
  auto sizeVal = args[3];
568
-
569
- if (slotVal->IsUint32() && bufferVal->IsObject()) {
570
- auto slot = slotVal.As<v8::Uint32>()->Value();
571
- if (GetNativeType(bufferVal) != NativeType::GPUBuffer) {
572
- // todo throw ??
573
- return;
574
- }
594
+ auto type = GetNativeType(bufferVal);
595
+ auto isolate = args.GetIsolate();
596
+ if (type == NativeType::GPUBuffer) {
597
+ auto context = isolate->GetCurrentContext();
598
+ auto slot = slotVal->ToUint32(context).ToLocalChecked();
599
+
600
+
575
601
 
576
602
  auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
577
603
 
@@ -583,7 +609,7 @@ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8
583
609
  size = (int64_t) sizeVal.As<v8::Number>()->Value();
584
610
  }
585
611
 
586
- canvas_native_webgpu_render_pass_encoder_set_vertex_buffer(ptr->GetPass(), slot,
612
+ canvas_native_webgpu_render_pass_encoder_set_vertex_buffer(ptr->GetPass(), slot->Value(),
587
613
  buffer->GetGPUBuffer(), offset,
588
614
  size);
589
615
 
@@ -32,12 +32,15 @@ public:
32
32
  v8::EscapableHandleScope scope(isolate);
33
33
  auto object = GPURenderPassEncoderImpl::GetCtor(isolate)->GetFunction(
34
34
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
35
- SetNativeType(object, NativeType::GPURenderPassEncoder);
35
+ SetNativeType(encoder, NativeType::GPURenderPassEncoder);
36
36
  object->SetAlignedPointerInInternalField(0, encoder);
37
37
  encoder->BindFinalizer(isolate, object);
38
38
  return scope.Escape(object);
39
39
  }
40
40
 
41
+ static void GetLabel(v8::Local<v8::Name> name,
42
+ const v8::PropertyCallbackInfo<v8::Value> &info);
43
+
41
44
  static void BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args);
42
45
 
43
46
  static void Draw(const v8::FunctionCallbackInfo<v8::Value> &args);
@@ -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);
@@ -5,6 +5,7 @@
5
5
  #include "GPUTextureImpl.h"
6
6
  #include "Caches.h"
7
7
  #include "GPUTextureViewImpl.h"
8
+ #include "GPULabel.h"
8
9
 
9
10
  GPUTextureImpl::GPUTextureImpl(const CanvasGPUTexture *texture) : texture_(texture) {}
10
11
 
@@ -47,6 +48,10 @@ v8::Local<v8::FunctionTemplate> GPUTextureImpl::GetCtor(v8::Isolate *isolate) {
47
48
  auto tmpl = ctorTmpl->InstanceTemplate();
48
49
  tmpl->SetInternalFieldCount(2);
49
50
 
51
+ tmpl->SetLazyDataProperty(
52
+ ConvertToV8String(isolate, "label"),
53
+ GetLabel
54
+ );
50
55
 
51
56
  tmpl->Set(
52
57
  ConvertToV8String(isolate, "destroy"),
@@ -107,6 +112,27 @@ v8::Local<v8::FunctionTemplate> GPUTextureImpl::GetCtor(v8::Isolate *isolate) {
107
112
  return ctorTmpl;
108
113
  }
109
114
 
115
+
116
+ void
117
+ GPUTextureImpl::GetLabel(v8::Local<v8::Name> name,
118
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
119
+ auto ptr = GetPointer(info.This());
120
+ if (ptr != nullptr) {
121
+ auto label = canvas_native_webgpu_texture_get_label(ptr->texture_);
122
+ if (label == nullptr) {
123
+ info.GetReturnValue().SetEmptyString();
124
+ return;
125
+ }
126
+ info.GetReturnValue().Set(
127
+ ConvertToV8String(info.GetIsolate(), label)
128
+ );
129
+ canvas_native_string_destroy(label);
130
+ return;
131
+ }
132
+
133
+ info.GetReturnValue().SetEmptyString();
134
+ }
135
+
110
136
  void
111
137
  GPUTextureImpl::GetDimension(v8::Local<v8::Name> name,
112
138
  const v8::PropertyCallbackInfo<v8::Value> &info) {
@@ -249,6 +275,7 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
249
275
  aspect, 0, -1, 0, -1
250
276
  };
251
277
 
278
+ GPULabel label;
252
279
 
253
280
  if (descVal->IsObject()) {
254
281
  descriptor = new CanvasCreateTextureViewDescriptor{};
@@ -269,7 +296,6 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
269
296
  }
270
297
 
271
298
 
272
-
273
299
  v8::Local<v8::Value> arrayLayerCountVal;
274
300
  if (descObj->Get(context, ConvertToV8String(isolate, "arrayLayerCount")).ToLocal(
275
301
  &arrayLayerCountVal) && arrayLayerCountVal->IsInt32()) {
@@ -297,16 +323,15 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
297
323
  descriptor->range = &range;
298
324
 
299
325
 
300
-
301
326
  v8::Local<v8::Value> formatVal;
302
327
  descObj->Get(context, ConvertToV8String(isolate, "format")).ToLocal(&formatVal);
303
328
  auto formatStr = ConvertFromV8String(isolate, formatVal);
304
329
 
305
- descriptor->format = CanvasOptionalGPUTextureFormat {
306
- CanvasOptionalGPUTextureFormatNone
330
+ descriptor->format = CanvasOptionalGPUTextureFormat{
331
+ CanvasOptionalGPUTextureFormatNone
307
332
  };
308
333
 
309
- if (!formatStr.empty()){
334
+ if (!formatStr.empty()) {
310
335
  auto format = canvas_native_webgpu_enum_string_to_gpu_texture(formatStr.c_str());
311
336
  descriptor->format = format;
312
337
  }
@@ -317,9 +342,9 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
317
342
  v8::Local<v8::Value> labelVal;
318
343
  descObj->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
319
344
 
320
- if (!labelVal.IsEmpty() && labelVal->IsString()) {
321
- descriptor->label = *v8::String::Utf8Value(isolate, labelVal);
322
- }
345
+ label = GPULabel(isolate, labelVal);
346
+
347
+ descriptor->label = *label;
323
348
 
324
349
  v8::Local<v8::Value> dimensionVal;
325
350
  if (descObj->Get(context, ConvertToV8String(isolate, "dimension")).ToLocal(&dimensionVal)) {
@@ -347,6 +372,7 @@ void GPUTextureImpl::CreateView(const v8::FunctionCallbackInfo<v8::Value> &args)
347
372
 
348
373
  if (descriptor != nullptr) {
349
374
  delete descriptor;
375
+ descriptor = nullptr;
350
376
  }
351
377
 
352
378
  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
+ }
@@ -11,7 +11,7 @@
11
11
 
12
12
  class GPUTextureViewImpl : ObjectWrapperImpl {
13
13
  public:
14
- GPUTextureViewImpl(const CanvasGPUTextureView *view);
14
+ explicit GPUTextureViewImpl(const CanvasGPUTextureView *view);
15
15
 
16
16
  ~GPUTextureViewImpl() {
17
17
  canvas_native_webgpu_texture_view_release(this->GetTextureView());
@@ -30,12 +30,15 @@ public:
30
30
  v8::EscapableHandleScope scope(isolate);
31
31
  auto object = GPUTextureViewImpl::GetCtor(isolate)->GetFunction(
32
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
- SetNativeType(object, NativeType::GPUTextureView);
33
+ SetNativeType(view, NativeType::GPUTextureView);
34
34
  object->SetAlignedPointerInInternalField(0, view);
35
35
  view->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 CanvasGPUTextureView *view_;