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

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 (126) 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.abi.json +6577 -5995
  8. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  9. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/NSCCanvas.nib +0 -0
  10. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  11. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +132 -132
  12. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  13. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  14. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  15. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +6577 -5995
  16. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  17. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +6577 -5995
  18. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  19. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/NSCCanvas.nib +0 -0
  20. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  21. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +646 -646
  22. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +684 -684
  23. package/platforms/ios/src/NSOperationQueueWrapper.h +2 -0
  24. package/platforms/ios/src/cpp/AsyncCallback.h +206 -0
  25. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1 -1
  26. package/platforms/ios/src/cpp/Helpers.h +2 -164
  27. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +2 -2
  28. package/platforms/ios/src/cpp/ImageBitmapImpl.h +2 -1
  29. package/platforms/ios/src/cpp/NativeType.h +87 -0
  30. package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
  31. package/platforms/ios/src/cpp/PromiseCallback.h +198 -0
  32. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +7 -6
  33. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
  34. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +1 -1
  35. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +5 -5
  36. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +15 -10
  37. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +2 -2
  38. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +1 -1
  39. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
  40. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
  41. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
  42. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
  43. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
  44. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
  45. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
  46. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
  47. package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
  48. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
  49. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
  50. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
  51. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
  52. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
  53. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
  54. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
  55. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
  56. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
  57. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
  58. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
  59. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
  60. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
  61. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
  62. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
  63. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
  64. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
  65. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
  66. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
  67. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
  68. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
  69. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
  70. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
  71. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
  72. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
  73. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
  74. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
  75. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
  76. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
  77. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
  78. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
  79. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
  80. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
  81. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
  82. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +123 -57
  83. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +1 -1
  84. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +1 -1
  85. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +1 -1
  86. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +1 -1
  87. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +1 -1
  88. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +1 -1
  89. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +1 -1
  90. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +44 -30
  91. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +4 -4
  92. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +1 -1
  93. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +1 -1
  94. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +1 -1
  95. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +30 -31
  96. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +1 -1
  97. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +1 -1
  98. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +1 -1
  99. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +1 -1
  100. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +1 -1
  101. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +93 -66
  102. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +1 -1
  103. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +52 -39
  104. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +1 -1
  105. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +1 -1
  106. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +5 -4
  107. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +1 -1
  108. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +1 -1
  109. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +38 -23
  110. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +1 -1
  111. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +1 -1
  112. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +1 -1
  113. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +1 -1
  114. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +1 -1
  115. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +1 -1
  116. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +1 -1
  117. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +1 -1
  118. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +1 -1
  119. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +1 -1
  120. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +1 -1
  121. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +2 -2
  122. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +2 -2
  123. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +2 -2
  124. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +4 -4
  125. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +1 -1
  126. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +2 -2
