@nativescript/canvas 1.1.0 → 2.0.0-alpha.1

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 (175) hide show
  1. package/Canvas/common.d.ts +1 -5
  2. package/Canvas/common.js +41 -133
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +4 -4
  5. package/Canvas/index.android.js +62 -52
  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 -42
  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 +212 -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 +92 -109
  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 +1 -4
  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 +1 -4
  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 +1 -4
  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 -292
  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/SVG/SVG.js.map +1 -1
  77. package/TextDecoder/TextDecoder.android.d.ts +2 -1
  78. package/TextDecoder/TextDecoder.android.js +35 -38
  79. package/TextDecoder/TextDecoder.android.js.map +1 -1
  80. package/TextDecoder/common.d.ts +0 -1
  81. package/TextDecoder/common.js +1 -4
  82. package/TextDecoder/common.js.map +1 -1
  83. package/TextEncoder/TextEncoder.android.d.ts +2 -0
  84. package/TextEncoder/TextEncoder.android.js +35 -5
  85. package/TextEncoder/TextEncoder.android.js.map +1 -1
  86. package/TextEncoder/common.d.ts +0 -2
  87. package/TextEncoder/common.js +0 -7
  88. package/TextEncoder/common.js.map +1 -1
  89. package/WebGL/WebGLActiveInfo.d.ts +5 -8
  90. package/WebGL/WebGLActiveInfo.js +8 -24
  91. package/WebGL/WebGLActiveInfo.js.map +1 -1
  92. package/WebGL/WebGLExtensions/index.android.d.ts +9 -0
  93. package/WebGL/WebGLExtensions/index.android.js +94 -57
  94. package/WebGL/WebGLExtensions/index.android.js.map +1 -1
  95. package/WebGL/WebGLProgram.d.ts +1 -0
  96. package/WebGL/WebGLProgram.js +3 -0
  97. package/WebGL/WebGLProgram.js.map +1 -1
  98. package/WebGL/WebGLRenderingContext/common.d.ts +3 -1
  99. package/WebGL/WebGLRenderingContext/common.js +188 -178
  100. package/WebGL/WebGLRenderingContext/common.js.map +1 -1
  101. package/WebGL/WebGLRenderingContext/index.android.d.ts +8 -13
  102. package/WebGL/WebGLRenderingContext/index.android.js +1272 -954
  103. package/WebGL/WebGLRenderingContext/index.android.js.map +1 -1
  104. package/WebGL/WebGLRenderingContext/index.d.ts +11 -14
  105. package/WebGL/WebGLRenderingContext/index.ios.js +6 -5
  106. package/WebGL/WebGLRenderingContext/index.ios.js.map +1 -1
  107. package/WebGL/WebGLShaderPrecisionFormat.d.ts +5 -4
  108. package/WebGL/WebGLShaderPrecisionFormat.js +11 -4
  109. package/WebGL/WebGLShaderPrecisionFormat.js.map +1 -1
  110. package/WebGL2/WebGL2RenderingContext/common.d.ts +1 -1
  111. package/WebGL2/WebGL2RenderingContext/common.js +199 -199
  112. package/WebGL2/WebGL2RenderingContext/common.js.map +1 -1
  113. package/WebGL2/WebGL2RenderingContext/index.android.d.ts +5 -6
  114. package/WebGL2/WebGL2RenderingContext/index.android.js +276 -318
  115. package/WebGL2/WebGL2RenderingContext/index.android.js.map +1 -1
  116. package/WebGL2/WebGL2RenderingContext/index.ios.js +1 -1
  117. package/WebGL2/WebGL2RenderingContext/index.ios.js.map +1 -1
  118. package/angular/esm2020/index.mjs +5 -5
  119. package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
  120. package/angular/fesm2015/nativescript-canvas-angular.mjs.map +1 -1
  121. package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
  122. package/angular/fesm2020/nativescript-canvas-angular.mjs.map +1 -1
  123. package/angular/nativescript-canvas-angular.d.ts +5 -0
  124. package/angular/package.json +2 -2
  125. package/helpers.d.ts +5 -0
  126. package/helpers.js +18 -0
  127. package/helpers.js.map +1 -0
  128. package/index.js +6 -0
  129. package/index.js.map +1 -1
  130. package/package.json +2 -3
  131. package/platforms/android/canvas-release.aar +0 -0
  132. package/platforms/android/include.gradle +5 -6
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +33 -89
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +1 -1
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64.swiftsourceinfo +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +22 -49
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64.swiftdoc +0 -0
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/{arm64-apple-ios.private.swiftinterface → arm64.swiftinterface} +22 -49
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/module.modulemap +2 -2
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +66 -168
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +1 -1
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64.swiftsourceinfo +0 -0
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64.swiftsourceinfo +0 -0
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +22 -49
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64.swiftdoc +0 -0
  156. 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
  157. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  158. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +22 -49
  159. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64.swiftdoc +0 -0
  160. 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
  161. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/module.modulemap +2 -2
  162. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +83 -50
  163. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  164. package/utils.d.ts +1 -3
  165. package/utils.js +20 -7
  166. package/utils.js.map +1 -1
  167. package/LICENSE +0 -201
  168. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +0 -1636
  169. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +0 -75693
  170. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +0 -1636
  171. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -75693
  172. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -75693
  173. package/typings/objc!CanvasNative.d.ts +0 -2036
  174. package/typings/objc!CanvasNative.js +0 -1
  175. package/typings/objc!CanvasNative.js.map +0 -1
@@ -6,294 +6,290 @@ import { WebGLFramebuffer } from '../../WebGL/WebGLFramebuffer';
6
6
  import { WebGLActiveInfo } from '../../WebGL/WebGLActiveInfo';
7
7
  import { WebGLBuffer } from '../../WebGL/WebGLBuffer';
8
8
  import { ImageAsset } from '../../ImageAsset';
9
- import { ImageSource } from '@nativescript/core';
9
+ import { ImageSource, Screen } from '@nativescript/core';
10
10
  import { WebGL2RenderingContextBase } from './common';
11
11
  import { Canvas } from '../../Canvas';
12
12
  import { ImageBitmap } from '../../ImageBitmap';
