uview-plus 3.3.30 → 3.3.32

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 (30) hide show
  1. package/changelog.md +7 -0
  2. package/components/u-car-keyboard/u-car-keyboard.vue +2 -2
  3. package/components/u-number-keyboard/u-number-keyboard.vue +1 -0
  4. package/components/u-qrcode/qrcode.js +56 -27
  5. package/components/u-qrcode/u-qrcode.vue +42 -11
  6. package/index.js +1 -1
  7. package/libs/util/gcanvas/bridge/bridge-weex.js +241 -0
  8. package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  9. package/libs/util/gcanvas/context-2d/FillStylePattern.js +8 -0
  10. package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  11. package/libs/util/gcanvas/context-2d/RenderingContext.js +666 -0
  12. package/libs/util/gcanvas/context-webgl/ActiveInfo.js +11 -0
  13. package/libs/util/gcanvas/context-webgl/Buffer.js +21 -0
  14. package/libs/util/gcanvas/context-webgl/Framebuffer.js +21 -0
  15. package/libs/util/gcanvas/context-webgl/GLenum.js +298 -0
  16. package/libs/util/gcanvas/context-webgl/GLmethod.js +142 -0
  17. package/libs/util/gcanvas/context-webgl/GLtype.js +23 -0
  18. package/libs/util/gcanvas/context-webgl/Program.js +21 -0
  19. package/libs/util/gcanvas/context-webgl/Renderbuffer.js +21 -0
  20. package/libs/util/gcanvas/context-webgl/RenderingContext.js +1191 -0
  21. package/libs/util/gcanvas/context-webgl/Shader.js +22 -0
  22. package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  23. package/libs/util/gcanvas/context-webgl/Texture.js +22 -0
  24. package/libs/util/gcanvas/context-webgl/UniformLocation.js +22 -0
  25. package/libs/util/gcanvas/context-webgl/classUtils.js +3 -0
  26. package/libs/util/gcanvas/env/canvas.js +74 -0
  27. package/libs/util/gcanvas/env/image.js +96 -0
  28. package/libs/util/gcanvas/env/tool.js +24 -0
  29. package/libs/util/gcanvas/index.js +39 -0
  30. package/package.json +1 -1