@@ -0,0 +1,198 @@
1
+ //
2
+ // Created by Osei Fortune on 05/08/2024.
3
+ //
4
+
5
+ #pragma once
6
+
7
+ #include "Common.h"
8
+ #include <thread>
9
+
10
+ #ifdef __ANDROID__
11
+
12
+ #include <android/looper.h>
13
+ #include <cassert>
14
+
15
+ #endif
16
+
17
+ #ifdef __APPLE__
18
+ #include "NSOperationQueueWrapper.h"
19
+ #endif
20
+
21
+
22
+ #include <unistd.h>
23
+ #include <fcntl.h>
24
+
25
+ typedef void(*CompleteCallback)(bool success, void *data);
26
+
27
+ #ifdef __APPLE__
28
+ struct PromiseCallback {
29
+ struct Inner {
30
+ NSOperationQueueWrapper* current_queue = nullptr;
31
+ v8::Isolate *isolate_;
32
+ v8::Persistent<v8::Promise::Resolver> callback_;
33
+ v8::Persistent<v8::Value> error_;
34
+ CompleteCallback completeCallback_;
35
+ CompleteCallback completeCallbackWrapper_;
36
+ bool isPrepared_ = false;
37
+ void* data;
38
+
39
+ Inner(v8::Isolate *isolate, v8::Local<v8::Promise::Resolver> callback,
40
+ CompleteCallback completeCallback) : isolate_(isolate),
41
+ callback_(v8::Persistent<v8::Promise::Resolver>(
42
+ isolate,
43
+ callback)) {
44
+ this->completeCallback_ = completeCallback;
45
+ this->completeCallbackWrapper_ = [](bool success, void *data){
46
+ if(data != nullptr){
47
+ auto* callback = static_cast<PromiseCallback*>(data);
48
+ auto inner = callback->inner_.get();
49
+ if(inner == nullptr || inner->current_queue != nullptr){
50
+ return;
51
+ }
52
+
53
+ inner->current_queue->addOperation([success, data, inner, callback](){
54
+ inner->completeCallback_(success, data);
55
+ // delete callback;
56
+ });
57
+ }
58
+ };
59
+ }
60
+
61
+ void prepare(){
62
+ current_queue = new NSOperationQueueWrapper(true);
63
+ isPrepared_ = true;
64
+ }
65
+
66
+ void execute(bool complete, PromiseCallback* callback){
67
+ completeCallbackWrapper_(complete, callback);
68
+ }
69
+
70
+ ~Inner(){
71
+ callback_.Reset();
72
+ error_.Reset();
73
+ }
74
+ };
75
+
76
+ std::shared_ptr<Inner> inner_;
77
+
78
+ void prepare(){
79
+ auto inner = this->inner_.get();
80
+ if(inner == nullptr){return;}
81
+ inner->prepare();
82
+ }
83
+
84
+ void execute(bool complete) {
85
+ auto inner = this->inner_.get();
86
+ if (inner == nullptr) { return; }
87
+ inner->execute(complete, this);
88
+ }
89
+
90
+ explicit PromiseCallback(std::shared_ptr<Inner> inner) : inner_(std::move(inner)) {}
91
+
92
+ PromiseCallback(v8::Isolate *isolate, v8::Local<v8::Promise::Resolver> callback,
93
+ CompleteCallback completeCallback) : inner_(
94
+ std::make_shared<Inner>(isolate, callback, completeCallback)) {}
95
+ };
96
+ #endif
97
+
98
+ #ifdef __ANDROID__
99
+
100
+ struct PromiseCallback {
101
+ struct Inner {
102
+ int fd_[2];
103
+ ALooper *looper_ = nullptr;
104
+ v8::Isolate *isolate_;
105
+ v8::Persistent<v8::Promise::Resolver> callback_;
106
+ void *data = nullptr;
107
+ CompleteCallback completeCallback_;
108
+ bool isPrepared_ = false;
109
+
110
+ Inner(v8::Isolate *isolate, v8::Local<v8::Promise::Resolver> callback,
111
+ CompleteCallback completeCallback) : isolate_(isolate),
112
+ callback_(v8::Persistent<v8::Promise::Resolver>(
113
+ isolate,
114
+ callback)) {
115
+ this->completeCallback_ = completeCallback;
116
+ }
117
+
118
+ void prepare() {
119
+ // release previous looper
120
+ if (isPrepared_) {
121
+ ALooper_removeFd(looper_, fd_[0]);
122
+ close(fd_[0]);
123
+ fd_[0] = -1;
124
+ fd_[1] = -1;
125
+ ALooper_release(looper_);
126
+ }
127
+
128
+ auto res = pipe(fd_);
129
+ assert(res != -1);
130
+ res = fcntl(fd_[1], F_SETFL, O_NONBLOCK);
131
+ assert(res != -1);
132
+ looper_ = ALooper_prepare(0);
133
+ ALooper_acquire(looper_);
134
+
135
+ isPrepared_ = true;
136
+ }
137
+
138
+ void execute(bool complete) const {
139
+ if (!isPrepared_) { return; }
140
+ write(fd_[1],
141
+ &complete,
142
+ sizeof(bool));
143
+ }
144
+
145
+
146
+ ~Inner() {
147
+ if (!isPrepared_) {
148
+ return;
149
+ }
150
+ ALooper_removeFd(looper_, fd_[0]);
151
+ close(fd_[0]);
152
+ ALooper_release(looper_);
153
+ callback_.Reset();
154
+ }
155
+ };
156
+
157
+ void prepare() const {
158
+ auto inner = this->inner_.get();
159
+ if (inner == nullptr) { return; }
160
+ inner->prepare();
161
+ auto looper = inner->looper_;
162
+ auto fd = inner->fd_[0];
163
+ auto data = new PromiseCallback(this->inner_);
164
+ ALooper_addFd(looper,
165
+ fd,
166
+ ALOOPER_POLL_CALLBACK,
167
+ ALOOPER_EVENT_INPUT,
168
+ [](int fd, int events,
169
+ void *data) {
170
+ auto cb = static_cast<PromiseCallback *>(data);
171
+ bool done = false;
172
+ read(fd, &done,
173
+ sizeof(bool));
174
+ cb->inner_->completeCallback_(done, data);
175
+ return 0;
176
+ }, (void *) data);
177
+
178
+ ALooper_wake(looper);
179
+ inner->isPrepared_ = true;
180
+ }
181
+
182
+ void execute(bool complete) const {
183
+ auto inner = this->inner_.get();
184
+ if (inner == nullptr) { return; }
185
+ inner->execute(complete);
186
+ }
187
+
188
+ std::shared_ptr<Inner> inner_;
189
+
190
+ explicit PromiseCallback(std::shared_ptr<Inner> inner) : inner_(std::move(inner)) {}
191
+
192
+ PromiseCallback(v8::Isolate *isolate, v8::Local<v8::Promise::Resolver> callback,
193
+ CompleteCallback completeCallback) : inner_(
194
+ std::make_shared<Inner>(isolate, callback, completeCallback)) {}
195
+
196
+ };
197
+
198
+ #endif
@@ -3,21 +3,22 @@
3
3
  //