13
+ import { Helpers } from '../../helpers';
14
+ let ctor;
13
15
  export class WebGL2RenderingContext extends WebGL2RenderingContextBase {
14
- constructor(context) {
15
- super(context);
16
- }
17
- /* Transform feedback */
18
- static toPrimitive(value) {
19
- if (value instanceof java.lang.Integer) {
20
- return value.intValue();
21
- }
22
- else if (value instanceof java.lang.Long) {
23
- return value.longValue();
24
- }
25
- else if (value instanceof java.lang.Short) {
26
- return value.shortValue();
27
- }
28
- else if (value instanceof java.lang.Byte) {
29
- return value.byteValue();
30
- }
31
- else if (value instanceof java.lang.Boolean) {
32
- return value.booleanValue();
33
- }
34
- else if (value instanceof java.lang.String) {
35
- return value.toString();
36
- }
37
- else if (value instanceof java.lang.Float) {
38
- return value.floatValue();
16
+ constructor(context, contextOptions) {
17
+ super(null);
18
+ const ctx = BigInt(context.getNativeContext().toString());
19
+ let direction = 0;
20
+ if (androidx.core.text.TextUtilsCompat.getLayoutDirectionFromLocale(java.util.Locale.getDefault()) === androidx.core.view.ViewCompat.LAYOUT_DIRECTION_RTL) {
21
+ direction = 1;
39
22
  }
40
- else if (value instanceof java.lang.Double) {
41
- return value.doubleValue();
42
- }
43
- return value;
23
+ const native = ctor(contextOptions, ctx, Screen.mainScreen.scale, -16777216, Screen.mainScreen.scale * 160, direction);
24
+ this._context = native;
44
25
  }
26
+ /* Transform feedback */
45
27
  beginQuery(target, query) {
46
28
  this._glCheckError('beginQuery');
47
- const value = query ? query.native : 0;
48
- this.native.beginQuery(target, value);
29
+ const value = query.native;
30
+ const beginQuery = this._getMethod('beginQuery');
31
+ beginQuery(target, value);
49
32
  }
50
33
  beginTransformFeedback(primitiveMode) {
51
34
  this._glCheckError('beginTransformFeedback');
52
- this.native.beginTransformFeedback(primitiveMode);
35
+ const beginTransformFeedback = this._getMethod('beginTransformFeedback');
36
+ beginTransformFeedback(primitiveMode);
53
37
  }
54
38
  bindBufferBase(target, index, buffer) {
55
39
  this._glCheckError('bindBufferBase');
56
- const value = buffer ? buffer.native : 0;
57
- this.native.bindBufferBase(target, index, value);
40
+ const value = buffer ? buffer.native : null;
41
+ const bindBufferBase = this._getMethod('bindBufferBase');
42
+ bindBufferBase(target, index, value);
58
43
  }
59
44
  bindBufferRange(target, index, buffer, offset, size) {
60
45
  this._glCheckError('bindBufferRange');
61
- const value = buffer ? buffer.native : 0;
62
- this.native.bindBufferRange(target, index, value, offset, size);
46
+ const value = buffer ? buffer.native : null;
47
+ const bindBufferRange = this._getMethod('bindBufferRange');
48
+ bindBufferRange(target, index, value, offset, size);
63
49
  }
64
50
  bindSampler(unit, sampler) {
65
51
  this._glCheckError('bindSampler');
66
- const value = sampler ? sampler.native : 0;
67
- this.native.bindSampler(unit, value);
52
+ const value = sampler ? sampler.native : null;
53
+ const bindSampler = this._getMethod('bindSampler');
54
+ bindSampler(unit, value);
68
55
  }
69
56
  bindTransformFeedback(target, transformFeedback) {
70
57
  this._glCheckError('bindTransformFeedback');
71
- const value = transformFeedback ? transformFeedback.native : 0;
72
- this.native.bindTransformFeedback(target, value);
58
+ const value = transformFeedback ? transformFeedback.native : null;
59
+ const bindTransformFeedback = this._getMethod('bindTransformFeedback');
60
+ bindTransformFeedback(target, value);
73
61
  }
74
62
  bindVertexArray(vertexArray) {
75
63
  this._glCheckError('bindVertexArray');
76
- const value = vertexArray ? vertexArray.native : 0;
77
- if (value) {
78
- this.native.bindVertexArray(value);
79
- }
80
- else {
81
- this.native.bindVertexArray();
82
- }
64
+ const value = vertexArray ? vertexArray.native : null;
65
+ const bindVertexArray = this._getMethod('bindVertexArray');
66
+ bindVertexArray(value);
83
67
  }
84
68
  blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter) {
85
69
  this._glCheckError('blitFramebuffer');
86
- this.native.blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
70
+ const blitFramebuffer = this._getMethod('blitFramebuffer');
71
+ blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
87
72
  }
88
73
  clearBufferfi(buffer, drawbuffer, depth, stencil) {
89
74
  this._glCheckError('clearBufferfi');
90
- const value = buffer ? buffer.native : 0;
91
- this.native.clearBufferfi(value, drawbuffer, depth, stencil);
75
+ const value = buffer.native;
76
+ const clearBufferfi = this._getMethod('clearBufferfi');
77
+ clearBufferfi(value, drawbuffer, depth, stencil);
92
78
  }
93
79
  clearBufferfv(buffer, drawbuffer, values) {
94
80
  this._glCheckError('clearBufferfv');
95
- const value = buffer ? buffer.native : 0;
96
- if (values instanceof Float32Array) {
97
- values = this.toNativeArray(values, 'float');
98
- }
99
- this.native.clearBufferfv(value, drawbuffer, values);
81
+ const clearBufferfv = this._getMethod('clearBufferfv');
82
+ const value = buffer.native;
83
+ clearBufferfv(value, drawbuffer, values);
100
84
  }
101
85
  clearBufferiv(buffer, drawbuffer, values) {
102
86
  this._glCheckError('clearBufferiv');
87
+ const clearBufferiv = this._getMethod('clearBufferiv');
103
88
  const value = buffer ? buffer.native : 0;
104
- if (values instanceof Int32Array) {
105
- values = this.toNativeArray(values, 'int');
106
- }
107
- this.native.clearBufferiv(value, drawbuffer, values);
89
+ clearBufferiv(value, drawbuffer, values);
108
90
  }
109
91
  clearBufferuiv(buffer, drawbuffer, values) {
110
92
  this._glCheckError('clearBufferuiv');
93
+ const clearBufferuiv = this._getMethod('clearBufferuiv');
111
94
  const value = buffer ? buffer.native : 0;
112
- if (values instanceof Uint32Array) {
113
- values = this.toNativeArray(values, 'int');
114
- }
115
- this.native.clearBufferuiv(value, drawbuffer, values);
95
+ clearBufferuiv(value, drawbuffer, values);
116
96
  }
117
97
  clientWaitSync(sync, flags, timeout) {
118
98
  this._glCheckError('clientWaitSync');
119
- const value = sync ? sync.native : 0;
120
- return this.native.clientWaitSync(value, flags, timeout);
99
+ const clientWaitSync = this._getMethod('clientWaitSync');
100
+ const value = sync.native;
101
+ return clientWaitSync(value, flags, timeout);
121
102
  }
122
103
  compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, srcData, srcOffset = 0, srcLengthOverride = 0) {
123
104
  this._glCheckError('compressedTexSubImage3D');
124
- if (typeof srcOffset === 'number') {
125
- this.native.compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, srcData, srcOffset);
126
- }
127
- else if (srcData && srcData.buffer) {
128
- if (srcData instanceof Uint8Array) {
129
- this.native.compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, this.toNativeArray(srcData, 'byte'), srcOffset, srcLengthOverride);
130
- }
131
- }
105
+ const compressedTexSubImage3D = this._getMethod('compressedTexSubImage3D');
106
+ compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, srcData, srcOffset);
132
107
  }