@@ -0,0 +1,666 @@
1
+ import FillStylePattern from './FillStylePattern';
2
+ import FillStyleLinearGradient from './FillStyleLinearGradient';
3
+ import FillStyleRadialGradient from './FillStyleRadialGradient';
4
+ import GImage from '../env/image.js';
5
+ import {
6
+ ArrayBufferToBase64,
7
+ Base64ToUint8ClampedArray
8
+ } from '../env/tool.js';
9
+
10
+ export default class CanvasRenderingContext2D {
11
+
12
+ _drawCommands = '';
13
+
14
+ _globalAlpha = 1.0;
15
+
16
+ _fillStyle = 'rgb(0,0,0)';
17
+ _strokeStyle = 'rgb(0,0,0)';
18
+
19
+ _lineWidth = 1;
20
+ _lineCap = 'butt';
21
+ _lineJoin = 'miter';
22
+
23
+ _miterLimit = 10;
24
+
25
+ _globalCompositeOperation = 'source-over';
26
+
27
+ _textAlign = 'start';
28
+ _textBaseline = 'alphabetic';
29
+
30
+ _font = '10px sans-serif';
31
+
32
+ _savedGlobalAlpha = [];
33
+
34
+ timer = null;
35
+ componentId = null;
36
+
37
+ _notCommitDrawImageCache = [];
38
+ _needRedrawImageCache = [];
39
+ _redrawCommands = '';
40
+ _autoSaveContext = true;
41
+ // _imageMap = new GHashMap();
42
+ // _textureMap = new GHashMap();
43
+
44
+ constructor() {
45
+ this.className = 'CanvasRenderingContext2D';
46
+ //this.save()
47
+ }
48
+
49
+ setFillStyle(value) {
50
+ this.fillStyle = value;
51
+ }
52
+
53
+ set fillStyle(value) {
54
+ this._fillStyle = value;
55
+
56
+ if (typeof(value) == 'string') {
57
+ this._drawCommands = this._drawCommands.concat("F" + value + ";");
58
+ } else if (value instanceof FillStylePattern) {
59
+ const image = value._img;
60
+ if (!image.complete) {
61
+ image.onload = () => {
62
+ var index = this._needRedrawImageCache.indexOf(image);
63
+ if (index > -1) {
64
+ this._needRedrawImageCache.splice(index, 1);
65
+ CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
66
+ this._redrawflush(true);
67
+ }
68
+ }
69
+ this._notCommitDrawImageCache.push(image);
70
+ } else {
71
+ CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
72
+ }
73
+
74
+ //CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
75
+ this._drawCommands = this._drawCommands.concat("G" + image._id + "," + value._style + ";");
76
+ } else if (value instanceof FillStyleLinearGradient) {
77
+ var command = "D" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," +
78
+ value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," +
79
+ value._stop_count;
80
+ for (var i = 0; i < value._stop_count; ++i) {
81
+ command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
82
+ }
83
+ this._drawCommands = this._drawCommands.concat(command + ";");
84
+ } else if (value instanceof FillStyleRadialGradient) {
85
+ var command = "H" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._start_pos._r
86
+ .toFixed(2) + "," +
87
+ value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," + value._end_pos._r.toFixed(2) + "," +
88
+ value._stop_count;
89
+ for (var i = 0; i < value._stop_count; ++i) {
90
+ command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
91
+ }
92
+ this._drawCommands = this._drawCommands.concat(command + ";");
93
+ }
94
+ }
95
+
96
+ get fillStyle() {
97
+ return this._fillStyle;
98
+ }
99
+
100
+ get globalAlpha() {
101
+ return this._globalAlpha;
102
+ }
103
+
104
+ setGlobalAlpha(value) {
105
+ this.globalAlpha = value;
106
+ }
107
+
108
+ set globalAlpha(value) {
109
+ this._globalAlpha = value;
110
+ this._drawCommands = this._drawCommands.concat("a" + value.toFixed(2) + ";");
111
+ }
112
+
113
+
114
+ get strokeStyle() {
115
+ return this._strokeStyle;
116
+ }
117
+
118
+ setStrokeStyle(value) {
119
+ this.strokeStyle = value;
120
+ }
121
+
122
+ set strokeStyle(value) {
123
+
124
+ this._strokeStyle = value;
125
+
126
+ if (typeof(value) == 'string') {
127
+ this._drawCommands = this._drawCommands.concat("S" + value + ";");
128
+ } else if (value instanceof FillStylePattern) {
129
+ CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
130
+ this._drawCommands = this._drawCommands.concat("G" + image._id + "," + value._style + ";");
131
+ } else if (value instanceof FillStyleLinearGradient) {
132
+ var command = "D" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," +
133
+ value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," +
134
+ value._stop_count;
135
+
136
+ for (var i = 0; i < value._stop_count; ++i) {
137
+ command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
138
+ }
139
+ this._drawCommands = this._drawCommands.concat(command + ";");
140
+ } else if (value instanceof FillStyleRadialGradient) {
141
+ var command = "H" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._start_pos._r
142
+ .toFixed(2) + "," +
143
+ value._end_pos._x.toFixed(2) + "," + value._end_pos._y + ",".toFixed(2) + value._end_pos._r.toFixed(2) + "," +
144
+ value._stop_count;
145
+
146
+ for (var i = 0; i < value._stop_count; ++i) {
147
+ command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
148
+ }
149
+ this._drawCommands = this._drawCommands.concat(command + ";");
150
+ }
151
+ }
152
+
153
+ get lineWidth() {
154
+ return this._lineWidth;
155
+ }
156
+
157
+ setLineWidth(value) {
158
+ this.lineWidth = value;
159
+ }
160
+
161
+ set lineWidth(value) {
162
+ this._lineWidth = value;
163
+ this._drawCommands = this._drawCommands.concat("W" + value + ";");
164
+ }
165
+
166
+ get lineCap() {
167
+ return this._lineCap;
168
+ }
169
+
170
+ setLineCap(value) {
171
+ this.lineCap = value;
172
+ }
173
+
174
+ set lineCap(value) {
175
+ this._lineCap = value;
176
+ this._drawCommands = this._drawCommands.concat("C" + value + ";");
177
+ }
178
+
179
+ get lineJoin() {
180
+ return this._lineJoin;
181
+ }
182
+
183
+ setLineJoin(value) {
184
+ this.lineJoin = value
185
+ }
186
+
187
+ set lineJoin(value) {
188
+ this._lineJoin = value;
189
+ this._drawCommands = this._drawCommands.concat("J" + value + ";");
190
+ }
191
+
192
+ get miterLimit() {
193
+ return this._miterLimit;
194
+ }
195
+
196
+ setMiterLimit(value) {
197
+ this.miterLimit = value
198
+ }
199
+
200
+ set miterLimit(value) {
201
+ this._miterLimit = value;
202
+ this._drawCommands = this._drawCommands.concat("M" + value + ";");
203
+ }
204
+
205
+ get globalCompositeOperation() {
206
+ return this._globalCompositeOperation;
207
+ }
208
+
209
+ set globalCompositeOperation(value) {
210
+
211
+ this._globalCompositeOperation = value;
212
+ let mode = 0;
213
+ switch (value) {
214
+ case "source-over":
215
+ mode = 0;
216
+ break;
217
+ case "source-atop":
218
+ mode = 5;
219
+ break;
220
+ case "source-in":
221
+ mode = 0;
222
+ break;
223
+ case "source-out":
224
+ mode = 2;
225
+ break;
226
+ case "destination-over":
227
+ mode = 4;
228
+ break;
229
+ case "destination-atop":
230
+ mode = 4;
231
+ break;
232
+ case "destination-in":
233
+ mode = 4;
234
+ break;
235
+ case "destination-out":
236
+ mode = 3;
237
+ break;
238
+ case "lighter":
239
+ mode = 1;
240
+ break;
241
+ case "copy":
242
+ mode = 2;
243
+ break;
244
+ case "xor":
245
+ mode = 6;
246
+ break;
247
+ default:
248
+ mode = 0;
249
+ }
250
+
251
+ this._drawCommands = this._drawCommands.concat("B" + mode + ";");
252
+ }
253
+
254
+ get textAlign() {
255
+ return this._textAlign;
256
+ }
257
+
258
+ setTextAlign(value) {
259
+ this.textAlign = value
260
+ }
261
+
262
+ set textAlign(value) {
263
+
264
+ this._textAlign = value;
265
+ let Align = 0;
266
+ switch (value) {
267
+ case "start":
268
+ Align = 0;
269
+ break;
270
+ case "end":
271
+ Align = 1;
272
+ break;
273
+ case "left":
274
+ Align = 2;
275
+ break;
276
+ case "center":
277
+ Align = 3;
278
+ break;
279
+ case "right":
280
+ Align = 4;
281
+ break;
282
+ default:
283
+ Align = 0;
284
+ }
285
+
286
+ this._drawCommands = this._drawCommands.concat("A" + Align + ";");
287
+ }
288
+
289
+ get textBaseline() {
290
+ return this._textBaseline;
291
+ }
292
+
293
+ setTextBaseline(value) {
294
+ this.textBaseline = value
295
+ }
296
+
297
+ set textBaseline(value) {
298
+ this._textBaseline = value;
299
+ let baseline = 0;
300
+ switch (value) {
301
+ case "alphabetic":
302
+ baseline = 0;
303
+ break;
304
+ case "middle":
305
+ baseline = 1;
306
+ break;
307
+ case "top":
308
+ baseline = 2;
309
+ break;
310
+ case "hanging":
311
+ baseline = 3;
312
+ break;
313
+ case "bottom":
314
+ baseline = 4;
315
+ break;
316
+ case "ideographic":
317
+ baseline = 5;
318
+ break;
319
+ default:
320
+ baseline = 0;
321
+ break;
322
+ }
323
+
324
+ this._drawCommands = this._drawCommands.concat("E" + baseline + ";");
325
+ }
326
+
327
+ get font() {
328
+ return this._font;
329
+ }
330
+
331
+ setFontSize(size) {
332
+ var str = this._font;
333
+ var strs = str.trim().split(/\s+/);
334
+ for (var i = 0; i < strs.length; i++) {
335
+ var values = ["normal", "italic", "oblique", "normal", "small-caps", "normal", "bold",
336
+ "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900",
337
+ "normal", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
338
+ "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
339
+ ];
340
+
341
+ if (-1 == values.indexOf(strs[i].trim())) {
342
+ if (typeof size === 'string') {
343
+ strs[i] = size;
344
+ } else if (typeof size === 'number') {
345
+ strs[i] = String(size) + 'px';
346
+ }
347
+ break;
348
+ }
349
+ }
350
+ this.font = strs.join(" ");
351
+ }
352
+
353
+ set font(value) {
354
+ this._font = value;
355
+ this._drawCommands = this._drawCommands.concat("j" + value + ";");
356
+ }
357
+
358
+ setTransform(a, b, c, d, tx, ty) {
359
+ this._drawCommands = this._drawCommands.concat("t" +
360
+ (a === 1 ? "1" : a.toFixed(2)) + "," +
361
+ (b === 0 ? "0" : b.toFixed(2)) + "," +
362
+ (c === 0 ? "0" : c.toFixed(2)) + "," +
363
+ (d === 1 ? "1" : d.toFixed(2)) + "," + tx.toFixed(2) + "," + ty.toFixed(2) + ";");
364
+ }
365
+
366
+ transform(a, b, c, d, tx, ty) {
367
+ this._drawCommands = this._drawCommands.concat("f" +
368
+ (a === 1 ? "1" : a.toFixed(2)) + "," +
369
+ (b === 0 ? "0" : b.toFixed(2)) + "," +
370
+ (c === 0 ? "0" : c.toFixed(2)) + "," +
371
+ (d === 1 ? "1" : d.toFixed(2)) + "," + tx + "," + ty + ";");
372
+ }
373
+
374
+ resetTransform() {
375
+ this._drawCommands = this._drawCommands.concat("m;");
376
+ }
377
+
378
+ scale(a, d) {
379
+ this._drawCommands = this._drawCommands.concat("k" + a.toFixed(2) + "," +
380
+ d.toFixed(2) + ";");
381
+ }
382
+
383
+ rotate(angle) {
384
+ this._drawCommands = this._drawCommands
385
+ .concat("r" + angle.toFixed(6) + ";");
386
+ }
387
+
388
+ translate(tx, ty) {
389
+ this._drawCommands = this._drawCommands.concat("l" + tx.toFixed(2) + "," + ty.toFixed(2) + ";");
390
+ }
391
+
392
+ save() {
393
+ this._savedGlobalAlpha.push(this._globalAlpha);
394
+ this._drawCommands = this._drawCommands.concat("v;");
395
+ }
396
+
397
+ restore() {
398
+ this._drawCommands = this._drawCommands.concat("e;");
399
+ this._globalAlpha = this._savedGlobalAlpha.pop();
400
+ }
401
+
402
+ createPattern(img, pattern) {
403
+ if (typeof img === 'string') {
404
+ var imgObj = new GImage();
405
+ imgObj.src = img;
406
+ img = imgObj;
407
+ }
408
+ return new FillStylePattern(img, pattern);
409
+ }
410
+
411
+ createLinearGradient(x0, y0, x1, y1) {
412
+ return new FillStyleLinearGradient(x0, y0, x1, y1);
413
+ }
414
+
415
+ createRadialGradient = function(x0, y0, r0, x1, y1, r1) {
416
+ return new FillStyleRadialGradient(x0, y0, r0, x1, y1, r1);
417
+ };
418
+
419
+ createCircularGradient = function(x0, y0, r0) {
420
+ return new FillStyleRadialGradient(x0, y0, 0, x0, y0, r0);
421
+ };
422
+
423
+ strokeRect(x, y, w, h) {
424
+ this._drawCommands = this._drawCommands.concat("s" + x + "," + y + "," + w + "," + h + ";");
425
+ }
426
+
427
+
428
+ clearRect(x, y, w, h) {
429
+ this._drawCommands = this._drawCommands.concat("c" + x + "," + y + "," + w +
430
+ "," + h + ";");
431
+ }
432
+
433
+ clip() {
434
+ this._drawCommands = this._drawCommands.concat("p;");
435
+ }
436
+
437
+ resetClip() {
438
+ this._drawCommands = this._drawCommands.concat("q;");
439
+ }
440
+
441
+ closePath() {
442
+ this._drawCommands = this._drawCommands.concat("o;");
443
+ }
444
+
445
+ moveTo(x, y) {
446
+ this._drawCommands = this._drawCommands.concat("g" + x.toFixed(2) + "," + y.toFixed(2) + ";");
447
+ }
448
+
449
+ lineTo(x, y) {
450
+ this._drawCommands = this._drawCommands.concat("i" + x.toFixed(2) + "," + y.toFixed(2) + ";");
451
+ }
452
+
453
+ quadraticCurveTo = function(cpx, cpy, x, y) {
454
+ this._drawCommands = this._drawCommands.concat("u" + cpx + "," + cpy + "," + x + "," + y + ";");
455
+ }
456
+
457
+ bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, ) {
458
+ this._drawCommands = this._drawCommands.concat(
459
+ "z" + cp1x.toFixed(2) + "," + cp1y.toFixed(2) + "," + cp2x.toFixed(2) + "," + cp2y.toFixed(2) + "," +
460
+ x.toFixed(2) + "," + y.toFixed(2) + ";");
461
+ }
462
+
463
+ arcTo(x1, y1, x2, y2, radius) {
464
+ this._drawCommands = this._drawCommands.concat("h" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + radius + ";");
465
+ }
466
+
467
+ beginPath() {
468
+ this._drawCommands = this._drawCommands.concat("b;");
469
+ }
470
+
471
+
472
+ fillRect(x, y, w, h) {
473
+ this._drawCommands = this._drawCommands.concat("n" + x + "," + y + "," + w +
474
+ "," + h + ";");
475
+ }
476
+
477
+ rect(x, y, w, h) {
478
+ this._drawCommands = this._drawCommands.concat("w" + x + "," + y + "," + w + "," + h + ";");
479
+ }
480
+
481
+ fill() {
482
+ this._drawCommands = this._drawCommands.concat("L;");
483
+ }
484
+
485
+ stroke(path) {
486
+ this._drawCommands = this._drawCommands.concat("x;");
487
+ }
488
+
489
+ arc(x, y, radius, startAngle, endAngle, anticlockwise) {
490
+
491
+ let ianticlockwise = 0;
492
+ if (anticlockwise) {
493
+ ianticlockwise = 1;
494
+ }
495
+
496
+ this._drawCommands = this._drawCommands.concat(
497
+ "y" + x.toFixed(2) + "," + y.toFixed(2) + "," +
498
+ radius.toFixed(2) + "," + startAngle + "," + endAngle + "," + ianticlockwise +
499
+ ";"
500
+ );
501
+ }
502
+
503
+ fillText(text, x, y) {
504
+ let tmptext = text.replace(/!/g, "!!");
505
+ tmptext = tmptext.replace(/,/g, "!,");
506
+ tmptext = tmptext.replace(/;/g, "!;");
507
+ this._drawCommands = this._drawCommands.concat("T" + tmptext + "," + x + "," + y + ",0.0;");
508
+ }
509
+
510
+ strokeText = function(text, x, y) {
511
+ let tmptext = text.replace(/!/g, "!!");
512
+ tmptext = tmptext.replace(/,/g, "!,");
513
+ tmptext = tmptext.replace(/;/g, "!;");
514
+ this._drawCommands = this._drawCommands.concat("U" + tmptext + "," + x + "," + y + ",0.0;");
515
+ }
516
+
517
+ measureText(text) {
518
+ return CanvasRenderingContext2D.GBridge.measureText(text, this.font, this.componentId);
519
+ }
520
+
521
+ isPointInPath = function(x, y) {
522
+ throw new Error('GCanvas not supported yet');
523
+ }
524
+
525
+ drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
526
+ if (typeof image === 'string') {
527
+ var imgObj = new GImage();
528
+ imgObj.src = image;
529
+ image = imgObj;
530
+ }
531
+ if (image instanceof GImage) {
532
+ if (!image.complete) {
533
+ imgObj.onload = () => {
534
+ var index = this._needRedrawImageCache.indexOf(image);
535
+ if (index > -1) {
536
+ this._needRedrawImageCache.splice(index, 1);
537
+ CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
538
+ this._redrawflush(true);
539
+ }
540
+ }
541
+ this._notCommitDrawImageCache.push(image);
542
+ } else {
543
+ CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
544
+ }
545
+ var srcArgs = [image, sx, sy, sw, sh, dx, dy, dw, dh];
546
+ var args = [];
547
+ for (var arg in srcArgs) {
548
+ if (typeof(srcArgs[arg]) != 'undefined') {
549
+ args.push(srcArgs[arg]);
550
+ }
551
+ }
552
+ this.__drawImage.apply(this, args);
553
+ //this.__drawImage(image,sx, sy, sw, sh, dx, dy, dw, dh);
554
+ }
555
+ }
556
+
557
+ __drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
558
+ const numArgs = arguments.length;
559
+
560
+ function drawImageCommands() {
561
+
562
+ if (numArgs === 3) {
563
+ const x = parseFloat(sx) || 0.0;
564
+ const y = parseFloat(sy) || 0.0;
565
+
566
+ return ("d" + image._id + ",0,0," +
567
+ image.width + "," + image.height + "," +
568
+ x + "," + y + "," + image.width + "," + image.height + ";");
569
+ } else if (numArgs === 5) {
570
+ const x = parseFloat(sx) || 0.0;
571
+ const y = parseFloat(sy) || 0.0;
572
+ const width = parseInt(sw) || image.width;
573
+ const height = parseInt(sh) || image.height;
574
+
575
+ return ("d" + image._id + ",0,0," +
576
+ image.width + "," + image.height + "," +
577
+ x + "," + y + "," + width + "," + height + ";");
578
+ } else if (numArgs === 9) {
579
+ sx = parseFloat(sx) || 0.0;
580
+ sy = parseFloat(sy) || 0.0;
581
+ sw = parseInt(sw) || image.width;
582
+ sh = parseInt(sh) || image.height;
583
+ dx = parseFloat(dx) || 0.0;
584
+ dy = parseFloat(dy) || 0.0;
585
+ dw = parseInt(dw) || image.width;
586
+ dh = parseInt(dh) || image.height;
587
+
588
+ return ("d" + image._id + "," +
589
+ sx + "," + sy + "," + sw + "," + sh + "," +
590
+ dx + "," + dy + "," + dw + "," + dh + ";");
591
+ }
592
+ }
593
+ this._drawCommands += drawImageCommands();
594
+ }
595
+
596
+ _flush(reserve, callback) {
597
+ const commands = this._drawCommands;
598
+ this._drawCommands = '';
599
+ CanvasRenderingContext2D.GBridge.render2d(this.componentId, commands, callback);
600
+ this._needRender = false;
601
+ }
602
+
603
+ _redrawflush(reserve, callback) {
604
+ const commands = this._redrawCommands;
605
+ CanvasRenderingContext2D.GBridge.render2d(this.componentId, commands, callback);
606
+ if (this._needRedrawImageCache.length == 0) {
607
+ this._redrawCommands = '';
608
+ }
609
+ }
610
+
611
+ draw(reserve, callback) {
612
+ if (!reserve) {
613
+ this._globalAlpha = this._savedGlobalAlpha.pop();
614
+ this._savedGlobalAlpha.push(this._globalAlpha);
615
+ this._redrawCommands = this._drawCommands;
616
+ this._needRedrawImageCache = this._notCommitDrawImageCache;
617
+ if (this._autoSaveContext) {
618
+ this._drawCommands = ("v;" + this._drawCommands);
619
+ this._autoSaveContext = false;
620
+ } else {
621
+ this._drawCommands = ("e;X;v;" + this._drawCommands);
622
+ }
623
+ } else {
624
+ this._needRedrawImageCache = this._needRedrawImageCache.concat(this._notCommitDrawImageCache);
625
+ this._redrawCommands += this._drawCommands;
626
+ if (this._autoSaveContext) {
627
+ this._drawCommands = ("v;" + this._drawCommands);
628
+ this._autoSaveContext = false;
629
+ }
630
+ }
631
+ this._notCommitDrawImageCache = [];
632
+ if (this._flush) {
633
+ this._flush(reserve, callback);
634
+ }
635
+ }
636
+
637
+ getImageData(x, y, w, h, callback) {
638
+ CanvasRenderingContext2D.GBridge.getImageData(this.componentId, x, y, w, h, function(res) {
639
+ res.data = Base64ToUint8ClampedArray(res.data);
640
+ if (typeof(callback) == 'function') {
641
+ callback(res);
642
+ }
643
+ });
644
+ }
645
+
646
+ putImageData(data, x, y, w, h, callback) {
647
+ if (data instanceof Uint8ClampedArray) {
648
+ data = ArrayBufferToBase64(data);
649
+ CanvasRenderingContext2D.GBridge.putImageData(this.componentId, data, x, y, w, h, function(res) {
650
+ if (typeof(callback) == 'function') {
651
+ callback(res);
652
+ }
653
+ });
654
+ }
655
+ }
656
+
657
+ toTempFilePath(x, y, width, height, destWidth, destHeight, fileType, quality, callback) {
658
+ CanvasRenderingContext2D.GBridge.toTempFilePath(this.componentId, x, y, width, height, destWidth, destHeight,
659
+ fileType, quality,
660
+ function(res) {
661
+ if (typeof(callback) == 'function') {
662
+ callback(res);
663
+ }
664
+ });
665
+ }
666
+ }
@@ -0,0 +1,11 @@
1
+ export default class WebGLActiveInfo {
2
+ className = 'WebGLActiveInfo';
3
+
4
+ constructor({
5
+ type, name, size
6
+ }) {
7
+ this.type = type;
8
+ this.name = name;
9
+ this.size = size;
10
+ }
11
+ }
@@ -0,0 +1,21 @@
1
+ import {getTransferedObjectUUID} from './classUtils';
2
+
3
+ const name = 'WebGLBuffer';
4
+
5
+ function uuid(id) {
6
+ return getTransferedObjectUUID(name, id);
7
+ }
8
+
9
+ export default class WebGLBuffer {
10
+ className = name;
11
+
12
+ constructor(id) {
13
+ this.id = id;
14
+ }
15
+
16
+ static uuid = uuid;
17
+
18
+ uuid() {
19
+ return uuid(this.id);
20
+ }
21
+ }
@@ -0,0 +1,21 @@
1
+ import {getTransferedObjectUUID} from './classUtils';
2
+
3
+ const name = 'WebGLFrameBuffer';
4
+
5
+ function uuid(id) {
6
+ return getTransferedObjectUUID(name, id);
7
+ }
8
+
9
+ export default class WebGLFramebuffer {
10
+ className = name;
11
+
12
+ constructor(id) {
13
+ this.id = id;
14
+ }
15
+
16
+ static uuid = uuid;
17
+
18
+ uuid() {
19
+ return uuid(this.id);
20
+ }
21
+ }