4
4
 
5
5
  #pragma once
6
+
6
7
  #include <vector>
7
8
  #include "Common.h"
8
9
  #include "Helpers.h"
9
10
  #include "ObjectWrapperImpl.h"
10
11
 
11
- class CanvasGradient: ObjectWrapperImpl {
12
+ class CanvasGradient : ObjectWrapperImpl {
12
13
  public:
13
- explicit CanvasGradient(PaintStyle*style);
14
+ explicit CanvasGradient(PaintStyle *style);
14
15
 
15
- ~CanvasGradient(){
16
+ ~CanvasGradient() {
16
17
  canvas_native_paint_style_release(this->GetPaintStyle());
17
18
  this->style_ = nullptr;
18
19
  }
19
20
 
20
- PaintStyle * GetPaintStyle();
21
+ PaintStyle *GetPaintStyle();
21
22
 
22
23
  static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
23
24
 
@@ -30,7 +31,7 @@ public:
30
31
  v8::EscapableHandleScope scope(isolate);
31
32
  auto object = CanvasGradient::GetCtor(isolate)->GetFunction(
32
33
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
- SetNativeType( object, NativeType::CanvasGradient);
34
+ SetNativeType(gradient, NativeType::CanvasGradient);
34
35
  object->SetAlignedPointerInInternalField(0, gradient);
35
36
  gradient->BindFinalizer(isolate, object);
36
37
  return scope.Escape(object);
@@ -39,6 +40,6 @@ public:
39
40
  static void AddColorStop(const v8::FunctionCallbackInfo<v8::Value> &args);
40
41
 
41
42
  private:
42
- PaintStyle* style_;
43
+ PaintStyle *style_;
43
44
  };
44
45
 
@@ -17,7 +17,7 @@ void CanvasPattern::Init(const v8::Local<v8::Object> &canvasModule, v8::Isolate
17
17
  auto context = isolate->GetCurrentContext();
18
18
  auto func = ctor->GetFunction(context).ToLocalChecked();
19
19
 
20
- canvasModule->Set(context, ConvertToV8String(isolate, "CanvasPattern"), func);
20
+ canvasModule->Set(context, ConvertToV8String(isolate, "CanvasPattern"), func).FromJust();
21
21
  }
22
22
 
23
23
  v8::CFunction CanvasPattern::fast_set_transform_(
@@ -30,7 +30,7 @@ public:
30
30
  v8::EscapableHandleScope scope(isolate);
31
31
  auto object = CanvasPattern::GetCtor(isolate)->GetFunction(
32
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
- SetNativeType(object, NativeType::CanvasPattern);
33
+ SetNativeType(pattern, NativeType::CanvasPattern);
34
34
  object->SetAlignedPointerInInternalField(0, pattern);
35
35
  pattern->BindFinalizer(isolate, object);
36
36
  return scope.Escape(object);
@@ -1609,7 +1609,7 @@ CanvasRenderingContext2DImpl::CreateImageData(const v8::FunctionCallbackInfo<v8:
1609
1609
 
1610
1610
  ret->SetAlignedPointerInInternalField(0, data);
1611
1611
 
1612
- SetNativeType(ret, NativeType::ImageData);
1612
+ SetNativeType(data, NativeType::ImageData);
1613
1613
 
1614
1614
  args.GetReturnValue().Set(ret);
1615
1615
 
@@ -1629,7 +1629,7 @@ CanvasRenderingContext2DImpl::CreateImageData(const v8::FunctionCallbackInfo<v8:
1629
1629
 
1630
1630
  ret->SetAlignedPointerInInternalField(0, data);
1631
1631
 
1632
- SetNativeType(ret, NativeType::ImageData);
1632
+ SetNativeType(data, NativeType::ImageData);
1633
1633
 
1634
1634
  args.GetReturnValue().Set(ret);
1635
1635
  }
@@ -2475,7 +2475,7 @@ CanvasRenderingContext2DImpl::GetImageData(const v8::FunctionCallbackInfo<v8::Va
2475
2475
 
2476
2476
  ret->SetAlignedPointerInInternalField(0, data);
2477
2477
 
2478
- SetNativeType(ret, NativeType::ImageData);
2478
+ SetNativeType(data, NativeType::ImageData);
2479
2479
 
2480
2480
  args.GetReturnValue().Set(ret);
2481
2481
  return;
@@ -2648,7 +2648,7 @@ CanvasRenderingContext2DImpl::MeasureText(const v8::FunctionCallbackInfo<v8::Val
2648
2648
 
2649
2649
  data->BindFinalizer(isolate, ret);
2650
2650
 
2651
- SetNativeType(ret, NativeType::TextMetrics);
2651
+ SetNativeType(data, NativeType::TextMetrics);
2652
2652
 
2653
2653
  args.GetReturnValue().Set(ret);
2654
2654
 
@@ -2957,7 +2957,7 @@ CanvasRenderingContext2DImpl::GetTransform(const v8::FunctionCallbackInfo<v8::Va
2957
2957
 
2958
2958
  ret->SetAlignedPointerInInternalField(0, object);
2959
2959
 
2960
- SetNativeType(ret, NativeType::Matrix);
2960
+ SetNativeType(object, NativeType::Matrix);
2961
2961
 
2962
2962
  object->BindFinalizer(isolate, ret);
2963
2963
 
@@ -171,7 +171,7 @@ public:
171
171
  v8::EscapableHandleScope scope(isolate);
172
172
  auto object = CanvasRenderingContext2DImpl::GetCtor(isolate)->GetFunction(
173
173
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
174
- SetNativeType(object, NativeType::CanvasRenderingContext2D);
174
+ SetNativeType(renderingContext, NativeType::CanvasRenderingContext2D);
175
175
  object->SetAlignedPointerInInternalField(0, renderingContext);
176
176
  renderingContext->BindFinalizer(isolate, object);
177
177
  return scope.Escape(object);
@@ -548,7 +548,8 @@ public:
548
548
  canvas_native_context_clip(
549
549
  ptr->GetContext(), path->GetPath(), CanvasFillRuleEvenOdd);
550
550
  break;
551
- default: break;
551
+ default:
552
+ break;
552
553
  }
553
554
  }
554
555
 
@@ -909,7 +910,8 @@ public:
909
910
  object->GetPath(),
910
911
  CanvasFillRuleEvenOdd);
911
912
  break;
912
- default: break;
913
+ default:
914
+ break;
913
915
  }
914
916
 
915
917
  ptr->UpdateInvalidateState();
@@ -948,7 +950,8 @@ public:
948
950
  canvas_native_context_fill(
949
951
  ptr->GetContext(), CanvasFillRuleEvenOdd);
950
952
  break;
951
- default: break;
953
+ default:
954
+ break;
952
955
  }
953
956
 
954
957
 
@@ -1023,7 +1026,8 @@ public:
1023
1026
  }
1024
1027
 
1025
1028
  return canvas_native_context_is_point_in_path(
1026
- ptr->GetContext(), static_cast<float>(x), static_cast<float>(y), CanvasFillRuleNonZero);
1029
+ ptr->GetContext(), static_cast<float>(x), static_cast<float>(y),
1030
+ CanvasFillRuleNonZero);
1027
1031
  }
1028
1032
 
1029
1033
  static bool
@@ -1036,7 +1040,8 @@ public:
1036
1040
 
1037
1041
 
1038
1042
  return canvas_native_context_is_point_in_path(
1039
- ptr->GetContext(), static_cast<float>(x), static_cast<float>(y), rule == 0 ? CanvasFillRuleNonZero : CanvasFillRuleEvenOdd);
1043
+ ptr->GetContext(), static_cast<float>(x), static_cast<float>(y),
1044
+ rule == 0 ? CanvasFillRuleNonZero : CanvasFillRuleEvenOdd);
1040
1045
  }
