@tplc/wot 0.1.23 → 0.1.25

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 (35) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/components/wd-qr-code/common/cache.js +1 -0
  3. package/components/wd-qr-code/common/queue.js +41 -0
  4. package/components/wd-qr-code/common/types/cache.d.ts +3 -0
  5. package/components/wd-qr-code/common/types/queue.d.ts +4 -0
  6. package/components/wd-qr-code/js_sdk/gcanvas/bridge/bridge-weex.js +241 -0
  7. package/components/wd-qr-code/js_sdk/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  8. package/components/wd-qr-code/js_sdk/gcanvas/context-2d/FillStylePattern.js +8 -0
  9. package/components/wd-qr-code/js_sdk/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  10. package/components/wd-qr-code/js_sdk/gcanvas/context-2d/RenderingContext.js +666 -0
  11. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/ActiveInfo.js +11 -0
  12. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/Buffer.js +21 -0
  13. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/Framebuffer.js +21 -0
  14. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/GLenum.js +298 -0
  15. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/GLmethod.js +142 -0
  16. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/GLtype.js +23 -0
  17. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/Program.js +21 -0
  18. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/Renderbuffer.js +21 -0
  19. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/RenderingContext.js +1191 -0
  20. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/Shader.js +22 -0
  21. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  22. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/Texture.js +22 -0
  23. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/UniformLocation.js +22 -0
  24. package/components/wd-qr-code/js_sdk/gcanvas/context-webgl/classUtils.js +3 -0
  25. package/components/wd-qr-code/js_sdk/gcanvas/env/canvas.js +74 -0
  26. package/components/wd-qr-code/js_sdk/gcanvas/env/image.js +96 -0
  27. package/components/wd-qr-code/js_sdk/gcanvas/env/tool.js +24 -0
  28. package/components/wd-qr-code/js_sdk/gcanvas/index.js +39 -0
  29. package/components/wd-qr-code/js_sdk/uqrcode/uqrcode.js +34 -0
  30. package/components/wd-qr-code/types.ts +36 -0
  31. package/components/wd-qr-code/wd-qr-code.vue +1150 -0
  32. package/components/wd-swiper/wd-swiper.vue +8 -12
  33. package/package.json +9 -6
  34. package/types/components/wd-qr-code/wd-qr-code.vue.d.ts +327 -0
  35. package/types/components/wd-text/wd-text.vue.d.ts +1 -1
