@nativescript/canvas 1.1.0-alpha.9 → 2.0.0-alpha.0

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 (168) hide show
  1. package/Canvas/common.d.ts +1 -5
  2. package/Canvas/common.js +31 -69
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +4 -4
  5. package/Canvas/index.android.js +62 -55
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +0 -4
  8. package/Canvas/index.ios.d.ts +0 -2
  9. package/Canvas/index.ios.js +24 -43
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasGradient/CanvasGradient.android.d.ts +2 -0
  12. package/Canvas2D/CanvasGradient/CanvasGradient.android.js +10 -1
  13. package/Canvas2D/CanvasGradient/CanvasGradient.android.js.map +1 -1
  14. package/Canvas2D/CanvasPattern/CanvasPattern.android.d.ts +2 -0
  15. package/Canvas2D/CanvasPattern/CanvasPattern.android.js +10 -1
  16. package/Canvas2D/CanvasPattern/CanvasPattern.android.js.map +1 -1
  17. package/Canvas2D/CanvasPattern/CanvasPattern.ios.d.ts +0 -1
  18. package/Canvas2D/CanvasPattern/CanvasPattern.ios.js +0 -3
  19. package/Canvas2D/CanvasPattern/CanvasPattern.ios.js.map +1 -1
  20. package/Canvas2D/CanvasRenderingContext2D/common.d.ts +1 -3
  21. package/Canvas2D/CanvasRenderingContext2D/common.js.map +1 -1
  22. package/Canvas2D/CanvasRenderingContext2D/index.android.d.ts +5 -6
  23. package/Canvas2D/CanvasRenderingContext2D/index.android.js +188 -394
  24. package/Canvas2D/CanvasRenderingContext2D/index.android.js.map +1 -1
  25. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +0 -6
  26. package/Canvas2D/CanvasRenderingContext2D/index.ios.d.ts +0 -3
  27. package/Canvas2D/CanvasRenderingContext2D/index.ios.js +90 -107
  28. package/Canvas2D/CanvasRenderingContext2D/index.ios.js.map +1 -1
  29. package/Canvas2D/DOMMatrix/DOMMatrix.android.d.ts +24 -0
  30. package/Canvas2D/DOMMatrix/DOMMatrix.android.js +81 -46
  31. package/Canvas2D/DOMMatrix/DOMMatrix.android.js.map +1 -1
  32. package/Canvas2D/DOMMatrix/DOMMatrix.d.ts +3 -2
  33. package/Canvas2D/DOMMatrix/common.d.ts +0 -2
  34. package/Canvas2D/DOMMatrix/common.js +0 -7
  35. package/Canvas2D/DOMMatrix/common.js.map +1 -1
  36. package/Canvas2D/ImageData/ImageData.android.d.ts +4 -5
  37. package/Canvas2D/ImageData/ImageData.android.js +48 -29
  38. package/Canvas2D/ImageData/ImageData.android.js.map +1 -1
  39. package/Canvas2D/ImageData/ImageData.d.ts +4 -2
  40. package/Canvas2D/ImageData/common.d.ts +0 -1
  41. package/Canvas2D/ImageData/common.js +0 -3
  42. package/Canvas2D/ImageData/common.js.map +1 -1
  43. package/Canvas2D/Path2D/Path2D.android.d.ts +3 -2
  44. package/Canvas2D/Path2D/Path2D.android.js +45 -25
  45. package/Canvas2D/Path2D/Path2D.android.js.map +1 -1
  46. package/Canvas2D/Path2D/Path2D.d.ts +0 -4
  47. package/Canvas2D/Path2D/Path2D.ios.d.ts +0 -2
  48. package/Canvas2D/Path2D/Path2D.ios.js +1 -9
  49. package/Canvas2D/Path2D/Path2D.ios.js.map +1 -1
  50. package/Canvas2D/Path2D/common.d.ts +1 -4
  51. package/Canvas2D/Path2D/common.js +2 -6
  52. package/Canvas2D/Path2D/common.js.map +1 -1
  53. package/Canvas2D/TextMetrics/TextMetrics.android.js +12 -12
  54. package/Canvas2D/TextMetrics/TextMetrics.android.js.map +1 -1
  55. package/Canvas2D/TextMetrics/common.d.ts +0 -1
  56. package/Canvas2D/TextMetrics/common.js +0 -3
  57. package/Canvas2D/TextMetrics/common.js.map +1 -1
  58. package/ImageAsset/ImageAsset.android.d.ts +11 -12
  59. package/ImageAsset/ImageAsset.android.js +92 -127
  60. package/ImageAsset/ImageAsset.android.js.map +1 -1
  61. package/ImageAsset/ImageAsset.d.ts +8 -12
  62. package/ImageAsset/ImageAsset.ios.js +3 -3
  63. package/ImageAsset/ImageAsset.ios.js.map +1 -1
  64. package/ImageAsset/common.d.ts +0 -1
  65. package/ImageAsset/common.js +0 -3
  66. package/ImageAsset/common.js.map +1 -1
  67. package/ImageBitmap/common.d.ts +0 -2
  68. package/ImageBitmap/common.js +0 -7
  69. package/ImageBitmap/common.js.map +1 -1
  70. package/ImageBitmap/index.android.d.ts +2 -2
  71. package/ImageBitmap/index.android.js +55 -294
  72. package/ImageBitmap/index.android.js.map +1 -1
  73. package/ImageBitmap/index.ios.d.ts +1 -2
  74. package/ImageBitmap/index.ios.js +34 -23
  75. package/ImageBitmap/index.ios.js.map +1 -1
  76. package/TextDecoder/TextDecoder.android.d.ts +2 -1
  77. package/TextDecoder/TextDecoder.android.js +19 -38
  78. package/TextDecoder/TextDecoder.android.js.map +1 -1
  79. package/TextDecoder/common.d.ts +0 -1
  80. package/TextDecoder/common.js +0 -3
  81. package/TextDecoder/common.js.map +1 -1
  82. package/TextEncoder/TextEncoder.android.d.ts +2 -0
  83. package/TextEncoder/TextEncoder.android.js +19 -5
  84. package/TextEncoder/TextEncoder.android.js.map +1 -1
  85. package/TextEncoder/common.d.ts +0 -2
  86. package/TextEncoder/common.js +0 -7
  87. package/TextEncoder/common.js.map +1 -1
  88. package/WebGL/WebGLActiveInfo.d.ts +5 -8
  89. package/WebGL/WebGLActiveInfo.js +8 -24
  90. package/WebGL/WebGLActiveInfo.js.map +1 -1
  91. package/WebGL/WebGLExtensions/index.android.d.ts +9 -0
  92. package/WebGL/WebGLExtensions/index.android.js +94 -57
  93. package/WebGL/WebGLExtensions/index.android.js.map +1 -1
  94. package/WebGL/WebGLProgram.d.ts +1 -0
  95. package/WebGL/WebGLProgram.js +3 -0
  96. package/WebGL/WebGLProgram.js.map +1 -1
  97. package/WebGL/WebGLRenderingContext/index.android.d.ts +10 -13
  98. package/WebGL/WebGLRenderingContext/index.android.js +449 -952
  99. package/WebGL/WebGLRenderingContext/index.android.js.map +1 -1
  100. package/WebGL/WebGLRenderingContext/index.ios.js +4 -3
  101. package/WebGL/WebGLRenderingContext/index.ios.js.map +1 -1
  102. package/WebGL/WebGLShaderPrecisionFormat.d.ts +5 -4
  103. package/WebGL/WebGLShaderPrecisionFormat.js +11 -4
  104. package/WebGL/WebGLShaderPrecisionFormat.js.map +1 -1
  105. package/WebGL2/WebGL2RenderingContext/common.d.ts +1 -1
  106. package/WebGL2/WebGL2RenderingContext/common.js +199 -199
  107. package/WebGL2/WebGL2RenderingContext/common.js.map +1 -1
  108. package/WebGL2/WebGL2RenderingContext/index.android.d.ts +8 -7
  109. package/WebGL2/WebGL2RenderingContext/index.android.js +290 -328
  110. package/WebGL2/WebGL2RenderingContext/index.android.js.map +1 -1
  111. package/WebGL2/WebGL2RenderingContext/index.ios.js +1 -1
  112. package/WebGL2/WebGL2RenderingContext/index.ios.js.map +1 -1
  113. package/angular/esm2020/index.mjs +4 -4
  114. package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
  115. package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
  116. package/angular/nativescript-canvas-angular.d.ts +5 -0
  117. package/angular/package.json +2 -2
  118. package/helpers.d.ts +5 -0
  119. package/helpers.js +18 -0
  120. package/helpers.js.map +1 -0
  121. package/index.js +6 -0
  122. package/index.js.map +1 -1
  123. package/package.json +1 -1
  124. package/platforms/android/canvas-release.aar +0 -0
  125. package/platforms/android/include.gradle +5 -6
  126. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  127. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +33 -89
  128. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +1 -1
  129. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64.swiftsourceinfo +0 -0
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +22 -49
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64.swiftdoc +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/{arm64-apple-ios.private.swiftinterface → arm64.swiftinterface} +22 -49
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/module.modulemap +2 -2
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +66 -168
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +1 -1
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64.swiftsourceinfo +0 -0
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64.swiftsourceinfo +0 -0
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +22 -49
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64.swiftdoc +0 -0
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/{arm64-apple-ios-simulator.private.swiftinterface → arm64.swiftinterface} +22 -49
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +22 -49
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64.swiftdoc +0 -0
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/{x86_64-apple-ios-simulator.private.swiftinterface → x86_64.swiftinterface} +22 -49
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/module.modulemap +2 -2
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +83 -50
  156. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  157. package/utils.d.ts +1 -3
  158. package/utils.js +20 -7
  159. package/utils.js.map +1 -1
  160. package/LICENSE +0 -201
  161. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +0 -1636
  162. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +0 -75693
  163. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +0 -1636
  164. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -75693
  165. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -75693
  166. package/typings/objc!CanvasNative.d.ts +0 -2036
  167. package/typings/objc!CanvasNative.js +0 -1
  168. package/typings/objc!CanvasNative.js.map +0 -1
@@ -8,638 +8,440 @@ import { WebGLActiveInfo } from '../WebGLActiveInfo';
8
8
  import { WebGLRenderbuffer } from '../WebGLRenderbuffer';
9
9
  import { WebGLShaderPrecisionFormat } from '../WebGLShaderPrecisionFormat';
10
10
  import { WebGLBuffer } from '../WebGLBuffer';
11
- import { ImageSource } from '@nativescript/core';
11
+ import { ImageSource, Screen } from '@nativescript/core';
12
12
  import { ANGLE_instanced_arrays, EXT_blend_minmax, EXT_color_buffer_half_float, EXT_disjoint_timer_query, EXT_shader_texture_lod, EXT_sRGB, EXT_texture_filter_anisotropic, OES_element_index_uint, OES_standard_derivatives, OES_texture_float, OES_texture_float_linear, OES_texture_half_float, OES_texture_half_float_linear, OES_vertex_array_object, WEBGL_color_buffer_float, WEBGL_compressed_texture_atc, WEBGL_compressed_texture_etc, WEBGL_compressed_texture_etc1, WEBGL_compressed_texture_pvrtc, WEBGL_compressed_texture_s3tc, WEBGL_depth_texture, WEBGL_draw_buffers, WEBGL_lose_context, } from '../WebGLExtensions';
13
13
  import { ImageAsset } from '../../ImageAsset';
14
14
  import { Canvas } from '../../Canvas';
15
15
  import { ImageBitmap } from '../../ImageBitmap';