1041
1046
 
1042
1047
  static bool
@@ -1061,15 +1066,16 @@ public:
1061
1066
 
1062
1067
  ret = canvas_native_context_is_point_in_path_with_path(
1063
1068
  ptr->GetContext(),
1064
- path->GetPath(), (float)x, (float)y, CanvasFillRuleNonZero);
1069
+ path->GetPath(), (float) x, (float) y, CanvasFillRuleNonZero);
1065
1070
  break;
1066
1071
  case 1:
1067
1072
 
1068
1073
  ret = canvas_native_context_is_point_in_path_with_path(
1069
1074
  ptr->GetContext(),
1070
- path->GetPath(), (float)x, (float)y, CanvasFillRuleEvenOdd);
1075
+ path->GetPath(), (float) x, (float) y, CanvasFillRuleEvenOdd);
1076
+ break;
1077
+ default:
1071
1078
  break;
1072
- default: break;
1073
1079
  }
1074
1080
 
1075
1081
  }
@@ -1447,7 +1453,6 @@ public:
1447
1453
  static void StrokeText(const v8::FunctionCallbackInfo<v8::Value> &args);
1448
1454
 
1449
1455
 
1450
-
1451
1456
  static void StrokeOval(const v8::FunctionCallbackInfo<v8::Value> &args);
