@nativescript/canvas 2.0.0-beta.2 → 2.0.0-beta.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 (201) hide show
  1. package/Canvas/common.d.ts +23 -15
  2. package/Canvas/common.js +127 -55
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +1 -0
  5. package/Canvas/index.android.js +53 -88
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +2 -0
  8. package/Canvas/index.ios.d.ts +4 -1
  9. package/Canvas/index.ios.js +58 -52
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +14 -0
  12. package/Canvas2D/CanvasRenderingContext2D/index.js +207 -19
  13. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  14. package/Canvas2D/DOMMatrix/index.d.ts +14 -0
  15. package/Canvas2D/DOMMatrix/index.js +62 -0
  16. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  17. package/Canvas2D/ImageData/index.js +4 -6
  18. package/Canvas2D/ImageData/index.js.map +1 -1
  19. package/Canvas2D/Path2D/index.d.ts +2 -1
  20. package/Canvas2D/Path2D/index.js +3 -12
  21. package/Canvas2D/Path2D/index.js.map +1 -1
  22. package/Dom/Dom.d.ts +20 -1
  23. package/Dom/Dom.js +78 -10
  24. package/Dom/Dom.js.map +1 -1
  25. package/Dom/Group.d.ts +5 -0
  26. package/Dom/Group.js +15 -0
  27. package/Dom/Group.js.map +1 -1
  28. package/Dom/Image.d.ts +1 -0
  29. package/Dom/Image.js +20 -0
  30. package/Dom/Image.js.map +1 -1
  31. package/Dom/Paint.d.ts +4 -0
  32. package/Dom/Paint.js +19 -7
  33. package/Dom/Paint.js.map +1 -1
  34. package/Dom/Shadow.js +9 -0
  35. package/Dom/Shadow.js.map +1 -1
  36. package/Dom/Text.js +11 -1
  37. package/Dom/Text.js.map +1 -1
  38. package/Dom/index.d.ts +1 -0
  39. package/Dom/index.js +1 -0
  40. package/Dom/index.js.map +1 -1
  41. package/Dom/shaders/Gradients.d.ts +3 -0
  42. package/Dom/shaders/Gradients.js +4 -0
  43. package/Dom/shaders/Gradients.js.map +1 -0
  44. package/Dom/shaders/LinearGradient.d.ts +14 -0
  45. package/Dom/shaders/LinearGradient.js +44 -0
  46. package/Dom/shaders/LinearGradient.js.map +1 -0
  47. package/Dom/shaders/TwoPointConicalGradient.d.ts +16 -0
  48. package/Dom/shaders/TwoPointConicalGradient.js +60 -0
  49. package/Dom/shaders/TwoPointConicalGradient.js.map +1 -0
  50. package/Dom/shaders/index.d.ts +2 -0
  51. package/Dom/shaders/index.js +3 -0
  52. package/Dom/shaders/index.js.map +1 -0
  53. package/Dom/shapes/Atlas.d.ts +22 -0
  54. package/Dom/shapes/Atlas.js +60 -0
  55. package/Dom/shapes/Atlas.js.map +1 -0
  56. package/Dom/shapes/Circle.js +11 -0
  57. package/Dom/shapes/Circle.js.map +1 -1
  58. package/Dom/shapes/Line.d.ts +16 -4
  59. package/Dom/shapes/Line.js +13 -8
  60. package/Dom/shapes/Line.js.map +1 -1
  61. package/Dom/shapes/Oval.d.ts +12 -0
  62. package/Dom/shapes/Oval.js +87 -0
  63. package/Dom/shapes/Oval.js.map +1 -0
  64. package/Dom/shapes/Path.d.ts +19 -2
  65. package/Dom/shapes/Path.js +68 -4
  66. package/Dom/shapes/Path.js.map +1 -1
  67. package/Dom/shapes/Points.js +9 -1
  68. package/Dom/shapes/Points.js.map +1 -1
  69. package/Dom/shapes/Rect.js +27 -5
  70. package/Dom/shapes/Rect.js.map +1 -1
  71. package/Dom/shapes/RoundedRect.d.ts +2 -1
  72. package/Dom/shapes/RoundedRect.js +13 -2
  73. package/Dom/shapes/RoundedRect.js.map +1 -1
  74. package/Dom/shapes/index.d.ts +17 -0
  75. package/Dom/shapes/index.js +31 -0
  76. package/Dom/shapes/index.js.map +1 -1
  77. package/WebGL/WebGLRenderingContext/index.d.ts +1 -0
  78. package/WebGL/WebGLRenderingContext/index.js +104 -14
  79. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  80. package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -0
  81. package/WebGL2/WebGL2RenderingContext/index.js +2 -3
  82. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  83. package/index.d.ts +0 -1
  84. package/index.js +14 -15
  85. package/index.js.map +1 -1
  86. package/package.json +1 -4
  87. package/platforms/android/canvas-release.aar +0 -0
  88. package/platforms/ios/CanvasNative.xcframework/Info.plist +4 -0
  89. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  90. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +35 -25
  91. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +50 -4
  92. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +139 -16
  93. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  94. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  95. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +982 -3319
  96. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +18 -33
  97. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  98. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +18 -33
  99. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/module.modulemap +1 -1
  100. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/NSCCanvas.nib +0 -0
  101. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  102. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +622 -0
  103. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  104. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +70 -50
  105. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +50 -4
  106. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +139 -16
  107. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  108. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  109. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  110. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +982 -3319
  111. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +18 -33
  112. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  113. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +18 -33
  114. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +982 -3319
  115. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +18 -33
  116. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  117. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +18 -33
  118. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/module.modulemap +1 -1
  119. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/NSCCanvas.nib +0 -0
  120. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +35 -35
  121. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  122. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +624 -0
  123. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +624 -0
  124. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +297 -397
  125. package/platforms/ios/src/cpp/Helpers.h +3 -4
  126. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +30 -30
  127. package/platforms/ios/src/cpp/ImageAssetImpl.h +8 -5
  128. package/platforms/ios/src/cpp/URLImpl.cpp +73 -0
  129. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +339 -33
  130. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +150 -55
  131. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
  132. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
  133. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +19 -48
  134. package/platforms/ios/src/cpp/canvas2d/Path2D.h +19 -0
  135. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +105 -119
  136. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +37 -7
  137. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +10 -0
  138. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
  139. package/src-native/ios/NativeScript.podspec +1 -1
  140. package/SVG/Circle.d.ts +0 -11
  141. package/SVG/Circle.js +0 -21
  142. package/SVG/Circle.js.map +0 -1
  143. package/SVG/ClipPath.d.ts +0 -4
  144. package/SVG/ClipPath.js +0 -9
  145. package/SVG/ClipPath.js.map +0 -1
  146. package/SVG/Defs.d.ts +0 -4
  147. package/SVG/Defs.js +0 -9
  148. package/SVG/Defs.js.map +0 -1
  149. package/SVG/Ellipse.d.ts +0 -13
  150. package/SVG/Ellipse.js +0 -26
  151. package/SVG/Ellipse.js.map +0 -1
  152. package/SVG/G.d.ts +0 -7
  153. package/SVG/G.js +0 -9
  154. package/SVG/G.js.map +0 -1
  155. package/SVG/Image.d.ts +0 -11
  156. package/SVG/Image.js +0 -40
  157. package/SVG/Image.js.map +0 -1
  158. package/SVG/Line.d.ts +0 -13
  159. package/SVG/Line.js +0 -26
  160. package/SVG/Line.js.map +0 -1
  161. package/SVG/LinearGradient.d.ts +0 -10
  162. package/SVG/LinearGradient.js +0 -13
  163. package/SVG/LinearGradient.js.map +0 -1
  164. package/SVG/Path.d.ts +0 -7
  165. package/SVG/Path.js +0 -14
  166. package/SVG/Path.js.map +0 -1
  167. package/SVG/Pattern.d.ts +0 -4
  168. package/SVG/Pattern.js +0 -9
  169. package/SVG/Pattern.js.map +0 -1
  170. package/SVG/Polygon.d.ts +0 -7
  171. package/SVG/Polygon.js +0 -14
  172. package/SVG/Polygon.js.map +0 -1
  173. package/SVG/Polyline.d.ts +0 -7
  174. package/SVG/Polyline.js +0 -14
  175. package/SVG/Polyline.js.map +0 -1
  176. package/SVG/Rect.d.ts +0 -8
  177. package/SVG/Rect.js +0 -13
  178. package/SVG/Rect.js.map +0 -1
  179. package/SVG/SVG.d.ts +0 -31
  180. package/SVG/SVG.js +0 -190
  181. package/SVG/SVG.js.map +0 -1
  182. package/SVG/SVGItem.d.ts +0 -5
  183. package/SVG/SVGItem.js +0 -8
  184. package/SVG/SVGItem.js.map +0 -1
  185. package/SVG/Stop.d.ts +0 -5
  186. package/SVG/Stop.js +0 -9
  187. package/SVG/Stop.js.map +0 -1
  188. package/SVG/Symbol.d.ts +0 -4
  189. package/SVG/Symbol.js +0 -9
  190. package/SVG/Symbol.js.map +0 -1
  191. package/SVG/Text.d.ts +0 -14
  192. package/SVG/Text.js +0 -26
  193. package/SVG/Text.js.map +0 -1
  194. package/SVG/Use.d.ts +0 -4
  195. package/SVG/Use.js +0 -9
  196. package/SVG/Use.js.map +0 -1
  197. package/SVG/index.d.ts +0 -18
  198. package/SVG/index.js +0 -19
  199. package/SVG/index.js.map +0 -1
  200. package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
  201. package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