133
108
  /* Transform feedback */
134
109
  /* Framebuffers and renderbuffers */
135
110
  copyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size) {
136
111
  this._glCheckError('copyBufferSubData');
137
- this.native.copyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
112
+ const copyBufferSubData = this._getMethod('copyBufferSubData');
113
+ copyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
138
114
  }
139
115
  copyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height) {
140
116
  this._glCheckError('copyTexSubImage3D');
141
- this.native.copyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
117
+ const copyTexSubImage3D = this._getMethod('copyTexSubImage3D');
118
+ copyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
142
119
  }
143
120
  createQuery() {
144
121
  this._glCheckError('createQuery');
145
- return new WebGLQuery(this.native.createQuery());
122
+ const createQuery = this._getMethod('createQuery');
123
+ return new WebGLQuery(createQuery());
146
124
  }
147
125
  createSampler() {
148
126
  this._glCheckError('createSampler');
149
- return new WebGLSampler(this.native.createSampler());
127
+ const createSampler = this._getMethod('createSampler');
128
+ return new WebGLSampler(createSampler());
150
129
  }
151
130
  createTransformFeedback() {
152
131
  this._glCheckError('createTransformFeedback');
153
- return new WebGLTransformFeedback(this.native.createTransformFeedback());
132
+ const createTransformFeedback = this._getMethod('createTransformFeedback');
133
+ return new WebGLTransformFeedback(createTransformFeedback());
154
134
  }
155
135
  createVertexArray() {
156
136
  this._glCheckError('createVertexArray');
157
- return new WebGLVertexArrayObject(this.native.createVertexArray());
158
- }
159
- deleteQueryWithQuery(query) {
160
- this._glCheckError('deleteQueryWithQuery');
161
- const value = query ? query.native : 0;
162
- this.native.deleteQuery(value);
163
- }
164
- deleteSamplerWithSampler(sampler) {
165
- this._glCheckError('deleteSamplerWithSampler');
166
- const value = sampler ? sampler.native : 0;
167
- this.native.deleteSampler(value);
168
- }
169
- deleteSyncWithSync(sync) {
170
- this._glCheckError('deleteSyncWithSync');
171
- const value = sync ? sync.native : 0;
172
- this.native.deleteSync(value);
137
+ const createVertexArray = this._getMethod('createVertexArray');
138
+ return new WebGLVertexArrayObject(createVertexArray());
139
+ }
140
+ deleteQuery(query) {
141
+ this._glCheckError('deleteQuery');
142
+ const deleteQuery = this._getMethod('deleteQuery');
143
+ const value = query.native;
144
+ deleteQuery(value);
145
+ }
146
+ deleteSampler(sampler) {
147
+ this._glCheckError('deleteSampler');
148
+ const deleteSampler = this._getMethod('deleteSampler');
149
+ const value = sampler.native;
150
+ deleteSampler(value);
151
+ }
152
+ deleteSync(sync) {
153
+ this._glCheckError('deleteSync');
154
+ const deleteSync = this._getMethod('deleteSync');
155
+ const value = sync.native;
156
+ deleteSync(value);
173
157
  }
174
158
  deleteTransformFeedback(transformFeedback) {
175
159
  this._glCheckError('deleteTransformFeedback');
176
- const value = transformFeedback ? transformFeedback.native : 0;
177
- this.native.deleteTransformFeedback(value);
160
+ const deleteTransformFeedback = this._getMethod('deleteTransformFeedback');
161
+ const value = transformFeedback.native;
162
+ deleteTransformFeedback(value);
178
163
  }
179
164
  deleteVertexArray(vertexArray) {
180
165
  this._glCheckError('deleteVertexArray');
181
- const value = vertexArray ? vertexArray.native : 0;
182
- this.native.deleteVertexArray(value);
166
+ const deleteVertexArray = this._getMethod('deleteVertexArray');
167
+ const value = vertexArray.native;
168
+ deleteVertexArray(value);
183
169
  }
184
170
  drawArraysInstanced(mode, first, count, instanceCount) {
185
171
  this._glCheckError('drawArraysInstanced');
186
- this.native.drawArraysInstanced(mode, first, count, instanceCount);
172
+ const drawArraysInstanced = this._getMethod('drawArraysInstanced');
173
+ drawArraysInstanced(mode, first, count, instanceCount);
187
174
  }
188
175
  drawBuffers(buffers) {
189
176
  this._glCheckError('drawBuffers');
190
- this.native.drawBuffers(buffers);
177
+ const drawBuffers = this._getMethod('drawBuffers');
178
+ drawBuffers(buffers);
191
179
  }
192
180
  drawElementsInstanced(mode, count, type, offset, instanceCount) {
193
181
  this._glCheckError('drawElementsInstanced');
194
- this.native.drawElementsInstanced(mode, count, type, offset, instanceCount);
182
+ const drawElementsInstanced = this._getMethod('drawElementsInstanced');
183
+ drawElementsInstanced(mode, count, type, offset, instanceCount);
195
184
  }
196
185
  drawRangeElements(mode, start, end, count, type, offset) {
197
186
  this._glCheckError('drawRangeElements');
198
- this.native.drawRangeElements(mode, start, end, count, type, offset);
187
+ const drawRangeElements = this._getMethod('drawRangeElements');
188
+ drawRangeElements(mode, start, end, count, type, offset);
199
189
  }