1452
1457
 
1453
1458
 
@@ -115,7 +115,7 @@ void ImageDataImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
115
115
 
116
116
  object->BindFinalizer(isolate, ret);
117
117
 
118
- SetNativeType(ret, NativeType::ImageData);
118
+ SetNativeType(object, NativeType::ImageData);
119
119
 
120
120
  args.GetReturnValue().Set(ret);
121
121
  return;
@@ -136,7 +136,7 @@ void ImageDataImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
136
136
 
137
137
  ret->SetAlignedPointerInInternalField(0, object);
138
138
 
139
- SetNativeType(ret, NativeType::ImageData);
139
+ SetNativeType(object, NativeType::ImageData);
140
140
 
141
141
  object->BindFinalizer(isolate, ret);
142
142
 
@@ -8,7 +8,7 @@
8
8
  #include "Common.h"
9
9
  #include "ObjectWrapperImpl.h"
10
10
 
11
- class ImageDataImpl: ObjectWrapperImpl {
11
+ class ImageDataImpl : public ObjectWrapperImpl {
12
12
  public:
13
13
  explicit ImageDataImpl(ImageData* imageData);
14
14
 
@@ -281,7 +281,7 @@ void MatrixImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
281
281
 
282
282
  ret->SetAlignedPointerInInternalField(0, object);
283
283
 
284
- SetNativeType(ret, NativeType::Matrix);
284
+ SetNativeType(object, NativeType::Matrix);
285
285
 
286
286
  object->BindFinalizer(isolate, ret);
287
287
 
@@ -307,7 +307,7 @@ void MatrixImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
307
307
 
308
308
  ret->SetAlignedPointerInInternalField(0, object);
309
309
 
310
- SetNativeType(ret, NativeType::Matrix);
310
+ SetNativeType(object, NativeType::Matrix);
311
311
 
312
312
  object->BindFinalizer(isolate, ret);
313
313
 
@@ -322,7 +322,7 @@ void MatrixImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
322
322
 
323
323
  ret->SetAlignedPointerInInternalField(0, object);
324
324
 
325
- SetNativeType(ret, NativeType::Matrix);
325
+ SetNativeType(object, NativeType::Matrix);
326
326
 
327
327
  object->BindFinalizer(isolate, ret);
328
328
 
@@ -897,7 +897,7 @@ void MatrixImpl::Translate(const v8::FunctionCallbackInfo<v8::Value> &args) {
897
897
 
898
898
  ret->SetAlignedPointerInInternalField(0, object);
899
899
 
900
- SetNativeType(ret, NativeType::Matrix);
900
+ SetNativeType(object, NativeType::Matrix);
901
901
 
902
902
  object->BindFinalizer(isolate, ret);
903
903
 
@@ -989,7 +989,7 @@ void MatrixImpl::ScaleNonUniform(const v8::FunctionCallbackInfo<v8::Value> &args
989
989
 
990
990
  ret->SetAlignedPointerInInternalField(0, object);
991
991
 
992
- SetNativeType(ret, NativeType::Matrix);
992
+ SetNativeType(object, NativeType::Matrix);
993
993
 
994
994
  object->BindFinalizer(isolate, ret);
995
995
 
@@ -1048,7 +1048,7 @@ void MatrixImpl::Rotate(const v8::FunctionCallbackInfo<v8::Value> &args) {
1048
1048
 
1049
1049
  ret->SetAlignedPointerInInternalField(0, object);
1050
1050
 
1051
- SetNativeType(ret, NativeType::Matrix);
1051
+ SetNativeType(object, NativeType::Matrix);
1052
1052
 
1053
1053
  object->BindFinalizer(isolate, ret);
1054
1054
 
@@ -1105,7 +1105,7 @@ void MatrixImpl::SkewX(const v8::FunctionCallbackInfo<v8::Value> &args) {
1105
1105
 
1106
1106
  ret->SetAlignedPointerInInternalField(0, object);
1107
1107
 
1108
- SetNativeType(ret, NativeType::Matrix);
1108
+ SetNativeType(object, NativeType::Matrix);
1109
1109
 
1110
1110
  object->BindFinalizer(isolate, ret);
1111
1111
 
@@ -1144,7 +1144,7 @@ void MatrixImpl::SkewY(const v8::FunctionCallbackInfo<v8::Value> &args) {
1144
1144
  if (type == NativeType::Matrix) {
1145
1145
  auto ptr = MatrixImpl::GetPointer(value.As<v8::Object>());
1146
1146
  auto matrix = canvas_native_matrix_skew_y(
1147
- angle->NumberValue(context).ToChecked(),
1147
+ (float) angle->NumberValue(context).ToChecked(),
1148
1148
  ptr->GetMatrix());
1149
1149
  if (matrix == nullptr) {
1150
1150
  args.GetReturnValue().SetUndefined();
@@ -1158,7 +1158,7 @@ void MatrixImpl::SkewY(const v8::FunctionCallbackInfo<v8::Value> &args) {
1158
1158
 
1159
1159
  ret->SetAlignedPointerInInternalField(0, object);
1160
1160
 
1161
- SetNativeType(ret, NativeType::Matrix);
1161
+ SetNativeType(object, NativeType::Matrix);
1162
1162
 
1163
1163
  object->BindFinalizer(isolate, ret);
1164
1164
 
@@ -1198,7 +1198,7 @@ void MatrixImpl::Clone(const v8::FunctionCallbackInfo<v8::Value> &args) {
1198
1198
 
1199
1199
  ret->SetAlignedPointerInInternalField(0, object);
1200
1200
 
1201
- SetNativeType(ret, NativeType::Matrix);
1201
+ SetNativeType(object, NativeType::Matrix);
1202
1202
 
1203
1203
  object->BindFinalizer(isolate, ret);
1204
1204
 
@@ -75,8 +75,6 @@ void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
75
75
 
76
76
  auto ret = args.This();
77
77
 
78
- SetNativeType(ret, NativeType::Path2D);
79
-
80
78
  if (count > 0) {
81
79
  if (value->IsString()) {
82
80
  auto d = ConvertFromV8String(isolate, value);
@@ -87,6 +85,8 @@ void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
87
85
 
88
86
  object->BindFinalizer(isolate, ret);
89
87
 
88
+ SetNativeType(object, NativeType::Path2D);
89
+
90
90
  args.GetReturnValue().Set(ret);
91
91
 
92
92
  return;
@@ -102,6 +102,8 @@ void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
102
102
 
103
103
  object->BindFinalizer(isolate, ret);
104
104
 
105
+ SetNativeType(object, NativeType::Path2D);
106
+
105
107
  args.GetReturnValue().Set(ret);
106
108
  return;
107
109
  }
@@ -109,11 +111,12 @@ void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
109
111
  } else {
110
112
  auto path = new Path2D(canvas_native_path_create());
111
113
 
112
-
113
114
  ret->SetAlignedPointerInInternalField(0, path);
114
115
 
115
116
  path->BindFinalizer(isolate, ret);
116
117
 
118
+ SetNativeType(path, NativeType::Path2D);
119
+
117
120
  args.GetReturnValue().Set(ret);
118
121
  return;
119
122
 
@@ -25,7 +25,7 @@ public:
25
25
  v8::EscapableHandleScope scope(isolate);
26
26
  auto object = WebGLActiveInfoImpl::GetCtor(isolate)->GetFunction(
27
27
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
28
- SetNativeType( object, NativeType::WebGLActiveInfo);
28
+ SetNativeType( info, NativeType::WebGLActiveInfo);
29
29
  object->SetAlignedPointerInInternalField(0, info);
30
30
  info->BindFinalizer(isolate, object);
31
31
  return scope.Escape(object);
@@ -35,7 +35,7 @@ public:
35
35
  v8::EscapableHandleScope scope(isolate);
36
36
  auto object = WebGLBuffer::GetCtor(isolate)->GetFunction(
37
37
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
38
- SetNativeType( object, NativeType::WebGLBuffer);
38
+ SetNativeType( buffer, NativeType::WebGLBuffer);
39
39
  object->SetAlignedPointerInInternalField(0, buffer);
40
40
  buffer->BindFinalizer(isolate, object);
41
41
  return scope.Escape(object);
@@ -35,7 +35,7 @@ public:
35
35
  v8::EscapableHandleScope scope(isolate);
36
36
  auto object = WebGLFramebuffer::GetCtor(isolate)->GetFunction(
37
37
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
38
- SetNativeType( object, NativeType::WebGLFramebuffer);
38
+ SetNativeType( buffer, NativeType::WebGLFramebuffer);
39
39
  object->SetAlignedPointerInInternalField(0, buffer);
40
40
  buffer->BindFinalizer(isolate, object);
41
41
  return scope.Escape(object);
@@ -9,9 +9,9 @@
9
9
 
10
10
  class WebGLProgram:ObjectWrapperImpl {
11
11
  public:
12
- WebGLProgram(uint32_t program) : program_(program) {}
12
+ explicit WebGLProgram(uint32_t program) : program_(program) {}
13
13
 
14
- uint32_t GetProgram() {
14
+ uint32_t GetProgram() const {
15
15
  return this->program_;
16
16
  }
17
17
 
@@ -39,7 +39,7 @@ public:
39
39
  v8::EscapableHandleScope scope(isolate);
40
40
  auto object = WebGLProgram::GetCtor(isolate)->GetFunction(
41
41
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
42
- SetNativeType( object, NativeType::WebGLProgram);
42
+ SetNativeType( program, NativeType::WebGLProgram);
43
43
  object->SetAlignedPointerInInternalField(0, program);
44
44
  program->BindFinalizer(isolate, object);
45
45
  return scope.Escape(object);
@@ -8,7 +8,7 @@
8
8
  #include "ObjectWrapperImpl.h"
9
9
  class WebGLRenderbuffer: ObjectWrapperImpl {
10
10
  public:
11
- WebGLRenderbuffer(uint32_t renderbuffer) : renderbuffer_(renderbuffer) {}
11
+ explicit WebGLRenderbuffer(uint32_t renderbuffer) : renderbuffer_(renderbuffer) {}
12
12
 
13
13
  static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate) {
14
14
  auto cache = Caches::Get(isolate);
@@ -34,7 +34,7 @@ public:
34
34
  v8::EscapableHandleScope scope(isolate);
35
35
  auto object = WebGLRenderbuffer::GetCtor(isolate)->GetFunction(
36
36
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
37
- SetNativeType( object, NativeType::WebGLRenderbuffer);
37
+ SetNativeType( buffer, NativeType::WebGLRenderbuffer);
38
38
  object->SetAlignedPointerInInternalField(0, buffer);
39
39
  buffer->BindFinalizer(isolate, object);
40
40
  return scope.Escape(object);
@@ -48,7 +48,7 @@ public:
48
48
  return static_cast<WebGLRenderbuffer *>(ptr);
49
49
  }
50
50
 
51
- uint32_t GetRenderBuffer() {
51
+ uint32_t GetRenderBuffer() const {
52
52
  return this->renderbuffer_;
53
53
  }
54
54
 
@@ -301,7 +301,7 @@ public:
301
301
  v8::EscapableHandleScope scope(isolate);
302
302
  auto object = WebGLRenderingContext::GetCtor(isolate)->GetFunction(
303
303
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
304
- SetNativeType(object, NativeType::WebGLRenderingContextBase);
304
+ SetNativeType(renderingContext, NativeType::WebGLRenderingContextBase);
305
305
  object->SetAlignedPointerInInternalField(0, renderingContext);
306
306
  renderingContext->BindFinalizer(isolate, object);
307
307
  return scope.Escape(object);
@@ -34,7 +34,7 @@ public:
34
34
  v8::EscapableHandleScope scope(isolate);
35
35
  auto object = WebGLShader::GetCtor(isolate)->GetFunction(
36
36
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
37
- SetNativeType( object, NativeType::WebGLShader);
37
+ SetNativeType( shader, NativeType::WebGLShader);
38
38
  object->SetAlignedPointerInInternalField(0, shader);
39
39
  shader->BindFinalizer(isolate, object);
40
40
  return scope.Escape(object);