@@ -7,7 +7,121 @@
7
7
  #include "JSIRuntime.h"
8
8
  #include "JSIReadFileCallback.h"
9
9
  #include "Helpers.h"
10
- #include "PerIsolateData.h"
10
+
11
+ struct GLOptions {
12
+ int32_t version;
13
+ bool alpha;
14
+ bool antialias;
15
+ bool depth;
16
+ bool failIfMajorPerformanceCaveat;
17
+ int32_t powerPreference;
18
+ bool premultipliedAlpha;
19
+ bool preserveDrawingBuffer;
20
+ bool stencil;
21
+ bool desynchronized;
22
+ bool xrCompatible;
23
+
24
+ public:
25
+ GLOptions() {
26
+ this->version = 0;
27
+ this->alpha = true;
28
+ this->antialias = true;
29
+ this->depth = true;
30
+ this->failIfMajorPerformanceCaveat = false;
31
+ this->powerPreference = 0;
32
+ this->premultipliedAlpha = true;
33
+ this->preserveDrawingBuffer = false;
34
+ this->stencil = false;
35
+ this->desynchronized = false;
36
+ this->xrCompatible = false;
37
+ }
38
+
39
+ void parseGLOptions(const v8::FunctionCallbackInfo<v8::Value> &args) {
40
+ auto configValue = args[0];
41
+
42
+ if (!(!configValue->IsNullOrUndefined() && configValue->IsObject())) {
43
+ return;
44
+ }
45
+
46
+ auto isolate = args.GetIsolate();
47
+ auto context = isolate->GetCurrentContext();
48
+ auto config = configValue.As<v8::Object>();
49
+
50
+ v8::Local<v8::Value> versionValue;
51
+
52
+ config->Get(context, ConvertToV8String(isolate, "version")).ToLocal(&versionValue);
53
+
54
+ if (!versionValue.IsEmpty() && versionValue->IsInt32()) {
55
+ versionValue->Int32Value(context).To(&this->version);
56
+ }
57
+
58
+ v8::Local<v8::Value> alphaValue;
59
+
60
+ config->Get(context, ConvertToV8String(isolate, "alpha")).ToLocal(&alphaValue);
61
+ if (!alphaValue.IsEmpty() && alphaValue->IsBoolean()) {
62
+ this->alpha = alphaValue->BooleanValue(isolate);
63
+ }
64
+
65
+ v8::Local<v8::Value> antialiasValue;
66
+ config->Get(context, ConvertToV8String(isolate, "antialias")).ToLocal(
67
+ &antialiasValue);
68
+ if (!antialiasValue.IsEmpty() && antialiasValue->IsBoolean()) {
69
+ this->antialias = antialiasValue->BooleanValue(isolate);
70
+ }
71
+
72
+ v8::Local<v8::Value> failIfMajorPerformanceCaveatValue;
73
+ config->Get(context, ConvertToV8String(isolate, "failIfMajorPerformanceCaveat")).ToLocal(
74
+ &failIfMajorPerformanceCaveatValue);
75
+ if (!failIfMajorPerformanceCaveatValue.IsEmpty() &&
76
+ failIfMajorPerformanceCaveatValue->IsBoolean()) {
77
+ this->failIfMajorPerformanceCaveat = failIfMajorPerformanceCaveatValue->BooleanValue(
78
+ isolate);
79
+ }
80
+
81
+ v8::Local<v8::Value> powerPreferenceValue;
82
+ config->Get(context, ConvertToV8String(isolate, "powerPreference")).ToLocal(
83
+ &powerPreferenceValue);
84
+ if (!powerPreferenceValue.IsEmpty() && powerPreferenceValue->IsInt32()) {
85
+ powerPreferenceValue->Int32Value(context).To(&this->powerPreference);
86
+ }
87
+
88
+ v8::Local<v8::Value> premultipliedAlphaValue;
89
+ config->Get(context,
90
+ ConvertToV8String(isolate, "premultipliedAlpha")).ToLocal(
91
+ &premultipliedAlphaValue);
92
+ if (!premultipliedAlphaValue.IsEmpty() && premultipliedAlphaValue->IsBoolean()) {
93
+ this->premultipliedAlpha = premultipliedAlphaValue->BooleanValue(isolate);
94
+ }
95
+
96
+ v8::Local<v8::Value> preserveDrawingBufferValue;
97
+ config->Get(context,
98
+ ConvertToV8String(isolate, "preserveDrawingBuffer")).ToLocal(
99
+ &preserveDrawingBufferValue);
100
+ if (!preserveDrawingBufferValue.IsEmpty() && preserveDrawingBufferValue->IsBoolean()) {
101
+ this->preserveDrawingBuffer = preserveDrawingBufferValue->BooleanValue(isolate);
102
+ }
103
+
104
+ v8::Local<v8::Value> stencilValue;
105
+ config->Get(context, ConvertToV8String(isolate, "stencil")).ToLocal(&stencilValue);
106
+ if (!stencilValue.IsEmpty() && stencilValue->IsBoolean()) {
107
+ this->stencil = stencilValue->BooleanValue(isolate);
108
+ }
109
+
110
+ v8::Local<v8::Value> desynchronizedValue;
111
+ config->Get(context, ConvertToV8String(isolate, "desynchronized")).ToLocal(
112
+ &desynchronizedValue);
113
+ if (!desynchronizedValue.IsEmpty() && desynchronizedValue->IsBoolean()) {
114
+ this->desynchronized = desynchronizedValue->BooleanValue(isolate);
115
+ }
116
+
117
+ v8::Local<v8::Value> xrCompatibleValue;
118
+ config->Get(context, ConvertToV8String(isolate, "xrCompatible")).ToLocal(
119
+ &xrCompatibleValue);
120
+ if (!xrCompatibleValue.IsEmpty() && xrCompatibleValue->IsBoolean()) {
121
+ this->xrCompatible = xrCompatibleValue->BooleanValue(isolate);
122
+ }
123
+ }
124
+ };
11
125
 