200
190
  endQuery(target) {
201
191
  this._glCheckError('endQuery');
202
- this.native.endQuery(target);
192
+ const endQuery = this._getMethod('endQuery');
193
+ endQuery(target);
203
194
  }
204
195
  endTransformFeedback() {
205
196
  this._glCheckError('endTransformFeedback');
206
- this.native.endTransformFeedback();
197
+ const endTransformFeedback = this._getMethod('endTransformFeedback');
198
+ endTransformFeedback();
207
199
  }
208
200
  fenceSync(condition, flags) {
209
201
  this._glCheckError('fenceSync');
210
- this.native.fenceSync(condition, flags);
202
+ const fenceSync = this._getMethod('fenceSync');
203
+ fenceSync(condition, flags);
211
204
  }
212
205
  framebufferTextureLayer(target, attachment, texture, level, layer) {
213
206
  this._glCheckError('framebufferTextureLayer');
214
- const value = texture ? texture.native : 0;
215
- this.native.framebufferTextureLayer(target, attachment, value, level, layer);
207
+ const framebufferTextureLayer = this._getMethod('framebufferTextureLayer');
208
+ const value = texture.native;
209
+ framebufferTextureLayer(target, attachment, value, level, layer);
216
210
  }
217
211
  /* Framebuffers and renderbuffers */
218
212
  /* Uniforms */
219
213
  getActiveUniformBlockName(program, uniformBlockIndex) {
220
214
  this._glCheckError('getActiveUniformBlockName');
221
- const value = program ? program.native : 0;
222
- return this.native.getActiveUniformBlockName(value, uniformBlockIndex);
215
+ const getActiveUniformBlockName = this._getMethod('getActiveUniformBlockName');
216
+ const value = program.native;
217
+ return getActiveUniformBlockName(value, uniformBlockIndex);
223
218
  }
224
219
  getActiveUniformBlockParameter(program, uniformBlockIndex, pname) {
225
220
  this._glCheckError('getActiveUniformBlockParameter');
226
- const value = program ? program.native : 0;
227
- const param = this.native.getActiveUniformBlockParameter(value, uniformBlockIndex, pname);
228
- if (pname === this.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) {
229
- return new Uint32Array(this.getJSArray(param));
230
- }
231
- return WebGL2RenderingContext.toPrimitive(param);
221
+ const getActiveUniformBlockParameter = this._getMethod('getActiveUniformBlockParameter');
222
+ const value = program.native;
223
+ return getActiveUniformBlockParameter(value, uniformBlockIndex, pname);
232
224
  }
233
225
  getActiveUniforms(program, uniformIndices, pname) {
234
226
  this._glCheckError('getActiveUniforms');
235
- const value = program ? program.native : 0;
236
- return this.getJSArray(this.native.getActiveUniforms(value, uniformIndices, pname));
227
+ const getActiveUniforms = this._getMethod('getActiveUniforms');
228
+ const value = program.native;
229
+ return getActiveUniforms(value, uniformIndices, pname);
237
230
  }
238
231
  getBufferSubData(target, srcByteOffset, dstData, dstOffset = 0, length = 0) {
239
232
  this._glCheckError('getBufferSubData');
240
- this.native.getBufferSubData(target, srcByteOffset, new Uint8Array(dstData.slice(0)), dstOffset, length);
233
+ const getBufferSubData = this._getMethod('getBufferSubData');
234
+ getBufferSubData(target, srcByteOffset, dstData, dstOffset, length);
241
235
  }
242
236
  getFragDataLocation(program, name) {
243
237
  this._glCheckError('getFragDataLocation');
244
- const value = program ? program.native : 0;
245
- const result = this.native.getFragDataLocation(value, name);
238
+ const getFragDataLocation = this._getMethod('getFragDataLocation');
239
+ const value = program.native;
240
+ const result = getFragDataLocation(value, name);
246
241
  return result !== -1 ? result : null;
247
242
  }
248
243
  getIndexedParameter(target, index) {
249
244
  this._glCheckError('getIndexedParameter');
250
- const param = this.native.getIndexedParameter(target, index);
245
+ const getIndexedParameter = this._getMethod('getIndexedParameter');
246
+ const param = getIndexedParameter(target, index);
251
247
  if (target === this.TRANSFORM_FEEDBACK_BUFFER_BINDING || target === this.UNIFORM_BUFFER_BINDING) {
252
248
  return new WebGLBuffer(param);
253
249
  }
254
- return WebGL2RenderingContext.toPrimitive(param);
250
+ return param;
255
251
  }
256
252
  getInternalformatParameter(target, internalformat, pname) {
257
253
  this._glCheckError('getInternalformatParameter');
258
- const param = this.native.getInternalformatParameter(target, internalformat, pname);
259
- if (pname === this.SAMPLES) {
260
- return new Int32Array(this.getJSArray(param));
261
- }
262
- return WebGL2RenderingContext.toPrimitive(param);
254
+ const getInternalformatParameter = this._getMethod('getInternalformatParameter');
255
+ return getInternalformatParameter(target, internalformat, pname);
263
256
  }
264
257
  getQueryParameter(query, pname) {
265
258
  this._glCheckError('getQueryParameter');
266
- const value = query ? query.native : 0;
267
- const result = this.native.getQueryParameter(value, pname);
259
+ const getQueryParameter = this._getMethod('getQueryParameter');
260
+ const value = query.native;
261
+ const result = getQueryParameter(value, pname);
268
262
  if (result === 0) {
269
263
  return null;
270
264
  }
271
- return WebGL2RenderingContext.toPrimitive(result);
265
+ return result;
272
266
  }
273
267
  //@ts-ignore
274
268
  getParameter(pname) {
275
269
  this._glCheckError('getParameter');
276
- this._checkArgs('activeTexture', arguments);
277
- const value = this.native.getParameter(pname);
270
+ this._checkArgs('getParameter', arguments);
271
+ const getParameter = this._getMethod('getParameter');
272
+ const value = getParameter(pname);
278
273
  switch (pname) {
279
274
  case this.COPY_READ_BUFFER_BINDING:
280
275
  case this.COPY_WRITE_BUFFER_BINDING:
281
276
  if (value) {
282
- new WebGLBuffer(WebGL2RenderingContext.toPrimitive(value));
277
+ return new WebGLBuffer(value);
283
278
  }
284
279
  return null;
285
280
  case this.DRAW_FRAMEBUFFER_BINDING:
286
281
  if (value) {
287
- return new WebGLFramebuffer(WebGL2RenderingContext.toPrimitive(value));
282
+ return new WebGLFramebuffer(value);
288
283
  }
289
284
  return null;
290
285
  default:
291
- return super.getParameter(pname);
286
+ return this._handleGetParameter(pname, value);
292
287
  }
293
288
  }