16
- import { Utils } from '../../utils';
16
+ import { Helpers } from '../../helpers';
17
+ let ctor;
17
18
  export class WebGLRenderingContext extends WebGLRenderingContextBase {
18
- constructor(context) {
19
+ constructor(context, contextOptions) {
19
20
  super(context);
20
- this._lastTexture = { target: 0, texture: 0 };
21
- this.context = context;
21
+ this._methodCache = new Map();
22
+ this._flipY = false;
23
+ if (contextOptions) {
24
+ const ctx = BigInt(context.getNativeContext().toString());
25
+ let direction = 0;
26
+ if (androidx.core.text.TextUtilsCompat.getLayoutDirectionFromLocale(java.util.Locale.getDefault()) === androidx.core.view.ViewCompat.LAYOUT_DIRECTION_RTL) {
27
+ direction = 1;
28
+ }
29
+ this._context = ctor(contextOptions, ctx, Screen.mainScreen.scale, -16777216, Screen.mainScreen.scale * 160, direction);
30
+ }
31
+ else {
32
+ this._context = context;
33
+ }
22
34
  }
23
35
  get native() {
24
- return this.context;
36
+ return this._context;
25
37
  }
26
38
  get drawingBufferHeight() {
27
- return this.context.getDrawingBufferHeight();
39
+ return this.native.drawingBufferHeight;
28
40
  }
29
41
  get drawingBufferWidth() {
30
- return this.context.getDrawingBufferWidth();
42
+ return this.native.drawingBufferWidth;
31
43
  }
32
- static toPrimitive(value) {
33
- if (value instanceof java.lang.Integer) {
34
- return value.intValue();
35
- }
36
- else if (value instanceof java.lang.Long) {
37
- return value.longValue();
38
- }
39
- else if (value instanceof java.lang.Short) {
40
- return value.shortValue();
41
- }
42
- else if (value instanceof java.lang.Byte) {
43
- return value.byteValue();
44
- }
45
- else if (value instanceof java.lang.Boolean) {
46
- return value.booleanValue();
44
+ _getMethod(name) {
45
+ const cached = this._methodCache.get(name);
46
+ if (cached === undefined) {
47
+ const ret = this.native[name];
48
+ this._methodCache.set(name, ret);
49
+ return ret;
47
50
  }
48
- else if (value instanceof java.lang.String) {
49
- return value.toString();
50
- }
51
- else if (value instanceof java.lang.Float) {
52
- return value.floatValue();
53
- }
54
- else if (value instanceof java.lang.Double) {
55
- return value.doubleValue();
56
- }
57
- return value;
51
+ return cached;
58
52
  }
59
- getJSArray(value) {
60
- const count = value.length;
61
- const array = [];
62
- for (let i = 0; i < count; i++) {
63
- array.push(value[i]);
64
- }
65
- return array;
53
+ __toDataURL() {
54
+ const __toDataURL = this._getMethod('__toDataURL');
55
+ return __toDataURL(arguments[0], arguments[1]);
66
56
  }
67
57
  activeTexture(texture) {
68
58
  this._glCheckError('activeTexture');
69
59
  this._checkArgs('activeTexture', arguments);
70
- this.context.activeTexture(texture);
60
+ const activeTexture = this._getMethod('activeTexture');
61
+ activeTexture(texture);
71
62
  }
72
63
  attachShader(program, shader) {
73
64
  this._glCheckError('attachShader');
74
65
  this._checkArgs('attachShader', arguments);
75
- const value = program ? program.native : 0;
76
- const value2 = shader ? shader.native : 0;
77
- this.context.attachShader(value, value2);
66
+ const value = program.native;
67
+ const value2 = shader.native;
68
+ const attachShader = this._getMethod('attachShader');
69
+ attachShader(value, value2);
78
70
  }
79
71
  bindAttribLocation(program, index, name) {
80
72
  this._glCheckError('bindAttribLocation');
81
73
  this._checkArgs('bindAttribLocation', arguments);
82
- const value = program ? program.native : 0;
83
- this.context.bindAttribLocation(value, index, name);
74
+ const bindAttribLocation = this._getMethod('bindAttribLocation');
75
+ const value = program.native;
76
+ bindAttribLocation(value, index, name);
84
77
  }
85
78
  bindBuffer(target, buffer) {
86
79
  this._glCheckError('bindBuffer');
87
80
  this._checkArgs('bindBuffer', arguments);
88
- let value = buffer ? buffer.native : 0;
89
- this.context.bindBuffer(target, value);
81
+ const value = buffer ? buffer.native : null;
82
+ const bindBuffer = this._getMethod('bindBuffer');
83
+ bindBuffer(target, value);
90
84
  }
91
85
  bindFramebuffer(target, framebuffer) {
92
86
  this._glCheckError('bindFramebuffer');
93
87
  this._checkArgs('bindFramebuffer', arguments);
94
- const value = framebuffer ? framebuffer.native : 0;
95
- this.context.bindFramebuffer(target, value);
88
+ const value = framebuffer ? framebuffer.native : null;
89
+ const bindFramebuffer = this._getMethod('bindFramebuffer');
90
+ bindFramebuffer(target, value);
96
91
  }
97
92
  bindRenderbuffer(target, renderbuffer) {
98
93
  this._glCheckError('bindRenderbuffer');
99
94
  this._checkArgs('bindRenderbuffer', arguments);
100
- const value = renderbuffer ? renderbuffer.native : 0;
101
- this.context.bindRenderbuffer(target, value);
95
+ const value = renderbuffer ? renderbuffer.native : null;
96
+ const bindRenderbuffer = this._getMethod('bindRenderbuffer');
97
+ bindRenderbuffer(target, value);
102
98
  }
103
99
  bindTexture(target, texture) {
104
100
  this._glCheckError('bindTexture');
105
101
  this._checkArgs('bindTexture', arguments);
106
- const value = texture ? texture.native : 0;
107
- if (value > 0) {
108
- this._lastTexture = {
109
- target,
110
- texture: value,
111
- };
112
- }
113
- this.context.bindTexture(target, value);
102
+ const value = texture ? texture.native : null;
103
+ const bindTexture = this._getMethod('bindTexture');
104
+ bindTexture(target, value);
114
105
  }
115
106
  blendColor(red, green, blue, alpha) {
116
107
  this._glCheckError('blendColor');
117
108
  this._checkArgs('blendColor', arguments);
118
- this.context.blendColor(red, green, blue, alpha);
109
+ const blendColor = this._getMethod('blendColor');
110
+ blendColor(red, green, blue, alpha);
119
111
  }
120
112
  blendEquationSeparate(modeRGB, modeAlpha) {
121
113
  this._glCheckError('blendEquationSeparate');
122
114
  this._checkArgs('blendEquationSeparate', arguments);
123
- this.context.blendEquationSeparate(modeRGB, modeAlpha);
115
+ const blendEquationSeparate = this._getMethod('blendEquationSeparate');
116
+ blendEquationSeparate(modeRGB, modeAlpha);
124
117
  }
125
118
  blendEquation(mode) {
126
119
  this._glCheckError('blendEquation');
127
120
  this._checkArgs('blendEquation', arguments);
128
- this.context.blendEquation(mode);
121
+ const blendEquation = this._getMethod('blendEquation');
122
+ blendEquation(mode);
129
123
  }
130
124
  blendFuncSeparate(srcRGB = this.ONE, dstRGB = this.ZERO, srcAlpha = this.ONE, dstAlpha = this.ZERO) {
131
125
  this._glCheckError('blendFuncSeparate');
132
126
  this._checkArgs('blendFuncSeparate', arguments);
133
- this.context.blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
127
+ const blendFuncSeparate = this._getMethod('blendFuncSeparate');
128
+ blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
134
129
  }
135
130
  blendFunc(sfactor = this.ONE, dfactor = this.ZERO) {
136
131
  this._glCheckError('blendFunc');
137
132
  this._checkArgs('blendFunc', arguments);
138
- this.context.blendFunc(sfactor, dfactor);
139
- }
140
- toNativeArray(value, type) {
141
- // if (value && value.length && typeof type === 'string') {
142
- // const size = value.length;
143
- // const nativeArray = Array.create(type, size);
144
- // for (let i = 0; i < size; i++) {
145
- // nativeArray[i] = value[i];
146
- // }
147
- // return nativeArray;
148
- // }
149
- let length = 0;
150
- if (value instanceof Int8Array || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int16Array || value instanceof Uint16Array || value instanceof Int32Array || value instanceof Uint32Array || value instanceof Float32Array || value instanceof Float64Array) {
151
- length = value.length;
152
- }
153
- else if (Array.isArray(value)) {
154
- length = value.length;
155
- }
156
- if (typeof type === 'string') {
157
- const array = Array.from(value);
158
- let nativeArray;
159
- switch (type) {
160
- case 'byte':
161
- nativeArray = java.nio.ByteBuffer.wrap(array).array();
162
- break;
163
- case 'short':
164
- nativeArray = java.nio.ShortBuffer.wrap(array).array();
165
- break;
166
- case 'float':
167
- nativeArray = java.nio.FloatBuffer.wrap(array).array();
168
- break;
169
- case 'int':
170
- nativeArray = java.nio.IntBuffer.wrap(array).array();
171
- break;
172
- case 'double':
173
- nativeArray = java.nio.DoubleBuffer.wrap(array).array();
174
- break;
175
- case 'long':
176
- nativeArray = java.nio.LongBuffer.wrap(array).array();
177
- break;
178
- default:
179
- nativeArray = array;
180
- break;
181
- }
182
- return nativeArray;
183
- }
184
- return [];
185
- }
186
- get _isSupported() {
187
- return Utils.IS_SUPPORTED_TYPED_ARRAYS_VERSION;
133
+ const blendFunc = this._getMethod('blendFunc');
134
+ blendFunc(sfactor, dfactor);
188
135
  }
189
136
  bufferData(target, srcData, usage) {
190
137
  this._glCheckError('bufferData');
191
138
  this._checkArgs('bufferData', arguments);
192
- if (typeof srcData === 'number') {
193
- this.context.bufferData(target, srcData, usage);
194
- }
195
- else if (srcData instanceof ArrayBuffer) {
196
- // @ts-ignore
197
- if (srcData.nativeObject) {
198
- // @ts-ignore
199
- this.context.bufferData(target, srcData.nativeObject, usage);
200
- }
201
- else {
202
- if (this._isSupported) {
203
- this.context.bufferDataByteBuffer(target, srcData, usage);
204
- }
205
- else {
206
- this.context.bufferDataByte(target, Array.from(new Uint8Array(srcData)), usage);
207
- }
208
- }
209
- //this.context.bufferData(target, this.toNativeArray(new Uint8Array(srcData as any) as any, 'byte'), usage);
210
- }
211
- else if (srcData && srcData.buffer instanceof ArrayBuffer) {
212
- // @ts-ignore
213
- if (srcData.buffer.nativeObject) {
214
- // @ts-ignore
215
- this.context.bufferData(target, offset, srcData.buffer.nativeObject);
216
- }
217
- else {
218
- if (srcData instanceof Uint8Array || srcData instanceof Uint8ClampedArray) {
219
- if (this._isSupported) {
220
- this.context.bufferDataByteBuffer(target, srcData, usage);
221
- }
222
- else {
223
- this.context.bufferDataByte(target, Array.from(srcData), usage);
224
- }
225
- }
226
- else if (srcData instanceof Uint16Array || srcData instanceof Int16Array) {
227
- if (this._isSupported) {
228
- this.context.bufferDataShortBuffer(target, srcData, usage);
229
- }
230
- else {
231
- this.context.bufferDataShort(target, Array.from(srcData), usage);
232
- }
233
- }
234
- else if (srcData instanceof Uint32Array || srcData instanceof Int32Array) {
235
- if (this._isSupported) {
236
- this.context.bufferDataIntBuffer(target, srcData, usage);
237
- }
238
- else {
239
- this.context.bufferDataInt(target, Array.from(srcData), usage);
240
- }
241
- }
242
- else if (srcData instanceof Float32Array) {
243
- if (this._isSupported) {
244
- this.context.bufferDataFloatBuffer(target, srcData, usage);
245
- }
246
- else {
247
- this.context.bufferDataFloat(target, Array.from(srcData), usage);
248
- }
249
- }
250
- }
251
- }
252
- else if (arguments.length === 3 && !srcData) {
253
- this.context.bufferData(target, 0, usage);
254
- }
139
+ const bufferData = this._getMethod('bufferData');
140
+ bufferData(target, srcData, usage);
255
141
  }
256
142
  bufferSubData(target, offset, srcData) {
257
143
  this._glCheckError('bufferSubData');
258
144
  this._checkArgs('bufferSubData', arguments);
259
- if (srcData instanceof ArrayBuffer) {
260
- //this.context.bufferSubData(target, offset, this.toNativeArray(new Uint8Array(srcData as any) as any, 'byte'));
261
- // @ts-ignore
262
- if (srcData.nativeObject) {
263
- // @ts-ignore
264
- this.context.bufferSubData(target, offset, srcData.nativeObject);
265
- }
266
- else {
267
- if (this._isSupported) {
268
- this.context.bufferSubDataByteBuffer(target, offset, srcData);
269
- }
270
- else {
271
- this.context.bufferSubDataByte(target, offset, Array.from(new Uint8Array(srcData)));
272
- }
273
- }
274
- }
275
- else if (srcData && srcData.buffer instanceof ArrayBuffer) {
276
- // @ts-ignore
277
- if (srcData.buffer.nativeObject) {
278
- // @ts-ignore
279
- this.context.bufferSubData(target, offset, srcData.buffer.nativeObject);
280
- }
281
- else {
282
- if (srcData instanceof Uint8Array || srcData instanceof Uint8ClampedArray) {
283
- if (this._isSupported) {
284
- this.context.bufferSubDataByteBuffer(target, offset, srcData);
285
- }
286
- else {
287
- this.context.bufferSubDataByte(target, offset, Array.from(srcData));
288
- }
289
- }
290
- else if (srcData instanceof Uint16Array || srcData instanceof Int16Array) {
291
- if (this._isSupported) {
292
- this.context.bufferSubDataShortBuffer(target, offset, srcData);
293
- }
294
- else {
295
- this.context.bufferSubDataShort(target, offset, Array.from(srcData));
296
- }
297
- }
298
- else if (srcData instanceof Uint32Array || srcData instanceof Int32Array) {
299
- if (this._isSupported) {
300
- this.context.bufferSubDataIntBuffer(target, offset, srcData);
301
- }
302
- else {
303
- this.context.bufferSubDataInt(target, offset, Array.from(srcData));
304
- }
305
- }
306
- else if (srcData instanceof Float32Array) {
307
- if (this._isSupported) {
308
- this.context.bufferSubDataFloatBuffer(target, offset, srcData);
309
- }
310
- else {
311
- this.context.bufferSubDataFloat(target, offset, Array.from(srcData));
312
- }
313
- }
314
- }
315
- }
145
+ const bufferSubData = this._getMethod('bufferSubData');
146
+ bufferSubData(target, offset, srcData);
316
147
  }
317
148
  checkFramebufferStatus(target) {
318
149
  this._glCheckError('checkFramebufferStatus');
319
150
  this._checkArgs('checkFramebufferStatus', arguments);
320
- return this.context.checkFramebufferStatus(target);
151
+ const checkFramebufferStatus = this._getMethod('checkFramebufferStatus');
152
+ return checkFramebufferStatus(target);
321
153
  }
322
154
  clearColor(red, green, blue, alpha) {
323
155
  this._glCheckError('clearColor');
324
156
  this._checkArgs('clearColor', arguments);
325
- this.context.clearColor(red, green, blue, alpha);
157
+ const clearColor = this._getMethod('clearColor');
158
+ clearColor(red, green, blue, alpha);
326
159
  }
327
160
  clearDepth(depth) {
328
161
  this._glCheckError('clearDepth');
329
162
  this._checkArgs('clearDepth', arguments);
330
- this.context.clearDepth(depth);
163
+ const clearDepth = this._getMethod('clearDepth');
164
+ clearDepth(depth);
331
165
  }
332
166
  clearStencil(stencil) {
333
167
  this._glCheckError('clearStencil');
334
168
  this._checkArgs('clearStencil', arguments);
335
- this.context.clearStencil(stencil);
169
+ const clearStencil = this._getMethod('clearStencil');
170
+ clearStencil(stencil);
336
171
  }
337
172
  clear(mask) {
338
173
  this._glCheckError('clear');
339
174
  this._checkArgs('clear', arguments);
340
- this.context.clear(mask);
175
+ const clear = this._getMethod('clear');
176
+ clear(mask);
341
177
  }
342
178
  colorMask(red, green, blue, alpha) {
343
179
  this._glCheckError('colorMask');
344
180
  this._checkArgs('colorMask', arguments);
345
- this.context.colorMask(red, green, blue, alpha);
181
+ const colorMask = this._getMethod('colorMask');
182
+ colorMask(red, green, blue, alpha);
346
183
  }
347
184
  commit() {
348
185
  // NOOP
349
- this.context.commit();
186
+ const commit = this._getMethod('commit');
187
+ commit();
350
188
  }
351
189
  compileShader(shader) {
352
190
  this._glCheckError('compileShader');
353
191
  this._checkArgs('compileShader', arguments);
354
- const value = shader ? shader.native : 0;
355
- this.context.compileShader(value);
192
+ const compileShader = this._getMethod('compileShader');
193
+ const value = shader.native;
194
+ compileShader(value);
356
195
  }
357
196
  compressedTexImage2D(target, level, internalformat, width, height, border, pixels) {
358
197
  this._glCheckError('compressedTexImage2D');
359
198
  this._checkArgs('compressedTexImage2D', arguments);
360
- // @ts-ignore
361
- if (pixels && pixels.buffer instanceof ArrayBuffer) {
362
- // @ts-ignore
363
- if (pixels.buffer.nativeObject) {
364
- // @ts-ignore
365
- this.context.compressedTexImage2D(target, level, internalformat, width, height, border, pixels.buffer.nativeObject);
366
- }
367
- else {
368
- if (pixels instanceof Uint8Array) {
369
- // this.context.compressedTexImage2D(target, level, internalformat, width, height, border, this.toNativeArray(pixels as any, 'byte'));
370
- this.context.compressedTexImage2DByte(target, level, internalformat, width, height, border, Array.from(pixels));
371
- }
372
- else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
373
- // this.context.compressedTexImage2D(target, level, internalformat, width, height, border, this.toNativeArray(pixels as any, 'short'));
374
- this.context.compressedTexImage2DShort(target, level, internalformat, width, height, border, Array.from(pixels));
375
- }
376
- else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
377
- // this.context.compressedTexImage2D(target, level, internalformat, width, height, border, this.toNativeArray(pixels as any, 'int'));
378
- this.context.compressedTexImage2DInt(target, level, internalformat, width, height, border, Array.from(pixels));
379
- }
380
- else if (pixels instanceof Float32Array) {
381
- // this.context.compressedTexImage2D(target, level, internalformat, width, height, border, this.toNativeArray(pixels as any, 'float'));
382
- this.context.compressedTexImage2DFloat(target, level, internalformat, width, height, border, Array.from(pixels));
383
- }
384
- }
385
- }
386
- else if (pixels instanceof ArrayBuffer) {
387
- // this.context.compressedTexImage2D(target, level, internalformat, width, height, border, this.toNativeArray(new Uint8Array(pixels as any) as any, 'byte'));
388
- // @ts-ignore
389
- if (pixels.nativeObject) {
390
- // @ts-ignore
391
- this.context.compressedTexImage2D(target, level, internalformat, width, height, border, pixels.nativeObject);
392
- }
393
- else {
394
- this.context.compressedTexImage2DByte(target, level, internalformat, width, height, border, Array.from(new Uint8Array(pixels)));
395
- }
396
- }
199
+ const compressedTexImage2D = this._getMethod('compressedTexImage2D');
200
+ compressedTexImage2D(target, level, internalformat, width, height, border, pixels);
397
201
  }
398
202
  compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, pixels) {
399
203
  this._glCheckError('compressedTexSubImage2D');
400
204
  this._checkArgs('compressedTexSubImage2D', arguments);
401
- if (pixels && pixels.buffer instanceof ArrayBuffer) {
402
- if (pixels instanceof Uint8Array) {
403
- // this.context.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, this.toNativeArray(pixels as any, 'byte'));
404
- this.context.compressedTexSubImage2DByte(target, level, xoffset, yoffset, width, height, format, Array.from(pixels));
405
- }
406
- else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
407
- // this.context.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, this.toNativeArray(pixels as any, 'short'));
408
- this.context.compressedTexSubImage2DShort(target, level, xoffset, yoffset, width, height, format, Array.from(pixels));
409
- }
410
- else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
411
- // this.context.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, this.toNativeArray(pixels as any, 'int'));
412
- this.context.compressedTexSubImage2DInt(target, level, xoffset, yoffset, width, height, format, Array.from(pixels));
413
- }
414
- else if (pixels instanceof Float32Array) {
415
- // this.context.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, this.toNativeArray(pixels as any, 'float'));
416
- this.context.compressedTexSubImage2DFloat(target, level, xoffset, yoffset, width, height, format, Array.from(pixels));
417
- }
418
- }
419
- else if (pixels instanceof ArrayBuffer) {
420
- // this.context.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, this.toNativeArray(new Uint8Array(pixels as any) as any, 'byte'));
421
- // @ts-ignore
422
- if (pixels.nativeObject) {
423
- // @ts-ignore
424
- this.context.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, pixels.nativeObject);
425
- }
426
- else {
427
- this.context.compressedTexSubImage2DByte(target, level, xoffset, yoffset, width, height, format, Array.from(new Uint8Array(pixels)));
428
- }
429
- }
205
+ const compressedTexSubImage2D = this._getMethod('compressedTexSubImage2D');
206
+ compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, pixels);
430
207
  }
