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

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 (123) hide show
  1. package/angular/package.json +20 -0
  2. package/package.json +1 -3
  3. package/platforms/android/canvas-release.aar +0 -0
  4. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  5. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  6. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  7. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  8. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/NSCCanvas.nib +0 -0
  9. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  10. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +132 -132
  11. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  12. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  13. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  14. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  15. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  16. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/NSCCanvas.nib +0 -0
  17. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  18. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +646 -646
  19. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +684 -684
  20. package/platforms/ios/src/NSOperationQueueWrapper.h +2 -0
  21. package/platforms/ios/src/cpp/AsyncCallback.h +206 -0
  22. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1 -1
  23. package/platforms/ios/src/cpp/Helpers.h +2 -164
  24. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +2 -2
  25. package/platforms/ios/src/cpp/ImageBitmapImpl.h +2 -1
  26. package/platforms/ios/src/cpp/NativeType.h +87 -0
  27. package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
  28. package/platforms/ios/src/cpp/PromiseCallback.h +198 -0
  29. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +7 -6
  30. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
  31. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +1 -1
  32. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +5 -5
  33. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +15 -10
  34. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +2 -2
  35. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +1 -1
  36. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
  37. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
  38. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
  39. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
  40. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
  41. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
  42. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
  43. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
  44. package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
  45. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
  46. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
  47. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
  48. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
  49. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
  50. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
  51. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
  52. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
  53. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
  54. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
  55. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
  56. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
  57. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
  58. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
  59. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
  60. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
  61. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
  62. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
  63. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
  64. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
  65. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
  66. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
  67. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
  68. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
  69. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
  70. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
  71. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
  72. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
  73. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
  74. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
  75. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
  76. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
  77. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
  78. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
  79. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +123 -57
  80. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +1 -1
  81. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +1 -1
  82. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +1 -1
  83. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +1 -1
  84. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +1 -1
  85. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +1 -1
  86. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +1 -1
  87. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +44 -30
  88. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +4 -4
  89. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +1 -1
  90. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +1 -1
  91. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +1 -1
  92. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +30 -31
  93. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +1 -1
  94. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +1 -1
  95. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +1 -1
  96. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +1 -1
  97. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +1 -1
  98. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +93 -66
  99. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +1 -1
  100. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +52 -39
  101. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +1 -1
  102. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +1 -1
  103. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +5 -4
  104. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +1 -1
  105. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +1 -1
  106. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +38 -23
  107. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +1 -1
  108. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +1 -1
  109. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +1 -1
  110. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +1 -1
  111. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +1 -1
  112. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +1 -1
  113. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +1 -1
  114. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +1 -1
  115. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +1 -1
  116. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +1 -1
  117. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +1 -1
  118. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +2 -2
  119. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +2 -2
  120. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +2 -2
  121. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +4 -4
  122. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +1 -1
  123. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +2 -2
@@ -10,9 +10,9 @@
10
10
  #include "Common.h"
11
11
  #include "ObjectWrapperImpl.h"
12
12
 