12
126
  void CanvasJSIModule::install(v8::Isolate *isolate) {
13
127
 
@@ -37,45 +151,39 @@ void CanvasJSIModule::install(v8::Isolate *isolate) {
37
151
  TextMetricsImpl::Init(canvasMod, isolate);
38
152
  URLImpl::Init(canvasMod, isolate);
39
153
 
40
- // always use the last slot
41
- auto lastSlot = isolate->GetNumberOfDataSlots() - 1;
42
- auto data = new PerIsolateData(isolate);
43
- isolate->SetData(lastSlot, data);
44
-
45
- v8Global->Set(context, ConvertToV8String(isolate, "CanvasModule"), canvasMod);
154
+ v8Global->Set(context, ConvertToV8String(isolate, "CanvasModule"), canvasMod).FromJust();
46
155
  canvasMod->Set(context, ConvertToV8String(isolate, "create2DContext"),
47
156
  v8::FunctionTemplate::New(isolate, &Create2DContext)->GetFunction(
48
- context).ToLocalChecked());
157
+ context).ToLocalChecked()).FromJust();
49
158
  canvasMod->Set(context, ConvertToV8String(isolate, "createImageBitmap"),
50
159
  v8::FunctionTemplate::New(isolate, &CreateImageBitmap)->GetFunction(
51
- context).ToLocalChecked());
160
+ context).ToLocalChecked()).FromJust();
52
161
  canvasMod->Set(context, ConvertToV8String(isolate, "create2DContextWithPointer"),
53
162
  v8::FunctionTemplate::New(isolate, &Create2DContextWithPointer)->GetFunction(
54
- context).ToLocalChecked());
163
+ context).ToLocalChecked()).FromJust();
55
164
  canvasMod->Set(context, ConvertToV8String(isolate, "readFile"),
56
165
  v8::FunctionTemplate::New(isolate, &ReadFile)->GetFunction(
57
- context).ToLocalChecked());
166
+ context).ToLocalChecked()).FromJust();
58
167
 