431
208
  copyTexImage2D(target, level, internalformat, x, y, width, height, border) {
432
209
  this._glCheckError('copyTexImage2D');
433
210
  this._checkArgs('copyTexImage2D', arguments);
434
- this.context.copyTexImage2D(target, level, internalformat, x, y, width, height, border);
211
+ const copyTexImage2D = this._getMethod('copyTexImage2D');
212
+ copyTexImage2D(target, level, internalformat, x, y, width, height, border);
435
213
  }
436
214
  copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height) {
437
215
  this._glCheckError('copyTexSubImage2D');
438
216
  this._checkArgs('copyTexSubImage2D', arguments);
439
- this.context.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
217
+ const copyTexSubImage2D = this._getMethod('copyTexSubImage2D');
218
+ copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
440
219
  }
441
220
  createBuffer() {
442
221
  this._glCheckError('createBuffer');
443
222
  this._checkArgs('createBuffer', arguments);
444
- const id = this.context.createBuffer();
223
+ const createBuffer = this._getMethod('createBuffer');
224
+ const id = createBuffer();
445
225
  return new WebGLBuffer(id);
446
226
  }
447
227
  createFramebuffer() {
448
228
  this._glCheckError('createFramebuffer');
449
229
  this._checkArgs('createFramebuffer', arguments);
450
- return new WebGLFramebuffer(this.context.createFramebuffer());
230
+ const createFramebuffer = this._getMethod('createFramebuffer');
231
+ return new WebGLFramebuffer(createFramebuffer());
451
232
  }
452
233
  createProgram() {
453
234
  this._glCheckError('createProgram');
454
235
  this._checkArgs('createProgram', arguments);
455
- return new WebGLProgram(this.context.createProgram());
236
+ const createProgram = this._getMethod('createProgram');
237
+ return new WebGLProgram(createProgram());
456
238
  }
457
239
  createRenderbuffer() {
458
240
  this._glCheckError('createRenderbuffer');
459
241
  this._checkArgs('createRenderbuffer', arguments);
460
- return new WebGLRenderbuffer(this.context.createRenderbuffer());
242
+ const createRenderbuffer = this._getMethod('createRenderbuffer');
243
+ return new WebGLRenderbuffer(createRenderbuffer());
461
244
  }
462
245
  createShader(type) {
463
246
  this._glCheckError('createShader');
464
247
  this._checkArgs('createShader', arguments);
465
- return new WebGLShader(this.context.createShader(type));
248
+ const createShader = this._getMethod('createShader');
249
+ return new WebGLShader(createShader(type));
466
250
  }
467
251
  createTexture() {
468
252
  this._glCheckError('createTexture');
469
253
  this._checkArgs('createTexture', arguments);
470
- return new WebGLTexture(this.context.createTexture());
254
+ const createTexture = this._getMethod('createTexture');
255
+ return new WebGLTexture(createTexture());
471
256
  }
472
257
  cullFace(mode) {
473
258
  this._glCheckError('cullFace');
474
259
  this._checkArgs('cullFace', arguments);
475
- this.context.cullFace(mode);
260
+ const cullFace = this._getMethod('cullFace');
261
+ cullFace(mode);
476
262
  }
477
263
  deleteBuffer(buffer) {
478
264
  this._glCheckError('deleteBuffer');
479
265
  this._checkArgs('deleteBuffer', arguments);
480
- const value = buffer ? buffer.native : 0;
481
- this.context.deleteBuffer(value);
266
+ const value = buffer.native;
267
+ const deleteBuffer = this._getMethod('deleteBuffer');
268
+ deleteBuffer(value);
482
269
  }
483
270
  deleteFramebuffer(frameBuffer) {
484
271
  this._glCheckError('deleteFramebuffer');
485
272
  this._checkArgs('deleteFramebuffer', arguments);
486
- const value = frameBuffer ? frameBuffer.native : 0;
487
- this.context.deleteFramebuffer(value);
273
+ const value = frameBuffer.native;
274
+ const deleteFramebuffer = this._getMethod('deleteFramebuffer');
275
+ deleteFramebuffer(value);
488
276
  }
489
277
  deleteProgram(program) {
490
278
  this._glCheckError('deleteProgram');
491
279
  this._checkArgs('deleteProgram', arguments);
492
- const value = program ? program.native : 0;
493
- this.context.deleteProgram(value);
280
+ const value = program.native;
281
+ const deleteProgram = this._getMethod('deleteProgram');
282
+ deleteProgram(value);
494
283
  }
495
284
  deleteRenderbuffer(renderBuffer) {
496
285
  this._glCheckError('deleteRenderbuffer');
497
286
  this._checkArgs('deleteRenderbuffer', arguments);
498
- const value = renderBuffer ? renderBuffer.native : 0;
499
- this.context.deleteRenderbuffer(value);
287
+ const value = renderBuffer.native;
288
+ const deleteRenderbuffer = this._getMethod('deleteRenderbuffer');
289
+ deleteRenderbuffer(value);
500
290
  }
501
291
  deleteShader(shader) {
502
292
  this._glCheckError('deleteShader');
503
293
  this._checkArgs('deleteShader', arguments);
504
- const value = shader ? shader.native : 0;
505
- this.context.deleteShader(value);
294
+ const deleteShader = this._getMethod('deleteShader');
295
+ deleteShader(shader.native);
506
296
  }
507
297
  deleteTexture(texture) {
508
298
  this._glCheckError('deleteTexture');
509
299
  this._checkArgs('deleteTexture', arguments);
510
- const value = texture ? texture.native : 0;
511
- this.context.deleteTexture(value);
300
+ const value = texture.native;
301
+ const deleteTexture = this._getMethod('deleteTexture');
302
+ deleteTexture(value);
512
303
  }
513
304
  depthFunc(func) {
514
305
  this._glCheckError('depthFunc');
515
306
  this._checkArgs('depthFunc', arguments);
516
- this.context.depthFunc(func);
307
+ const depthFunc = this._getMethod('depthFunc');
308
+ depthFunc(func);
517
309
  }
518
310
  depthMask(flag) {
519
311
  this._glCheckError('depthMask');
520
312
  this._checkArgs('depthMask', arguments);
521
- this.context.depthMask(flag);
313
+ const depthMask = this._getMethod('depthMask');
314
+ depthMask(flag);
522
315
  }
523
316
  depthRange(zNear, zFar) {
524
317
  this._glCheckError('depthRange');
525
318
  this._checkArgs('depthRange', arguments);
526
- this.context.depthRange(zNear, zFar);
319
+ const depthRange = this._getMethod('depthRange');
320
+ depthRange(zNear, zFar);
527
321
  }
528
322
  detachShader(program, shader) {
529
323
  this._glCheckError('detachShader');
530
324
  this._checkArgs('detachShader', arguments);
531
- const value = program ? program.native : 0;
532
- const value2 = shader ? shader.native : 0;
533
- this.context.detachShader(value, value2);
325
+ const value = program.native;
326
+ const value2 = shader.native;
327
+ const detachShader = this._getMethod('detachShader');
328
+ detachShader(value, value2);
534
329
  }