294
289
  getQuery(target, pname) {
295
290
  this._glCheckError('getQuery');
296
- const query = this.native.getQuery(target, pname);
291
+ const getQuery = this._getMethod('getQuery');
292
+ const query = getQuery(target, pname);
297
293
  if (query) {
298
294
  return new WebGLQuery(query);
299
295
  }
@@ -301,368 +297,330 @@ export class WebGL2RenderingContext extends WebGL2RenderingContextBase {
301
297
  }
302
298
  getSamplerParameter(sampler, pname) {
303
299
  this._glCheckError('getSamplerParameter');
304
- const value = sampler ? sampler.native : 0;
305
- return WebGL2RenderingContext.toPrimitive(this.native.getSamplerParameter(value, pname));
300
+ const getSamplerParameter = this._getMethod('getSamplerParameter');
301
+ const value = sampler.native;
302
+ return getSamplerParameter(value, pname);
306
303
  }
307
304
  getSyncParameter(sync, pname) {
308
305
  this._glCheckError('getSyncParameter');
309
- const value = sync ? sync.native : 0;
310
- return WebGL2RenderingContext.toPrimitive(this.native.getSyncParameter(value, pname));
306
+ const getSyncParameter = this._getMethod('getSyncParameter');
307
+ const value = sync.native;
308
+ return getSyncParameter(value, pname);
311
309
  }
312
310
  getTransformFeedbackVarying(program, index) {
313
311
  this._glCheckError('getTransformFeedbackVarying');
314
- const value = program ? program.native : 0;
315
- const info = this.native.getTransformFeedbackVarying(value, index);
312
+ const value = program.native;
313
+ const getTransformFeedbackVarying = this._getMethod('getTransformFeedbackVarying');
314
+ const info = getTransformFeedbackVarying(value, index);
316
315
  if (info) {
317
- return new WebGLActiveInfo(info.name, info.size, info.size);
316
+ return new WebGLActiveInfo(info);
318
317
  }
319
318
  return null;
320
319
  }
321
320
  getUniformBlockIndex(program, uniformBlockName) {
322
321
  this._glCheckError('getUniformBlockIndex');
323
- const value = program ? program.native : 0;
324
- return this.native.getUniformBlockIndex(value, uniformBlockName);
322
+ const getUniformBlockIndex = this._getMethod('getUniformBlockIndex');
323
+ const value = program.native;
324
+ return getUniformBlockIndex(value, uniformBlockName);
325
325
  }
326
326
  getUniformIndices(program, uniformNames) {
327
327
  this._glCheckError('getUniformIndices');
328
- const value = program ? program.native : 0;
329
- return this.getJSArray(this.native.getUniformIndices(value, uniformNames));
328
+ const getUniformIndices = this._getMethod('getUniformIndices');
329
+ const value = program.native;
330
+ return getUniformIndices(value, uniformNames);
330
331
  }
331
332
  invalidateFramebuffer(target, attachments) {
332
333
  this._glCheckError('invalidateFramebuffer');
333
- this.native.invalidateFramebuffer(target, attachments);
334
+ const invalidateFramebuffer = this._getMethod('invalidateFramebuffer');
335
+ invalidateFramebuffer(target, attachments);
334
336
  }
335
337
  invalidateSubFramebuffer(target, attachments, x, y, width, height) {
336
338
  this._glCheckError('invalidateSubFramebuffer');
337
- this.native.invalidateSubFramebuffer(target, attachments, x, y, width, height);
339
+ const invalidateSubFramebuffer = this._getMethod('invalidateSubFramebuffer');
340
+ invalidateSubFramebuffer(target, attachments, x, y, width, height);
338
341
  }
339
342
  isQuery(query) {
340
343
  this._glCheckError('isQuery');
341
- const value = query ? query.native : 0;
342
- return this.native.isQuery(value);
344
+ const isQuery = this._getMethod('isQuery');
345
+ const value = query.native;
346
+ return isQuery(value);
343
347
  }
344
348
  isSampler(sampler) {
345
349
  this._glCheckError('isSampler');
346
- const value = sampler ? sampler.native : 0;
347
- return this.native.isSampler(value);
350
+ const isSampler = this._getMethod('isSampler');
351
+ const value = sampler.native;
352
+ return isSampler(value);
348
353
  }
349
354
  isSync(sync) {
350
355
  this._glCheckError('isSync');
351
- const value = sync ? sync.native : 0;
352
- return this.native.isSync(value);
356
+ const isSync = this._getMethod('isSync');
357
+ const value = sync.native;
358
+ return isSync(value);
353
359
  }
354
360
  isTransformFeedback(transformFeedback) {
355
361
  this._glCheckError('isTransformFeedback');
356
- const value = transformFeedback ? transformFeedback.native : 0;
357
- return this.native.isTransformFeedback(value);
362
+ const isTransformFeedback = this._getMethod('isTransformFeedback');
363
+ const value = transformFeedback.native;
364
+ return isTransformFeedback(value);
358
365
  }
359
366
  isVertexArray(vertexArray) {
360
367
  this._glCheckError('isVertexArray');
361
- const value = vertexArray ? vertexArray.native : 0;
362
- return this.native.isVertexArray(value);
368
+ const isVertexArray = this._getMethod('isVertexArray');
369
+ const value = vertexArray.native;
370
+ return isVertexArray(value);
363
371
  }
364
372
  pauseTransformFeedback() {
365
373
  this._glCheckError('pauseTransformFeedback');
366
- this.native.pauseTransformFeedback();
374
+ const pauseTransformFeedback = this._getMethod('pauseTransformFeedback');
375
+ pauseTransformFeedback();
367
376
  }
368
377
  readBuffer(src) {
369
378
  this._glCheckError('readBuffer');
370
- this.native.readBuffer(src);
379
+ const readBuffer = this._getMethod('readBuffer');
380
+ readBuffer(src);
371
381
  }
372
382
  renderbufferStorageMultisample(target, samples, internalFormat, width, height) {
373
383
  this._glCheckError('renderbufferStorageMultisample');
374
- this.native.renderbufferStorageMultisample(target, samples, internalFormat, width, height);
384
+ const renderbufferStorageMultisample = this._getMethod('renderbufferStorageMultisample');
385
+ renderbufferStorageMultisample(target, samples, internalFormat, width, height);
375
386
  }
376
387
  resumeTransformFeedback() {
377
388
  this._glCheckError('resumeTransformFeedback');
378
- this.native.resumeTransformFeedback();
389
+ const resumeTransformFeedback = this._getMethod('resumeTransformFeedback');
390
+ resumeTransformFeedback();
379
391
  }
380
392
  samplerParameterf(sampler, pname, param) {
381
393
  this._glCheckError('samplerParameterf');
382
- const value = sampler ? sampler.native : 0;
383
- this.native.samplerParameterf(value, pname, param);
394
+ const samplerParameterf = this._getMethod('samplerParameterf');
395
+ const value = sampler.native;
396
+ samplerParameterf(value, pname, param);
384
397
  }
385
398
  /* Uniforms */
386
399
  /* Sync objects */
387
400
  samplerParameteri(sampler, pname, param) {
388
401
  this._glCheckError('samplerParameteri');
389
- const value = sampler ? sampler.native : 0;
390
- this.native.samplerParameteri(value, pname, param);
402
+ const samplerParameteri = this._getMethod('samplerParameteri');
403
+ const value = sampler.native;
404
+ samplerParameteri(value, pname, param);
391
405
  }
392
406
  texImage3D(target, level, internalformat, width, height, depth, border, format, type, source) {
393
407
  this._glCheckError('texImage3D');
408
+ const texImage3D = this._getMethod('texImage3D');
394
409
  if (typeof source === 'number') {
395
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source);
410
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source);
396
411
  }