59
168
  canvasMod->Set(context, ConvertToV8String(isolate, "createWebGLContext"),
60
169
  v8::FunctionTemplate::New(isolate, &CreateWebGLContext)->GetFunction(
61
- context).ToLocalChecked());
170
+ context).ToLocalChecked()).FromJust();
62
171
 
63
172
  canvasMod->Set(context, ConvertToV8String(isolate, "createWebGL2Context"),
64
173
  v8::FunctionTemplate::New(isolate, &CreateWebGL2Context)->GetFunction(
65
- context).ToLocalChecked());
174
+ context).ToLocalChecked()).FromJust();
66
175
 
67
176
 
68
177
  canvasMod->Set(context, ConvertToV8String(isolate, "__addFontFamily"),
69
178
  v8::FunctionTemplate::New(isolate, &AddFontFamily)->GetFunction(
70
- context).ToLocalChecked());
179
+ context).ToLocalChecked()).FromJust();
71
180
 
72
181
  global->Set(context,
73
- ConvertToV8String(isolate, "CanvasModule"), canvasMod);
182
+ ConvertToV8String(isolate, "CanvasModule"), canvasMod).FromJust();
74
183
 
75
184
  }
76
185
  }
77
186
 
78
-
79
187
  void CanvasJSIModule::AddFontFamily(const v8::FunctionCallbackInfo<v8::Value> &args) {
80
188
  auto isolate = args.GetIsolate();
81
189
  auto context = isolate->GetCurrentContext();
@@ -807,7 +915,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
807
915
  }
808
916
  }
809
917
 
810
- auto type = GetNativeType( image);
918
+ auto type = GetNativeType(image);
811
919
 