535
330
  disableVertexAttribArray(index) {
536
331
  this._glCheckError('disableVertexAttribArray');
537
332
  this._checkArgs('disableVertexAttribArray', arguments);
538
- this.context.disableVertexAttribArray(index);
333
+ const disableVertexAttribArray = this._getMethod('disableVertexAttribArray');
334
+ disableVertexAttribArray(index);
539
335
  }
540
336
  disable(cap) {
541
337
  this._glCheckError('disable');
542
338
  this._checkArgs('disable', arguments);
543
- this.context.disable(cap);
339
+ const disable = this._getMethod('disable');
340
+ disable(cap);
544
341
  }
545
342
  drawArrays(mode, first, count) {
546
343
  this._glCheckError('drawArrays');
547
344
  this._checkArgs('drawArrays', arguments);
548
- this.context.drawArrays(mode, first, count);
345
+ const drawArrays = this._getMethod('drawArrays');
346
+ drawArrays(mode, first, count);
549
347
  }
550
348
  drawElements(mode, count, type, offset) {
551
349
  this._glCheckError('drawElements');
552
350
  this._checkArgs('drawElements', arguments);
553
- this.context.drawElements(mode, count, type, offset);
351
+ const drawElements = this._getMethod('drawElements');
352
+ drawElements(mode, count, type, offset);
554
353
  }
555
354
  enableVertexAttribArray(index) {
556
355
  this._glCheckError('enableVertexAttribArray');
557
356
  this._checkArgs('enableVertexAttribArray', arguments);
558
- this.context.enableVertexAttribArray(index);
357
+ const enableVertexAttribArray = this._getMethod('enableVertexAttribArray');
358
+ enableVertexAttribArray(index);
559
359
  }
560
360
  enable(cap) {
561
361
  this._glCheckError('enable');
562
362
  this._checkArgs('enable', arguments);
563
- this.context.enable(cap);
363
+ const enable = this._getMethod('enable');
364
+ enable(cap);
564
365
  }
565
366
  finish() {
566
367
  this._glCheckError('finish');
567
- this.context.finish();
368
+ const finish = this._getMethod('finish');
369
+ finish();
568
370
  }
569
371
  flush() {
570
372
  this._glCheckError('flush');
571
- this.context.flush();
373
+ const flush = this._getMethod('flush');
374
+ flush();
572
375
  }
573
376
  framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer) {
574
377
  this._glCheckError('framebufferRenderbuffer');
575
378
  this._checkArgs('framebufferRenderbuffer', arguments);
576
- const value = renderbuffer ? renderbuffer.native : 0;
577
- this.context.framebufferRenderbuffer(target, attachment, renderbuffertarget, value);
379
+ const value = renderbuffer.native;
380
+ const framebufferRenderbuffer = this._getMethod('framebufferRenderbuffer');
381
+ framebufferRenderbuffer(target, attachment, renderbuffertarget, value);
578
382
  }
579
383
  framebufferTexture2D(target, attachment, textarget, texture, level) {
580
384
  this._glCheckError('framebufferTexture2D');
581
- this._checkArgs('activeTexture', arguments);
582
- const value = texture ? texture.native : 0;
583
- this.context.framebufferTexture2D(target, attachment, textarget, value, level);
385
+ this._checkArgs('framebufferTexture2D', arguments);
386
+ const value = texture.native;
387
+ const framebufferTexture2D = this._getMethod('framebufferTexture2D');
388
+ framebufferTexture2D(target, attachment, textarget, value, level);
584
389
  }
585
390
  frontFace(mode) {
586
- this._checkArgs('activeTexture', arguments);
587
- this._glCheckError('activeTexture');
588
- this.context.frontFace(mode);
391
+ this._checkArgs('frontFace', arguments);
392
+ this._glCheckError('frontFace');
393
+ const frontFace = this._getMethod('frontFace');
394
+ frontFace(mode);
589
395
  }
590
396
  generateMipmap(target) {
591
- this._checkArgs('activeTexture', arguments);
592
- this._glCheckError('activeTexture');
593
- this.context.generateMipmap(target);
397
+ this._checkArgs('generateMipmap', arguments);
398
+ this._glCheckError('generateMipmap');
399
+ const generateMipmap = this._getMethod('generateMipmap');
400
+ generateMipmap(target);
594
401
  }
595
402
  getActiveAttrib(program, index) {
596
403
  this._glCheckError('getActiveAttrib');
597
404
  this._checkArgs('getActiveAttrib', arguments);
598
- const value = program ? program.native : 0;
599
- const attrib = this.context.getActiveAttrib(value, index);
405
+ const value = program.native;
406
+ const getActiveAttrib = this._getMethod('getActiveAttrib');
407
+ const attrib = getActiveAttrib(value, index);
600
408
  return new WebGLActiveInfo(attrib);
601
409
  }
602
410
  getActiveUniform(program, index) {
603
411
  this._glCheckError('getActiveUniform');
604
412
  this._checkArgs('getActiveUniform', arguments);
605
- const value = program ? program.native : 0;
606
- const uniform = this.context.getActiveUniform(value, index);
413
+ const value = program.native;
414
+ const getActiveUniform = this._getMethod('getActiveUniform');
415
+ const uniform = getActiveUniform(value, index);
607
416
  return new WebGLActiveInfo(uniform);
608
- ;
609
417
  }
610
418
  getAttachedShaders(program) {
611
419
  this._glCheckError('getAttachedShaders');
612
420
  this._checkArgs('getAttachedShaders', arguments);
613
- const value = program ? program.native : 0;
614
- return this.getJSArray(this.context.getAttachedShaders(value)).map((shader) => new WebGLShader(shader));
421
+ const getAttachedShaders = this._getMethod('getAttachedShaders');
422
+ const value = program.native;
423
+ return getAttachedShaders(value).map((shader) => new WebGLShader(shader));
615
424
  }
616
425
  getAttribLocation(program, name) {
617
426
  this._glCheckError('getAttribLocation');
618
427
  this._checkArgs('getAttribLocation', arguments);
619
- const value = program ? program.native : 0;
620
- return this.context.getAttribLocation(value, name);
428
+ const getAttribLocation = this._getMethod('getAttribLocation');
429
+ const value = program.native;
430
+ return getAttribLocation(value, name);
621
431
  }
622
432
  getBufferParameter(target, pname) {
623
433
  this._glCheckError('getBufferParameter');
624
434
  this._checkArgs('getBufferParameter', arguments);
625
- return this.context.getBufferParameter(target, pname);
435
+ const getBufferParameter = this._getMethod('getBufferParameter');
436
+ return getBufferParameter(target, pname);
626
437
  }
627
438
  getContextAttributes() {
628
- const attributes = this.context.getContextAttributes();
629
- if (!attributes) {
630
- return null;
631
- }
632
- const keys = attributes.keySet().toArray();
633
- const length = keys.length;
634
- const contextAttributes = {};
635
- for (let i = 0; i < length; i++) {
636
- const key = keys[i];
637
- contextAttributes[key] = attributes.get(key);
638
- }
639
- return contextAttributes;
439
+ const getContextAttributes = this._getMethod('getContextAttributes');
440
+ return getContextAttributes();
640
441
  }
641
442
  getError() {
642
- return this.context.getError();
443
+ const getError = this._getMethod('getError');
444
+ return getError();
643
445
  }