397
412
  else if (source && source.buffer) {
398
- if (source && source.buffer) {
399
- if (source instanceof Uint8Array || source instanceof Uint8ClampedArray) {
400
- this.native.texImage3DByte(target, level, internalformat, width, height, depth, border, format, type, Array.from(source));
401
- }
402
- else if (source instanceof Uint16Array || source instanceof Int16Array) {
403
- this.native.texImage3DShort(target, level, internalformat, width, height, depth, border, format, type, Array.from(source));
404
- }
405
- else if (source instanceof Uint32Array || source instanceof Int32Array) {
406
- this.native.texImage3DInt(target, level, internalformat, width, height, depth, border, format, type, Array.from(source));
407
- }
408
- else if (source instanceof Float32Array) {
409
- this.native.texImage3DFloat(target, level, internalformat, width, height, depth, border, format, type, Array.from(source));
410
- }
411
- else if (source instanceof Float64Array) {
412
- this.native.texImage3DDouble(target, level, internalformat, width, height, depth, border, format, type, Array.from(source));
413
- }
414
- }
415
- else if (source instanceof ArrayBuffer) {
416
- // @ts-ignore
417
- if (source.nativeObject) {
418
- // @ts-ignore
419
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type,
420
- // @ts-ignore
421
- source.nativeObject);
422
- }
423
- else {
424
- this.native.texImage3DByte(target, level, internalformat, width, height, depth, border, format, type, Array.from(new Uint8Array(source)));
425
- }
426
- }
413
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source);
427
414
  }
428
415
  else if (source instanceof android.graphics.Bitmap) {
429
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source);
416
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source);
430
417
  }
431
418
  else if (source instanceof ImageSource) {
432
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source.android);
419
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source.android);
433
420
  }
434
421
  else if (source instanceof ImageAsset) {
435
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source.native);
422
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source.native);
436
423
  }
437
- else if (source instanceof ImageBitmap || source?.native instanceof org.nativescript.canvas.TNSImageBitmap) {
438
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source.native);
424
+ else if (source instanceof ImageBitmap) {
425
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source.native);
439
426
  }
440
427
  else if (source && typeof source.tagName === 'string' && (source.tagName === 'IMG' || source.tagName === 'IMAGE')) {
441
428
  if (source._imageSource instanceof ImageSource) {
442
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._imageSource.android);
429
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._imageSource.android);
443
430
  }
444
431
  else if (source._image instanceof android.graphics.Bitmap) {
445
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._image);
432
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._image);
446
433
  }
447
434
  else if (source._asset instanceof ImageAsset) {
448
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._asset.native);
435
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._asset.native);
449
436
  }
450
437
  else if (typeof source.src === 'string') {
451
438
  const result = ImageSource.fromFileSync(source.src);
452
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, result ? result.android : null);
439
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, result ? result.android : null);
453
440
  }
454
441
  }
455
442
  else if (source && typeof source.tagName === 'string' && source.tagName === 'CANVAS' && source._canvas instanceof Canvas) {
456
- this.native.texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._canvas.android);
443
+ texImage3D(target, level, internalformat, width, height, depth, border, format, type, source._canvas.native);
457
444
  }
458
445
  }
459
446
  texStorage2D(target, levels, internalformat, width, height) {
460
447
  this._glCheckError('texStorage2D');
461
- this.native.texStorage2D(target, levels, internalformat, width, height);
448
+ const texStorage2D = this._getMethod('texStorage2D');
449
+ texStorage2D(target, levels, internalformat, width, height);
462
450
  }
463
451
  texStorage3D(target, levels, internalformat, width, height, depth) {
464
452
  this._glCheckError('texStorage3D');
465
- this.native.texStorage3D(target, levels, internalformat, width, height, depth);
453
+ const texStorage3D = this._getMethod('texStorage3D');
454
+ texStorage3D(target, levels, internalformat, width, height, depth);
466
455
  }
467
456
  texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData, srcOffset = 0) {
468
457
  this._glCheckError('texSubImage3D');
458
+ const texSubImage3D = this._getMethod('texSubImage3D');
469
459
  if (typeof srcData === 'number') {
470
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData);
460
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData);
471
461
  }