812
920
  if (len == 1 || len == 2) {
813
921
  if (len == 2) {
@@ -1190,404 +1298,196 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
1190
1298
  }
1191
1299
 
1192
1300
  void CanvasJSIModule::CreateWebGLContext(const v8::FunctionCallbackInfo<v8::Value> &args) {
1193
- auto configValue = args[0];
1194
- auto isolate = args.GetIsolate();
1195
- auto context = isolate->GetCurrentContext();
1196
- if (!configValue->IsNullOrUndefined() && configValue->IsObject()) {
1197
- auto config = configValue.As<v8::Object>();
1198
- std::string version("none");
1199
- auto alpha = true;
1200
- auto antialias = true;
1201
- auto depth = true;
1202
- auto fail_if_major_performance_caveat = false;
1203
- std::string power_preference("default");
1204
- auto premultiplied_alpha = true;
1205
- auto preserve_drawing_buffer = false;
1206
- auto stencil = false;
1207
- auto desynchronized = false;
1208
- auto xr_compatible = false;
1209
-
1210
- auto last = isolate->GetNumberOfDataSlots() - 1;
1211
- auto data = isolate->GetData(last);
1212
-
1213
- if (data != nullptr) {
1214
- auto consts = static_cast<PerIsolateData *>(data);
1215
-
1216
- v8::Local<v8::Value> versionValue;
1217
-
1218
- config->Get(context, consts->VERSION_PERSISTENT->Get(isolate)).ToLocal(&versionValue);
1219
-
1220
- if (!versionValue.IsEmpty() && versionValue->IsString()) {
1221
- version = ConvertFromV8String(isolate, versionValue);
1222
- }
1223
-
1224
- v8::Local<v8::Value> alphaValue;
1225
-
1226
- config->Get(context, consts->ALPHA_PERSISTENT->Get(isolate)).ToLocal(&alphaValue);
1227
- if (!alphaValue.IsEmpty() && alphaValue->IsBoolean()) {
1228
- alpha = alphaValue->BooleanValue(isolate);
1229
- }
1230
-
1231
- v8::Local<v8::Value> antialiasValue;
1232
- config->Get(context, consts->ANTIALIAS_PERSISTENT->Get(isolate)).ToLocal(
1233
- &antialiasValue);
1234
- if (!antialiasValue.IsEmpty() && antialiasValue->IsBoolean()) {
1235
- antialias = antialiasValue->BooleanValue(isolate);
1236
- }
1237
-
1238
- v8::Local<v8::Value> failIfMajorPerformanceCaveatValue;
1239
- config->Get(context,
1240
- consts->FAIL_IF_MAJOR_PERFORMANCE_CAVEAT_PERSISTENT->Get(isolate)).ToLocal(
1241
- &failIfMajorPerformanceCaveatValue);
1242
- if (!failIfMajorPerformanceCaveatValue.IsEmpty() &&
1243
- failIfMajorPerformanceCaveatValue->IsBoolean()) {
1244
- fail_if_major_performance_caveat = failIfMajorPerformanceCaveatValue->BooleanValue(
1245
- isolate);
1246
- }
1247
-
1248
- v8::Local<v8::Value> powerPreferenceValue;
1249
- config->Get(context, consts->POWER_PREFERENCE_PERSISTENT->Get(isolate)).ToLocal(
1250
- &powerPreferenceValue);
1251
- if (!powerPreferenceValue.IsEmpty() && powerPreferenceValue->IsString()) {
1252
- power_preference = ConvertFromV8String(isolate, powerPreferenceValue);
1253
- }
1254
-
1255
- v8::Local<v8::Value> premultipliedAlphaValue;
1256
- config->Get(context,
1257
- consts->PREMULTIPLIED_ALPHA_PERSISTENT->Get(isolate)).ToLocal(
1258
- &premultipliedAlphaValue);
1259
- if (!premultipliedAlphaValue.IsEmpty() && premultipliedAlphaValue->IsBoolean()) {
1260
- premultiplied_alpha = premultipliedAlphaValue->BooleanValue(isolate);
1261
- }
1262
-
1263
- v8::Local<v8::Value> preserveDrawingBufferValue;
1264
- config->Get(context,
1265
- consts->PRESERVE_DRAWING_BUFFER_PERSISTENT->Get(isolate)).ToLocal(
1266
- &preserveDrawingBufferValue);
1267
- if (!preserveDrawingBufferValue.IsEmpty() && preserveDrawingBufferValue->IsBoolean()) {
1268
- preserve_drawing_buffer = preserveDrawingBufferValue->BooleanValue(isolate);
1269
- }
1270
-
1271
- v8::Local<v8::Value> stencilValue;
1272
- config->Get(context, consts->STENCIL_PERSISTENT->Get(isolate)).ToLocal(&stencilValue);
1273
- if (!stencilValue.IsEmpty() && stencilValue->IsBoolean()) {
1274
- stencil = stencilValue->BooleanValue(isolate);
1275
- }
1276
-
1277
- v8::Local<v8::Value> desynchronizedValue;
1278
- config->Get(context, consts->DESYNCHRONIZED_PERSISTENT->Get(isolate)).ToLocal(
1279
- &desynchronizedValue);
1280
- if (!desynchronizedValue.IsEmpty() && desynchronizedValue->IsBoolean()) {
1281
- desynchronized = desynchronizedValue->BooleanValue(isolate);
1282
- }
1283
-
1284
- v8::Local<v8::Value> xrCompatibleValue;
1285
- config->Get(context,
1286
- consts->XR_COMPATIBLE_PERSISTENT->Get(isolate)).ToLocal(&xrCompatibleValue);
1287
- if (!xrCompatibleValue.IsEmpty() && xrCompatibleValue->IsBoolean()) {
1288
- xr_compatible = xrCompatibleValue->BooleanValue(isolate);
1289
- }
1290
- }
1291
-
1292
1301
 
1293
- if (version !=
1294
- "v1") {
1295
- args.GetReturnValue().SetNull();
1296
- return;
1297
- } else {
1298
- auto count = args.Length();
1299
- if (count == 6) {
1300
- auto ctx = args[1].As<v8::BigInt>()->Int64Value();
1301
- // auto density = args[2]->NumberValue(context).ToChecked();
1302
- // auto fontColor = args[3]->NumberValue(context).ToChecked();
1303
- // auto ppi = args[4]->NumberValue(context).ToChecked();
1304
- // auto direction = args[5]->NumberValue(context).ToChecked();
1305
- auto webgl = canvas_native_webgl_create(
1306
- ctx,
1307
- version.c_str(),
1308
- alpha,
1309
- antialias,
1310
- depth,
1311
- fail_if_major_performance_caveat,
1312
- power_preference.c_str(),
1313
- premultiplied_alpha,
1314
- preserve_drawing_buffer,
1315
- stencil,
1316
- desynchronized,
1317
- xr_compatible
1318
- );
1319
-
1320
- auto renderingContext = WebGLRenderingContext::NewInstance(isolate,
1321
- new WebGLRenderingContext(
1322
- webgl));
1323
-
1324
- args.GetReturnValue().Set(renderingContext);
1325
- return;
1326
- } else if (count == 7) {
1327
- auto width = args[1]->NumberValue(context).ToChecked();
1328
- auto height = args[2]->NumberValue(context).ToChecked();
1329
- // auto density = args[3]->NumberValue(context).ToChecked();
1330
- // auto fontColor = args[4]->NumberValue(context).ToChecked();
1331
- // auto ppi = args[5]->NumberValue(context).ToChecked();
1332
- // auto direction = args[6]->NumberValue(context).ToChecked();
1333
- auto ctx = canvas_native_webgl_create_no_window(
1334
- (int32_t) width,
1335
- (int32_t) height,
1336
- version.c_str(),
1337
- alpha,
1338
- antialias,
1339
- depth,
1340
- fail_if_major_performance_caveat,
1341
- power_preference.c_str(),
1342
- premultiplied_alpha,
1343
- preserve_drawing_buffer,
1344
- stencil,
1345
- desynchronized,
1346
- xr_compatible,
1347
- false
1348
- );
1349
-
1350
- auto renderingContext = WebGLRenderingContext::NewInstance(isolate,
1351
- new WebGLRenderingContext(
1352
- ctx));
1353
-
1354
- args.GetReturnValue().Set(renderingContext);
1355
- return;
1302
+ auto options = GLOptions();
1303
+ options.parseGLOptions(args);
1356
1304
 
1357
- } else {
1358
- auto width = (int32_t) args[1]->NumberValue(context).ToChecked();
1359
- auto height = (int32_t) args[2]->NumberValue(context).ToChecked();
1360
-
1361
- auto ctx = canvas_native_webgl_create_no_window(
1362
- width,
1363
- height,
1364
- version.c_str(),
1365
- alpha,
1366
- antialias,
1367
- depth,
1368
- fail_if_major_performance_caveat,
1369
- power_preference.c_str(),
1370
- premultiplied_alpha,
1371
- preserve_drawing_buffer,
1372
- stencil,
1373
- desynchronized,
1374
- xr_compatible,
1375
- false
1376
- );
1377
-
1378
- auto renderingContext = WebGLRenderingContext::NewInstance(isolate,
1379
- new WebGLRenderingContext(
1380
- ctx));
1381
-
1382
- args.GetReturnValue().Set(renderingContext);
1383
- return;
1384
- }
1385
-
1386
- }
1305
+ if (options.version != 1) {
1306
+ args.GetReturnValue().SetNull();
1307
+ return;
1387
1308
  }
1388
- args.GetReturnValue().SetNull();
1389
- }
1390
1309
 
1391
- void CanvasJSIModule::CreateWebGL2Context(const v8::FunctionCallbackInfo<v8::Value> &args) {
1392
- auto configValue = args[0];
1393
1310
  auto isolate = args.GetIsolate();
1394
1311
  auto context = isolate->GetCurrentContext();
1395
- if (!configValue->IsNullOrUndefined() && configValue->IsObject()) {
1396
- auto config = configValue.As<v8::Object>();
1397
- std::string version("none");
1398
- auto alpha = true;
1399
- auto antialias = true;
1400
- auto depth = true;
1401
- auto fail_if_major_performance_caveat = false;
1402
- std::string power_preference("default");
1403
- auto premultiplied_alpha = true;
1404
- auto preserve_drawing_buffer = false;
1405
- auto stencil = false;
1406
- auto desynchronized = false;
1407
- auto xr_compatible = false;
1408
1312
 
1409
1313
 
1410
- auto last = isolate->GetNumberOfDataSlots() - 1;
1411
- auto data = isolate->GetData(last);
1412
-
1413
- if (data != nullptr) {
1414
- auto consts = static_cast<PerIsolateData *>(data);
1415
-
1416
- v8::Local<v8::Value> versionValue;
1417
-
1418
- config->Get(context, consts->VERSION_PERSISTENT->Get(isolate)).ToLocal(&versionValue);
1419
-
1420
- if (!versionValue.IsEmpty() && versionValue->IsString()) {
1421
- version = ConvertFromV8String(isolate, versionValue);
1422
- }
1423
-
1424
- v8::Local<v8::Value> alphaValue;
1425
-
1426
- config->Get(context, consts->ALPHA_PERSISTENT->Get(isolate)).ToLocal(&alphaValue);
1427
- if (!alphaValue.IsEmpty() && alphaValue->IsBoolean()) {
1428
- alpha = alphaValue->BooleanValue(isolate);
1429
- }
1430
-
1431
- v8::Local<v8::Value> antialiasValue;
1432
- config->Get(context, consts->ANTIALIAS_PERSISTENT->Get(isolate)).ToLocal(
1433
- &antialiasValue);
1434
- if (!antialiasValue.IsEmpty() && antialiasValue->IsBoolean()) {
1435
- antialias = antialiasValue->BooleanValue(isolate);
1436
- }
1314
+ auto count = args.Length();
1315
+ if (count == 6) {
1316
+ auto ctx = args[1].As<v8::BigInt>()->Int64Value();
1317
+ auto webgl = canvas_native_webgl_create(
1318
+ ctx,
1319
+ options.version,
1320
+ options.alpha,
1321
+ options.antialias,
1322
+ options.depth,
1323
+ options.failIfMajorPerformanceCaveat,
1324
+ options.powerPreference,
1325
+ options.premultipliedAlpha,
1326
+ options.preserveDrawingBuffer,
1327
+ options.stencil,
1328
+ options.desynchronized,
1329
+ options.xrCompatible
1330
+ );
1331
+
1332
+ auto renderingContext = WebGLRenderingContext::NewInstance(isolate,
1333
+ new WebGLRenderingContext(
1334
+ webgl));
1335
+
1336
+ args.GetReturnValue().Set(renderingContext);
1337
+ return;
1338
+ } else if (count == 7) {
1339
+ auto width = args[1]->NumberValue(context).ToChecked();
1340
+ auto height = args[2]->NumberValue(context).ToChecked();
1341
+ auto ctx = canvas_native_webgl_create_no_window(
1342
+ (int32_t) width,
1343
+ (int32_t) height,
1344
+ options.version,
1345
+ options.alpha,
1346
+ options.antialias,
1347
+ options.depth,
1348
+ options.failIfMajorPerformanceCaveat,
1349
+ options.powerPreference,
1350
+ options.premultipliedAlpha,
1351
+ options.preserveDrawingBuffer,
1352
+ options.stencil,
1353
+ options.desynchronized,
1354
+ options.xrCompatible,
1355
+ false
1356
+ );
1357
+
1358
+ auto renderingContext = WebGLRenderingContext::NewInstance(isolate,
1359
+ new WebGLRenderingContext(
1360
+ ctx));
1361
+
1362
+ args.GetReturnValue().Set(renderingContext);
1363
+ return;
1437
1364
 
1438
- v8::Local<v8::Value> failIfMajorPerformanceCaveatValue;
1439
- config->Get(context,
1440
- consts->FAIL_IF_MAJOR_PERFORMANCE_CAVEAT_PERSISTENT->Get(isolate)).ToLocal(
1441
- &failIfMajorPerformanceCaveatValue);
1442
- if (!failIfMajorPerformanceCaveatValue.IsEmpty() &&
1443
- failIfMajorPerformanceCaveatValue->IsBoolean()) {
1444
- fail_if_major_performance_caveat = failIfMajorPerformanceCaveatValue->BooleanValue(
1445
- isolate);
1446
- }
1365
+ } else {
1366
+ auto width = (int32_t) args[1]->NumberValue(context).ToChecked();
1367
+ auto height = (int32_t) args[2]->NumberValue(context).ToChecked();
1368
+
1369
+ auto ctx = canvas_native_webgl_create_no_window(
1370
+ width,
1371
+ height,
1372
+ options.version,
1373
+ options.alpha,
1374
+ options.antialias,
1375
+ options.depth,
1376
+ options.failIfMajorPerformanceCaveat,
1377
+ options.powerPreference,
1378
+ options.premultipliedAlpha,
1379
+ options.preserveDrawingBuffer,
1380
+ options.stencil,
1381
+ options.desynchronized,
1382
+ options.xrCompatible,
1383
+ false
1384
+ );
1385
+
1386
+ auto renderingContext = WebGLRenderingContext::NewInstance(isolate,
1387
+ new WebGLRenderingContext(
1388
+ ctx));
1389
+
1390
+ args.GetReturnValue().Set(renderingContext);
1391
+ return;
1392
+ }
1393
+ }
1447
1394
 
1448
- v8::Local<v8::Value> powerPreferenceValue;
1449
- config->Get(context, consts->POWER_PREFERENCE_PERSISTENT->Get(isolate)).ToLocal(
1450
- &powerPreferenceValue);
1451
- if (!powerPreferenceValue.IsEmpty() && powerPreferenceValue->IsString()) {
1452
- power_preference = ConvertFromV8String(isolate, powerPreferenceValue);
1453
- }
1395
+ void CanvasJSIModule::CreateWebGL2Context(const v8::FunctionCallbackInfo<v8::Value> &args) {
1454
1396
 
1455
- v8::Local<v8::Value> premultipliedAlphaValue;
1456
- config->Get(context,
1457
- consts->PREMULTIPLIED_ALPHA_PERSISTENT->Get(isolate)).ToLocal(
1458
- &premultipliedAlphaValue);
1459
- if (!premultipliedAlphaValue.IsEmpty() && premultipliedAlphaValue->IsBoolean()) {
1460
- premultiplied_alpha = premultipliedAlphaValue->BooleanValue(isolate);
1461
- }
1462
1397
 
1463
- v8::Local<v8::Value> preserveDrawingBufferValue;
1464
- config->Get(context,
1465
- consts->PRESERVE_DRAWING_BUFFER_PERSISTENT->Get(isolate)).ToLocal(
1466
- &preserveDrawingBufferValue);
1467
- if (!preserveDrawingBufferValue.IsEmpty() && preserveDrawingBufferValue->IsBoolean()) {
1468
- preserve_drawing_buffer = preserveDrawingBufferValue->BooleanValue(isolate);
1469
- }
1398
+ auto options = GLOptions();
1399
+ options.parseGLOptions(args);
1470
1400
 
1471
- v8::Local<v8::Value> stencilValue;
1472
- config->Get(context, consts->STENCIL_PERSISTENT->Get(isolate)).ToLocal(&stencilValue);
1473
- if (!stencilValue.IsEmpty() && stencilValue->IsBoolean()) {
1474
- stencil = stencilValue->BooleanValue(isolate);
1475
- }
1401
+ if (options.version != 2) {
1402
+ args.GetReturnValue().SetNull();
1403
+ return;
1404
+ }
1476
1405
 
1477
- v8::Local<v8::Value> desynchronizedValue;
1478
- config->Get(context, consts->DESYNCHRONIZED_PERSISTENT->Get(isolate)).ToLocal(
1479
- &desynchronizedValue);
1480
- if (!desynchronizedValue.IsEmpty() && desynchronizedValue->IsBoolean()) {
1481
- desynchronized = desynchronizedValue->BooleanValue(isolate);
1482
- }
1483
1406
 
1484
- v8::Local<v8::Value> xrCompatibleValue;
1485
- config->Get(context,
1486
- consts->XR_COMPATIBLE_PERSISTENT->Get(isolate)).ToLocal(&xrCompatibleValue);
1487
- if (!xrCompatibleValue.IsEmpty() && xrCompatibleValue->IsBoolean()) {
1488
- xr_compatible = xrCompatibleValue->BooleanValue(isolate);
1489
- }
1490
- }
1407
+ auto isolate = args.GetIsolate();
1408
+ auto context = isolate->GetCurrentContext();
1491
1409
 
1492
1410
 
1493
- if (version !=
1494
- "v2") {
1495
- args.GetReturnValue().SetNull();
1496
- return;
1497
- } else {
1498
- auto count = args.Length();
1499
- if (count == 6) {
1500
- auto ctx = args[1].As<v8::BigInt>()->Int64Value();
1501
- // auto density = args[2]->NumberValue(context).ToChecked();
1502
- // auto fontColor = args[3]->NumberValue(context).ToChecked();
1503
- // auto ppi = args[4]->NumberValue(context).ToChecked();
1504
- // auto direction = args[5]->NumberValue(context).ToChecked();
1505
-
1506
- auto webgl = canvas_native_webgl_create(
1507
- ctx,
1508
- version.c_str(),
1509
- alpha,
1510
- antialias,
1511
- depth,
1512
- fail_if_major_performance_caveat,
1513
- power_preference.c_str(),
1514
- premultiplied_alpha,
1515
- preserve_drawing_buffer,
1516
- stencil,
1517
- desynchronized,
1518
- xr_compatible
1519
- );
1520
-
1521
- auto renderingContext = WebGL2RenderingContext::NewInstance(isolate,
1522
- new WebGL2RenderingContext(
1523
- webgl,
1524
- WebGLRenderingVersion::V2));
1525
-
1526
- args.GetReturnValue().Set(renderingContext);
1527
- return;
1411
+ auto count = args.Length();
1412
+ if (count == 6) {
1413
+ auto ctx = args[1].As<v8::BigInt>()->Int64Value();
1414
+ auto webgl = canvas_native_webgl_create(
1415
+ ctx,
1416
+ options.version,
1417
+ options.alpha,
1418
+ options.antialias,
1419
+ options.depth,
1420
+ options.failIfMajorPerformanceCaveat,
1421
+ options.powerPreference,
1422
+ options.premultipliedAlpha,
1423
+ options.preserveDrawingBuffer,
1424
+ options.stencil,
1425
+ options.desynchronized,
1426
+ options.xrCompatible
1427
+ );
1428
+
1429
+ auto renderingContext = WebGL2RenderingContext::NewInstance(isolate,
1430
+ new WebGL2RenderingContext(
1431
+ webgl,
1432
+ WebGLRenderingVersion::V2));
1433
+
1434
+ args.GetReturnValue().Set(renderingContext);
1435
+ return;
1528
1436
 
1529
- } else if (count ==
1530
- 7) {
1531
- auto width = args[1]->NumberValue(context).ToChecked();
1532
- auto height = args[2]->NumberValue(context).ToChecked();
1533
- // auto density = args[3]->NumberValue(context).ToChecked();
1534
- // auto fontColor = args[4]->NumberValue(context).ToChecked();
1535
- // auto ppi = args[5]->NumberValue(context).ToChecked();
1536
- // auto direction = args[6]->NumberValue(context).ToChecked();
1537
- auto ctx = canvas_native_webgl_create_no_window(
1538
- (int32_t) width,
1539
- (int32_t) height,
1540
- version.c_str(),
1541
- alpha,
1542
- antialias,
1543
- depth,
1544
- fail_if_major_performance_caveat,
1545
- power_preference.c_str(),
1546
- premultiplied_alpha,
1547
- preserve_drawing_buffer,
1548
- stencil,
1549
- desynchronized,
1550
- xr_compatible,
1551
- false
1552
- );
1553
- auto renderingContext = WebGL2RenderingContext::NewInstance(isolate,
1554
- new WebGL2RenderingContext(
1555
- ctx,
1556
- WebGLRenderingVersion::V2));
1557
-
1558
- args.GetReturnValue().Set(renderingContext);
1559
- return;
1437
+ } else if (count ==
1438
+ 7) {
1439
+ auto width = args[1]->NumberValue(context).ToChecked();
1440
+ auto height = args[2]->NumberValue(context).ToChecked();
1441
+ auto ctx = canvas_native_webgl_create_no_window(
1442
+ (int32_t) width,
1443
+ (int32_t) height,
1444
+ options.version,
1445
+ options.alpha,
1446
+ options.antialias,
1447
+ options.depth,
1448
+ options.failIfMajorPerformanceCaveat,
1449
+ options.powerPreference,
1450
+ options.premultipliedAlpha,
1451
+ options.preserveDrawingBuffer,
1452
+ options.stencil,
1453
+ options.desynchronized,
1454
+ options.xrCompatible,
1455
+ false
1456
+ );
1457
+ auto renderingContext = WebGL2RenderingContext::NewInstance(isolate,
1458
+ new WebGL2RenderingContext(
1459
+ ctx,
1460
+ WebGLRenderingVersion::V2));
1461
+
1462
+ args.GetReturnValue().Set(renderingContext);
1463
+ return;
1560
1464
 
1561
- } else {
1562
- auto width = (int32_t) args[1]->NumberValue(context).ToChecked();
1563
- auto height = (int32_t) args[2]->NumberValue(context).ToChecked();
1564
- auto ctx = canvas_native_webgl_create_no_window(
1565
- width,
1566
- height,
1567
- version.c_str(),
1568
- alpha,
1569
- antialias,
1570
- depth,
1571
- fail_if_major_performance_caveat,
1572
- power_preference.c_str(),
1573
- premultiplied_alpha,
1574
- preserve_drawing_buffer,
1575
- stencil,
1576
- desynchronized,
1577
- xr_compatible,
1578
- false
1579
- );
1580
-
1581
- auto renderingContext = WebGL2RenderingContext::NewInstance(isolate,
1582
- new WebGL2RenderingContext(
1583
- ctx,
1584
- WebGLRenderingVersion::V2));
1585
-
1586
- args.GetReturnValue().Set(renderingContext);
1587
- return;
1588
- }
1589
- }
1465
+ } else {
1466
+ auto width = (int32_t) args[1]->NumberValue(context).ToChecked();
1467
+ auto height = (int32_t) args[2]->NumberValue(context).ToChecked();
1468
+ auto ctx = canvas_native_webgl_create_no_window(
1469
+ width,
1470
+ height,
1471
+ options.version,
1472
+ options.alpha,
1473
+ options.antialias,
1474
+ options.depth,
1475
+ options.failIfMajorPerformanceCaveat,
1476
+ options.powerPreference,
1477
+ options.premultipliedAlpha,
1478
+ options.preserveDrawingBuffer,
1479
+ options.stencil,
1480
+ options.desynchronized,
1481
+ options.xrCompatible,
1482
+ false
1483
+ );
1484
+
1485
+ auto renderingContext = WebGL2RenderingContext::NewInstance(isolate,
1486
+ new WebGL2RenderingContext(
1487
+ ctx,
1488
+ WebGLRenderingVersion::V2));
1489
+
1490
+ args.GetReturnValue().Set(renderingContext);
1491
+ return;
1590
1492
  }
1591
-
1592
- args.GetReturnValue().SetNull();
1593
1493
  }