644
446
  getExtension(name) {
645
447
  this._glCheckError('getExtension');
@@ -647,56 +449,56 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
647
449
  if (name === 'EXT_disjoint_timer_query_webgl2') {
648
450
  return null;
649
451
  }
650
- const ext = this.context.getExtension(name);
452
+ const getExtension = this._getMethod('getExtension');
453
+ const ext = getExtension(name);
651
454
  if (ext) {
652
- const clazz = ext && ext.getClass();
653
- const classObjName = clazz && clazz.getName();
654
- switch (classObjName) {
655
- case 'org.nativescript.canvas.extensions.ANGLE_instanced_arrays':
455
+ const ext_name = ext.ext_name;
456
+ switch (ext_name) {
457
+ case 'ANGLE_instanced_arrays':
656
458
  return new ANGLE_instanced_arrays(ext);
657
- case 'org.nativescript.canvas.extensions.EXT_blend_minmax':
459
+ case 'EXT_blend_minmax':
658
460
  return new EXT_blend_minmax(ext);
659
- case 'org.nativescript.canvas.extensions.EXT_color_buffer_half_float':
461
+ case 'EXT_color_buffer_half_float':
660
462
  return new EXT_color_buffer_half_float(ext);
661
- case 'org.nativescript.canvas.extensions.EXT_disjoint_timer_query':
463
+ case 'EXT_disjoint_timer_query':
662
464
  return new EXT_disjoint_timer_query(ext);
663
- case 'org.nativescript.canvas.extensions.EXT_sRGB':
465
+ case 'EXT_sRGB':
664
466
  return new EXT_sRGB(ext);
665
- case 'org.nativescript.canvas.extensions.EXT_shader_texture_lod':
467
+ case 'EXT_shader_texture_lod':
666
468
  return new EXT_shader_texture_lod(ext);
667
- case 'org.nativescript.canvas.extensions.EXT_texture_filter_anisotropic':
469
+ case 'EXT_texture_filter_anisotropic':
668
470
  return new EXT_texture_filter_anisotropic(ext);
669
- case 'org.nativescript.canvas.extensions.OES_element_index_uint':
471
+ case 'OES_element_index_uint':
670
472
  return new OES_element_index_uint(ext);
671
- case 'org.nativescript.canvas.extensions.OES_standard_derivatives':
473
+ case 'OES_standard_derivatives':
672
474
  return new OES_standard_derivatives(ext);
673
- case 'org.nativescript.canvas.extensions.OES_texture_float':
475
+ case 'OES_texture_float':
674
476
  return new OES_texture_float(ext);
675
- case 'org.nativescript.canvas.extensions.OES_texture_float_linear':
477
+ case 'OES_texture_float_linear':
676
478
  return new OES_texture_float_linear(ext);
677
- case 'org.nativescript.canvas.extensions.OES_texture_half_float':
479
+ case 'OES_texture_half_float':
678
480
  return new OES_texture_half_float(ext);
679
- case 'org.nativescript.canvas.extensions.OES_texture_half_float_linear':
481
+ case 'OES_texture_half_float_linear':
680
482
  return new OES_texture_half_float_linear(ext);
681
- case 'org.nativescript.canvas.extensions.OES_vertex_array_object':
483
+ case 'OES_vertex_array_object':
682
484
  return new OES_vertex_array_object(ext);
683
- case 'org.nativescript.canvas.extensions.WEBGL_color_buffer_float':
485
+ case 'WEBGL_color_buffer_float':
684
486
  return new WEBGL_color_buffer_float(ext);
685
- case 'org.nativescript.canvas.extensions.WEBGL_compressed_texture_atc':
487
+ case 'WEBGL_compressed_texture_atc':
686
488
  return new WEBGL_compressed_texture_atc(ext);
687
- case 'org.nativescript.canvas.extensions.WEBGL_compressed_texture_etc':
489
+ case 'WEBGL_compressed_texture_etc':
688
490
  return new WEBGL_compressed_texture_etc(ext);
689
- case 'org.nativescript.canvas.extensions.WEBGL_compressed_texture_etc1':
491
+ case 'WEBGL_compressed_texture_etc1':
690
492
  return new WEBGL_compressed_texture_etc1(ext);
691
- case 'org.nativescript.canvas.extensions.WEBGL_compressed_texture_pvrtc':
493
+ case 'WEBGL_compressed_texture_pvrtc':
692
494
  return new WEBGL_compressed_texture_pvrtc(ext);
693
- case 'org.nativescript.canvas.extensions.WEBGL_compressed_texture_s3tc':
495
+ case 'WEBGL_compressed_texture_s3tc':
694
496
  return new WEBGL_compressed_texture_s3tc(ext);
695
- case 'org.nativescript.canvas.extensions.WEBGL_lose_context':
497
+ case 'WEBGL_lose_context':
696
498
  return new WEBGL_lose_context(ext);
697
- case 'org.nativescript.canvas.extensions.WEBGL_depth_texture':
499
+ case 'WEBGL_depth_texture':
698
500
  return new WEBGL_depth_texture(ext);
699
- case 'org.nativescript.canvas.extensions.WEBGL_draw_buffers':
501
+ case 'WEBGL_draw_buffers':
700
502
  return new WEBGL_draw_buffers(ext);
701
503
  }
702
504
  }
@@ -705,19 +507,19 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
705
507
  getFramebufferAttachmentParameter(target, attachment, pname) {
706
508
  this._glCheckError('getFramebufferAttachmentParameter');
707
509
  this._checkArgs('getFramebufferAttachmentParameter', arguments);
708
- const param = this.context.getFramebufferAttachmentParameter(target, attachment, pname);
709
- if (param.isRenderbuffer()) {
710
- return new WebGLRenderbuffer(param.getValue());
711
- }
712
- else if (param.isTexture()) {
713
- return new WebGLTexture(param.getValue());
510
+ const getFramebufferAttachmentParameter = this._getMethod('getFramebufferAttachmentParameter');
511
+ const param = getFramebufferAttachmentParameter(target, attachment, pname);
512
+ if (typeof param === 'object') {
513
+ if (param.isRenderbuffer) {
514
+ return new WebGLRenderbuffer(param);
515
+ }
516
+ else if (param.isTexture()) {
517
+ return new WebGLTexture(param);
518
+ }
714
519
  }
715
- return WebGLRenderingContext.toPrimitive(param.getValue());
520
+ return param;
716
521
  }
717
- getParameter(pname) {
718
- this._glCheckError('getParameter');
719
- this._checkArgs('activeTexture', arguments);
720
- const value = this.context.getParameter(pname);
522
+ _handleGetParameter(pname, value) {
721
523
  switch (pname) {
722
524
  case this.COLOR_WRITEMASK:
723
525
  case this.COLOR_CLEAR_VALUE:
@@ -725,38 +527,38 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
725
527
  case this.ALIASED_LINE_WIDTH_RANGE:
726
528
  case this.ALIASED_POINT_SIZE_RANGE:
727
529
  case this.DEPTH_RANGE:
728
- return new Float32Array(this.getJSArray(value));
530
+ return value;
729
531
  case this.ARRAY_BUFFER_BINDING:
730
532
  case this.ELEMENT_ARRAY_BUFFER_BINDING:
731
533
  if (value) {
732
- new WebGLBuffer(WebGLRenderingContext.toPrimitive(value));
534
+ new WebGLBuffer(value);
733
535
  }
734
536
  return null;
735
537
  case this.CURRENT_PROGRAM:
736
538
  if (value) {
737
- return new WebGLProgram(WebGLRenderingContext.toPrimitive(value));
539
+ return new WebGLProgram(value);
738
540
  }
739
541
  return null;
740
542
  case this.COMPRESSED_TEXTURE_FORMATS:
741
- return new Uint32Array(this.getJSArray(value));
543
+ return value;
742
544
  case this.RENDERBUFFER_BINDING:
743
545
  if (value) {
744
- return new WebGLRenderbuffer(WebGLRenderingContext.toPrimitive(value));
546
+ return new WebGLRenderbuffer(value);
745
547
  }
746
548
  return null;
747
549
  case this.FRAMEBUFFER_BINDING:
748
550
  if (value) {
749
- return new WebGLFramebuffer(WebGLRenderingContext.toPrimitive(value));
551
+ return new WebGLFramebuffer(value);
750
552
  }
751
553
  return null;
752
554
  case this.VIEWPORT:
753
555
  case this.SCISSOR_BOX:
754
556
  case this.MAX_VIEWPORT_DIMS:
755
- return new Int32Array(this.getJSArray(value));
557
+ return value;
756
558
  case this.TEXTURE_BINDING_CUBE_MAP:
757
559
  case this.TEXTURE_BINDING_2D:
758
560
  if (value) {
759
- return new WebGLTexture(WebGLRenderingContext.toPrimitive(value));
561
+ return new WebGLTexture(value);
760
562
  }
761
563
  return null;
762
564
  case this.VERSION:
@@ -767,66 +569,83 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
767
569
  return 'WebGL 1.0 (OpenGL ES 2.0 NativeScript)';
768
570
  }
769
571
  default:
770
- return WebGLRenderingContext.toPrimitive(value);
572
+ return value;
771
573
  }
772
574
  }
575
+ getParameter(pname) {
576
+ this._glCheckError('getParameter');
577
+ this._checkArgs('getParameter', arguments);
578
+ const getParameter = this._getMethod('getParameter');
579
+ const value = getParameter(pname);
580
+ return this._handleGetParameter(pname, value);
581
+ }
773
582
  getProgramInfoLog(program) {
774
583
  this._glCheckError('getProgramInfoLog');
775
584
  this._checkArgs('getProgramInfoLog', arguments);
776
- const value = program ? program.native : 0;
777
- return this.context.getProgramInfoLog(value);
585
+ const getProgramInfoLog = this._getMethod('getProgramInfoLog');
586
+ const value = program.native;
587
+ return getProgramInfoLog(value);
778
588
  }
779
589
  getProgramParameter(program, pname) {
780
590
  this._glCheckError('getProgramParameter');
781
591
  this._checkArgs('getProgramParameter', arguments);
782
- const value = program ? program.native : 0;
783
- const result = this.context.getProgramParameter(value, pname);
784
- return WebGLRenderingContext.toPrimitive(result);
592
+ const getProgramParameter = this._getMethod('getProgramParameter');
593
+ const value = program.native;
594
+ const result = getProgramParameter(value, pname);
595
+ return result;
785
596
  }
786
597
  getRenderbufferParameter(target, pname) {
787
598
  this._glCheckError('getRenderbufferParameter');
788
599
  this._checkArgs('getRenderbufferParameter', arguments);
789
- return this.context.getRenderbufferParameter(target, pname);
600
+ const getRenderbufferParameter = this._getMethod('getRenderbufferParameter');
601
+ return getRenderbufferParameter(target, pname);
790
602
  }
791
603
  getShaderInfoLog(shader) {
792
604
  this._glCheckError('getShaderInfoLog');
793
605
  this._checkArgs('getShaderInfoLog', arguments);
794
- const value = shader ? shader.native : 0;
795
- return this.context.getShaderInfoLog(value);
606
+ const getShaderInfoLog = this._getMethod('getShaderInfoLog');
607
+ const value = shader.native;
608
+ return getShaderInfoLog(value);
796
609
  }
797
610
  getShaderParameter(shader, pname) {
798
611
  this._glCheckError('getShaderParameter');
799
612
  this._checkArgs('getShaderParameter', arguments);
800
- const value = shader ? shader.native : 0;
801
- const result = this.context.getShaderParameter(value, pname);
802
- return WebGLRenderingContext.toPrimitive(result);
613
+ const getShaderParameter = this._getMethod('getShaderParameter');
614
+ const value = shader.native;
615
+ const result = getShaderParameter(value, pname);
616
+ return result;
803
617
  }
804
618
  getShaderPrecisionFormat(shaderType, precisionType) {
805
619
  this._glCheckError('getShaderPrecisionFormat');
806
620
  this._checkArgs('getShaderPrecisionFormat', arguments);
807
- const precision = this.context.getShaderPrecisionFormat(shaderType, precisionType);
808
- return new WebGLShaderPrecisionFormat(precision.getRangeMin(), precision.getRangeMax(), precision.getPrecision());
621
+ const getShaderPrecisionFormat = this._getMethod('getShaderPrecisionFormat');
622
+ const precision = getShaderPrecisionFormat(shaderType, precisionType);
623
+ return new WebGLShaderPrecisionFormat(precision);
809
624
  }
810
625
  getShaderSource(shader) {
811
626
  this._glCheckError('getShaderSource');
812
627
  this._checkArgs('getShaderSource', arguments);
628
+ const getShaderSource = this._getMethod('getShaderSource');
813
629
  const value = shader ? shader.native : 0;
814
- return this.context.getShaderSource(value);
630
+ return getShaderSource(value);
815
631
  }
816
632
  getSupportedExtensions() {
817
633
  this._glCheckError('getSupportedExtensions');
818
- return this.getJSArray(this.context.getSupportedExtensions());
634
+ const getSupportedExtensions = this._getMethod('getSupportedExtensions');
635
+ return getSupportedExtensions();
819
636
  }
820
637
  getTexParameter(target, pname) {
821
638
  this._glCheckError('getTexParameter');
822
639
  this._checkArgs('getTexParameter', arguments);
823
- return this.context.getTexParameter(target, pname);
640
+ const getTexParameter = this._getMethod('getTexParameter');
641
+ return getTexParameter(target, pname);
824
642
  }
825
643
  getUniformLocation(program, name) {
826
644
  this._glCheckError('getUniformLocation');
827
645
  this._checkArgs('getUniformLocation', arguments);
828
- const value = program ? program.native : 0;
829
- const id = this.context.getUniformLocation(value, name);
646
+ const getUniformLocation = this._getMethod('getUniformLocation');
647
+ const value = program.native;
648
+ const id = getUniformLocation(value, name);
830
649
  if (id === -1) {
831
650
  return null;
832
651
  }
@@ -835,94 +654,112 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
835
654
  getUniform(program, location) {
836
655
  this._glCheckError('getUniform');
837
656
  this._checkArgs('getUniform', arguments);
838
- const value = program ? program.native : 0;
839
- const value2 = location ? location.native : 0;
840
- const uniform = this.context.getUniform(value, value2);
657
+ const getUniform = this._getMethod('getUniform');
658
+ const value = program.native;
659
+ const value2 = location.native;
660
+ const uniform = getUniform(value, value2);
841
661
  if (uniform && uniform.length) {
842
- return this.getJSArray(uniform);
662
+ return uniform;
843
663
  }
844
- return WebGLRenderingContext.toPrimitive(uniform);
664
+ return uniform;
845
665
  }
846
666
  getVertexAttribOffset(index, pname) {
847
667
  this._glCheckError('getVertexAttribOffset');
848
668
  this._checkArgs('getVertexAttribOffset', arguments);
849
- return this.context.getVertexAttribOffset(index, pname);
669
+ const getVertexAttribOffset = this._getMethod('getVertexAttribOffset');
670
+ return getVertexAttribOffset(index, pname);
850
671
  }
851
672
  getVertexAttrib(index, pname) {
852
673
  this._glCheckError('getVertexAttrib');
853
674
  this._checkArgs('getVertexAttrib', arguments);
854
- const value = this.context.getVertexAttrib(index, pname);
675
+ const getVertexAttrib = this._getMethod('getVertexAttrib');
676
+ const value = getVertexAttrib(index, pname);
855
677
  if (pname === this.CURRENT_VERTEX_ATTRIB) {
856
- return new Float32Array(this.getJSArray(value));
678
+ return value;
857
679
  }
858
- return WebGLRenderingContext.toPrimitive(value);
680
+ return value;
859
681
  }
860
682
  hint(target, mode) {
861
683
  this._glCheckError('hint');
862
684
  this._checkArgs('hint', arguments);
863
- this.context.hint(target, mode);
685
+ const hint = this._getMethod('hint');
686
+ hint(target, mode);
864
687
  }
865
688
  isBuffer(buffer) {
866
689
  this._glCheckError('isBuffer');
867
690
  this._checkArgs('isBuffer', arguments);
868
- const value = buffer ? buffer.native : 0;
869
- return this.context.isBuffer(value);
691
+ const isBuffer = this._getMethod('isBuffer');
692
+ const value = buffer.native;
693
+ return isBuffer(value);
870
694
  }
871
695
  isContextLost() {
872
696
  this._glCheckError('isContextLost');
873
- return this.context.isContextLost();
697
+ const isContextLost = this._getMethod('isContextLost');
698
+ return isContextLost();
874
699
  }
875
700
  isEnabled(cap) {
876
701
  this._glCheckError('isEnabled');
877
702
  this._checkArgs('isEnabled', arguments);
878
- return this.context.isEnabled(cap);
703
+ const isEnabled = this._getMethod('isEnabled');
704
+ return isEnabled(cap);
879
705
  }
880
706
  isFramebuffer(framebuffer) {
881
707
  this._glCheckError('isFramebuffer');
882
708
  this._checkArgs('isFramebuffer', arguments);
709
+ const isFramebuffer = this._getMethod('isFramebuffer');
883
710
  const value = framebuffer ? framebuffer.native : 0;
884
- return this.context.isFramebuffer(value);
711
+ return isFramebuffer(value);
885
712
  }
886
713
  isProgram(program) {
887
714
  this._glCheckError('isProgram');
888
715
  this._checkArgs('isProgram', arguments);
889
- const value = program ? program.native : 0;
890
- return this.context.isProgram(value);
716
+ const isProgram = this._getMethod('isProgram');
717
+ const value = program.native;
718
+ return isProgram(value);
891
719
  }
892
720
  isRenderbuffer(renderbuffer) {
893
721
  this._glCheckError('isRenderbuffer');
894
722
  this._checkArgs('isRenderbuffer', arguments);
895
- const value = renderbuffer ? renderbuffer.native : 0;
896
- return this.context.isRenderbuffer(value);
723
+ const isRenderbuffer = this._getMethod('isRenderbuffer');
724
+ const value = renderbuffer.native;
725
+ return isRenderbuffer(value);
897
726
  }
898
727
  isShader(shader) {
899
728
  this._glCheckError('isShader');
900
729
  this._checkArgs('isShader', arguments);
901
- const value = shader ? shader.native : 0;
902
- return this.context.isShader(value);
730
+ const isShader = this._getMethod('isShader');
731
+ const value = shader.native;
732
+ return isShader(value);
903
733
  }
904
734
  isTexture(texture) {
905
735
  this._glCheckError('isTexture');
906
736
  this._checkArgs('isTexture', arguments);
907
- const value = texture ? texture.native : 0;
908
- return this.context.isTexture(value);
737
+ const isTexture = this._getMethod('isTexture');
738
+ const value = texture.native;
739
+ return isTexture(value);
909
740
  }
910
741
  lineWidth(width) {
911
742
  this._glCheckError('lineWidth');
912
743
  this._checkArgs('lineWidth', arguments);
913
- this.context.lineWidth(width);
744
+ const lineWidth = this._getMethod('lineWidth');
745
+ lineWidth(width);
914
746
  }
915
747
  linkProgram(program) {
916
748
  this._glCheckError('linkProgram');
917
749
  this._checkArgs('linkProgram', arguments);
750
+ const linkProgram = this._getMethod('linkProgram');
918
751
  const value = program ? program.native : 0;
919
- this.context.linkProgram(value);
752
+ linkProgram(value);
920
753
  }
921
754
  pixelStorei(pname, param) {
922
755
  this._glCheckError('pixelStorei');
923
756
  this._checkArgs('pixelStorei', arguments);
757
+ const pixelStorei = this._getMethod('pixelStorei');
924
758
  if (pname === this.UNPACK_FLIP_Y_WEBGL || pname === this.UNPACK_PREMULTIPLY_ALPHA_WEBGL) {
925
- this.context.pixelStorei(pname, java.lang.Boolean.valueOf(!!param));
759
+ if (pname === this.UNPACK_FLIP_Y_WEBGL) {
760
+ this._flipY = param;
761
+ }
762
+ pixelStorei(pname, param);
926
763
  }
927
764
  else if (pname === this.PACK_ALIGNMENT || pname === this.UNPACK_ALIGNMENT || pname === this.UNPACK_COLORSPACE_CONVERSION_WEBGL) {
928
765
  if (pname === this.UNPACK_COLORSPACE_CONVERSION_WEBGL) {
@@ -931,333 +768,183 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
931
768
  else if (pname === this.PACK_ALIGNMENT || pname === this.UNPACK_ALIGNMENT) {
932
769
  param = 4;
933
770
  }
934
- this.context.pixelStorei(pname, java.lang.Integer.valueOf(param));
771
+ pixelStorei(pname, param);
935
772
  }
936
773
  else {
937
- this.context.pixelStorei(pname, param);
774
+ pixelStorei(pname, param);
938
775
  }
939
776
  }
940
777
  polygonOffset(factor, units) {
941
778
  this._glCheckError('polygonOffset');
942
779
  this._checkArgs('polygonOffset', arguments);
943
- this.context.polygonOffset(factor, units);
780
+ const polygonOffset = this._getMethod('polygonOffset');
781
+ polygonOffset(factor, units);
944
782
  }
945
783
  readPixels(x, y, width, height, format, type, pixels) {
946
784
  this._glCheckError('readPixels');
947
785
  this._checkArgs('readPixels', arguments);
948
- // @ts-ignore
949
- if (pixels && pixels.buffer instanceof ArrayBuffer) {
950
- // @ts-ignore
951
- if (pixels.buffer.nativeObject) {
952
- // @ts-ignore
953
- this.context.readPixels(x, y, width, height, format, type, pixels.buffer.nativeObject);
954
- }
955
- else {
956
- if (pixels instanceof Uint8Array) {
957
- if (this._isSupported) {
958
- this.context.readPixelsByteBuffer(x, y, width, height, format, type, pixels);
959
- }
960
- else {
961
- this.context.readPixelsByte(x, y, width, height, format, type, Array.from(pixels));
962
- }
963
- }
964
- else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
965
- if (this._isSupported) {
966
- this.context.readPixelsShortBuffer(x, y, width, height, format, type, pixels);
967
- }
968
- else {
969
- this.context.readPixelsShort(x, y, width, height, format, type, Array.from(pixels));
970
- }
971
- }
972
- else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
973
- if (this._isSupported) {
974
- this.context.readPixelsIntBuffer(x, y, width, height, format, type, pixels);
975
- }
976
- else {
977
- this.context.readPixelsInt(x, y, width, height, format, type, Array.from(pixels));
978
- }
979
- }
980
- else if (pixels instanceof Float32Array) {
981
- if (this._isSupported) {
982
- this.context.readPixelsFloatBuffer(x, y, width, height, format, type, pixels);
983
- }
984
- else {
985
- this.context.readPixelsFloat(x, y, width, height, format, type, Array.from(pixels));
986
- }
987
- }
988
- }
989
- }
990
- else if (pixels instanceof ArrayBuffer) {
991
- // @ts-ignore
992
- if (pixels.nativeObject) {
993
- // @ts-ignore
994
- this.context.readPixels(x, y, width, height, format, type, pixels.nativeObject);
995
- }
996
- else {
997
- if (this._isSupported) {
998
- this.context.readPixelsByteBuffer(x, y, width, height, format, type, pixels);
999
- }
1000
- else {
1001
- this.context.readPixelsByte(x, y, width, height, format, type, Array.from(new Uint8Array(pixels)));
1002
- }
1003
- }
1004
- }
786
+ const readPixels = this._getMethod('readPixels');
787
+ readPixels(x, y, width, height, format, type, pixels);
1005
788
  }
1006
789
  renderbufferStorage(target, internalFormat, width, height) {
1007
790
  this._glCheckError('renderbufferStorage');
1008
791
  this._checkArgs('renderbufferStorage', arguments);
792
+ const renderbufferStorage = this._getMethod('renderbufferStorage');
1009
793
  if (internalFormat === this.DEPTH_STENCIL) {
1010
794
  // DEPTH24_STENCIL8 = 35056
1011
795
  // DEPTH24_STENCIL8_OES = 0x88F0
1012
796
  internalFormat = 0x88f0;
1013
797
  }
1014
- this.context.renderbufferStorage(target, internalFormat, width, height);
798
+ renderbufferStorage(target, internalFormat, width, height);
1015
799
  }
1016
800
  sampleCoverage(value, invert) {
1017
801
  this._glCheckError('sampleCoverage');
1018
802
  this._checkArgs('sampleCoverage', arguments);
1019
- this.context.sampleCoverage(value, invert);
803
+ const sampleCoverage = this._getMethod('sampleCoverage');
804
+ sampleCoverage(value, invert);
1020
805
  }
1021
806
  scissor(x, y, width, height) {
1022
807
  this._glCheckError('scissor');
1023
808
  this._checkArgs('scissor', arguments);
1024
- this.context.scissor(x, y, width, height);
809
+ const scissor = this._getMethod('scissor');
810
+ scissor(x, y, width, height);
1025
811
  }
1026
812
  shaderSource(shader, source) {
1027
813
  this._glCheckError('shaderSource');
1028
814
  this._checkArgs('shaderSource', arguments);
815
+ const shaderSource = this._getMethod('shaderSource');
1029
816
  const value = shader ? shader.native : 0;
1030
- this.context.shaderSource(value, source);
817
+ shaderSource(value, source);
1031
818
  }
1032
819
  stencilFuncSeparate(face, func, ref, mask) {
1033
820
  this._glCheckError('stencilFuncSeparate');
1034
821
  this._checkArgs('stencilFuncSeparate', arguments);
1035
- this.context.stencilFuncSeparate(face, func, ref, mask);
822
+ const stencilFuncSeparate = this._getMethod('stencilFuncSeparate');
823
+ stencilFuncSeparate(face, func, ref, mask);
1036
824
  }
1037
825
  stencilFunc(func, ref, mask) {
1038
826
  this._glCheckError('stencilFunc');
1039
827
  this._checkArgs('stencilFunc', arguments);
1040
- this.context.stencilFunc(func, ref, mask);
828
+ const stencilFunc = this._getMethod('stencilFunc');
829
+ stencilFunc(func, ref, mask);
1041
830
  }
1042
831
  stencilMaskSeparate(face, mask) {
1043
832
  this._glCheckError('stencilMaskSeparate');
1044
833
  this._checkArgs('stencilMaskSeparate', arguments);
1045
- this.context.stencilMaskSeparate(face, mask);
834
+ const stencilMaskSeparate = this._getMethod('stencilMaskSeparate');
835
+ stencilMaskSeparate(face, mask);
1046
836
  }
1047
837
  stencilMask(mask) {
1048
838
  this._glCheckError('stencilMask');
1049
839
  this._checkArgs('stencilMask', arguments);
1050
- this.context.stencilMask(mask);
840
+ const stencilMask = this._getMethod('stencilMask');
841
+ stencilMask(mask);
1051
842
  }
1052
843
  stencilOpSeparate(face, fail, zfail, zpass) {
1053
844
  this._glCheckError('stencilOpSeparate');
1054
845
  this._checkArgs('stencilOpSeparate', arguments);
1055
- this.context.stencilOpSeparate(face, fail, zfail, zpass);
846
+ const stencilOpSeparate = this._getMethod('stencilOpSeparate');
847
+ stencilOpSeparate(face, fail, zfail, zpass);
1056
848
  }
1057
849
  stencilOp(fail, zfail, zpass) {
1058
850
  this._glCheckError('stencilOp');
1059
851
  this._checkArgs('stencilOp', arguments);
1060
- this.context.stencilOp(fail, zfail, zpass);
852
+ const stencilOp = this._getMethod('stencilOp');
853
+ stencilOp(fail, zfail, zpass);
1061
854
  }
1062
855
  texImage2D(target, level, internalformat, width, height, border, format, type, pixels) {
1063
856
  this._glCheckError('texImage2D');
1064
857
  this._checkArgs('texImage2D', arguments);
858
+ const texImage2D = this._getMethod('texImage2D');
1065
859
  if (arguments.length === 9) {
1066
- if (pixels && pixels.buffer instanceof ArrayBuffer) {
1067
- if (pixels.buffer.nativeObject) {
1068
- // @ts-ignore
1069
- this.context.texImage2D(target, level, internalformat, width, height, border, format, type, pixels.buffer.nativeObject);
1070
- }
1071
- else {
1072
- if (pixels instanceof Uint8Array) {
1073
- if (this._isSupported) {
1074
- this.context.texImage2DByteBuffer(target, level, internalformat, width, height, border, format, type, pixels);
1075
- }
1076
- else {
1077
- this.context.texImage2DByte(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
1078
- }
1079
- }
1080
- else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
1081
- if (this._isSupported) {
1082
- this.context.texSubImage2DShortBuffer(target, level, internalformat, width, height, border, format, type, pixels);
1083
- }
1084
- else {
1085
- this.context.texSubImage2DShort(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
1086
- }
1087
- }
1088
- else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
1089
- if (this._isSupported) {
1090
- this.context.texImage2DIntBuffer(target, level, internalformat, width, height, border, format, type, pixels);
1091
- }
1092
- else {
1093
- this.context.texImage2DInt(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
1094
- }
1095
- }
1096
- else if (pixels instanceof Float32Array) {
1097
- if (this._isSupported) {
1098
- this.context.texImage2DFloatBuffer(target, level, internalformat, width, height, border, format, type, pixels);
1099
- }
1100
- else {
1101
- this.context.texImage2DFloat(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
1102
- }
1103
- }
1104
- }
1105
- }
1106
- else if (pixels instanceof ArrayBuffer) {
1107
- // @ts-ignore // ArrayBuffer backed by nio buffer
1108
- if (pixels.nativeObject) {
1109
- // @ts-ignore
1110
- this.context.texImage2D(target, level, internalformat, width, height, border, format, type, pixels.nativeObject);
1111
- }
1112
- else {
1113
- if (this._isSupported) {
1114
- this.context.texImage2DByteBuffer(target, level, internalformat, width, height, border, format, type, pixels);
1115
- }
1116
- else {
1117
- this.context.texImage2DByte(target, level, internalformat, width, height, border, format, type, Array.from(new Uint8Array(pixels)));
1118
- }
1119
- }
1120
- }
1121
- else {
1122
- this.context.texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
1123
- }
860
+ texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
1124
861
  }
1125
862
  else if (arguments.length === 6) {
1126
863
  if (border && typeof border.tagName === 'string' && (border.tagName === 'VID' || border.tagName === 'VIDEO') && border._video && typeof border._video.getCurrentFrame === 'function') {
1127
- border._video.getCurrentFrame(this.context, this, target, level, internalformat, width, height);
864
+ border._video.getCurrentFrame(this.native, this, target, level, internalformat, width, height);
1128
865
  }
1129
866
  else if (border && typeof border.getCurrentFrame === 'function') {
1130
- border.getCurrentFrame(this.context, this, target, level, internalformat, width, height);
867
+ border.getCurrentFrame(this.native, this, target, level, internalformat, width, height);
1131
868
  }
1132
869
  else if (border instanceof ImageAsset) {
1133
- this.context.texImage2D(target, level, internalformat, width, height, border.native);
870
+ texImage2D(target, level, internalformat, width, height, border.native);
1134
871
  }
1135
- else if (border instanceof ImageBitmap || (border === null || border === void 0 ? void 0 : border.native) instanceof org.nativescript.canvas.TNSImageBitmap) {
1136
- this.context.texImage2D(target, level, internalformat, width, height, border.native);
872
+ else if (border instanceof ImageBitmap) {
873
+ texImage2D(target, level, internalformat, width, height, border.native);
1137
874
  }
1138
875
  else if (border instanceof android.graphics.Bitmap) {
1139
- this.context.texImage2D(target, level, internalformat, width, height, border);
876
+ texImage2D(target, level, internalformat, width, height, border);
1140
877
  }
1141
878
  else if (border instanceof ImageSource) {
1142
- this.context.texImage2D(target, level, internalformat, width, height, border.android);
879
+ texImage2D(target, level, internalformat, width, height, border.android);
1143
880
  }
1144
881
  else if (border && typeof border.tagName === 'string' && (border.tagName === 'IMG' || border.tagName === 'IMAGE')) {
1145
882
  if (border._asset instanceof ImageAsset) {
1146
- this.context.texImage2D(target, level, internalformat, width, height, border._asset.native);
883
+ texImage2D(target, level, internalformat, width, height, border._asset.native);
1147
884
  }
1148
885
  else if (border._imageSource instanceof ImageSource) {
1149
- this.context.texImage2D(target, level, internalformat, width, height, border._imageSource.android);
886
+ texImage2D(target, level, internalformat, width, height, border._imageSource.android);
1150
887
  }
1151
888
  else if (border._image instanceof android.graphics.Bitmap) {
1152
- this.context.texImage2D(target, level, internalformat, width, height, border._image);
889
+ texImage2D(target, level, internalformat, width, height, border._image);
1153
890
  }
1154
891
  else if (typeof border.src === 'string') {
1155
- this.context.texImage2D(target, level, internalformat, width, height, ImageSource.fromFileSync(border.src).android);
892
+ texImage2D(target, level, internalformat, width, height, ImageSource.fromFileSync(border.src).android);
1156
893
  }
1157
894
  }
1158
895
  else if (border && typeof border.tagName === 'string' && border.tagName === 'CANVAS' && border._canvas instanceof Canvas) {
1159
- this.context.texImage2D(target, level, internalformat, width, height, border._canvas.android);
896
+ texImage2D(target, level, internalformat, width, height, border._canvas.native);
1160
897
  }
1161
898
  }
1162
899
  }
1163
900
  texParameterf(target, pname, param) {
1164
901
  this._glCheckError('texParameterf');
1165
902
  this._checkArgs('texParameterf', arguments);
1166
- this.context.texParameterf(target, pname, param);
903
+ const texParameterf = this._getMethod('texParameterf');
904
+ texParameterf(target, pname, param);
1167
905
  }
1168
906
  texParameteri(target, pname, param) {
1169
907
  this._glCheckError('texParameteri');
1170
908
  this._checkArgs('texParameteri', arguments);
1171
- this.context.texParameteri(target, pname, param);
909
+ const texParameteri = this._getMethod('texParameteri');
910
+ texParameteri(target, pname, param);
1172
911
  }
1173
912
  texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels) {
1174
913
  this._glCheckError('texSubImage2D');
1175
914
  this._checkArgs('texSubImage2D', arguments);
915
+ const texSubImage2D = this._getMethod('texSubImage2D');
1176
916
  if (arguments.length === 9) {
1177
- if (pixels && pixels.buffer) {
1178
- if (pixels.buffer.nativeObject) {
1179
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels.buffer.nativeObject);
1180
- }
1181
- else {
1182
- if (pixels instanceof Uint8Array) {
1183
- if (this._isSupported) {
1184
- this.context.texSubImage2DByteBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
1185
- }
1186
- else {
1187
- this.context.texSubImage2DByte(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
1188
- }
1189
- }
1190
- else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
1191
- if (this._isSupported) {
1192
- this.context.texSubImage2DShortBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
1193
- }
1194
- else {
1195
- this.context.texSubImage2DShort(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
1196
- }
1197
- }
1198
- else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
1199
- if (this._isSupported) {
1200
- this.context.texSubImage2DIntBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
1201
- }
1202
- else {
1203
- this.context.texSubImage2DInt(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
1204
- }
1205
- }
1206
- else if (pixels instanceof Float32Array) {
1207
- if (this._isSupported) {
1208
- this.context.texSubImage2DByte(target, level, xoffset, yoffset, width, height, format, type, pixels);
1209
- }
1210
- else {
1211
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
1212
- }
1213
- }
1214
- }
1215
- }
1216
- else if (pixels instanceof ArrayBuffer) {
1217
- // @ts-ignore
1218
- if (pixels.nativeObject) {
1219
- // @ts-ignore
1220
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels.nativeObject);
1221
- }
1222
- else {
1223
- if (this._isSupported) {
1224
- this.context.texSubImage2DByteBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
1225
- }
1226
- else {
1227
- this.context.texSubImage2DByte(target, level, xoffset, yoffset, width, height, format, type, Array.from(new Uint8Array(pixels)));
1228
- }
1229
- }
1230
- }
917
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
1231
918
  }
1232
919
  else if (arguments.length === 7) {
1233
920
  if (format instanceof android.graphics.Bitmap) {
1234
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format);
921
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format);
1235
922
  }
1236
923
  else if (format instanceof ImageSource) {
1237
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format.android);
924
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format.android);
1238
925
  }
1239
926
  else if (format instanceof ImageAsset) {
1240
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format.native);
927
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format.native);
1241
928
  }