472
462
  else if (srcData && srcData.buffer) {
473
- if (srcData instanceof Uint8Array) {
474
- if (srcOffset) {
475
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, this.toNativeArray(srcData, 'byte'), srcOffset);
476
- }
477
- else {
478
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, this.toNativeArray(srcData, 'byte'));
479
- }
480
- }
481
- if (srcData && srcData.buffer) {
482
- if (srcData instanceof Uint8Array || srcData instanceof Uint8ClampedArray) {
483
- this.native.texSubImage3DByte(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, Array.from(srcData), srcOffset);
484
- }
485
- else if (srcData instanceof Uint16Array || srcData instanceof Int16Array) {
486
- this.native.texSubImage3DShort(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, Array.from(srcData), srcOffset);
487
- }
488
- else if (srcData instanceof Uint32Array || srcData instanceof Int32Array) {
489
- this.native.texSubImage3DInt(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, Array.from(srcData), srcOffset);
490
- }
491
- else if (srcData instanceof Float32Array) {
492
- this.native.texSubImage3DFloat(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, Array.from(srcData), srcOffset);
493
- }
494
- else if (srcData instanceof Float64Array) {
495
- this.native.texSubImage3DDouble(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, Array.from(srcData), srcOffset);
496
- }
497
- }
498
- else if (srcData instanceof ArrayBuffer) {
499
- // @ts-ignore
500
- if (source.nativeObject) {
501
- this.native.texSubImage3DByte(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type,
502
- // @ts-ignore
503
- source.nativeObject, srcOffset);
504
- }
505
- else {
506
- this.native.texSubImage3DDouble(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, Array.from(new Uint8Array(srcData)), srcOffset);
507
- }
508
- }
463
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData, srcOffset);
509
464
  }
510
465
  else if (srcData instanceof android.graphics.Bitmap) {
511
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData);
466
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData);
512
467
  }
513
468
  else if (srcData instanceof ImageSource) {
514
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData.android);
469
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData.android);
515
470
  }
516
471
  else if (srcData instanceof ImageAsset) {
517
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData.native);
472
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData.native);
518
473
  }
519
- else if (srcData instanceof ImageBitmap || srcData?.native instanceof org.nativescript.canvas.TNSImageBitmap) {
520
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData.native);
474
+ else if (srcData instanceof ImageBitmap) {
475
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData.native);
521
476
  }
522
477
  else if (srcData && typeof srcData.tagName === 'string' && (srcData.tagName === 'IMG' || srcData.tagName === 'IMAGE')) {
523
478
  if (srcData._imageSource instanceof ImageSource) {
524
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._imageSource.android);
479
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._imageSource.android);
525
480
  }
526
481
  else if (srcData._image instanceof android.graphics.Bitmap) {
527
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._image);
482
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._image);
528
483
  }
529
484
  else if (srcData._asset instanceof ImageAsset) {
530
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._asset.native);
485
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._asset.native);
531
486
  }
532
487
  else if (typeof srcData.src === 'string') {
533
488
  const result = ImageSource.fromFileSync(srcData.src);
534
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, result ? result.android : null);
489
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, result ? result.android : null);
535
490
  }
536
491
  }
537
492
  else if (srcData && typeof srcData.tagName === 'string' && srcData.tagName === 'CANVAS' && srcData._canvas instanceof TNSCanvas) {
538
- this.native.texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._canvas.android);
493
+ texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, srcData._canvas.native);
539
494
  }
540
495
  }
541
496
  transformFeedbackVaryings(program, varyings, bufferMode) {
542
497
  this._glCheckError('transformFeedbackVaryings');
543
- const value = program ? program.native : 0;
544
- this.native.transformFeedbackVaryings(value, varyings, bufferMode);
498
+ const transformFeedbackVaryings = this._getMethod('transformFeedbackVaryings');
499
+ const value = program.native;
500
+ transformFeedbackVaryings(value, varyings, bufferMode);
545
501
  }
546
502
  uniform1ui(location, v0) {
547
503
  this._glCheckError('uniform1ui');
548
- const value = location ? location.native : 0;
549
- this.native.uniform1ui(value, v0);
504
+ const value = location.native;
505
+ const uniform1ui = this._getMethod('uniform1ui');
506
+ uniform1ui(value, v0);
550
507
  }
551
508
  uniform1uiv(location, data) {
552
509
  this._glCheckError('uniform1uiv');
553
- const value = location ? location.native : 0;
554
- this.native.uniform1uiv(value, Array.from(data));
510
+ const uniform1uiv = this._getMethod('uniform1uiv');
511
+ const value = location.native;
512
+ uniform1uiv(value, data);
555
513
  }
556
514
  uniform2ui(location, v0, v1) {
557
515
  this._glCheckError('uniform2ui');
558
- const value = location ? location.native : 0;
559
- this.native.uniform2ui(value, v0, v1);
516
+ const uniform2ui = this._getMethod('uniform2ui');
517
+ const value = location.native;
518
+ uniform2ui(value, v0, v1);
560
519
  }
561
520
  uniform2uiv(location, data) {
562
521
  this._glCheckError('uniform2uiv');
563
- const value = location ? location.native : 0;
564
- this.native.uniform2uiv(value, Array.from(data));
522
+ const uniform2uiv = this._getMethod('uniform2uiv');
523
+ const value = location.native;
524
+ uniform2uiv(value, data);
565
525
  }
566
526
  /* Sync objects */
567
527
  /* Miscellaneous constants */
568
528
  uniform3ui(location, v0, v1, v2) {
569
529
  this._glCheckError('uniform3ui');
570
- const value = location ? location.native : 0;
571
- this.native.uniform3ui(value, v0, v1, v2);
530
+ const uniform3ui = this._getMethod('uniform3ui');
531
+ const value = location.native;
532
+ uniform3ui(value, v0, v1, v2);
572
533
  }
573
534
  uniform3uiv(location, data) {
574
535
  this._glCheckError('uniform3uiv');
575
- const value = location ? location.native : 0;
576
- this.native.uniform3uiv(value, Array.from(data));
536
+ console.log('uniform3uiv');
537
+ const uniform3uiv = this._getMethod('uniform3uiv');
538
+ const value = location.native;
539
+ uniform3uiv(value, data);
577
540
  }
578
541
  uniform4ui(location, v0, v1, v2, v3) {
579
542
  this._glCheckError('uniform4ui');
580
- const value = location ? location.native : 0;
581
- this.native.uniform4ui(value, v0, v1, v2, v3);
543
+ const uniform4ui = this._getMethod('uniform4ui');
544
+ const value = location.native;
545
+ uniform4ui(value, v0, v1, v2, v3);
582
546
  }
583
547
  uniform4uiv(location, data) {
584
548
  this._glCheckError('uniform4uiv');
585
- const value = location ? location.native : 0;
586
- this.native.uniform4uiv(value, Array.from(data));
549
+ console.log('uniform4uiv');
550
+ const uniform4uiv = this._getMethod('uniform4uiv');
551
+ const value = location.native;
552
+ uniform4uiv(value, data);
587
553
  }
