@nativescript/canvas 1.0.0-alpha.1 → 1.0.0-alpha.10
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.
- package/Canvas/common.d.ts +2 -1
- package/Canvas/common.js +21 -12
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.js +9 -1
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.ios.js +9 -2
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.android.js +6 -0
- package/Canvas2D/CanvasRenderingContext2D/index.android.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.ios.js +9 -0
- package/Canvas2D/CanvasRenderingContext2D/index.ios.js.map +1 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.android.js +3 -0
- package/Canvas2D/DOMMatrix/DOMMatrix.android.js.map +1 -1
- package/Canvas2D/DOMMatrix/DOMMatrix.ios.js +3 -0
- package/Canvas2D/DOMMatrix/DOMMatrix.ios.js.map +1 -1
- package/Canvas2D/ImageData/ImageData.android.js +24 -13
- package/Canvas2D/ImageData/ImageData.android.js.map +1 -1
- package/Canvas2D/ImageData/ImageData.ios.js +24 -13
- package/Canvas2D/ImageData/ImageData.ios.js.map +1 -1
- package/ImageBitmap/index.android.js +42 -10
- package/ImageBitmap/index.android.js.map +1 -1
- package/ImageBitmap/index.ios.js +42 -10
- package/ImageBitmap/index.ios.js.map +1 -1
- package/SVG/Image.js +6 -4
- package/SVG/Image.js.map +1 -1
- package/SVG/SVG.js +9 -0
- package/SVG/SVG.js.map +1 -1
- package/TextDecoder/TextDecoder.android.d.ts +1 -0
- package/TextDecoder/TextDecoder.android.js +29 -20
- package/TextDecoder/TextDecoder.android.js.map +1 -1
- package/TextDecoder/TextDecoder.ios.js +12 -16
- package/TextDecoder/TextDecoder.ios.js.map +1 -1
- package/WebGL/WebGLActiveInfo.js +3 -1
- package/WebGL/WebGLActiveInfo.js.map +1 -1
- package/WebGL/WebGLBuffer.js +3 -1
- package/WebGL/WebGLBuffer.js.map +1 -1
- package/WebGL/WebGLExtensions/index.android.js +1 -0
- package/WebGL/WebGLExtensions/index.android.js.map +1 -1
- package/WebGL/WebGLExtensions/index.ios.js +1 -0
- package/WebGL/WebGLExtensions/index.ios.js.map +1 -1
- package/WebGL/WebGLFramebuffer.js +3 -1
- package/WebGL/WebGLFramebuffer.js.map +1 -1
- package/WebGL/WebGLProgram.js +3 -1
- package/WebGL/WebGLProgram.js.map +1 -1
- package/WebGL/WebGLRenderbuffer.js +3 -1
- package/WebGL/WebGLRenderbuffer.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.android.d.ts +1 -0
- package/WebGL/WebGLRenderingContext/index.android.js +394 -111
- package/WebGL/WebGLRenderingContext/index.android.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.ios.js +43 -118
- package/WebGL/WebGLRenderingContext/index.ios.js.map +1 -1
- package/WebGL/WebGLShader.js +3 -1
- package/WebGL/WebGLShader.js.map +1 -1
- package/WebGL/WebGLShaderPrecisionFormat.js +3 -1
- package/WebGL/WebGLShaderPrecisionFormat.js.map +1 -1
- package/WebGL/WebGLTexture.js +3 -1
- package/WebGL/WebGLTexture.js.map +1 -1
- package/WebGL/WebGLUniformLocation.js +3 -1
- package/WebGL/WebGLUniformLocation.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.android.js +2 -2
- package/WebGL2/WebGL2RenderingContext/index.android.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.ios.js +29 -24
- package/WebGL2/WebGL2RenderingContext/index.ios.js.map +1 -1
- package/WebGL2/WebGLQuery.js +3 -1
- package/WebGL2/WebGLQuery.js.map +1 -1
- package/WebGL2/WebGLSampler.js +3 -1
- package/WebGL2/WebGLSampler.js.map +1 -1
- package/WebGL2/WebGLSync.js +3 -1
- package/WebGL2/WebGLSync.js.map +1 -1
- package/WebGL2/WebGLTransformFeedback.js +3 -1
- package/WebGL2/WebGLTransformFeedback.js.map +1 -1
- package/WebGL2/WebGLVertexArrayObject.js +3 -1
- package/WebGL2/WebGLVertexArrayObject.js.map +1 -1
- package/angular/bundles/nativescript-canvas-angular.umd.js +4 -4
- package/angular/bundles/nativescript-canvas-angular.umd.js.map +1 -1
- package/angular/esm2015/index.js +2 -2
- package/angular/esm2015/nativescript-canvas-angular.js +1 -1
- package/angular/fesm2015/nativescript-canvas-angular.js +1 -1
- package/angular/fesm2015/nativescript-canvas-angular.js.map +1 -1
- package/angular/package.json +2 -2
- package/index.d.ts +1 -3
- package/index.js +40 -4
- package/index.js.map +1 -1
- package/package.json +5 -5
- package/platforms/android/include.gradle +21 -1
- package/platforms/ios/Podfile +2 -2
- package/utils.d.ts +3 -0
- package/utils.js +28 -1
- package/utils.js.map +1 -1
- package/angular/bundles/nativescript-canvas-angular.umd.min.js +0 -2
- package/angular/bundles/nativescript-canvas-angular.umd.min.js.map +0 -1
|
@@ -13,6 +13,7 @@ import { ANGLE_instanced_arrays, EXT_blend_minmax, EXT_color_buffer_half_float,
|
|
|
13
13
|
import { ImageAsset } from '../../ImageAsset';
|
|
14
14
|
import { Canvas } from '../../Canvas';
|
|
15
15
|
import { ImageBitmap } from '../../ImageBitmap';
|
|
16
|
+
import { Utils } from '../../utils';
|
|
16
17
|
export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
17
18
|
constructor(context) {
|
|
18
19
|
super(context);
|
|
@@ -182,6 +183,9 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
182
183
|
}
|
|
183
184
|
return [];
|
|
184
185
|
}
|
|
186
|
+
get _isSupported() {
|
|
187
|
+
return Utils.IS_SUPPORTED_TYPED_ARRAYS_VERSION;
|
|
188
|
+
}
|
|
185
189
|
bufferData(target, srcData, usage) {
|
|
186
190
|
this._glCheckError('bufferData');
|
|
187
191
|
this._checkArgs('bufferData', arguments);
|
|
@@ -195,7 +199,12 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
195
199
|
this.context.bufferData(target, srcData.nativeObject, usage);
|
|
196
200
|
}
|
|
197
201
|
else {
|
|
198
|
-
this.
|
|
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
|
+
}
|
|
199
208
|
}
|
|
200
209
|
//this.context.bufferData(target, this.toNativeArray(new Uint8Array(srcData as any) as any, 'byte'), usage);
|
|
201
210
|
}
|
|
@@ -207,20 +216,36 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
207
216
|
}
|
|
208
217
|
else {
|
|
209
218
|
if (srcData instanceof Uint8Array || srcData instanceof Uint8ClampedArray) {
|
|
210
|
-
|
|
211
|
-
|
|
219
|
+
if (this._isSupported) {
|
|
220
|
+
this.context.bufferDataByteBuffer(target, srcData, usage);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this.context.bufferDataByte(target, Array.from(srcData), usage);
|
|
224
|
+
}
|
|
212
225
|
}
|
|
213
226
|
else if (srcData instanceof Uint16Array || srcData instanceof Int16Array) {
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
if (this._isSupported) {
|
|
228
|
+
this.context.bufferDataShortBuffer(target, srcData, usage);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
this.context.bufferDataShort(target, Array.from(srcData), usage);
|
|
232
|
+
}
|
|
216
233
|
}
|
|
217
234
|
else if (srcData instanceof Uint32Array || srcData instanceof Int32Array) {
|
|
218
|
-
|
|
219
|
-
|
|
235
|
+
if (this._isSupported) {
|
|
236
|
+
this.context.bufferDataIntBuffer(target, srcData, usage);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.context.bufferDataInt(target, Array.from(srcData), usage);
|
|
240
|
+
}
|
|
220
241
|
}
|
|
221
242
|
else if (srcData instanceof Float32Array) {
|
|
222
|
-
|
|
223
|
-
|
|
243
|
+
if (this._isSupported) {
|
|
244
|
+
this.context.bufferDataFloatBuffer(target, srcData, usage);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.context.bufferDataFloat(target, Array.from(srcData), usage);
|
|
248
|
+
}
|
|
224
249
|
}
|
|
225
250
|
}
|
|
226
251
|
}
|
|
@@ -239,7 +264,12 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
239
264
|
this.context.bufferSubData(target, offset, srcData.nativeObject);
|
|
240
265
|
}
|
|
241
266
|
else {
|
|
242
|
-
this.
|
|
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
|
+
}
|
|
243
273
|
}
|
|
244
274
|
}
|
|
245
275
|
else if (srcData && srcData.buffer instanceof ArrayBuffer) {
|
|
@@ -250,20 +280,36 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
250
280
|
}
|
|
251
281
|
else {
|
|
252
282
|
if (srcData instanceof Uint8Array || srcData instanceof Uint8ClampedArray) {
|
|
253
|
-
|
|
254
|
-
|
|
283
|
+
if (this._isSupported) {
|
|
284
|
+
this.context.bufferSubDataByteBuffer(target, offset, srcData);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
this.context.bufferSubDataByte(target, offset, Array.from(srcData));
|
|
288
|
+
}
|
|
255
289
|
}
|
|
256
290
|
else if (srcData instanceof Uint16Array || srcData instanceof Int16Array) {
|
|
257
|
-
|
|
258
|
-
|
|
291
|
+
if (this._isSupported) {
|
|
292
|
+
this.context.bufferSubDataShortBuffer(target, offset, srcData);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
this.context.bufferSubDataShort(target, offset, Array.from(srcData));
|
|
296
|
+
}
|
|
259
297
|
}
|
|
260
298
|
else if (srcData instanceof Uint32Array || srcData instanceof Int32Array) {
|
|
261
|
-
|
|
262
|
-
|
|
299
|
+
if (this._isSupported) {
|
|
300
|
+
this.context.bufferSubDataIntBuffer(target, offset, srcData);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
this.context.bufferSubDataInt(target, offset, Array.from(srcData));
|
|
304
|
+
}
|
|
263
305
|
}
|
|
264
306
|
else if (srcData instanceof Float32Array) {
|
|
265
|
-
|
|
266
|
-
|
|
307
|
+
if (this._isSupported) {
|
|
308
|
+
this.context.bufferSubDataFloatBuffer(target, offset, srcData);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
this.context.bufferSubDataFloat(target, offset, Array.from(srcData));
|
|
312
|
+
}
|
|
267
313
|
}
|
|
268
314
|
}
|
|
269
315
|
}
|
|
@@ -907,32 +953,52 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
907
953
|
}
|
|
908
954
|
else {
|
|
909
955
|
if (pixels instanceof Uint8Array) {
|
|
910
|
-
|
|
911
|
-
|
|
956
|
+
if (this._isSupported) {
|
|
957
|
+
this.context.readPixelsByteBuffer(x, y, width, height, format, type, pixels);
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
this.context.readPixelsByte(x, y, width, height, format, type, Array.from(pixels));
|
|
961
|
+
}
|
|
912
962
|
}
|
|
913
963
|
else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
|
|
914
|
-
|
|
915
|
-
|
|
964
|
+
if (this._isSupported) {
|
|
965
|
+
this.context.readPixelsShortBuffer(x, y, width, height, format, type, pixels);
|
|
966
|
+
}
|
|
967
|
+
else {
|
|
968
|
+
this.context.readPixelsShort(x, y, width, height, format, type, Array.from(pixels));
|
|
969
|
+
}
|
|
916
970
|
}
|
|
917
971
|
else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
|
|
918
|
-
|
|
919
|
-
|
|
972
|
+
if (this._isSupported) {
|
|
973
|
+
this.context.readPixelsIntBuffer(x, y, width, height, format, type, pixels);
|
|
974
|
+
}
|
|
975
|
+
else {
|
|
976
|
+
this.context.readPixelsInt(x, y, width, height, format, type, Array.from(pixels));
|
|
977
|
+
}
|
|
920
978
|
}
|
|
921
979
|
else if (pixels instanceof Float32Array) {
|
|
922
|
-
|
|
923
|
-
|
|
980
|
+
if (this._isSupported) {
|
|
981
|
+
this.context.readPixelsFloatBuffer(x, y, width, height, format, type, pixels);
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
this.context.readPixelsFloat(x, y, width, height, format, type, Array.from(pixels));
|
|
985
|
+
}
|
|
924
986
|
}
|
|
925
987
|
}
|
|
926
988
|
}
|
|
927
989
|
else if (pixels instanceof ArrayBuffer) {
|
|
928
|
-
// this.context.readPixels(x, y, width, height, format, type, this.toNativeArray(new Uint8Array(pixels as any) as any, 'byte'));
|
|
929
990
|
// @ts-ignore
|
|
930
991
|
if (pixels.nativeObject) {
|
|
931
992
|
// @ts-ignore
|
|
932
993
|
this.context.readPixels(x, y, width, height, format, type, pixels.nativeObject);
|
|
933
994
|
}
|
|
934
995
|
else {
|
|
935
|
-
this.
|
|
996
|
+
if (this._isSupported) {
|
|
997
|
+
this.context.readPixelsByteBuffer(x, y, width, height, format, type, pixels);
|
|
998
|
+
}
|
|
999
|
+
else {
|
|
1000
|
+
this.context.readPixelsByte(x, y, width, height, format, type, Array.from(new Uint8Array(pixels)));
|
|
1001
|
+
}
|
|
936
1002
|
}
|
|
937
1003
|
}
|
|
938
1004
|
}
|
|
@@ -995,10 +1061,6 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
995
1061
|
texImage2D(target, level, internalformat, width, height, border, format, type, pixels) {
|
|
996
1062
|
this._glCheckError('texImage2D');
|
|
997
1063
|
this._checkArgs('texImage2D', arguments);
|
|
998
|
-
/* TODO */
|
|
999
|
-
// this.blendFunc(this.SRC_ALPHA, this.ONE_MINUS_SRC_ALPHA);
|
|
1000
|
-
// this.enable(this.BLEND);
|
|
1001
|
-
/* TODO */
|
|
1002
1064
|
if (arguments.length === 9) {
|
|
1003
1065
|
if (pixels && pixels.buffer instanceof ArrayBuffer) {
|
|
1004
1066
|
if (pixels.buffer.nativeObject) {
|
|
@@ -1007,20 +1069,36 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1007
1069
|
}
|
|
1008
1070
|
else {
|
|
1009
1071
|
if (pixels instanceof Uint8Array) {
|
|
1010
|
-
|
|
1011
|
-
|
|
1072
|
+
if (this._isSupported) {
|
|
1073
|
+
this.context.texImage2DByteBuffer(target, level, internalformat, width, height, border, format, type, pixels);
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
this.context.texImage2DByte(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
|
|
1077
|
+
}
|
|
1012
1078
|
}
|
|
1013
1079
|
else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
|
|
1014
|
-
|
|
1015
|
-
|
|
1080
|
+
if (this._isSupported) {
|
|
1081
|
+
this.context.texSubImage2DShortBuffer(target, level, internalformat, width, height, border, format, type, pixels);
|
|
1082
|
+
}
|
|
1083
|
+
else {
|
|
1084
|
+
this.context.texSubImage2DShort(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
|
|
1085
|
+
}
|
|
1016
1086
|
}
|
|
1017
1087
|
else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
|
|
1018
|
-
|
|
1019
|
-
|
|
1088
|
+
if (this._isSupported) {
|
|
1089
|
+
this.context.texImage2DIntBuffer(target, level, internalformat, width, height, border, format, type, pixels);
|
|
1090
|
+
}
|
|
1091
|
+
else {
|
|
1092
|
+
this.context.texImage2DInt(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
|
|
1093
|
+
}
|
|
1020
1094
|
}
|
|
1021
1095
|
else if (pixels instanceof Float32Array) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1096
|
+
if (this._isSupported) {
|
|
1097
|
+
this.context.texImage2DFloatBuffer(target, level, internalformat, width, height, border, format, type, pixels);
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
this.context.texImage2DFloat(target, level, internalformat, width, height, border, format, type, Array.from(pixels));
|
|
1101
|
+
}
|
|
1024
1102
|
}
|
|
1025
1103
|
}
|
|
1026
1104
|
}
|
|
@@ -1031,8 +1109,12 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1031
1109
|
this.context.texImage2D(target, level, internalformat, width, height, border, format, type, pixels.nativeObject);
|
|
1032
1110
|
}
|
|
1033
1111
|
else {
|
|
1034
|
-
|
|
1035
|
-
|
|
1112
|
+
if (this._isSupported) {
|
|
1113
|
+
this.context.texImage2DByteBuffer(target, level, internalformat, width, height, border, format, type, pixels);
|
|
1114
|
+
}
|
|
1115
|
+
else {
|
|
1116
|
+
this.context.texImage2DByte(target, level, internalformat, width, height, border, format, type, Array.from(new Uint8Array(pixels)));
|
|
1117
|
+
}
|
|
1036
1118
|
}
|
|
1037
1119
|
}
|
|
1038
1120
|
else {
|
|
@@ -1049,7 +1131,7 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1049
1131
|
else if (border instanceof ImageAsset) {
|
|
1050
1132
|
this.context.texImage2D(target, level, internalformat, width, height, border.native);
|
|
1051
1133
|
}
|
|
1052
|
-
else if (border instanceof ImageBitmap) {
|
|
1134
|
+
else if (border instanceof ImageBitmap || (border === null || border === void 0 ? void 0 : border.native) instanceof org.nativescript.canvas.TNSImageBitmap) {
|
|
1053
1135
|
this.context.texImage2D(target, level, internalformat, width, height, border.native);
|
|
1054
1136
|
}
|
|
1055
1137
|
else if (border instanceof android.graphics.Bitmap) {
|
|
@@ -1076,8 +1158,6 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1076
1158
|
this.context.texImage2D(target, level, internalformat, width, height, border._canvas.android);
|
|
1077
1159
|
}
|
|
1078
1160
|
}
|
|
1079
|
-
// this.blendFunc(this.SRC_ALPHA, this.ZERO);
|
|
1080
|
-
// this.disable(this.BLEND);
|
|
1081
1161
|
}
|
|
1082
1162
|
texParameterf(target, pname, param) {
|
|
1083
1163
|
this._glCheckError('texParameterf');
|
|
@@ -1099,32 +1179,52 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1099
1179
|
}
|
|
1100
1180
|
else {
|
|
1101
1181
|
if (pixels instanceof Uint8Array) {
|
|
1102
|
-
|
|
1103
|
-
|
|
1182
|
+
if (this._isSupported) {
|
|
1183
|
+
this.context.texSubImage2DByteBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
this.context.texSubImage2DByte(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
|
|
1187
|
+
}
|
|
1104
1188
|
}
|
|
1105
1189
|
else if (pixels instanceof Uint16Array || pixels instanceof Int16Array) {
|
|
1106
|
-
|
|
1107
|
-
|
|
1190
|
+
if (this._isSupported) {
|
|
1191
|
+
this.context.texSubImage2DShortBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
this.context.texSubImage2DShort(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
|
|
1195
|
+
}
|
|
1108
1196
|
}
|
|
1109
1197
|
else if (pixels instanceof Uint32Array || pixels instanceof Int32Array) {
|
|
1110
|
-
|
|
1111
|
-
|
|
1198
|
+
if (this._isSupported) {
|
|
1199
|
+
this.context.texSubImage2DIntBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
this.context.texSubImage2DInt(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
|
|
1203
|
+
}
|
|
1112
1204
|
}
|
|
1113
1205
|
else if (pixels instanceof Float32Array) {
|
|
1114
|
-
|
|
1115
|
-
|
|
1206
|
+
if (this._isSupported) {
|
|
1207
|
+
this.context.texSubImage2DByte(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
1208
|
+
}
|
|
1209
|
+
else {
|
|
1210
|
+
this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, Array.from(pixels));
|
|
1211
|
+
}
|
|
1116
1212
|
}
|
|
1117
1213
|
}
|
|
1118
1214
|
}
|
|
1119
1215
|
else if (pixels instanceof ArrayBuffer) {
|
|
1120
|
-
// this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, this.toNativeArray(new Uint8Array(pixels as any) as any, 'byte'));
|
|
1121
1216
|
// @ts-ignore
|
|
1122
1217
|
if (pixels.nativeObject) {
|
|
1123
1218
|
// @ts-ignore
|
|
1124
1219
|
this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels.nativeObject);
|
|
1125
1220
|
}
|
|
1126
1221
|
else {
|
|
1127
|
-
this.
|
|
1222
|
+
if (this._isSupported) {
|
|
1223
|
+
this.context.texSubImage2DByteBuffer(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
1224
|
+
}
|
|
1225
|
+
else {
|
|
1226
|
+
this.context.texSubImage2DByte(target, level, xoffset, yoffset, width, height, format, type, Array.from(new Uint8Array(pixels)));
|
|
1227
|
+
}
|
|
1128
1228
|
}
|
|
1129
1229
|
}
|
|
1130
1230
|
}
|
|
@@ -1138,6 +1238,9 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1138
1238
|
else if (format instanceof ImageAsset) {
|
|
1139
1239
|
this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format.native);
|
|
1140
1240
|
}
|
|
1241
|
+
else if (format instanceof ImageBitmap || (format === null || format === void 0 ? void 0 : format.native) instanceof org.nativescript.canvas.TNSImageBitmap) {
|
|
1242
|
+
this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format.native);
|
|
1243
|
+
}
|
|
1141
1244
|
else if (format && typeof format.tagName === 'string' && (format.tagName === 'IMG' || format.tagName === 'IMAGE')) {
|
|
1142
1245
|
if (format._imageSource instanceof ImageSource) {
|
|
1143
1246
|
this.context.texSubImage2D(target, level, xoffset, yoffset, width, height, format._imageSource.android);
|
|
@@ -1167,20 +1270,44 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1167
1270
|
uniform1iv(location, value) {
|
|
1168
1271
|
this._glCheckError('uniform1iv');
|
|
1169
1272
|
this._checkArgs('uniform1iv', arguments);
|
|
1170
|
-
if (!Array.isArray(value)) {
|
|
1171
|
-
value = Array.from(value);
|
|
1172
|
-
}
|
|
1173
1273
|
const loc = location ? location.native : 0;
|
|
1174
|
-
this.
|
|
1274
|
+
if (this._isSupported) {
|
|
1275
|
+
if (!Array.isArray(value)) {
|
|
1276
|
+
this.context.uniform1ivBuffer(loc, value);
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
this.context.uniform1iv(loc, value);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
if (!Array.isArray(value)) {
|
|
1284
|
+
this.context.uniform1iv(loc, Array.from(value));
|
|
1285
|
+
}
|
|
1286
|
+
else {
|
|
1287
|
+
this.context.uniform1iv(loc, value);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1175
1290
|
}
|
|
1176
1291
|
uniform1fv(location, value) {
|
|
1177
1292
|
this._glCheckError('uniform1fv');
|
|
1178
1293
|
this._checkArgs('uniform1fv', arguments);
|
|
1179
|
-
if (!Array.isArray(value)) {
|
|
1180
|
-
value = Array.from(value);
|
|
1181
|
-
}
|
|
1182
1294
|
const loc = location ? location.native : 0;
|
|
1183
|
-
this.
|
|
1295
|
+
if (this._isSupported) {
|
|
1296
|
+
if (!Array.isArray(value)) {
|
|
1297
|
+
this.context.uniform1fvBuffer(loc, value);
|
|
1298
|
+
}
|
|
1299
|
+
else {
|
|
1300
|
+
this.context.uniform1fv(loc, value);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
if (!Array.isArray(value)) {
|
|
1305
|
+
this.context.uniform1fv(loc, Array.from(value));
|
|
1306
|
+
}
|
|
1307
|
+
else {
|
|
1308
|
+
this.context.uniform1fv(loc, value);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1184
1311
|
}
|
|
1185
1312
|
uniform1i(location, v0) {
|
|
1186
1313
|
this._glCheckError('uniform1i');
|
|
@@ -1197,20 +1324,44 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1197
1324
|
uniform2iv(location, value) {
|
|
1198
1325
|
this._glCheckError('uniform2iv');
|
|
1199
1326
|
this._checkArgs('uniform2iv', arguments);
|
|
1200
|
-
if (!Array.isArray(value)) {
|
|
1201
|
-
value = Array.from(value);
|
|
1202
|
-
}
|
|
1203
1327
|
const loc = location ? location.native : 0;
|
|
1204
|
-
this.
|
|
1328
|
+
if (this._isSupported) {
|
|
1329
|
+
if (!Array.isArray(value)) {
|
|
1330
|
+
this.context.uniform2ivBuffer(loc, value);
|
|
1331
|
+
}
|
|
1332
|
+
else {
|
|
1333
|
+
this.context.uniform2iv(loc, value);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
else {
|
|
1337
|
+
if (!Array.isArray(value)) {
|
|
1338
|
+
this.context.uniform2iv(loc, Array.from(value));
|
|
1339
|
+
}
|
|
1340
|
+
else {
|
|
1341
|
+
this.context.uniform2iv(loc, value);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1205
1344
|
}
|
|
1206
1345
|
uniform2fv(location, value) {
|
|
1207
1346
|
this._glCheckError('uniform2fv');
|
|
1208
1347
|
this._checkArgs('uniform2fv', arguments);
|
|
1209
|
-
if (!Array.isArray(value)) {
|
|
1210
|
-
value = Array.from(value);
|
|
1211
|
-
}
|
|
1212
1348
|
const loc = location ? location.native : 0;
|
|
1213
|
-
this.
|
|
1349
|
+
if (this._isSupported) {
|
|
1350
|
+
if (!Array.isArray(value)) {
|
|
1351
|
+
this.context.uniform2fvBuffer(loc, value);
|
|
1352
|
+
}
|
|
1353
|
+
else {
|
|
1354
|
+
this.context.uniform2fv(loc, value);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
if (!Array.isArray(value)) {
|
|
1359
|
+
this.context.uniform2fv(loc, Array.from(value));
|
|
1360
|
+
}
|
|
1361
|
+
else {
|
|
1362
|
+
this.context.uniform2fv(loc, value);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1214
1365
|
}
|
|
1215
1366
|
uniform2i(location, v0, v1) {
|
|
1216
1367
|
this._glCheckError('uniform2i');
|
|
@@ -1227,20 +1378,44 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1227
1378
|
uniform3iv(location, value) {
|
|
1228
1379
|
this._glCheckError('uniform3iv');
|
|
1229
1380
|
this._checkArgs('uniform3iv', arguments);
|
|
1230
|
-
if (!Array.isArray(value)) {
|
|
1231
|
-
value = Array.from(value);
|
|
1232
|
-
}
|
|
1233
1381
|
const loc = location ? location.native : 0;
|
|
1234
|
-
this.
|
|
1382
|
+
if (this._isSupported) {
|
|
1383
|
+
if (!Array.isArray(value)) {
|
|
1384
|
+
this.context.uniform3ivBuffer(loc, value);
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
this.context.uniform3iv(loc, value);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
if (!Array.isArray(value)) {
|
|
1392
|
+
this.context.uniform3iv(loc, Array.from(value));
|
|
1393
|
+
}
|
|
1394
|
+
else {
|
|
1395
|
+
this.context.uniform3iv(loc, value);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1235
1398
|
}
|
|
1236
1399
|
uniform3fv(location, value) {
|
|
1237
1400
|
this._glCheckError('uniform3fv');
|
|
1238
1401
|
this._checkArgs('uniform3fv', arguments);
|
|
1239
|
-
if (!Array.isArray(value)) {
|
|
1240
|
-
value = Array.from(value);
|
|
1241
|
-
}
|
|
1242
1402
|
const loc = location ? location.native : 0;
|
|
1243
|
-
this.
|
|
1403
|
+
if (this._isSupported) {
|
|
1404
|
+
if (!Array.isArray(value)) {
|
|
1405
|
+
this.context.uniform3fvBuffer(loc, value);
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
this.context.uniform3fv(loc, value);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
else {
|
|
1412
|
+
if (!Array.isArray(value)) {
|
|
1413
|
+
this.context.uniform3fv(loc, Array.from(value));
|
|
1414
|
+
}
|
|
1415
|
+
else {
|
|
1416
|
+
this.context.uniform3fv(loc, value);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1244
1419
|
}
|
|
1245
1420
|
uniform3i(location, v0, v1, v2) {
|
|
1246
1421
|
this._glCheckError('uniform3i');
|
|
@@ -1257,20 +1432,44 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1257
1432
|
uniform4iv(location, value) {
|
|
1258
1433
|
this._glCheckError('uniform4iv');
|
|
1259
1434
|
this._checkArgs('uniform4iv', arguments);
|
|
1260
|
-
if (!Array.isArray(value)) {
|
|
1261
|
-
value = Array.from(value);
|
|
1262
|
-
}
|
|
1263
1435
|
const loc = location ? location.native : 0;
|
|
1264
|
-
this.
|
|
1436
|
+
if (this._isSupported) {
|
|
1437
|
+
if (!Array.isArray(value)) {
|
|
1438
|
+
this.context.uniform4ivBuffer(loc, value);
|
|
1439
|
+
}
|
|
1440
|
+
else {
|
|
1441
|
+
this.context.uniform4iv(loc, value);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
else {
|
|
1445
|
+
if (!Array.isArray(value)) {
|
|
1446
|
+
this.context.uniform4iv(loc, Array.from(value));
|
|
1447
|
+
}
|
|
1448
|
+
else {
|
|
1449
|
+
this.context.uniform4iv(loc, value);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1265
1452
|
}
|
|
1266
1453
|
uniform4fv(location, value) {
|
|
1267
1454
|
this._glCheckError('uniform4fv');
|
|
1268
1455
|
this._checkArgs('uniform4fv', arguments);
|
|
1269
|
-
if (!Array.isArray(value)) {
|
|
1270
|
-
value = Array.from(value);
|
|
1271
|
-
}
|
|
1272
1456
|
const loc = location ? location.native : 0;
|
|
1273
|
-
this.
|
|
1457
|
+
if (this._isSupported) {
|
|
1458
|
+
if (!Array.isArray(value)) {
|
|
1459
|
+
this.context.uniform4fvBuffer(loc, value);
|
|
1460
|
+
}
|
|
1461
|
+
else {
|
|
1462
|
+
this.context.uniform4fv(loc, value);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1466
|
+
if (!Array.isArray(value)) {
|
|
1467
|
+
this.context.uniform4fv(loc, Array.from(value));
|
|
1468
|
+
}
|
|
1469
|
+
else {
|
|
1470
|
+
this.context.uniform4fv(loc, value);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1274
1473
|
}
|
|
1275
1474
|
uniform4i(location, v0, v1, v2, v3) {
|
|
1276
1475
|
this._glCheckError('uniform4i');
|
|
@@ -1281,29 +1480,65 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1281
1480
|
uniformMatrix2fv(location, transpose, value) {
|
|
1282
1481
|
this._glCheckError('uniformMatrix2fv');
|
|
1283
1482
|
this._checkArgs('uniformMatrix2fv', arguments);
|
|
1284
|
-
if (!Array.isArray(value)) {
|
|
1285
|
-
value = Array.from(value);
|
|
1286
|
-
}
|
|
1287
1483
|
const loc = location ? location.native : 0;
|
|
1288
|
-
this.
|
|
1484
|
+
if (this._isSupported) {
|
|
1485
|
+
if (!Array.isArray(value)) {
|
|
1486
|
+
this.context.uniformMatrix2fvBuffer(loc, transpose, value);
|
|
1487
|
+
}
|
|
1488
|
+
else {
|
|
1489
|
+
this.context.uniformMatrix2fv(loc, transpose, value);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
else {
|
|
1493
|
+
if (!Array.isArray(value)) {
|
|
1494
|
+
this.context.uniformMatrix2fv(loc, transpose, Array.from(value));
|
|
1495
|
+
}
|
|
1496
|
+
else {
|
|
1497
|
+
this.context.uniformMatrix2fv(loc, transpose, value);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1289
1500
|
}
|
|
1290
1501
|
uniformMatrix3fv(location, transpose, value) {
|
|
1291
1502
|
this._glCheckError('uniformMatrix3fv');
|
|
1292
1503
|
this._checkArgs('uniformMatrix3fv', arguments);
|
|
1293
|
-
if (!Array.isArray(value)) {
|
|
1294
|
-
value = Array.from(value);
|
|
1295
|
-
}
|
|
1296
1504
|
const loc = location ? location.native : 0;
|
|
1297
|
-
this.
|
|
1505
|
+
if (this._isSupported) {
|
|
1506
|
+
if (!Array.isArray(value)) {
|
|
1507
|
+
this.context.uniformMatrix3fvBuffer(loc, transpose, value);
|
|
1508
|
+
}
|
|
1509
|
+
else {
|
|
1510
|
+
this.context.uniformMatrix3fv(loc, transpose, value);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
else {
|
|
1514
|
+
if (!Array.isArray(value)) {
|
|
1515
|
+
this.context.uniformMatrix3fv(loc, transpose, Array.from(value));
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
this.context.uniformMatrix3fv(loc, transpose, value);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1298
1521
|
}
|
|
1299
1522
|
uniformMatrix4fv(location, transpose, value) {
|
|
1300
1523
|
this._glCheckError('uniformMatrix4fv');
|
|
1301
1524
|
this._checkArgs('uniformMatrix4fv', arguments);
|
|
1302
|
-
if (!Array.isArray(value)) {
|
|
1303
|
-
value = Array.from(value);
|
|
1304
|
-
}
|
|
1305
1525
|
const loc = location ? location.native : 0;
|
|
1306
|
-
this.
|
|
1526
|
+
if (this._isSupported) {
|
|
1527
|
+
if (!Array.isArray(value)) {
|
|
1528
|
+
this.context.uniformMatrix4fvBuffer(loc, transpose, value);
|
|
1529
|
+
}
|
|
1530
|
+
else {
|
|
1531
|
+
this.context.uniformMatrix4fv(loc, transpose, value);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
else {
|
|
1535
|
+
if (!Array.isArray(value)) {
|
|
1536
|
+
this.context.uniformMatrix4fv(loc, transpose, Array.from(value));
|
|
1537
|
+
}
|
|
1538
|
+
else {
|
|
1539
|
+
this.context.uniformMatrix4fv(loc, transpose, value);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1307
1542
|
}
|
|
1308
1543
|
useProgram(program) {
|
|
1309
1544
|
this._glCheckError('useProgram');
|
|
@@ -1325,10 +1560,22 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1325
1560
|
vertexAttrib1fv(index, value) {
|
|
1326
1561
|
this._glCheckError('vertexAttrib1fv');
|
|
1327
1562
|
this._checkArgs('vertexAttrib1fv', arguments);
|
|
1328
|
-
if (
|
|
1329
|
-
|
|
1563
|
+
if (this._isSupported) {
|
|
1564
|
+
if (!Array.isArray(value)) {
|
|
1565
|
+
this.context.vertexAttrib1fvBuffer(index, value);
|
|
1566
|
+
}
|
|
1567
|
+
else {
|
|
1568
|
+
this.context.vertexAttrib1fv(index, value);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
else {
|
|
1572
|
+
if (!Array.isArray(value)) {
|
|
1573
|
+
this.context.vertexAttrib1fv(index, Array.from(value));
|
|
1574
|
+
}
|
|
1575
|
+
else {
|
|
1576
|
+
this.context.vertexAttrib1fv(index, value);
|
|
1577
|
+
}
|
|
1330
1578
|
}
|
|
1331
|
-
this.context.vertexAttrib1fv(index, value);
|
|
1332
1579
|
}
|
|
1333
1580
|
vertexAttrib2f(index, v0, v1) {
|
|
1334
1581
|
this._glCheckError('vertexAttrib2f');
|
|
@@ -1338,10 +1585,22 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1338
1585
|
vertexAttrib2fv(index, value) {
|
|
1339
1586
|
this._glCheckError('vertexAttrib2fv');
|
|
1340
1587
|
this._checkArgs('vertexAttrib2fv', arguments);
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1588
|
+
if (this._isSupported) {
|
|
1589
|
+
if (!Array.isArray(value)) {
|
|
1590
|
+
this.context.vertexAttrib2fvBuffer(index, value);
|
|
1591
|
+
}
|
|
1592
|
+
else {
|
|
1593
|
+
this.context.vertexAttrib2fv(index, value);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
else {
|
|
1597
|
+
if (!Array.isArray(value)) {
|
|
1598
|
+
this.context.vertexAttrib2fv(index, Array.from(value));
|
|
1599
|
+
}
|
|
1600
|
+
else {
|
|
1601
|
+
this.context.vertexAttrib2fv(index, value);
|
|
1602
|
+
}
|
|
1343
1603
|
}
|
|
1344
|
-
this.context.vertexAttrib2fv(index, value);
|
|
1345
1604
|
}
|
|
1346
1605
|
vertexAttrib3f(index, v0, v1, v2) {
|
|
1347
1606
|
this._glCheckError('vertexAttrib3f');
|
|
@@ -1351,10 +1610,22 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1351
1610
|
vertexAttrib3fv(index, value) {
|
|
1352
1611
|
this._glCheckError('vertexAttrib3fv');
|
|
1353
1612
|
this._checkArgs('vertexAttrib3fv', arguments);
|
|
1354
|
-
if (
|
|
1355
|
-
|
|
1613
|
+
if (this._isSupported) {
|
|
1614
|
+
if (!Array.isArray(value)) {
|
|
1615
|
+
this.context.vertexAttrib3fvBuffer(index, value);
|
|
1616
|
+
}
|
|
1617
|
+
else {
|
|
1618
|
+
this.context.vertexAttrib3fv(index, value);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
else {
|
|
1622
|
+
if (!Array.isArray(value)) {
|
|
1623
|
+
this.context.vertexAttrib3fv(index, Array.from(value));
|
|
1624
|
+
}
|
|
1625
|
+
else {
|
|
1626
|
+
this.context.vertexAttrib3fv(index, value);
|
|
1627
|
+
}
|
|
1356
1628
|
}
|
|
1357
|
-
this.context.vertexAttrib3fv(index, value);
|
|
1358
1629
|
}
|
|
1359
1630
|
vertexAttrib4f(index, v0, v1, v2, v3) {
|
|
1360
1631
|
this._glCheckError('vertexAttrib4f');
|
|
@@ -1364,10 +1635,22 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
|
|
|
1364
1635
|
vertexAttrib4fv(index, value) {
|
|
1365
1636
|
this._glCheckError('vertexAttrib4fv');
|
|
1366
1637
|
this._checkArgs('vertexAttrib4fv', arguments);
|
|
1367
|
-
if (
|
|
1368
|
-
|
|
1638
|
+
if (this._isSupported) {
|
|
1639
|
+
if (!Array.isArray(value)) {
|
|
1640
|
+
this.context.vertexAttrib4fvBuffer(index, value);
|
|
1641
|
+
}
|
|
1642
|
+
else {
|
|
1643
|
+
this.context.vertexAttrib4fv(index, value);
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
else {
|
|
1647
|
+
if (!Array.isArray(value)) {
|
|
1648
|
+
this.context.vertexAttrib4fv(index, Array.from(value));
|
|
1649
|
+
}
|
|
1650
|
+
else {
|
|
1651
|
+
this.context.vertexAttrib4fv(index, value);
|
|
1652
|
+
}
|
|
1369
1653
|
}
|
|
1370
|
-
this.context.vertexAttrib4fv(index, value);
|
|
1371
1654
|
}
|
|
1372
1655
|
vertexAttribPointer(index, size, type, normalized, stride, offset) {
|
|
1373
1656
|
this._glCheckError('vertexAttribPointer');
|