1242
- else if (format instanceof ImageBitmap || (format === null || format === void 0 ? void 0 : format.native) instanceof org.nativescript.canvas.TNSImageBitmap) {
1243
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format.native);
929
+ else if (format instanceof ImageBitmap) {
930
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format.native);
1244
931
  }
1245
932
  else if (format && typeof format.tagName === 'string' && (format.tagName === 'IMG' || format.tagName === 'IMAGE')) {
1246
933
  if (format._imageSource instanceof ImageSource) {
1247
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format._imageSource.android);
934
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format._imageSource.android);
1248
935
  }
1249
936
  else if (format._image instanceof android.graphics.Bitmap) {
1250
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format._image);
937
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format._image);
1251
938
  }
1252
939
  else if (format._asset instanceof ImageAsset) {
1253
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format._asset.native);
940
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format._asset.native);
1254
941
  }
1255
942
  else if (typeof format.src === 'string') {
1256
943
  const result = ImageSource.fromFileSync(format.src);
1257
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, result ? result.android : null);
944
+ texSubImage2D(target, level, xoffset, yoffset, width, height, result ? result.android : null);
1258
945
  }
1259
946
  else if (format && typeof format.tagName === 'string' && format.tagName === 'CANVAS' && format._canvas instanceof Canvas) {
1260
- this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format._canvas.android);
947
+ texSubImage2D(target, level, xoffset, yoffset, width, height, format._canvas.native);
1261
948
  }