13
- class WebGLShaderPrecisionFormatImpl: ObjectWrapperImpl {
13
+ class WebGLShaderPrecisionFormatImpl : ObjectWrapperImpl {
14
14
  public:
15
- WebGLShaderPrecisionFormatImpl(WebGLShaderPrecisionFormat* shader);
15
+ explicit WebGLShaderPrecisionFormatImpl(WebGLShaderPrecisionFormat *shader);
16
16
 
17
17
  ~WebGLShaderPrecisionFormatImpl() {
18
18
  canvas_native_webgl_shader_precision_format_destroy(this->GetShaderPrecisionFormat());
@@ -51,7 +51,7 @@ public:
51
51
  v8::EscapableHandleScope scope(isolate);
52
52
  auto object = WebGLShaderPrecisionFormatImpl::GetCtor(isolate)->GetFunction(
53
53
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
54
- SetNativeType( object, NativeType::WebGLShaderPrecisionFormat);
54
+ SetNativeType(shaderPrecisionFormat, NativeType::WebGLShaderPrecisionFormat);
55
55
  object->SetAlignedPointerInInternalField(0, shaderPrecisionFormat);
56
56
  shaderPrecisionFormat->BindFinalizer(isolate, object);
57
57
  return scope.Escape(object);
@@ -75,9 +75,9 @@ public:
75
75
  static void GetPrecision(v8::Local<v8::Name> property,
76
76
  const v8::PropertyCallbackInfo<v8::Value> &info);
77
77
 
78
- WebGLShaderPrecisionFormat* GetShaderPrecisionFormat();
78
+ WebGLShaderPrecisionFormat *GetShaderPrecisionFormat();
79
79
 
80
80
  private:
81
- WebGLShaderPrecisionFormat* shader_;
81
+ WebGLShaderPrecisionFormat *shader_;
82
82
  };
83
83
 
@@ -6,7 +6,8 @@
6
6
 
7
7
  #include "Helpers.h"
8
8
  #include "ObjectWrapperImpl.h"
9
- class WebGLTexture: ObjectWrapperImpl {
9
+
10
+ class WebGLTexture : ObjectWrapperImpl {
10
11
  public:
11
12
  WebGLTexture(uint32_t texture) : texture_(texture) {}
12
13
 
@@ -34,7 +35,7 @@ public:
34
35
  v8::EscapableHandleScope scope(isolate);
35
36
  auto object = WebGLTexture::GetCtor(isolate)->GetFunction(
36
37
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
37
- SetNativeType( object, NativeType::WebGLTexture);
38
+ SetNativeType(texture, NativeType::WebGLTexture);
38
39
  object->SetAlignedPointerInInternalField(0, texture);
39
40
  texture->BindFinalizer(isolate, object);
40
41
  return scope.Escape(object);
@@ -9,7 +9,7 @@
9
9
  #include "Caches.h"
10
10
  #include "ObjectWrapperImpl.h"
11
11
 
12
- class WebGLUniformLocation: ObjectWrapperImpl {
12
+ class WebGLUniformLocation : ObjectWrapperImpl {
13
13
  public:
14
14
  WebGLUniformLocation(int32_t
15
15
  uniformLocation) :
@@ -41,7 +41,7 @@ public:
41
41
  v8::EscapableHandleScope scope(isolate);
42
42
  auto object = WebGLUniformLocation::GetCtor(isolate)->GetFunction(
43
43
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
44
- SetNativeType( object, NativeType::WebGLUniformLocation);
44
+ SetNativeType(uniformLocation, NativeType::WebGLUniformLocation);
45
45
  object->SetAlignedPointerInInternalField(0, uniformLocation);
46
46
  uniformLocation->BindFinalizer(isolate, object);
47
47
  return scope.Escape(object);
@@ -30,7 +30,7 @@ public:
30
30
  v8::EscapableHandleScope scope(isolate);
31
31
  auto object = ANGLE_instanced_arraysImpl::GetCtor(isolate)->GetFunction(
32
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
- SetNativeType(object, NativeType::ANGLE_instanced_arrays);
33
+ SetNativeType(arrays, NativeType::ANGLE_instanced_arrays);
34
34
  object->SetAlignedPointerInInternalField(0, arrays);
35
35
  arrays->BindFinalizer(isolate, object);
36
36
  return scope.Escape(object);
@@ -18,7 +18,7 @@ public:
18
18
  v8::EscapableHandleScope scope(isolate);
19
19
  auto object = EXT_blend_minmaxImpl::GetCtor(isolate)->GetFunction(
20
20
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
21
- SetNativeType( object, NativeType::EXT_blend_minmax);
21
+ SetNativeType( minmax, NativeType::EXT_blend_minmax);
22
22
  object->SetAlignedPointerInInternalField(0, minmax);
23
23
  object->Set(context, ConvertToV8String(isolate, "ext_name"),
24
24
  ConvertToV8String(isolate, "EXT_blend_minmax"));
@@ -18,7 +18,7 @@ public:
18
18
  v8::EscapableHandleScope scope(isolate);
19
19
  auto object = EXT_color_buffer_half_floatImpl::GetCtor(isolate)->GetFunction(
20
20
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
21
- SetNativeType( object, NativeType::EXT_color_buffer_half_float);
21
+ SetNativeType( buffer, NativeType::EXT_color_buffer_half_float);
22
22
  object->SetAlignedPointerInInternalField(0, buffer);
23
23
  object->Set(context, ConvertToV8String(isolate, "ext_name"),
24
24
  ConvertToV8String(isolate, "EXT_color_buffer_half_float"));
@@ -28,7 +28,7 @@ public:
28
28
  v8::EscapableHandleScope scope(isolate);
29
29
  auto object = EXT_disjoint_timer_queryImpl::GetCtor(isolate)->GetFunction(
30
30
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
31
- SetNativeType( object, NativeType::EXT_disjoint_timer_query);
31
+ SetNativeType( query, NativeType::EXT_disjoint_timer_query);
32
32
  object->SetAlignedPointerInInternalField(0, query);
33
33
  object->Set(context, ConvertToV8String(isolate, "ext_name"),
34
34
  ConvertToV8String(isolate, "EXT_disjoint_timer_query"));
@@ -45,7 +45,7 @@ public:
45
45
  v8::EscapableHandleScope scope(isolate);
46
46
  auto object = EXT_sRGBImpl::GetCtor(isolate)->GetFunction(
47
47
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
48
- SetNativeType( object, NativeType::EXT_sRGB);
48
+ SetNativeType( extSrgb, NativeType::EXT_sRGB);
49
49
  object->SetAlignedPointerInInternalField(0, extSrgb);
50
50
  extSrgb->BindFinalizer(isolate, object);
51
51
  return scope.Escape(object);
@@ -35,7 +35,7 @@ public:
35
35
  v8::EscapableHandleScope scope(isolate);
36
36
  auto object = EXT_shader_texture_lodImpl::GetCtor(isolate)->GetFunction(
37
37
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
38
- SetNativeType( object, NativeType::EXT_shader_texture_lod);
38
+ SetNativeType( texture, NativeType::EXT_shader_texture_lod);
39
39
  object->SetAlignedPointerInInternalField(0, texture);
40
40
  texture->BindFinalizer(isolate, object);
41
41
  return scope.Escape(object);
@@ -43,7 +43,7 @@ public:
43
43
  v8::EscapableHandleScope scope(isolate);
44
44
  auto object = EXT_texture_filter_anisotropicImpl::GetCtor(isolate)->GetFunction(
45
45
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
46
- SetNativeType( object, NativeType::EXT_texture_filter_anisotropic);
46
+ SetNativeType( filterAnisotropic, NativeType::EXT_texture_filter_anisotropic);
47
47
  object->SetAlignedPointerInInternalField(0, filterAnisotropic);
48
48
  filterAnisotropic->BindFinalizer(isolate, object);
49
49
  return scope.Escape(object);
@@ -43,10 +43,10 @@ public:
43
43
  v8::EscapableHandleScope scope(isolate);
44
44
  auto object = OES_element_index_uintImpl::GetCtor(isolate)->GetFunction(
45
45
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
46
- SetNativeType( object, NativeType::OES_element_index_uint);
46
+ SetNativeType( element, NativeType::OES_element_index_uint);
47
47
  object->SetAlignedPointerInInternalField(0, element);
48
48
  object->Set(context, ConvertToV8String(isolate, "ext_name"),
49
- ConvertToV8String(isolate, "OES_element_index_uint"));
49
+ ConvertToV8String(isolate, "OES_element_index_uint")).FromJust();
50
50
  element->BindFinalizer(isolate, object);
51
51
  return scope.Escape(object);
52
52
  }
@@ -32,16 +32,16 @@ public:
32
32
  }
33
33
 
34
34
  static v8::Local<v8::Object>
35
- NewInstance(v8::Isolate *isolate, OES_fbo_render_mipmapImpl *texture) {
35
+ NewInstance(v8::Isolate *isolate, OES_fbo_render_mipmapImpl *mipmap) {
36
36
  auto context = isolate->GetCurrentContext();
37
37
  v8::EscapableHandleScope scope(isolate);
38
38
  auto object = OES_fbo_render_mipmapImpl::GetCtor(isolate)->GetFunction(
39
39
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
40
- SetNativeType( object, NativeType::OES_fbo_render_mipmap);
41
- object->SetAlignedPointerInInternalField(0, texture);
40
+ SetNativeType( mipmap, NativeType::OES_fbo_render_mipmap);
41
+ object->SetAlignedPointerInInternalField(0, mipmap);
42
42
  object->Set(context, ConvertToV8String(isolate, "ext_name"),
43
- ConvertToV8String(isolate, "OES_fbo_render_mipmap"));
44
- texture->BindFinalizer(isolate, object);
43
+ ConvertToV8String(isolate, "OES_fbo_render_mipmap")).FromJust();
44
+ mipmap->BindFinalizer(isolate, object);
45
45
  return scope.Escape(object);
46
46
  }
47
47
 
@@ -40,7 +40,7 @@ public:
40
40
  v8::EscapableHandleScope scope(isolate);
41
41
  auto object = OES_standard_derivativesImpl::GetCtor(isolate)->GetFunction(
42
42
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
43
- SetNativeType( object, NativeType::OES_standard_derivatives);
43
+ SetNativeType( derivatives, NativeType::OES_standard_derivatives);
44
44
  object->SetAlignedPointerInInternalField(0, derivatives);
45
45
  derivatives->BindFinalizer(isolate, object);
46
46
  return scope.Escape(object);
@@ -36,7 +36,7 @@ public:
36
36
  v8::EscapableHandleScope scope(isolate);
37
37
  auto object = WebGLShader::GetCtor(isolate)->GetFunction(
38
38
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
39
- SetNativeType( object, NativeType::OES_texture_float);
39
+ SetNativeType( texture, NativeType::OES_texture_float);
40
40
  object->SetAlignedPointerInInternalField(0, texture);
41
41
  texture->BindFinalizer(isolate, object);
42
42
  return scope.Escape(object);
@@ -35,7 +35,7 @@ public:
35
35
  v8::EscapableHandleScope scope(isolate);
36
36
  auto object = OES_texture_float_linearImpl::GetCtor(isolate)->GetFunction(
37
37
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
38
- SetNativeType( object, NativeType::OES_texture_float_linear);
38
+ SetNativeType( texture, NativeType::OES_texture_float_linear);
39
39
  object->SetAlignedPointerInInternalField(0, texture);
40
40
  texture->BindFinalizer(isolate, object);
41
41
  return scope.Escape(object);
@@ -38,7 +38,7 @@ public:
38
38
  v8::EscapableHandleScope scope(isolate);
39
39
  auto object = OES_texture_half_floatImpl::GetCtor(isolate)->GetFunction(
40
40
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
41
- SetNativeType( object, NativeType::OES_texture_half_float);
41
+ SetNativeType( texture, NativeType::OES_texture_half_float);
42
42
  object->SetAlignedPointerInInternalField(0, texture);
43
43
  texture->BindFinalizer(isolate, object);
44
44
  return scope.Escape(object);
@@ -38,7 +38,7 @@ public:
38
38
  v8::EscapableHandleScope scope(isolate);
39
39
  auto object = OES_texture_half_float_linearImpl::GetCtor(isolate)->GetFunction(
40
40
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
41
- SetNativeType( object, NativeType::OES_texture_half_float_linear);
41
+ SetNativeType( texture, NativeType::OES_texture_half_float_linear);
42
42
  object->SetAlignedPointerInInternalField(0, texture);
43
43
  texture->BindFinalizer(isolate, object);
44
44
  return scope.Escape(object);
@@ -71,7 +71,7 @@ public:
71
71
  v8::EscapableHandleScope scope(isolate);
72
72
  auto object = OES_vertex_array_objectImpl::GetCtor(isolate)->GetFunction(
73
73
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
74
- SetNativeType(object, NativeType::OES_vertex_array_object);
74
+ SetNativeType(vertexArrayObject, NativeType::OES_vertex_array_object);
75
75
  object->SetAlignedPointerInInternalField(0, vertexArrayObject);
76
76
  vertexArrayObject->BindFinalizer(isolate, object);
77
77
  return scope.Escape(object);
@@ -47,7 +47,7 @@ public:
47
47
  v8::EscapableHandleScope scope(isolate);
48
48
  auto object = WEBGL_color_buffer_floatImpl::GetCtor(isolate)->GetFunction(
49
49
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
50
- SetNativeType( object, NativeType::WEBGL_color_buffer_float);
50
+ SetNativeType( buffer, NativeType::WEBGL_color_buffer_float);
51
51
  object->SetAlignedPointerInInternalField(0, buffer);
52
52
  buffer->BindFinalizer(isolate, object);
53
53
  return scope.Escape(object);
@@ -45,7 +45,7 @@ public:
45
45
  v8::EscapableHandleScope scope(isolate);
46
46
  auto object = WEBGL_compressed_texture_atcImpl::GetCtor(isolate)->GetFunction(
47
47
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
48
- SetNativeType( object, NativeType::WEBGL_compressed_texture_atc);
48
+ SetNativeType( compressedTextureAtc, NativeType::WEBGL_compressed_texture_atc);
49
49
  object->SetAlignedPointerInInternalField(0, compressedTextureAtc);
50
50
  compressedTextureAtc->BindFinalizer(isolate, object);
51
51
  return scope.Escape(object);
@@ -43,7 +43,7 @@ public:
43
43
  v8::EscapableHandleScope scope(isolate);
44
44
  auto object = WEBGL_compressed_texture_etc1Impl::GetCtor(isolate)->GetFunction(
45
45
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
46
- SetNativeType( object, NativeType::WEBGL_compressed_texture_etc1);
46
+ SetNativeType( compressedTextureEtc1, NativeType::WEBGL_compressed_texture_etc1);
47
47
  object->SetAlignedPointerInInternalField(0, compressedTextureEtc1);
48
48
  compressedTextureEtc1->BindFinalizer(isolate, object);
49
49
  return scope.Escape(object);
@@ -70,10 +70,10 @@ public:
70
70
  v8::EscapableHandleScope scope(isolate);
71
71
  auto object = WEBGL_compressed_texture_etcImpl::GetCtor(isolate)->GetFunction(
72
72
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
73
- SetNativeType( object, NativeType::WEBGL_compressed_texture_etc);
73
+ SetNativeType( compressedTextureEtc, NativeType::WEBGL_compressed_texture_etc);
74
74
  object->SetAlignedPointerInInternalField(0, compressedTextureEtc);
75
75
  object->Set(context, ConvertToV8String(isolate, "ext_name"),
76
- ConvertToV8String(isolate, "WEBGL_compressed_texture_etc"));
76
+ ConvertToV8String(isolate, "WEBGL_compressed_texture_etc")).FromJust();
77
77
  compressedTextureEtc->BindFinalizer(isolate, object);
78
78
  return scope.Escape(object);
79
79
  }
@@ -53,7 +53,7 @@ public:
53
53
  v8::EscapableHandleScope scope(isolate);
54
54
  auto object = WEBGL_compressed_texture_pvrtcImpl::GetCtor(isolate)->GetFunction(
55
55
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
56
- SetNativeType( object, NativeType::WEBGL_compressed_texture_pvrtc);
56
+ SetNativeType( compressedTexturePvrtc, NativeType::WEBGL_compressed_texture_pvrtc);
57
57
  object->SetAlignedPointerInInternalField(0, compressedTexturePvrtc);
58
58
  compressedTexturePvrtc->BindFinalizer(isolate, object);
59
59
  return scope.Escape(object);
@@ -49,7 +49,7 @@ public:
49
49
  v8::EscapableHandleScope scope(isolate);
50
50
  auto object = WEBGL_compressed_texture_s3tcImpl::GetCtor(isolate)->GetFunction(
51
51
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
52
- SetNativeType( object, NativeType::WEBGL_compressed_texture_s3tc);
52
+ SetNativeType( textureS3Tc, NativeType::WEBGL_compressed_texture_s3tc);
53
53
  object->SetAlignedPointerInInternalField(0, textureS3Tc);
54
54
  textureS3Tc->BindFinalizer(isolate, object);
55
55
  return scope.Escape(object);
@@ -53,7 +53,7 @@ public:
53
53
  v8::EscapableHandleScope scope(isolate);
54
54
  auto object = WEBGL_compressed_texture_s3tc_srgbImpl::GetCtor(isolate)->GetFunction(
55
55
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
56
- SetNativeType( object, NativeType::WEBGL_compressed_texture_s3tc_srgb);
56
+ SetNativeType( compressedTextureS3TcSrgb, NativeType::WEBGL_compressed_texture_s3tc_srgb);
57
57
  object->SetAlignedPointerInInternalField(0, compressedTextureS3TcSrgb);
58
58
  object->Set(context, ConvertToV8String(isolate, "ext_name"),
59
59
  ConvertToV8String(isolate, "WEBGL_compressed_texture_s3tc_srgb"));
@@ -43,7 +43,7 @@ public:
43
43
  v8::EscapableHandleScope scope(isolate);
44
44
  auto object = WEBGL_depth_textureImpl::GetCtor(isolate)->GetFunction(
45
45
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
46
- SetNativeType( object, NativeType::WEBGL_depth_texture);
46
+ SetNativeType( depthTexture, NativeType::WEBGL_depth_texture);
47
47
  object->SetAlignedPointerInInternalField(0, depthTexture);
48
48
  depthTexture->BindFinalizer(isolate, object);
49
49
  return scope.Escape(object);
@@ -126,7 +126,7 @@ public:
126
126
  v8::EscapableHandleScope scope(isolate);
127
127
  auto object = WEBGL_draw_buffersImpl::GetCtor(isolate)->GetFunction(
128
128
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
129
- SetNativeType(object, NativeType::WEBGL_draw_buffers);
129
+ SetNativeType(buffers, NativeType::WEBGL_draw_buffers);
130
130
  object->SetAlignedPointerInInternalField(0, buffers);
131
131
  buffers->BindFinalizer(isolate, object);
132
132
  return scope.Escape(object);
@@ -51,7 +51,7 @@ public:
51
51
  v8::EscapableHandleScope scope(isolate);
52
52
  auto object = WEBGL_lose_contextImpl::GetCtor(isolate)->GetFunction(
53
53
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
54
- SetNativeType( object, NativeType::WEBGL_lose_context);
54
+ SetNativeType( element, NativeType::WEBGL_lose_context);
55
55
  object->SetAlignedPointerInInternalField(0, element);
56
56
  element->BindFinalizer(isolate, object);
57
57
  return scope.Escape(object);
@@ -115,7 +115,7 @@ public:
115
115
  v8::EscapableHandleScope scope(isolate);
116
116
  auto object = WebGL2RenderingContext::GetCtor(isolate)->GetFunction(
117
117
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
118
- SetNativeType(object, NativeType::WebGLRenderingContextBase);
118
+ SetNativeType(renderingContext, NativeType::WebGLRenderingContextBase);
119
119
  object->SetAlignedPointerInInternalField(0, renderingContext);
120
120
  renderingContext->BindFinalizer(isolate, object);
121
121
  return scope.Escape(object);
@@ -35,7 +35,7 @@ public:
35
35
  v8::EscapableHandleScope scope(isolate);
36
36
  auto object = WebGLQuery::GetCtor(isolate)->GetFunction(
37
37
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
38
- SetNativeType( object, NativeType::WebGLQuery);
38
+ SetNativeType( query, NativeType::WebGLQuery);
39
39
  object->SetAlignedPointerInInternalField(0, query);
40
40
  query->BindFinalizer(isolate, object);
41
41
  return scope.Escape(object);
@@ -36,7 +36,7 @@ public:
36
36
  v8::EscapableHandleScope scope(isolate);
37
37
  auto object = WebGLSampler::GetCtor(isolate)->GetFunction(
38
38
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
39
- SetNativeType( object, NativeType::WebGLSampler);
39
+ SetNativeType( sampler, NativeType::WebGLSampler);
40
40
  object->SetAlignedPointerInInternalField(0, sampler);
41
41
  sampler->BindFinalizer(isolate, object);
42
42
  return scope.Escape(object);
@@ -35,7 +35,7 @@ public:
35
35
  v8::EscapableHandleScope scope(isolate);
36
36
  auto object = WebGLSyncImpl::GetCtor(isolate)->GetFunction(
37
37
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
38
- SetNativeType( object, NativeType::WebGLSync);
38
+ SetNativeType( sync, NativeType::WebGLSync);
39
39
  object->SetAlignedPointerInInternalField(0, sync);
40
40
  sync->BindFinalizer(isolate, object);
41
41
  return scope.Escape(object);
@@ -37,7 +37,7 @@ public:
37
37
  v8::EscapableHandleScope scope(isolate);
38
38
  auto object = WebGLTransformFeedback::GetCtor(isolate)->GetFunction(
39
39
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
40
- SetNativeType( object, NativeType::WebGLTransformFeedback);
40
+ SetNativeType( feedback, NativeType::WebGLTransformFeedback);
41
41
  object->SetAlignedPointerInInternalField(0, feedback);
42
42
  feedback->BindFinalizer(isolate, object);
43
43
  return scope.Escape(object);
@@ -9,7 +9,7 @@
9
9
  #include "Helpers.h"
10
10
  #include "ObjectWrapperImpl.h"
11
11
 
12
- class WebGLVertexArrayObject: ObjectWrapperImpl {
12
+ class WebGLVertexArrayObject : ObjectWrapperImpl {
13
13
  public:
14
14
  WebGLVertexArrayObject(uint32_t vertexArrayObject) : vertexArrayObject_(vertexArrayObject) {}
15
15
 
@@ -38,7 +38,7 @@ public:
38
38
  v8::EscapableHandleScope scope(isolate);
39
39
  auto object = WebGLVertexArrayObject::GetCtor(isolate)->GetFunction(
40
40
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
41
- SetNativeType( object, NativeType::WebGLVertexArrayObject);
41
+ SetNativeType(vertexArrayObject, NativeType::WebGLVertexArrayObject);
42
42
  object->SetAlignedPointerInInternalField(0, vertexArrayObject);
43
43
  vertexArrayObject->BindFinalizer(isolate, object);
44
44
  return scope.Escape(object);
@@ -158,6 +158,24 @@ void GPUAdapterImpl::RequestAdapterInfo(const v8::FunctionCallbackInfo<v8::Value
158
158
 
159
159
  }
160
160
 
161
+ struct RequestData {
162
+ char *error_;
163
+ const CanvasGPUDevice *device_;
164
+ char **required_features_data_;
165
+
166
+ ~RequestData() {
167
+ if (required_features_data_ != nullptr) {
168
+ delete[] required_features_data_;
169
+ required_features_data_ = nullptr;
170
+ }
171
+
172
+ if (error_ != nullptr) {
173
+ canvas_native_string_destroy(error_);
174
+ error_ = nullptr;
175
+ }
176
+ }
177
+ };
178
+
161
179
  void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &args) {
162
180
  GPUAdapterImpl *ptr = GetPointer(args.This());
163
181
  auto isolate = args.GetIsolate();
@@ -170,7 +188,7 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
170
188
  return;
171
189
  }
172
190
 
173
- v8::Global<v8::Function> func(isolate, cb.As<v8::Function>());
191
+ auto func = cb.As<v8::Function>();
174
192
 
175
193
  std::string label;
176
194
 
@@ -210,7 +228,6 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
210
228
  }
211
229
  }
212
230
 
213
-
214
231
  v8::Local<v8::Value> limitsValue;
215
232
 
216
233
  options->Get(context, ConvertToV8String(isolate, "requiredLimits")).ToLocal(
@@ -235,68 +252,117 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
235
252
  }
236
253
  }
237
254
 
238
-
239
255
  auto callback = new AsyncCallback{
240
256
  isolate,
241
- std::move(func),
242
- static_cast<void *>(required_features_data)
257
+ func,
258
+ [](bool done, void *data) {
259
+ if (data != nullptr) {
260
+ auto async_data = static_cast<AsyncCallback *>(data);
261
+ auto func = async_data->inner_.get();
262
+ if (func != nullptr && func->isolate_ != nullptr) {
263
+ v8::Isolate *isolate = func->isolate_;
264
+ v8::Locker locker(isolate);
265
+ v8::Isolate::Scope isolate_scope(isolate);
266
+ v8::HandleScope handle_scope(isolate);
267
+ v8::Local<v8::Function> callback = func->callback_.Get(
268
+ isolate);
269
+ v8::Local<v8::Context> context = callback->GetCreationContextChecked();
270
+ v8::Context::Scope context_scope(context);
271
+
272
+ RequestData *requestData = nullptr;
273
+ if (func->data != nullptr) {
274
+ requestData = static_cast<RequestData *>(func->data);
275
+ }
276
+
277
+ if (requestData == nullptr) {
278
+ // Should never happen
279
+ v8::Local<v8::Value> args[1] = {
280
+ v8::Exception::Error(
281
+ ConvertToV8String(isolate, "Internal Error"))};
282
+
283
+ callback->Call(context, context->Global(),
284
+ 1,
285
+ args); // ignore JS return value
286
+ delete static_cast<AsyncCallback *>(data);
287
+
288
+ return;
289
+ }
290
+
291
+ if (requestData->error_ != nullptr) {
292
+ v8::Local<v8::Value> args[1] = {
293
+ v8::Exception::Error(
294
+ ConvertToV8String(isolate,
295
+ requestData->error_))};
296
+
297
+ callback->Call(context, context->Global(),
298
+ 1,
299
+ args); // ignore JS return value
300
+ delete static_cast<AsyncCallback *>(data);
301
+ } else {
302
+
303
+ auto impl = new GPUDeviceImpl(requestData->device_);
304
+ auto ret = GPUDeviceImpl::NewInstance(
305
+ isolate, impl);
306
+
307
+ v8::Local<v8::Value> args[2] = {
308
+ v8::Null(isolate), ret};
309
+
310
+
311
+ callback->Call(context, context->Global(),
312
+ 2,
313
+ args); // ignore JS return value
314
+
315
+ delete static_cast<AsyncCallback *>(data);
316
+ }
317
+
318
+ if (requestData != nullptr) {
319
+ delete requestData;
320
+ requestData = nullptr;
321
+ }
322
+ }
323
+ }
324
+ }
243
325
  };
244
326
 
245
- canvas_native_webgpu_adapter_request_device(ptr->GetGPUAdapter(),
246
- label.empty() ? nullptr : label.c_str(),
247
- required_features_data, required_features_data_length,
248
- limits,
249
- [](char *error, const CanvasGPUDevice *device, void *data) {
250
- if (data != nullptr) {
251
- auto func = static_cast<AsyncCallback *>(data);
252
- if (func->isolate != nullptr) {
253
- v8::Isolate *isolate = func->isolate;
254
- v8::Locker locker(isolate);
255
- v8::Isolate::Scope isolate_scope(isolate);
256
- v8::HandleScope handle_scope(isolate);
257
- v8::Local<v8::Function> callback = func->callback.Get(
258
- isolate);
259
- v8::Local<v8::Context> context = callback->GetCreationContextChecked();
260
- v8::Context::Scope context_scope(context);
261
-
262
- if (func->data != nullptr) {
263
- delete[] static_cast<char **>(func->data);
264
- func->data = nullptr;
265
- }
266
-
267
- if (error != nullptr) {
268
- v8::Local<v8::Value> args[1] = {
269
- v8::Exception::Error(
270
- ConvertToV8String(isolate,
271
- error))};
272
-
273
- canvas_native_string_destroy(error);
274
-
275
- callback->Call(context, context->Global(),
276
- 1,
277
- args); // ignore JS return value
278
- delete static_cast<AsyncCallback *>(data);
279
- } else {
280
-
281
- auto impl = new GPUDeviceImpl(device);
282
- auto ret = GPUDeviceImpl::NewInstance(
283
- isolate, impl);
284
-
327
+ auto inner = callback->inner_.get();
285
328
 
286
- v8::Local<v8::Value> args[2] = {
287
- v8::Null(isolate), ret};
288
-
289
-
290
- callback->Call(context, context->Global(),
291
- 2,
292
- args); // ignore JS return value
329
+ if (required_features_data != nullptr) {
330
+ inner->data = new RequestData{
331
+ nullptr,
332
+ nullptr,
333
+ required_features_data
334
+ };
335
+ }
293
336
 
294
- delete static_cast<AsyncCallback *>(data);
337
+ callback->prepare();
295
338
 
339
+ canvas_native_webgpu_adapter_request_device(ptr->GetGPUAdapter(),
340
+ label.empty() ? nullptr : label.c_str(),
341
+ required_features_data,
342
+ required_features_data_length,
343
+ limits,
344
+ [](char *error, const CanvasGPUDevice *device,
345
+ void *data) {
346
+ if (data != nullptr) {
347
+ auto async_data = static_cast<AsyncCallback *>(data);
348
+ auto inner = async_data->inner_.get();
349
+ if (inner != nullptr) {
350
+ if (inner->data == nullptr) {
351
+ inner->data = new RequestData{
352
+ error,
353
+ device
354
+ };
355
+ } else {
356
+ auto request_data = static_cast<RequestData *>(inner->data);
357
+ request_data->error_ = error;
358
+ request_data->device_ = device;
359
+ delete request_data->required_features_data_;
360
+ request_data->required_features_data_ = nullptr;
361
+ }
362
+
363
+ async_data->execute(true);
364
+ }
296
365
  }
297
- }
298
- }
299
- }, callback);
300
-
366
+ }, callback);
301
367
 
302
368
  }