588
554
  uniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding) {
589
555
  this._glCheckError('uniformBlockBinding');
590
- const value = program ? program.native : 0;
591
- this.native.uniformBlockBinding(value, uniformBlockIndex, uniformBlockBinding);
556
+ const uniformBlockBindingFunc = this._getMethod('uniformBlockBinding');
557
+ const value = program.native;
558
+ uniformBlockBindingFunc(value, uniformBlockIndex, uniformBlockBinding);
592
559
  }
593
560
  uniformMatrix2x3fv(location, transpose, data) {
594
- if (data instanceof Float32Array) {
595
- data = Array.from(data); //this.toNativeArray(data as any, 'float');
596
- }
597
561
  this._glCheckError('uniformMatrix2x3fv');
598
- const value = location ? location.native : 0;
599
- this.native.uniformMatrix2x3fv(value, transpose, data);
562
+ const uniformMatrix2x3fv = this._getMethod('uniformMatrix2x3fv');
563
+ const value = location.native;
564
+ uniformMatrix2x3fv(value, transpose, data);
600
565
  }
601
566
  uniformMatrix2x4fv(location, transpose, data) {
602
- if (data instanceof Float32Array) {
603
- data = Array.from(data); //this.toNativeArray(data as any, 'float');
604
- }
605
567
  this._glCheckError('uniformMatrix2x4fv');
606
- const value = location ? location.native : 0;
607
- this.native.uniformMatrix2x4fv(value, transpose, data);
568
+ const uniformMatrix2x4fv = this._getMethod('uniformMatrix2x4fv');
569
+ const value = location.native;
570
+ uniformMatrix2x4fv(value, transpose, data);
608
571
  }
609
572
  uniformMatrix3x2fv(location, transpose, data) {
610
- if (data instanceof Float32Array) {
611
- data = Array.from(data); //this.toNativeArray(data as any, 'float');
612
- }
613
573
  this._glCheckError('uniformMatrix3x2fv');
614
- const value = location ? location.native : 0;
615
- this.native.uniformMatrix3x2fv(value, transpose, data);
574
+ const uniformMatrix3x2fv = this._getMethod('uniformMatrix3x2fv');
575
+ const value = location.native;
576
+ uniformMatrix3x2fv(value, transpose, data);
616
577
  }
617
578
  uniformMatrix3x4fv(location, transpose, data) {
618
- if (data instanceof Float32Array) {
619
- data = Array.from(data); //this.toNativeArray(data as any, 'float');
620
- }
621
579
  this._glCheckError('uniformMatrix3x4fv');
622
- const value = location ? location.native : 0;
623
- this.native.uniformMatrix3x4fv(value, transpose, data);
580
+ const uniformMatrix3x4fv = this._getMethod('uniformMatrix3x4fv');
581
+ const value = location.native;
582
+ uniformMatrix3x4fv(value, transpose, data);
624
583
  }
625
584
  uniformMatrix4x2fv(location, transpose, data) {
626
- if (data instanceof Float32Array) {
627
- data = Array.from(data); //this.toNativeArray(data as any, 'float');
628
- }
629
585
  this._glCheckError('uniformMatrix4x2fv');
630
- const value = location ? location.native : 0;
631
- this.native.uniformMatrix4x2fv(value, transpose, data);
586
+ const uniformMatrix4x2fv = this._getMethod('uniformMatrix4x2fv');
587
+ const value = location.native;
588
+ uniformMatrix4x2fv(value, transpose, data);
632
589
  }
633
590
  uniformMatrix4x3fv(location, transpose, data) {
634
- if (data instanceof Float32Array) {
635
- data = Array.from(data); //this.toNativeArray(data as any, 'float');
636
- }
637
591
  this._glCheckError('uniformMatrix4x3fv');
638
- const value = location ? location.native : 0;
639
- this.native.uniformMatrix4x3fv(value, transpose, data);
592
+ const uniformMatrix4x3fv = this._getMethod('uniformMatrix4x3fv');
593
+ const value = location.native;
594
+ uniformMatrix4x3fv(value, transpose, data);
640
595
  }
641
596
  vertexAttribDivisor(index, divisor) {
642
597
  this._glCheckError('vertexAttribDivisor');
643
- this.native.vertexAttribDivisor(index, divisor);
598
+ const vertexAttribDivisor = this._getMethod('vertexAttribDivisor');
599
+ vertexAttribDivisor(index, divisor);
644
600
  }
645
601
  vertexAttribI4i(index, v0, v1, v2, v3) {
646
602
  this._glCheckError('vertexAttribI4i');
647
- this.native.vertexAttribI4i(index, v0, v1, v2, v3);
603
+ const vertexAttribI4i = this._getMethod('vertexAttribI4i');
604
+ vertexAttribI4i(index, v0, v1, v2, v3);
648
605
  }
649
606
  vertexAttribI4iv(index, value) {
650
- if (value instanceof Int32Array) {
651
- value = Array.from(value); //this.toNativeArray(value as any, 'int');
652
- }
653
607
  this._glCheckError('vertexAttribI4iv');
654
- this.native.vertexAttribI4uiv(index, value);
608
+ const vertexAttribI4iv = this._getMethod('vertexAttribI4iv');
609
+ vertexAttribI4iv(index, value);
655
610
  }
656
611
  vertexAttribI4ui(index, v0, v1, v2, v3) {
657
612
  this._glCheckError('vertexAttribI4ui');
658
- this.native.vertexAttribI4ui(index, v0, v1, v2, v3);
613
+ const vertexAttribI4ui = this._getMethod('vertexAttribI4ui');
614
+ vertexAttribI4ui(index, v0, v1, v2, v3);
659
615
  }
660
616
  vertexAttribI4uiv(index, value) {
661
- if (value instanceof Uint32Array) {
662
- value = Array.from(value); //this.toNativeArray(value as any, 'int');
663
- }
664
617
  this._glCheckError('vertexAttribI4uiv');
665
- this.native.vertexAttribI4uiv(index, value);
618
+ const vertexAttribI4uiv = this._getMethod('vertexAttribI4uiv');
619
+ vertexAttribI4uiv(index, value);
666
620
  }
667
621
  }
622
+ (() => {
623
+ Helpers.initialize();
624
+ ctor = global.CanvasJSIModule.createWebGL2Context;
625
+ })();
668
626
  //# sourceMappingURL=index.android.js.map