1262
949
  }
1263
950
  }
@@ -1265,403 +952,209 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1265
952
  uniform1f(location, v0) {
1266
953
  this._glCheckError('uniform1f');
1267
954
  this._checkArgs('uniform1f', arguments);
1268
- const loc = location ? location.native : 0;
1269
- this.context.uniform1f(loc, v0);
955
+ const uniform1f = this._getMethod('uniform1f');
956
+ const loc = location.native;
957
+ uniform1f(loc, v0);
1270
958
  }
1271
959
  uniform1iv(location, value) {
1272
960
  this._glCheckError('uniform1iv');
1273
961
  this._checkArgs('uniform1iv', arguments);
1274
- const loc = location ? location.native : 0;
1275
- if (this._isSupported) {
1276
- if (!Array.isArray(value)) {
1277
- this.context.uniform1ivBuffer(loc, value);
1278
- }
1279
- else {
1280
- this.context.uniform1iv(loc, value);
1281
- }
1282
- }
1283
- else {
1284
- if (!Array.isArray(value)) {
1285
- this.context.uniform1iv(loc, Array.from(value));
1286
- }
1287
- else {
1288
- this.context.uniform1iv(loc, value);
1289
- }
1290
- }
962
+ const loc = location.native;
963
+ const uniform1iv = this._getMethod('uniform1iv');
964
+ uniform1iv(loc, value);
1291
965
  }
1292
966
  uniform1fv(location, value) {
1293
967
  this._glCheckError('uniform1fv');
1294
968
  this._checkArgs('uniform1fv', arguments);
1295
- const loc = location ? location.native : 0;
1296
- if (this._isSupported) {
1297
- if (!Array.isArray(value)) {
1298
- this.context.uniform1fvBuffer(loc, value);
1299
- }
1300
- else {
1301
- this.context.uniform1fv(loc, value);
1302
- }
1303
- }
1304
- else {
1305
- if (!Array.isArray(value)) {
1306
- this.context.uniform1fv(loc, Array.from(value));
1307
- }
1308
- else {
1309
- this.context.uniform1fv(loc, value);
1310
- }
1311
- }
969
+ const loc = location.native;
970
+ const uniform1fv = this._getMethod('uniform1fv');
971
+ uniform1fv(loc, value);
1312
972
  }
1313
973
  uniform1i(location, v0) {
1314
974
  this._glCheckError('uniform1i');
1315
975
  this._checkArgs('uniform1i', arguments);
1316
- const loc = location ? location.native : 0;
1317
- this.context.uniform1i(loc, Number(v0));
976
+ const uniform1i = this._getMethod('uniform1i');
977
+ const loc = location.native;
978
+ uniform1i(loc, Number(v0));
1318
979
  }
1319
980
  uniform2f(location, v0, v1) {
1320
981
  this._glCheckError('uniform2f');
1321
982
  this._checkArgs('uniform2f', arguments);
1322
- const loc = location ? location.native : 0;
1323
- this.context.uniform2f(loc, v0, v1);
983
+ const uniform2f = this._getMethod('uniform2f');
984
+ const loc = location.native;
985
+ uniform2f(loc, v0, v1);
1324
986
  }
1325
987
  uniform2iv(location, value) {
1326
988
  this._glCheckError('uniform2iv');
1327
989
  this._checkArgs('uniform2iv', arguments);
1328
- const loc = location ? location.native : 0;
1329
- if (this._isSupported) {
1330
- if (!Array.isArray(value)) {
1331
- this.context.uniform2ivBuffer(loc, value);
1332
- }
1333
- else {
1334
- this.context.uniform2iv(loc, value);
1335
- }
1336
- }
1337
- else {
1338
- if (!Array.isArray(value)) {
1339
- this.context.uniform2iv(loc, Array.from(value));
1340
- }
1341
- else {
1342
- this.context.uniform2iv(loc, value);
1343
- }
1344
- }
990
+ const loc = location.native;
991
+ const uniform2iv = this._getMethod('uniform2iv');
992
+ uniform2iv(loc, value);
1345
993
  }
1346
994
  uniform2fv(location, value) {
1347
995
  this._glCheckError('uniform2fv');
1348
996
  this._checkArgs('uniform2fv', arguments);
1349
- const loc = location ? location.native : 0;
1350
- if (this._isSupported) {
1351
- if (!Array.isArray(value)) {
1352
- this.context.uniform2fvBuffer(loc, value);
1353
- }
1354
- else {
1355
- this.context.uniform2fv(loc, value);
1356
- }
1357
- }
1358
- else {
1359
- if (!Array.isArray(value)) {
1360
- this.context.uniform2fv(loc, Array.from(value));
1361
- }
1362
- else {
1363
- this.context.uniform2fv(loc, value);
1364
- }
1365
- }
997
+ const loc = location.native;
998
+ const uniform2fv = this._getMethod('uniform2fv');
999
+ uniform2fv(loc, value);
1366
1000
  }
1367
1001
  uniform2i(location, v0, v1) {
1368
1002
  this._glCheckError('uniform2i');
1369
1003
  this._checkArgs('uniform2i', arguments);
1370
- const loc = location ? location.native : 0;
1371
- this.context.uniform2i(loc, v0, v1);
1004
+ const uniform2i = this._getMethod('uniform2i');
1005
+ const loc = location.native;
1006
+ uniform2i(loc, v0, v1);
1372
1007
  }
1373
1008
  uniform3f(location, v0, v1, v2) {
1374
1009
  this._glCheckError('uniform3f');
1375
1010
  this._checkArgs('uniform3f', arguments);
1376
- const loc = location ? location.native : 0;
1377
- this.context.uniform3f(loc, v0, v1, v2);
1011
+ const uniform3f = this._getMethod('uniform3f');
1012
+ const loc = location.native;
1013
+ uniform3f(loc, v0, v1, v2);
1378
1014
  }
1379
1015
  uniform3iv(location, value) {
1380
1016
  this._glCheckError('uniform3iv');
1381
1017
  this._checkArgs('uniform3iv', arguments);
1382
- const loc = location ? location.native : 0;
1383
- if (this._isSupported) {
1384
- if (!Array.isArray(value)) {
1385
- this.context.uniform3ivBuffer(loc, value);
1386
- }
1387
- else {
1388
- this.context.uniform3iv(loc, value);
1389
- }
1390
- }
1391
- else {
1392
- if (!Array.isArray(value)) {
1393
- this.context.uniform3iv(loc, Array.from(value));
1394
- }
1395
- else {
1396
- this.context.uniform3iv(loc, value);
1397
- }
1398
- }
1018
+ const loc = location.native;
1019
+ const uniform3iv = this._getMethod('uniform3iv');
1020
+ uniform3iv(loc, value);
1399
1021
  }
1400
1022
  uniform3fv(location, value) {
1401
1023
  this._glCheckError('uniform3fv');
1402
1024
  this._checkArgs('uniform3fv', arguments);
1403
- const loc = location ? location.native : 0;
1404
- if (this._isSupported) {
1405
- if (!Array.isArray(value)) {
1406
- this.context.uniform3fvBuffer(loc, value);
1407
- }
1408
- else {
1409
- this.context.uniform3fv(loc, value);
1410
- }
1411
- }
1412
- else {
1413
- if (!Array.isArray(value)) {
1414
- this.context.uniform3fv(loc, Array.from(value));
1415
- }
1416
- else {
1417
- this.context.uniform3fv(loc, value);
1418
- }
1419
- }
1025
+ const loc = location.native;
1026
+ const uniform3fv = this._getMethod('uniform3fv');
1027
+ uniform3fv(loc, value);
1420
1028
  }
1421
1029
  uniform3i(location, v0, v1, v2) {
1422
1030
  this._glCheckError('uniform3i');
1423
1031
  this._checkArgs('uniform3i', arguments);
1424
- const loc = location ? location.native : 0;
1425
- this.context.uniform3i(loc, v0, v1, v2);
1032
+ const uniform3i = this._getMethod('uniform3i');
1033
+ const loc = location.native;
1034
+ uniform3i(loc, v0, v1, v2);
1426
1035
  }