@@ -0,0 +1,1191 @@
1
+ import GLenum from './GLenum';
2
+ import ActiveInfo from './ActiveInfo';
3
+ import Buffer from './Buffer';
4
+ import Framebuffer from './Framebuffer';
5
+ import Renderbuffer from './Renderbuffer';
6
+ import Texture from './Texture';
7
+ import Program from './Program';
8
+ import Shader from './Shader';
9
+ import ShaderPrecisionFormat from './ShaderPrecisionFormat';
10
+ import UniformLocation from './UniformLocation';
11
+ import GLmethod from './GLmethod';
12
+
13
+ const processArray = (array, checkArrayType = false) => {
14
+
15
+ function joinArray(arr, sep) {
16
+ let res = '';
17
+ for (let i = 0; i < arr.length; i++) {
18
+ if (i !== 0) {
19
+ res += sep;
20
+ }
21
+ res += arr[i];
22
+ }
23
+ return res;
24
+ }
25
+
26
+ let type = 'Float32Array';
27
+ if (checkArrayType) {
28
+ if (array instanceof Uint8Array) {
29
+ type = 'Uint8Array'
30
+ } else if (array instanceof Uint16Array) {
31
+ type = 'Uint16Array';
32
+ } else if (array instanceof Uint32Array) {
33
+ type = 'Uint32Array';
34
+ } else if (array instanceof Float32Array) {
35
+ type = 'Float32Array';
36
+ } else {
37
+ throw new Error('Check array type failed. Array type is ' + typeof array);
38
+ }
39
+ }
40
+
41
+ const ArrayTypes = {
42
+ Uint8Array: 1,
43
+ Uint16Array: 2,
44
+ Uint32Array: 4,
45
+ Float32Array: 14
46
+ };
47
+ return ArrayTypes[type] + ',' + btoa(joinArray(array, ','))
48
+ }
49
+
50
+ export default class WebGLRenderingContext {
51
+
52
+ // static GBridge = null;
53
+
54
+ className = 'WebGLRenderingContext';
55
+
56
+ constructor(canvas, type, attrs) {
57
+ this._canvas = canvas;
58
+ this._type = type;
59
+ this._version = 'WebGL 1.0';
60
+ this._attrs = attrs;
61
+ this._map = new Map();
62
+
63
+ Object.keys(GLenum)
64
+ .forEach(name => Object.defineProperty(this, name, {
65
+ value: GLenum[name]
66
+ }));
67
+ }
68
+
69
+ get canvas() {
70
+ return this._canvas;
71
+ }
72
+
73
+ activeTexture = function (textureUnit) {
74
+ WebGLRenderingContext.GBridge.callNative(
75
+ this._canvas.id,
76
+ GLmethod.activeTexture + ',' + textureUnit,
77
+ true
78
+ );
79
+ }
80
+
81
+ attachShader = function (progarm, shader) {
82
+ WebGLRenderingContext.GBridge.callNative(
83
+ this._canvas.id,
84
+ GLmethod.attachShader + ',' + progarm.id + ',' + shader.id,
85
+ true
86
+ );
87
+ }
88
+
89
+ bindAttribLocation = function (program, index, name) {
90
+ WebGLRenderingContext.GBridge.callNative(
91
+ this._canvas.id,
92
+ GLmethod.bindAttribLocation + ',' + program.id + ',' + index + ',' + name,
93
+ true
94
+ )
95
+ }
96
+
97
+ bindBuffer = function (target, buffer) {
98
+ WebGLRenderingContext.GBridge.callNative(
99
+ this._canvas.id,
100
+ GLmethod.bindBuffer + ',' + target + ',' + (buffer ? buffer.id : 0),
101
+ true
102
+ );
103
+ }
104
+
105
+ bindFramebuffer = function (target, framebuffer) {
106
+ WebGLRenderingContext.GBridge.callNative(
107
+ this._canvas.id,
108
+ GLmethod.bindFramebuffer + ',' + target + ',' + (framebuffer ? framebuffer.id : 0),
109
+ true
110
+ )
111
+ }
112
+
113
+ bindRenderbuffer = function (target, renderBuffer) {
114
+ WebGLRenderingContext.GBridge.callNative(
115
+ this._canvas.id,
116
+ GLmethod.bindRenderbuffer + ',' + target + ',' + (renderBuffer ? renderBuffer.id : 0),
117
+ true
118
+ )
119
+ }
120
+
121
+ bindTexture = function (target, texture) {
122
+ WebGLRenderingContext.GBridge.callNative(
123
+ this._canvas.id,
124
+ GLmethod.bindTexture + ',' + target + ',' + (texture ? texture.id : 0),
125
+ true
126
+ )
127
+ }
128
+
129
+ blendColor = function (r, g, b, a) {
130
+ WebGLRenderingContext.GBridge.callNative(
131
+ this._canvas.id,
132
+ GLmethod.blendColor + ',' + target + ',' + r + ',' + g + ',' + b + ',' + a,
133
+ true
134
+ )
135
+ }
136
+
137
+ blendEquation = function (mode) {
138
+ WebGLRenderingContext.GBridge.callNative(
139
+ this._canvas.id,
140
+ GLmethod.blendEquation + ',' + mode,
141
+ true
142
+ )
143
+ }
144
+
145
+ blendEquationSeparate = function (modeRGB, modeAlpha) {
146
+ WebGLRenderingContext.GBridge.callNative(
147
+ this._canvas.id,
148
+ GLmethod.blendEquationSeparate + ',' + modeRGB + ',' + modeAlpha,
149
+ true
150
+ )
151
+ }
152
+
153
+
154
+ blendFunc = function (sfactor, dfactor) {
155
+ WebGLRenderingContext.GBridge.callNative(
156
+ this._canvas.id,
157
+ GLmethod.blendFunc + ',' + sfactor + ',' + dfactor,
158
+ true
159
+ );
160
+ }
161
+
162
+ blendFuncSeparate = function (srcRGB, dstRGB, srcAlpha, dstAlpha) {
163
+ WebGLRenderingContext.GBridge.callNative(
164
+ this._canvas.id,
165
+ GLmethod.blendFuncSeparate + ',' + srcRGB + ',' + dstRGB + ',' + srcAlpha + ',' + dstAlpha,
166
+ true
167
+ );
168
+ }
169
+
170
+ bufferData = function (target, data, usage) {
171
+ WebGLRenderingContext.GBridge.callNative(
172
+ this._canvas.id,
173
+ GLmethod.bufferData + ',' + target + ',' + processArray(data, true) + ',' + usage,
174
+ true
175
+ )
176
+ }
177
+
178
+ bufferSubData = function (target, offset, data) {
179
+ WebGLRenderingContext.GBridge.callNative(
180
+ this._canvas.id,
181
+ GLmethod.bufferSubData + ',' + target + ',' + offset + ',' + processArray(data, true),
182
+ true
183
+ )
184
+ }
185
+
186
+ checkFramebufferStatus = function (target) {
187
+ const result = WebGLRenderingContext.GBridge.callNative(
188
+ this._canvas.id,
189
+ GLmethod.checkFramebufferStatus + ',' + target
190
+ );
191
+ return Number(result);
192
+ }
193
+
194
+ clear = function (mask) {
195
+ WebGLRenderingContext.GBridge.callNative(
196
+ this._canvas.id,
197
+ GLmethod.clear + ',' + mask
198
+ );
199
+ this._canvas._needRender = true;
200
+ }
201
+
202
+ clearColor = function (r, g, b, a) {
203
+ WebGLRenderingContext.GBridge.callNative(
204
+ this._canvas.id,
205
+ GLmethod.clearColor + ',' + r + ',' + g + ',' + b,
206
+ true
207
+ )
208
+ }
209
+
210
+ clearDepth = function (depth) {
211
+ WebGLRenderingContext.GBridge.callNative(
212
+ this._canvas.id,
213
+ GLmethod.clearDepth + ',' + depth,
214
+ true
215
+ )
216
+ }
217
+
218
+ clearStencil = function (s) {
219
+ WebGLRenderingContext.GBridge.callNative(
220
+ this._canvas.id,
221
+ GLmethod.clearStencil + ',' + s
222
+ );
223
+ }
224
+
225
+ colorMask = function (r, g, b, a) {
226
+ WebGLRenderingContext.GBridge.callNative(
227
+ this._canvas.id,
228
+ GLmethod.colorMask + ',' + r + ',' + g + ',' + b + ',' + a
229
+ )
230
+ }
231
+
232
+ compileShader = function (shader) {
233
+ WebGLRenderingContext.GBridge.callNative(
234
+ this._canvas.id,
235
+ GLmethod.compileShader + ',' + shader.id,
236
+ true
237
+ )
238
+ }
239
+
240
+ compressedTexImage2D = function (target, level, internalformat, width, height, border, pixels) {
241
+ WebGLRenderingContext.GBridge.callNative(
242
+ this._canvas.id,
243
+ GLmethod.compressedTexImage2D + ',' + target + ',' + level + ',' + internalformat + ',' +
244
+ width + ',' + height + ',' + border + ',' + processArray(pixels),
245
+ true
246
+ )
247
+ }
248
+
249
+ compressedTexSubImage2D = function (target, level, xoffset, yoffset, width, height, format, pixels) {
250
+ WebGLRenderingContext.GBridge.callNative(
251
+ this._canvas.id,
252
+ GLmethod.compressedTexSubImage2D + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset + ',' +
253
+ width + ',' + height + ',' + format + ',' + processArray(pixels),
254
+ true
255
+ )
256
+ }
257
+
258
+
259
+ copyTexImage2D = function (target, level, internalformat, x, y, width, height, border) {
260
+ WebGLRenderingContext.GBridge.callNative(
261
+ this._canvas.id,
262
+ GLmethod.copyTexImage2D + ',' + target + ',' + level + ',' + internalformat + ',' + x + ',' + y + ',' +
263
+ width + ',' + height + ',' + border,
264
+ true
265
+ );
266
+ }
267
+
268
+ copyTexSubImage2D = function (target, level, xoffset, yoffset, x, y, width, height) {
269
+ WebGLRenderingContext.GBridge.callNative(
270
+ this._canvas.id,
271
+ GLmethod.copyTexSubImage2D + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset + ',' + x + ',' + y + ',' +
272
+ width + ',' + height
273
+ );
274
+ }
275
+
276
+ createBuffer = function () {
277
+ const result = WebGLRenderingContext.GBridge.callNative(
278
+ this._canvas.id,
279
+ GLmethod.createBuffer + ''
280
+ );
281
+ const buffer = new Buffer(result);
282
+ this._map.set(buffer.uuid(), buffer);
283
+ return buffer;
284
+ }
285
+
286
+ createFramebuffer = function () {
287
+ const result = WebGLRenderingContext.GBridge.callNative(
288
+ this._canvas.id,
289
+ GLmethod.createFramebuffer + ''
290
+ );
291
+ const framebuffer = new Framebuffer(result);
292
+ this._map.set(framebuffer.uuid(), framebuffer);
293
+ return framebuffer;
294
+ }
295
+
296
+
297
+ createProgram = function () {
298
+ const id = WebGLRenderingContext.GBridge.callNative(
299
+ this._canvas.id,
300
+ GLmethod.createProgram + ''
301
+ );
302
+ const program = new Program(id);
303
+ this._map.set(program.uuid(), program);
304
+ return program;
305
+ }
306
+
307
+ createRenderbuffer = function () {
308
+ const id = WebGLRenderingContext.GBridge.callNative(
309
+ this._canvas.id,
310
+ GLmethod.createRenderbuffer + ''
311
+ )
312
+ const renderBuffer = new Renderbuffer(id);
313
+ this._map.set(renderBuffer.uuid(), renderBuffer);
314
+ return renderBuffer;
315
+ }
316
+
317
+ createShader = function (type) {
318
+ const id = WebGLRenderingContext.GBridge.callNative(
319
+ this._canvas.id,
320
+ GLmethod.createShader + ',' + type
321
+ )
322
+ const shader = new Shader(id, type);
323
+ this._map.set(shader.uuid(), shader);
324
+ return shader;
325
+ }
326
+
327
+ createTexture = function () {
328
+ const id = WebGLRenderingContext.GBridge.callNative(
329
+ this._canvas.id,
330
+ GLmethod.createTexture + ''
331
+ );
332
+ const texture = new Texture(id);
333
+ this._map.set(texture.uuid(), texture);
334
+ return texture;
335
+ }
336
+
337
+ cullFace = function (mode) {
338
+ WebGLRenderingContext.GBridge.callNative(
339
+ this._canvas.id,
340
+ GLmethod.cullFace + ',' + mode,
341
+ true
342
+ )
343
+ }
344
+
345
+
346
+ deleteBuffer = function (buffer) {
347
+ WebGLRenderingContext.GBridge.callNative(
348
+ this._canvas.id,
349
+ GLmethod.deleteBuffer + ',' + buffer.id,
350
+ true
351
+ )
352
+ }
353
+
354
+ deleteFramebuffer = function (framebuffer) {
355
+ WebGLRenderingContext.GBridge.callNative(
356
+ this._canvas.id,
357
+ GLmethod.deleteFramebuffer + ',' + framebuffer.id,
358
+ true
359
+ )
360
+ }
361
+
362
+ deleteProgram = function (program) {
363
+ WebGLRenderingContext.GBridge.callNative(
364
+ this._canvas.id,
365
+ GLmethod.deleteProgram + ',' + program.id,
366
+ true
367
+ )
368
+ }
369
+
370
+ deleteRenderbuffer = function (renderbuffer) {
371
+ WebGLRenderingContext.GBridge.callNative(
372
+ this._canvas.id,
373
+ GLmethod.deleteRenderbuffer + ',' + renderbuffer.id,
374
+ true
375
+ )
376
+ }
377
+
378
+ deleteShader = function (shader) {
379
+ WebGLRenderingContext.GBridge.callNative(
380
+ this._canvas.id,
381
+ GLmethod.deleteShader + ',' + shader.id,
382
+ true
383
+ )
384
+ }
385
+
386
+ deleteTexture = function (texture) {
387
+ WebGLRenderingContext.GBridge.callNative(
388
+ this._canvas.id,
389
+ GLmethod.deleteTexture + ',' + texture.id,
390
+ true
391
+ )
392
+ }
393
+
394
+ depthFunc = function (func) {
395
+ WebGLRenderingContext.GBridge.callNative(
396
+ this._canvas.id,
397
+ GLmethod.depthFunc + ',' + func
398
+ )
399
+ }
400
+
401
+ depthMask = function (flag) {
402
+ WebGLRenderingContext.GBridge.callNative(
403
+ this._canvas.id,
404
+ GLmethod.depthMask + ',' + Number(flag),
405
+ true
406
+ )
407
+ }
408
+
409
+ depthRange = function (zNear, zFar) {
410
+ WebGLRenderingContext.GBridge.callNative(
411
+ this._canvas.id,
412
+ GLmethod.depthRange + ',' + zNear + ',' + zFar,
413
+ true
414
+ )
415
+ }
416
+
417
+ detachShader = function (program, shader) {
418
+ WebGLRenderingContext.GBridge.callNative(
419
+ this._canvas.id,
420
+ GLmethod.detachShader + ',' + program.id + ',' + shader.id,
421
+ true
422
+ )
423
+ }
424
+
425
+ disable = function (cap) {
426
+ WebGLRenderingContext.GBridge.callNative(
427
+ this._canvas.id,
428
+ GLmethod.disable + ',' + cap,
429
+ true
430
+ )
431
+ }
432
+
433
+ disableVertexAttribArray = function (index) {
434
+ WebGLRenderingContext.GBridge.callNative(
435
+ this._canvas.id,
436
+ GLmethod.disableVertexAttribArray + ',' + index,
437
+ true
438
+ );
439
+ }
440
+
441
+ drawArrays = function (mode, first, count) {
442
+ WebGLRenderingContext.GBridge.callNative(
443
+ this._canvas.id,
444
+ GLmethod.drawArrays + ',' + mode + ',' + first + ',' + count
445
+ )
446
+ this._canvas._needRender = true;
447
+ }
448
+
449
+ drawElements = function (mode, count, type, offset) {
450
+ WebGLRenderingContext.GBridge.callNative(
451
+ this._canvas.id,
452
+ GLmethod.drawElements + ',' + mode + ',' + count + ',' + type + ',' + offset + ';'
453
+ );
454
+ this._canvas._needRender = true;
455
+ }
456
+
457
+ enable = function (cap) {
458
+ WebGLRenderingContext.GBridge.callNative(
459
+ this._canvas.id,
460
+ GLmethod.enable + ',' + cap,
461
+ true
462
+ );
463
+ }
464
+
465
+ enableVertexAttribArray = function (index) {
466
+ WebGLRenderingContext.GBridge.callNative(
467
+ this._canvas.id,
468
+ GLmethod.enableVertexAttribArray + ',' + index,
469
+ true
470
+ )
471
+ }
472
+
473
+
474
+ flush = function () {
475
+ WebGLRenderingContext.GBridge.callNative(
476
+ this._canvas.id,
477
+ GLmethod.flush + ''
478
+ )
479
+ }
480
+
481
+ framebufferRenderbuffer = function (target, attachment, textarget, texture, level) {
482
+ WebGLRenderingContext.GBridge.callNative(
483
+ this._canvas.id,
484
+ GLmethod.framebufferRenderbuffer + ',' + target + ',' + attachment + ',' + textarget + ',' + (texture ? texture.id : 0) + ',' + level,
485
+ true
486
+ )
487
+ }
488
+
489
+ framebufferTexture2D = function (target, attachment, textarget, texture, level) {
490
+ WebGLRenderingContext.GBridge.callNative(
491
+ this._canvas.id,
492
+ GLmethod.framebufferTexture2D + ',' + target + ',' + attachment + ',' + textarget + ',' + (texture ? texture.id : 0) + ',' + level,
493
+ true
494
+ )
495
+ }
496
+
497
+ frontFace = function (mode) {
498
+ WebGLRenderingContext.GBridge.callNative(
499
+ this._canvas.id,
500
+ GLmethod.frontFace + ',' + mode,
501
+ true
502
+ )
503
+ }
504
+
505
+ generateMipmap = function (target) {
506
+ WebGLRenderingContext.GBridge.callNative(
507
+ this._canvas.id,
508
+ GLmethod.generateMipmap + ',' + target,
509
+ true
510
+ )
511
+ }
512
+
513
+ getActiveAttrib = function (progarm, index) {
514
+ const resultString = WebGLRenderingContext.GBridge.callNative(
515
+ this._canvas.id,
516
+ GLmethod.getActiveAttrib + ',' + progarm.id + ',' + index
517
+ )
518
+ const [type, size, name] = resultString.split(',');
519
+ return new ActiveInfo({
520
+ type: Number(type),
521
+ size: Number(size),
522
+ name
523
+ });
524
+ }
525
+
526
+ getActiveUniform = function (progarm, index) {
527
+ const resultString = WebGLRenderingContext.GBridge.callNative(
528
+ this._canvas.id,
529
+ GLmethod.getActiveUniform + ',' + progarm.id + ',' + index
530
+ );
531
+ const [type, size, name] = resultString.split(',');
532
+ return new ActiveInfo({
533
+ type: Number(type),
534
+ size: Number(size),
535
+ name
536
+ })
537
+ }
538
+
539
+ getAttachedShaders = function (progarm) {
540
+ const result = WebGLRenderingContext.GBridge.callNative(
541
+ this._canvas.id,
542
+ GLmethod.getAttachedShaders + ',' + progarm.id
543
+ );
544
+ const [type, ...ids] = result;
545
+ return ids.map(id => this._map.get(Shader.uuid(id)));
546
+ }
547
+
548
+ getAttribLocation = function (progarm, name) {
549
+ return WebGLRenderingContext.GBridge.callNative(
550
+ this._canvas.id,
551
+ GLmethod.getAttribLocation + ',' + progarm.id + ',' + name
552
+ )
553
+ }
554
+
555
+ getBufferParameter = function (target, pname) {
556
+ const result = WebGLRenderingContext.GBridge.callNative(
557
+ this._canvas.id,
558
+ GLmethod.getBufferParameter + ',' + target + ',' + pname
559
+ );
560
+ const [type, res] = getBufferParameter;
561
+ return res;
562
+ }
563
+
564
+ getError = function () {
565
+ const result = WebGLRenderingContext.GBridge.callNative(
566
+ this._canvas.id,
567
+ GLmethod.getError + ''
568
+ )
569
+ return result;
570
+ }
571
+
572
+ getExtension = function (name) {
573
+ return null;
574
+ }
575
+
576
+ getFramebufferAttachmentParameter = function (target, attachment, pname) {
577
+ const result = WebGLRenderingContext.GBridge.callNative(
578
+ this._canvas.id,
579
+ GLmethod.getFramebufferAttachmentParameter + ',' + target + ',' + attachment + ',' + pname
580
+ )
581
+ switch (pname) {
582
+ case GLenum.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
583
+ return this._map.get(Renderbuffer.uuid(result)) || this._map.get(Texture.uuid(result)) || null;
584
+ default:
585
+ return result;
586
+ }
587
+ }
588
+
589
+ getParameter = function (pname) {
590
+ const result = WebGLRenderingContext.GBridge.callNative(
591
+ this._canvas.id,
592
+ GLmethod.getParameter + ',' + pname
593
+ )
594
+ switch (pname) {
595
+ case GLenum.VERSION:
596
+ return this._version;
597
+ case GLenum.ARRAY_BUFFER_BINDING: // buffer
598
+ case GLenum.ELEMENT_ARRAY_BUFFER_BINDING: // buffer
599
+ return this._map.get(Buffer.uuid(result)) || null;
600
+ case GLenum.CURRENT_PROGRAM: // program
601
+ return this._map.get(Program.uuid(result)) || null;
602
+ case GLenum.FRAMEBUFFER_BINDING: // framebuffer
603
+ return this._map.get(Framebuffer.uuid(result)) || null;
604
+ case GLenum.RENDERBUFFER_BINDING: // renderbuffer
605
+ return this._map.get(Renderbuffer.uuid(result)) || null;
606
+ case GLenum.TEXTURE_BINDING_2D: // texture
607
+ case GLenum.TEXTURE_BINDING_CUBE_MAP: // texture
608
+ return this._map.get(Texture.uuid(result)) || null;
609
+ case GLenum.ALIASED_LINE_WIDTH_RANGE: // Float32Array
610
+ case GLenum.ALIASED_POINT_SIZE_RANGE: // Float32Array
611
+ case GLenum.BLEND_COLOR: // Float32Array
612
+ case GLenum.COLOR_CLEAR_VALUE: // Float32Array
613
+ case GLenum.DEPTH_RANGE: // Float32Array
614
+ case GLenum.MAX_VIEWPORT_DIMS: // Int32Array
615
+ case GLenum.SCISSOR_BOX: // Int32Array
616
+ case GLenum.VIEWPORT: // Int32Array
617
+ case GLenum.COMPRESSED_TEXTURE_FORMATS: // Uint32Array
618
+ default:
619
+ const [type, ...res] = result.split(',');
620
+ if (res.length === 1) {
621
+ return Number(res[0]);
622
+ } else {
623
+ return res.map(Number);
624
+ }
625
+ }
626
+ }
627
+
628
+ getProgramInfoLog = function (progarm) {
629
+ return WebGLRenderingContext.GBridge.callNative(
630
+ this._canvas.id,
631
+ GLmethod.getProgramInfoLog + ',' + progarm.id
632
+ )
633
+ }
634
+
635
+ getProgramParameter = function (program, pname) {
636
+ const res = WebGLRenderingContext.GBridge.callNative(
637
+ this._canvas.id,
638
+ GLmethod.getProgramParameter + ',' + program.id + ',' + pname
639
+ );
640
+
641
+ const [type, result] = res.split(',').map(i => parseInt(i));
642
+
643
+ if (type === 1) {
644
+ return Boolean(result);
645
+ } else if (type === 2) {
646
+ return result;
647
+ } else {
648
+ throw new Error('Unrecongized program paramater ' + res + ', type: ' + typeof res);
649
+ }
650
+ }
651
+
652
+
653
+ getRenderbufferParameter = function (target, pname) {
654
+ const result = WebGLRenderingContext.GBridge.callNative(
655
+ this._canvas.id,
656
+ GLmethod.getRenderbufferParameter + ',' + target + ',' + pname
657
+ )
658
+ return result;
659
+ }
660
+
661
+
662
+ getShaderInfoLog = function (shader) {
663
+ return WebGLRenderingContext.GBridge.callNative(
664
+ this._canvas.id,
665
+ GLmethod.getShaderInfoLog + ',' + shader.id
666
+ );
667
+ }
668
+
669
+ getShaderParameter = function (shader, pname) {
670
+ return WebGLRenderingContext.GBridge.callNative(
671
+ this._canvas.id,
672
+ GLmethod.getShaderParameter + ',' + shader.id + ',' + pname
673
+ )
674
+ }
675
+
676
+ getShaderPrecisionFormat = function (shaderType, precisionType) {
677
+ const [rangeMin, rangeMax, precision] = WebGLRenderingContext.GBridge.callNative(
678
+ this._canvas.id,
679
+ GLmethod.getShaderPrecisionFormat + ',' + shaderType + ',' + precisionType
680
+ );
681
+ const shaderPrecisionFormat = new ShaderPrecisionFormat({
682
+ rangeMin: Number(rangeMin),
683
+ rangeMax: Number(rangeMax),
684
+ precision: Number(precision)
685
+ });
686
+ return shaderPrecisionFormat;
687
+ }
688
+
689
+ getShaderSource = function (shader) {
690
+ const result = WebGLRenderingContext.GBridge.callNative(
691
+ this._canvas.id,
692
+ GLmethod.getShaderSource + ',' + shader.id
693
+ );
694
+ return result;
695
+ }
696
+
697
+ getSupportedExtensions = function () {
698
+ return Object.keys({});
699
+ }
700
+
701
+ getTexParameter = function (target, pname) {
702
+ const result = WebGLRenderingContext.GBridge.callNative(
703
+ this._canvas.id,
704
+ GLmethod.getTexParameter + ',' + target + ',' + pname
705
+ )
706
+ return result;
707
+ }
708
+
709
+ getUniformLocation = function (program, name) {
710
+ const id = WebGLRenderingContext.GBridge.callNative(
711
+ this._canvas.id,
712
+ GLmethod.getUniformLocation + ',' + program.id + ',' + name
713
+ );
714
+ if (id === -1) {
715
+ return null;
716
+ } else {
717
+ return new UniformLocation(Number(id));
718
+ }
719
+ }
720
+
721
+ getVertexAttrib = function (index, pname) {
722
+ const result = WebGLRenderingContext.GBridge.callNative(
723
+ this._canvas.id,
724
+ GLmethod.getVertexAttrib + ',' + index + ',' + pname
725
+ );
726
+ switch (pname) {
727
+ case GLenum.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
728
+ return this._map.get(Buffer.uuid(result)) || null;
729
+ case GLenum.CURRENT_VERTEX_ATTRIB: // Float32Array
730
+ default:
731
+ return result;
732
+ }
733
+ }
734
+
735
+ getVertexAttribOffset = function (index, pname) {
736
+ const result = WebGLRenderingContext.GBridge.callNative(
737
+ this._canvas.id,
738
+ GLmethod.getVertexAttribOffset + ',' + index + ',' + pname
739
+ )
740
+ return Number(result);
741
+ }
742
+
743
+ isBuffer = function (buffer) {
744
+ const result = WebGLRenderingContext.GBridge.callNative(
745
+ this._canvas.id,
746
+ GLmethod.isBuffer + ',' + buffer.id
747
+ )
748
+ return Boolean(result);
749
+ }
750
+
751
+ isContextLost = function () {
752
+ return false;
753
+ }
754
+
755
+ isEnabled = function (cap) {
756
+ const result = WebGLRenderingContext.GBridge.callNative(
757
+ this._canvas.id,
758
+ GLmethod.isEnabled + ',' + cap
759
+ )
760
+ return Boolean(result);
761
+ }
762
+
763
+ isFramebuffer = function (framebuffer) {
764
+ const result = WebGLRenderingContext.GBridge.callNative(
765
+ this._canvas.id,
766
+ GLmethod.isFramebuffer + ',' + framebuffer.id
767
+ )
768
+ return Boolean(result);
769
+ }
770
+
771
+ isProgram = function (program) {
772
+ const result = WebGLRenderingContext.GBridge.callNative(
773
+ this._canvas.id,
774
+ GLmethod.isProgram + ',' + program.id
775
+ )
776
+ return Boolean(result);
777
+ }
778
+
779
+ isRenderbuffer = function (renderBuffer) {
780
+ const result = WebGLRenderingContext.GBridge.callNative(
781
+ this._canvas.id,
782
+ GLmethod.isRenderbuffer + ',' + renderbuffer.id
783
+ )
784
+ return Boolean(result);
785
+ }
786
+
787
+ isShader = function (shader) {
788
+ const result = WebGLRenderingContext.GBridge.callNative(
789
+ this._canvas.id,
790
+ GLmethod.isShader + ',' + shader.id
791
+ )
792
+ return Boolean(result);
793
+ }
794
+
795
+ isTexture = function (texture) {
796
+ const result = WebGLRenderingContext.GBridge.callNative(
797
+ this._canvas.id,
798
+ GLmethod.isTexture + ',' + texture.id
799
+ );
800
+ return Boolean(result);
801
+ }
802
+
803
+ lineWidth = function (width) {
804
+ WebGLRenderingContext.GBridge.callNative(
805
+ this._canvas.id,
806
+ GLmethod.lineWidth + ',' + width,
807
+ true
808
+ )
809
+ }
810
+
811
+ linkProgram = function (program) {
812
+ WebGLRenderingContext.GBridge.callNative(
813
+ this._canvas.id,
814
+ GLmethod.linkProgram + ',' + program.id,
815
+ true
816
+ );
817
+ }
818
+
819
+
820
+ pixelStorei = function (pname, param) {
821
+ WebGLRenderingContext.GBridge.callNative(
822
+ this._canvas.id,
823
+ GLmethod.pixelStorei + ',' + pname + ',' + Number(param)
824
+ )
825
+ }
826
+
827
+ polygonOffset = function (factor, units) {
828
+ WebGLRenderingContext.GBridge.callNative(
829
+ this._canvas.id,
830
+ GLmethod.polygonOffset + ',' + factor + ',' + units
831
+ )
832
+ }
833
+
834
+ readPixels = function (x, y, width, height, format, type, pixels) {
835
+ const result = WebGLRenderingContext.GBridge.callNative(
836
+ this._canvas.id,
837
+ GLmethod.readPixels + ',' + x + ',' + y + ',' + width + ',' + height + ',' + format + ',' + type
838
+ )
839
+ return result;
840
+ }
841
+
842
+ renderbufferStorage = function (target, internalFormat, width, height) {
843
+ WebGLRenderingContext.GBridge.callNative(
844
+ this._canvas.id,
845
+ GLmethod.renderbufferStorage + ',' + target + ',' + internalFormat + ',' + width + ',' + height,
846
+ true
847
+ )
848
+ }
849
+
850
+ sampleCoverage = function (value, invert) {
851
+ WebGLRenderingContext.GBridge.callNative(
852
+ this._canvas.id,
853
+ GLmethod.sampleCoverage + ',' + value + ',' + Number(invert),
854
+ true
855
+ )
856
+ }
857
+
858
+ scissor = function (x, y, width, height) {
859
+ WebGLRenderingContext.GBridge.callNative(
860
+ this._canvas.id,
861
+ GLmethod.scissor + ',' + x + ',' + y + ',' + width + ',' + height,
862
+ true
863
+ )
864
+ }
865
+
866
+ shaderSource = function (shader, source) {
867
+ WebGLRenderingContext.GBridge.callNative(
868
+ this._canvas.id,
869
+ GLmethod.shaderSource + ',' + shader.id + ',' + source
870
+ )
871
+ }
872
+
873
+ stencilFunc = function (func, ref, mask) {
874
+ WebGLRenderingContext.GBridge.callNative(
875
+ this._canvas.id,
876
+ GLmethod.stencilFunc + ',' + func + ',' + ref + ',' + mask,
877
+ true
878
+ )
879
+ }
880
+
881
+ stencilFuncSeparate = function (face, func, ref, mask) {
882
+ WebGLRenderingContext.GBridge.callNative(
883
+ this._canvas.id,
884
+ GLmethod.stencilFuncSeparate + ',' + face + ',' + func + ',' + ref + ',' + mask,
885
+ true
886
+ )
887
+ }
888
+
889
+ stencilMask = function (mask) {
890
+ WebGLRenderingContext.GBridge.callNative(
891
+ this._canvas.id,
892
+ GLmethod.stencilMask + ',' + mask,
893
+ true
894
+ )
895
+ }
896
+
897
+ stencilMaskSeparate = function (face, mask) {
898
+ WebGLRenderingContext.GBridge.callNative(
899
+ this._canvas.id,
900
+ GLmethod.stencilMaskSeparate + ',' + face + ',' + mask,
901
+ true
902
+ )
903
+ }
904
+
905
+ stencilOp = function (fail, zfail, zpass) {
906
+ WebGLRenderingContext.GBridge.callNative(
907
+ this._canvas.id,
908
+ GLmethod.stencilOp + ',' + fail + ',' + zfail + ',' + zpass
909
+ )
910
+ }
911
+
912
+ stencilOpSeparate = function (face, fail, zfail, zpass) {
913
+ WebGLRenderingContext.GBridge.callNative(
914
+ this._canvas.id,
915
+ GLmethod.stencilOp + ',' + face + ',' + fail + ',' + zfail + ',' + zpass,
916
+ true
917
+ )
918
+ }
919
+
920
+ texImage2D = function (...args) {
921
+ WebGLRenderingContext.GBridge.texImage2D(this._canvas.id, ...args);
922
+ }
923
+
924
+
925
+ texParameterf = function (target, pname, param) {
926
+ WebGLRenderingContext.GBridge.callNative(
927
+ this._canvas.id,
928
+ GLmethod.texParameterf + ',' + target + ',' + pname + ',' + param,
929
+ true
930
+ )
931
+ }
932
+
933
+ texParameteri = function (target, pname, param) {
934
+ WebGLRenderingContext.GBridge.callNative(
935
+ this._canvas.id,
936
+ GLmethod.texParameteri + ',' + target + ',' + pname + ',' + param
937
+ )
938
+ }
939
+
940
+ texSubImage2D = function (...args) {
941
+ WebGLRenderingContext.GBridge.texSubImage2D(this._canvas.id, ...args);
942
+ }
943
+
944
+ uniform1f = function (location, v0) {
945
+ WebGLRenderingContext.GBridge.callNative(
946
+ this._canvas.id,
947
+ GLmethod.uniform1f + ',' + location.id + ',' + v0
948
+ )
949
+ }
950
+
951
+ uniform1fv = function (location, value) {
952
+ WebGLRenderingContext.GBridge.callNative(
953
+ this._canvas.id,
954
+ GLmethod.uniform1fv + ',' + location.id + ',' + processArray(value),
955
+ true
956
+ )
957
+ }
958
+
959
+ uniform1i = function (location, v0) {
960
+ WebGLRenderingContext.GBridge.callNative(
961
+ this._canvas.id,
962
+ GLmethod.uniform1i + ',' + location.id + ',' + v0,
963
+ // true
964
+ )
965
+ }
966
+
967
+ uniform1iv = function (location, value) {
968
+ WebGLRenderingContext.GBridge.callNative(
969
+ this._canvas.id,
970
+ GLmethod.uniform1iv + ',' + location.id + ',' + processArray(value),
971
+ true
972
+ )
973
+ }
974
+
975
+ uniform2f = function (location, v0, v1) {
976
+ WebGLRenderingContext.GBridge.callNative(
977
+ this._canvas.id,
978
+ GLmethod.uniform2f + ',' + location.id + ',' + v0 + ',' + v1,
979
+ true
980
+ )
981
+ }
982
+
983
+ uniform2fv = function (location, value) {
984
+ WebGLRenderingContext.GBridge.callNative(
985
+ this._canvas.id,
986
+ GLmethod.uniform2fv + ',' + location.id + ',' + processArray(value),
987
+ true
988
+ )
989
+ }
990
+
991
+ uniform2i = function (location, v0, v1) {
992
+ WebGLRenderingContext.GBridge.callNative(
993
+ this._canvas.id,
994
+ GLmethod.uniform2i + ',' + location.id + ',' + v0 + ',' + v1,
995
+ true
996
+ )
997
+ }
998
+
999
+ uniform2iv = function (location, value) {
1000
+ WebGLRenderingContext.GBridge.callNative(
1001
+ this._canvas.id,
1002
+ GLmethod.uniform2iv + ',' + location.id + ',' + processArray(value),
1003
+ true
1004
+ )
1005
+ }
1006
+
1007
+ uniform3f = function (location, v0, v1, v2) {
1008
+ WebGLRenderingContext.GBridge.callNative(
1009
+ this._canvas.id,
1010
+ GLmethod.uniform3f + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2,
1011
+ true
1012
+ )
1013
+ }
1014
+
1015
+ uniform3fv = function (location, value) {
1016
+ WebGLRenderingContext.GBridge.callNative(
1017
+ this._canvas.id,
1018
+ GLmethod.uniform3fv + ',' + location.id + ',' + processArray(value),
1019
+ true
1020
+ )
1021
+ }
1022
+
1023
+ uniform3i = function (location, v0, v1, v2) {
1024
+ WebGLRenderingContext.GBridge.callNative(
1025
+ this._canvas.id,
1026
+ GLmethod.uniform3i + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2,
1027
+ true
1028
+ )
1029
+ }
1030
+
1031
+ uniform3iv = function (location, value) {
1032
+ WebGLRenderingContext.GBridge.callNative(
1033
+ this._canvas.id,
1034
+ GLmethod.uniform3iv + ',' + location.id + ',' + processArray(value),
1035
+ true
1036
+ )
1037
+ }
1038
+
1039
+ uniform4f = function (location, v0, v1, v2, v3) {
1040
+ WebGLRenderingContext.GBridge.callNative(
1041
+ this._canvas.id,
1042
+ GLmethod.uniform4f + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2 + ',' + v3,
1043
+ true
1044
+ )
1045
+ }
1046
+
1047
+ uniform4fv = function (location, value) {
1048
+ WebGLRenderingContext.GBridge.callNative(
1049
+ this._canvas.id,
1050
+ GLmethod.uniform4fv + ',' + location.id + ',' + processArray(value),
1051
+ true
1052
+ )
1053
+ }
1054
+
1055
+ uniform4i = function (location, v0, v1, v2, v3) {
1056
+ WebGLRenderingContext.GBridge.callNative(
1057
+ this._canvas.id,
1058
+ GLmethod.uniform4i + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2 + ',' + v3,
1059
+ true
1060
+ )
1061
+ }
1062
+
1063
+ uniform4iv = function (location, value) {
1064
+ WebGLRenderingContext.GBridge.callNative(
1065
+ this._canvas.id,
1066
+ GLmethod.uniform4iv + ',' + location.id + ',' + processArray(value, true),
1067
+ true
1068
+ )
1069
+ }
1070
+
1071
+ uniformMatrix2fv = function (location, transpose, value) {
1072
+ WebGLRenderingContext.GBridge.callNative(
1073
+ this._canvas.id,
1074
+ GLmethod.uniformMatrix2fv + ',' + location.id + ',' + Number(transpose) + ',' + processArray(value),
1075
+ true
1076
+ )
1077
+ }
1078
+
1079
+ uniformMatrix3fv = function (location, transpose, value) {
1080
+ WebGLRenderingContext.GBridge.callNative(
1081
+ this._canvas.id,
1082
+ GLmethod.uniformMatrix3fv + ',' + location.id + ',' + Number(transpose) + ',' + processArray(value),
1083
+ true
1084
+ )
1085
+ }
1086
+
1087
+ uniformMatrix4fv = function (location, transpose, value) {
1088
+ WebGLRenderingContext.GBridge.callNative(
1089
+ this._canvas.id,
1090
+ GLmethod.uniformMatrix4fv + ',' + location.id + ',' + Number(transpose) + ',' + processArray(value),
1091
+ true
1092
+ );
1093
+ }
1094
+
1095
+ useProgram = function (progarm) {
1096
+ WebGLRenderingContext.GBridge.callNative(
1097
+ this._canvas.id,
1098
+ GLmethod.useProgram + ',' + progarm.id + '',
1099
+ true
1100
+ )
1101
+ }
1102
+
1103
+
1104
+ validateProgram = function (program) {
1105
+ WebGLRenderingContext.GBridge.callNative(
1106
+ this._canvas.id,
1107
+ GLmethod.validateProgram + ',' + program.id,
1108
+ true
1109
+ )
1110
+ }
1111
+
1112
+ vertexAttrib1f = function (index, v0) {
1113
+ WebGLRenderingContext.GBridge.callNative(
1114
+ this._canvas.id,
1115
+ GLmethod.vertexAttrib1f + ',' + index + ',' + v0,
1116
+ true
1117
+ )
1118
+ }
1119
+
1120
+ vertexAttrib2f = function (index, v0, v1) {
1121
+ WebGLRenderingContext.GBridge.callNative(
1122
+ this._canvas.id,
1123
+ GLmethod.vertexAttrib2f + ',' + index + ',' + v0 + ',' + v1,
1124
+ true
1125
+ )
1126
+ }
1127
+
1128
+ vertexAttrib3f = function (index, v0, v1, v2) {
1129
+ WebGLRenderingContext.GBridge.callNative(
1130
+ this._canvas.id,
1131
+ GLmethod.vertexAttrib3f + ',' + index + ',' + v0 + ',' + v1 + ',' + v2,
1132
+ true
1133
+ )
1134
+ }
1135
+
1136
+ vertexAttrib4f = function (index, v0, v1, v2, v3) {
1137
+ WebGLRenderingContext.GBridge.callNative(
1138
+ this._canvas.id,
1139
+ GLmethod.vertexAttrib4f + ',' + index + ',' + v0 + ',' + v1 + ',' + v2 + ',' + v3,
1140
+ true
1141
+ )
1142
+ }
1143
+
1144
+ vertexAttrib1fv = function (index, value) {
1145
+ WebGLRenderingContext.GBridge.callNative(
1146
+ this._canvas.id,
1147
+ GLmethod.vertexAttrib1fv + ',' + index + ',' + processArray(value),
1148
+ true
1149
+ )
1150
+ }
1151
+
1152
+ vertexAttrib2fv = function (index, value) {
1153
+ WebGLRenderingContext.GBridge.callNative(
1154
+ this._canvas.id,
1155
+ GLmethod.vertexAttrib2fv + ',' + index + ',' + processArray(value),
1156
+ true
1157
+ )
1158
+ }
1159
+
1160
+ vertexAttrib3fv = function (index, value) {
1161
+ WebGLRenderingContext.GBridge.callNative(
1162
+ this._canvas.id,
1163
+ GLmethod.vertexAttrib3fv + ',' + index + ',' + processArray(value),
1164
+ true
1165
+ )
1166
+ }
1167
+
1168
+ vertexAttrib4fv = function (index, value) {
1169
+ WebGLRenderingContext.GBridge.callNative(
1170
+ this._canvas.id,
1171
+ GLmethod.vertexAttrib4fv + ',' + index + ',' + processArray(value),
1172
+ true
1173
+ )
1174
+ }
1175
+
1176
+ vertexAttribPointer = function (index, size, type, normalized, stride, offset) {
1177
+ WebGLRenderingContext.GBridge.callNative(
1178
+ this._canvas.id,
1179
+ GLmethod.vertexAttribPointer + ',' + index + ',' + size + ',' + type + ',' + Number(normalized) + ',' + stride + ',' + offset,
1180
+ true
1181
+ )
1182
+ }
1183
+
1184
+ viewport = function (x, y, width, height) {
1185
+ WebGLRenderingContext.GBridge.callNative(
1186
+ this._canvas.id,
1187
+ GLmethod.viewport + ',' + x + ',' + y + ',' + width + ',' + height,
1188
+ true
1189
+ )
1190
+ }
1191
+ }