1427
1036
  uniform4f(location, v0, v1, v2, v3) {
1428
1037
  this._glCheckError('uniform4f');
1429
1038
  this._checkArgs('uniform4f', arguments);
1430
- const loc = location ? location.native : 0;
1431
- this.context.uniform4f(loc, v0, v1, v2, v3);
1039
+ const uniform4f = this._getMethod('uniform4f');
1040
+ const loc = location.native;
1041
+ uniform4f(loc, v0, v1, v2, v3);
1432
1042
  }
1433
1043
  uniform4iv(location, value) {
1434
1044
  this._glCheckError('uniform4iv');
1435
1045
  this._checkArgs('uniform4iv', arguments);
1436
- const loc = location ? location.native : 0;
1437
- if (this._isSupported) {
1438
- if (!Array.isArray(value)) {
1439
- this.context.uniform4ivBuffer(loc, value);
1440
- }
1441
- else {
1442
- this.context.uniform4iv(loc, value);
1443
- }
1444
- }
1445
- else {
1446
- if (!Array.isArray(value)) {
1447
- this.context.uniform4iv(loc, Array.from(value));
1448
- }
1449
- else {
1450
- this.context.uniform4iv(loc, value);
1451
- }
1452
- }
1046
+ const loc = location.native;
1047
+ const uniform4iv = this._getMethod('uniform4iv');
1048
+ uniform4iv(loc, value);
1453
1049
  }
1454
1050
  uniform4fv(location, value) {
1455
1051
  this._glCheckError('uniform4fv');
1456
1052
  this._checkArgs('uniform4fv', arguments);
1457
- const loc = location ? location.native : 0;
1458
- if (this._isSupported) {
1459
- if (!Array.isArray(value)) {
1460
- this.context.uniform4fvBuffer(loc, value);
1461
- }
1462
- else {
1463
- this.context.uniform4fv(loc, value);
1464
- }
1465
- }
1466
- else {
1467
- if (!Array.isArray(value)) {
1468
- this.context.uniform4fv(loc, Array.from(value));
1469
- }
1470
- else {
1471
- this.context.uniform4fv(loc, value);
1472
- }
1473
- }
1053
+ const loc = location.native;
1054
+ const uniform4fv = this._getMethod('uniform4fv');
1055
+ uniform4fv(loc, value);
1474
1056
  }
1475
1057
  uniform4i(location, v0, v1, v2, v3) {
1476
1058
  this._glCheckError('uniform4i');
1477
1059
  this._checkArgs('uniform4i', arguments);
1478
- const loc = location ? location.native : 0;
1479
- this.context.uniform4i(loc, v0, v1, v2, v3);
1060
+ const uniform4i = this._getMethod('uniform4i');
1061
+ const loc = location.native;
1062
+ uniform4i(loc, v0, v1, v2, v3);
1480
1063
  }
1481
1064
  uniformMatrix2fv(location, transpose, value) {
1482
1065
  this._glCheckError('uniformMatrix2fv');
1483
1066
  this._checkArgs('uniformMatrix2fv', arguments);
1484
- const loc = location ? location.native : 0;
1485
- if (this._isSupported) {
1486
- if (!Array.isArray(value)) {
1487
- this.context.uniformMatrix2fvBuffer(loc, transpose, value);
1488
- }
1489
- else {
1490
- this.context.uniformMatrix2fv(loc, transpose, value);
1491
- }
1492
- }
1493
- else {
1494
- if (!Array.isArray(value)) {
1495
- this.context.uniformMatrix2fv(loc, transpose, Array.from(value));
1496
- }
1497
- else {
1498
- this.context.uniformMatrix2fv(loc, transpose, value);
1499
- }
1500
- }
1067
+ const loc = location.native;
1068
+ const uniformMatrix2fv = this._getMethod('uniformMatrix2fv');
1069
+ uniformMatrix2fv(loc, transpose, value);
1501
1070
  }
1502
1071
  uniformMatrix3fv(location, transpose, value) {
1503
1072
  this._glCheckError('uniformMatrix3fv');
1504
1073
  this._checkArgs('uniformMatrix3fv', arguments);
1505
- const loc = location ? location.native : 0;
1506
- if (this._isSupported) {
1507
- if (!Array.isArray(value)) {
1508
- this.context.uniformMatrix3fvBuffer(loc, transpose, value);
1509
- }
1510
- else {
1511
- this.context.uniformMatrix3fv(loc, transpose, value);
1512
- }
1513
- }
1514
- else {
1515
- if (!Array.isArray(value)) {
1516
- this.context.uniformMatrix3fv(loc, transpose, Array.from(value));
1517
- }
1518
- else {
1519
- this.context.uniformMatrix3fv(loc, transpose, value);
1520
- }
1521
- }
1074
+ const loc = location.native;
1075
+ const uniformMatrix3fv = this._getMethod('uniformMatrix3fv');
1076
+ uniformMatrix3fv(loc, transpose, value);
1522
1077
  }
1523
1078
  uniformMatrix4fv(location, transpose, value) {
1524
1079
  this._glCheckError('uniformMatrix4fv');
1525
1080
  this._checkArgs('uniformMatrix4fv', arguments);
1526
- const loc = location ? location.native : 0;
1527
- if (this._isSupported) {
1528
- if (!Array.isArray(value)) {
1529
- this.context.uniformMatrix4fvBuffer(loc, transpose, value);
1530
- }
1531
- else {
1532
- this.context.uniformMatrix4fv(loc, transpose, value);
1533
- }
1534
- }
1535
- else {
1536
- if (!Array.isArray(value)) {
1537
- this.context.uniformMatrix4fv(loc, transpose, Array.from(value));
1538
- }
1539
- else {
1540
- this.context.uniformMatrix4fv(loc, transpose, value);
1541
- }
1542
- }
1081
+ const loc = location.native;
1082
+ const uniformMatrix4fv = this._getMethod('uniformMatrix4fv');
1083
+ uniformMatrix4fv(loc, transpose, value);
1543
1084
  }
1544
1085
  useProgram(program) {
1545
1086
  this._glCheckError('useProgram');
1546
1087
  this._checkArgs('useProgram', arguments);
1547
- const value = program ? program.native : 0;
1548
- this.context.useProgram(value);
1088
+ const useProgram = this._getMethod('useProgram');
1089
+ const value = program ? program.native : null;
1090
+ useProgram(value);
1549
1091
  }
1550
1092
  validateProgram(program) {
1551
1093
  this._glCheckError('validateProgram');
1552
1094
  this._checkArgs('validateProgram', arguments);
1553
- const value = program ? program.native : 0;
1554
- this.context.validateProgram(value);
1095
+ const validateProgram = this._getMethod('validateProgram');
1096
+ const value = program.native;
1097
+ validateProgram(value);
1555
1098
  }
1556
1099
  vertexAttrib1f(index, v0) {
1557
1100
  this._glCheckError('vertexAttrib1f');
1558
1101
  this._checkArgs('vertexAttrib1f', arguments);
1559
- this.context.vertexAttrib1f(index, v0);
1102
+ const vertexAttrib1f = this._getMethod('vertexAttrib1f');
1103
+ vertexAttrib1f(index, v0);
1560
1104
  }
1561
1105
  vertexAttrib1fv(index, value) {
1562
1106
  this._glCheckError('vertexAttrib1fv');
1563
1107
  this._checkArgs('vertexAttrib1fv', arguments);
1564
- if (this._isSupported) {
1565
- if (!Array.isArray(value)) {
1566
- this.context.vertexAttrib1fvBuffer(index, value);
1567
- }
1568
- else {
1569
- this.context.vertexAttrib1fv(index, value);
1570
- }
1571
- }
1572
- else {
1573
- if (!Array.isArray(value)) {
1574
- this.context.vertexAttrib1fv(index, Array.from(value));
1575
- }
1576
- else {
1577
- this.context.vertexAttrib1fv(index, value);
1578
- }
1579
- }
1108
+ const vertexAttrib1fv = this._getMethod('vertexAttrib1fv');
1109
+ vertexAttrib1fv(index, value);
1580
1110
  }
1581
1111
  vertexAttrib2f(index, v0, v1) {
1582
1112
  this._glCheckError('vertexAttrib2f');
1583
1113
  this._checkArgs('vertexAttrib2f', arguments);
1584
- this.context.vertexAttrib2f(index, v0, v1);
1114
+ const vertexAttrib2f = this._getMethod('vertexAttrib2f');
1115
+ vertexAttrib2f(index, v0, v1);
1585
1116
  }
1586
1117
  vertexAttrib2fv(index, value) {
1587
1118
  this._glCheckError('vertexAttrib2fv');
1588
1119
  this._checkArgs('vertexAttrib2fv', arguments);
1589
- if (this._isSupported) {
1590
- if (!Array.isArray(value)) {
1591
- this.context.vertexAttrib2fvBuffer(index, value);
1592
- }
1593
- else {
1594
- this.context.vertexAttrib2fv(index, value);
1595
- }
1596
- }
1597
- else {
1598
- if (!Array.isArray(value)) {
1599
- this.context.vertexAttrib2fv(index, Array.from(value));
1600
- }
1601
- else {
1602
- this.context.vertexAttrib2fv(index, value);
1603
- }
1604
- }
1120
+ const vertexAttrib2fv = this._getMethod('vertexAttrib2fv');
1121
+ vertexAttrib2fv(index, value);
1605
1122
  }
1606
1123
  vertexAttrib3f(index, v0, v1, v2) {
1607
1124
  this._glCheckError('vertexAttrib3f');
1608
1125
  this._checkArgs('vertexAttrib3f', arguments);
1609
- this.context.vertexAttrib3f(index, v0, v1, v2);
1126
+ const vertexAttrib3f = this._getMethod('vertexAttrib3f');
1127
+ vertexAttrib3f(index, v0, v1, v2);
1610
1128
  }
1611
1129
  vertexAttrib3fv(index, value) {
1612
1130
  this._glCheckError('vertexAttrib3fv');
1613
1131
  this._checkArgs('vertexAttrib3fv', arguments);
1614
- if (this._isSupported) {
1615
- if (!Array.isArray(value)) {
1616
- this.context.vertexAttrib3fvBuffer(index, value);
1617
- }
1618
- else {
1619
- this.context.vertexAttrib3fv(index, value);
1620
- }
1621
- }
1622
- else {
1623
- if (!Array.isArray(value)) {
1624
- this.context.vertexAttrib3fv(index, Array.from(value));
1625
- }
1626
- else {
1627
- this.context.vertexAttrib3fv(index, value);
1628
- }
1629
- }
1132
+ const vertexAttrib3fv = this._getMethod('vertexAttrib3fv');
1133
+ vertexAttrib3fv(index, value);
1630
1134
  }
1631
1135
  vertexAttrib4f(index, v0, v1, v2, v3) {
1632
1136
  this._glCheckError('vertexAttrib4f');
1633
1137
  this._checkArgs('vertexAttrib4f', arguments);
1634
- this.context.vertexAttrib4f(index, v0, v1, v2, v3);
1138
+ const vertexAttrib4f = this._getMethod('vertexAttrib4f');
1139
+ vertexAttrib4f(index, v0, v1, v2, v3);
1635
1140
  }
1636
1141
  vertexAttrib4fv(index, value) {
1637
1142
  this._glCheckError('vertexAttrib4fv');
1638
1143
  this._checkArgs('vertexAttrib4fv', arguments);
1639
- if (this._isSupported) {
1640
- if (!Array.isArray(value)) {
1641
- this.context.vertexAttrib4fvBuffer(index, value);
1642
- }
1643
- else {
1644
- this.context.vertexAttrib4fv(index, value);
1645
- }
1646
- }
1647
- else {
1648
- if (!Array.isArray(value)) {
1649
- this.context.vertexAttrib4fv(index, Array.from(value));
1650
- }
1651
- else {
1652
- this.context.vertexAttrib4fv(index, value);
1653
- }
1654
- }
1144
+ const vertexAttrib4fv = this._getMethod('vertexAttrib4fv');
1145
+ vertexAttrib4fv(index, value);
1655
1146
  }
1656
1147
  vertexAttribPointer(index, size, type, normalized, stride, offset) {
1657
1148
  this._glCheckError('vertexAttribPointer');
1658
1149
  this._checkArgs('vertexAttribPointer', arguments);
1659
- this.context.vertexAttribPointer(index, size, type, normalized, stride, offset);
1150
+ const vertexAttribPointer = this._getMethod('vertexAttribPointer');
1151
+ vertexAttribPointer(index, size, type, normalized, stride, offset);
1660
1152
  }
1661
1153
  viewport(x, y, width, height) {
1662
1154
  this._glCheckError('viewport');
1663
1155
  this._checkArgs('viewport', arguments);
1664
- this.context.viewport(x, y, width, height);
1156
+ const viewport = this._getMethod('viewport');
1157
+ viewport(x, y, width, height);
1665
1158
  }
1666
1159
  _glCheckError(message) {
1667
1160
  if (!WebGLRenderingContext.isDebug) {
@@ -1684,4 +1177,8 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1684
1177
  }
1685
1178
  WebGLRenderingContext.isDebug = false;
1686
1179
  WebGLRenderingContext.filter = 'both';
1180
+ (() => {
1181
+ Helpers.initialize();
1182
+ ctor = global.CanvasJSIModule.createWebGLContext;
1183
+ })();
1687
1184
  //# sourceMappingURL=index.android.js.map