uview-plus 3.3.30 → 3.3.31
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/changelog.md +5 -0
- package/components/u-qrcode/qrcode.js +56 -27
- package/components/u-qrcode/u-qrcode.vue +42 -11
- package/libs/util/gcanvas/bridge/bridge-weex.js +241 -0
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +666 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +21 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +298 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +142 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +23 -0
- package/libs/util/gcanvas/context-webgl/Program.js +21 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +22 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +22 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +3 -0
- package/libs/util/gcanvas/env/canvas.js +74 -0
- package/libs/util/gcanvas/env/image.js +96 -0
- package/libs/util/gcanvas/env/tool.js +24 -0
- package/libs/util/gcanvas/index.js +39 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {getTransferedObjectUUID} from './classUtils';
|
|
2
|
+
|
|
3
|
+
const name = 'WebGLShader';
|
|
4
|
+
|
|
5
|
+
function uuid(id) {
|
|
6
|
+
return getTransferedObjectUUID(name, id);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class WebGLShader {
|
|
10
|
+
className = name;
|
|
11
|
+
|
|
12
|
+
constructor(id, type) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.type = type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static uuid = uuid;
|
|
18
|
+
|
|
19
|
+
uuid() {
|
|
20
|
+
return uuid(this.id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {getTransferedObjectUUID} from './classUtils';
|
|
2
|
+
|
|
3
|
+
const name = 'WebGLTexture';
|
|
4
|
+
|
|
5
|
+
function uuid(id) {
|
|
6
|
+
return getTransferedObjectUUID(name, id);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class WebGLTexture {
|
|
10
|
+
className = name;
|
|
11
|
+
|
|
12
|
+
constructor(id, type) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.type = type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static uuid = uuid;
|
|
18
|
+
|
|
19
|
+
uuid() {
|
|
20
|
+
return uuid(this.id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {getTransferedObjectUUID} from './classUtils';
|
|
2
|
+
|
|
3
|
+
const name = 'WebGLUniformLocation';
|
|
4
|
+
|
|
5
|
+
function uuid(id) {
|
|
6
|
+
return getTransferedObjectUUID(name, id);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class WebGLUniformLocation {
|
|
10
|
+
className = name;
|
|
11
|
+
|
|
12
|
+
constructor(id, type) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.type = type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static uuid = uuid;
|
|
18
|
+
|
|
19
|
+
uuid() {
|
|
20
|
+
return uuid(this.id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import GContext2D from '../context-2d/RenderingContext';
|
|
2
|
+
import GContextWebGL from '../context-webgl/RenderingContext';
|
|
3
|
+
|
|
4
|
+
export default class GCanvas {
|
|
5
|
+
|
|
6
|
+
// static GBridge = null;
|
|
7
|
+
|
|
8
|
+
id = null;
|
|
9
|
+
|
|
10
|
+
_needRender = true;
|
|
11
|
+
|
|
12
|
+
constructor(id, { disableAutoSwap }) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
|
|
15
|
+
this._disableAutoSwap = disableAutoSwap;
|
|
16
|
+
if (disableAutoSwap) {
|
|
17
|
+
this._swapBuffers = () => {
|
|
18
|
+
GCanvas.GBridge.render(this.id);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getContext(type) {
|
|
24
|
+
|
|
25
|
+
let context = null;
|
|
26
|
+
|
|
27
|
+
if (type.match(/webgl/i)) {
|
|
28
|
+
context = new GContextWebGL(this);
|
|
29
|
+
|
|
30
|
+
context.componentId = this.id;
|
|
31
|
+
|
|
32
|
+
if (!this._disableAutoSwap) {
|
|
33
|
+
const render = () => {
|
|
34
|
+
if (this._needRender) {
|
|
35
|
+
GCanvas.GBridge.render(this.id);
|
|
36
|
+
this._needRender = false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
setInterval(render, 16);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
GCanvas.GBridge.callSetContextType(this.id, 1); // 0 for 2d; 1 for webgl
|
|
43
|
+
} else if (type.match(/2d/i)) {
|
|
44
|
+
context = new GContext2D(this);
|
|
45
|
+
|
|
46
|
+
context.componentId = this.id;
|
|
47
|
+
|
|
48
|
+
// const render = ( callback ) => {
|
|
49
|
+
//
|
|
50
|
+
// const commands = context._drawCommands;
|
|
51
|
+
// context._drawCommands = '';
|
|
52
|
+
//
|
|
53
|
+
// GCanvas.GBridge.render2d(this.id, commands, callback);
|
|
54
|
+
// this._needRender = false;
|
|
55
|
+
// }
|
|
56
|
+
// //draw方法触发
|
|
57
|
+
// context._flush = render;
|
|
58
|
+
// //setInterval(render, 16);
|
|
59
|
+
|
|
60
|
+
GCanvas.GBridge.callSetContextType(this.id, 0);
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error('not supported context ' + type);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return context;
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
reset() {
|
|
70
|
+
GCanvas.GBridge.callReset(this.id);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
let incId = 1;
|
|
2
|
+
|
|
3
|
+
const noop = function () { };
|
|
4
|
+
|
|
5
|
+
class GImage {
|
|
6
|
+
|
|
7
|
+
static GBridge = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
this._id = incId++;
|
|
11
|
+
this._width = 0;
|
|
12
|
+
this._height = 0;
|
|
13
|
+
this._src = undefined;
|
|
14
|
+
this._onload = noop;
|
|
15
|
+
this._onerror = noop;
|
|
16
|
+
this.complete = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get width() {
|
|
20
|
+
return this._width;
|
|
21
|
+
}
|
|
22
|
+
set width(v) {
|
|
23
|
+
this._width = v;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get height() {
|
|
27
|
+
return this._height;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
set height(v) {
|
|
31
|
+
this._height = v;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get src() {
|
|
35
|
+
return this._src;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
set src(v) {
|
|
39
|
+
|
|
40
|
+
if (v.startsWith('//')) {
|
|
41
|
+
v = 'http:' + v;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this._src = v;
|
|
45
|
+
|
|
46
|
+
GImage.GBridge.perloadImage([this._src, this._id], (data) => {
|
|
47
|
+
if (typeof data === 'string') {
|
|
48
|
+
data = JSON.parse(data);
|
|
49
|
+
}
|
|
50
|
+
if (data.error) {
|
|
51
|
+
var evt = { type: 'error', target: this };
|
|
52
|
+
this.onerror(evt);
|
|
53
|
+
} else {
|
|
54
|
+
this.complete = true;
|
|
55
|
+
this.width = typeof data.width === 'number' ? data.width : 0;
|
|
56
|
+
this.height = typeof data.height === 'number' ? data.height : 0;
|
|
57
|
+
var evt = { type: 'load', target: this };
|
|
58
|
+
this.onload(evt);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
addEventListener(name, listener) {
|
|
64
|
+
if (name === 'load') {
|
|
65
|
+
this.onload = listener;
|
|
66
|
+
} else if (name === 'error') {
|
|
67
|
+
this.onerror = listener;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
removeEventListener(name, listener) {
|
|
72
|
+
if (name === 'load') {
|
|
73
|
+
this.onload = noop;
|
|
74
|
+
} else if (name === 'error') {
|
|
75
|
+
this.onerror = noop;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get onload() {
|
|
80
|
+
return this._onload;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
set onload(v) {
|
|
84
|
+
this._onload = v;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get onerror() {
|
|
88
|
+
return this._onerror;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
set onerror(v) {
|
|
92
|
+
this._onerror = v;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default GImage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
export function ArrayBufferToBase64 (buffer) {
|
|
3
|
+
var binary = '';
|
|
4
|
+
var bytes = new Uint8ClampedArray(buffer);
|
|
5
|
+
for (var len = bytes.byteLength, i = 0; i < len; i++) {
|
|
6
|
+
binary += String.fromCharCode(bytes[i]);
|
|
7
|
+
}
|
|
8
|
+
return btoa(binary);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Base64ToUint8ClampedArray(base64String) {
|
|
12
|
+
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
|
13
|
+
const base64 = (base64String + padding)
|
|
14
|
+
.replace(/\-/g, '+')
|
|
15
|
+
.replace(/_/g, '/');
|
|
16
|
+
|
|
17
|
+
const rawData = atob(base64);
|
|
18
|
+
const outputArray = new Uint8ClampedArray(rawData.length);
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < rawData.length; ++i) {
|
|
21
|
+
outputArray[i] = rawData.charCodeAt(i);
|
|
22
|
+
}
|
|
23
|
+
return outputArray;
|
|
24
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import GCanvas from './env/canvas';
|
|
2
|
+
import GImage from './env/image';
|
|
3
|
+
|
|
4
|
+
import GWebGLRenderingContext from './context-webgl/RenderingContext';
|
|
5
|
+
import GContext2D from './context-2d/RenderingContext';
|
|
6
|
+
|
|
7
|
+
import GBridgeWeex from './bridge/bridge-weex';
|
|
8
|
+
|
|
9
|
+
export let Image = GImage;
|
|
10
|
+
|
|
11
|
+
export let WeexBridge = GBridgeWeex;
|
|
12
|
+
|
|
13
|
+
export function enable(el, { bridge, debug, disableAutoSwap, disableComboCommands } = {}) {
|
|
14
|
+
|
|
15
|
+
const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge;
|
|
16
|
+
|
|
17
|
+
GBridge.callEnable(el.ref, [
|
|
18
|
+
0, // renderMode: 0--RENDERMODE_WHEN_DIRTY, 1--RENDERMODE_CONTINUOUSLY
|
|
19
|
+
-1, // hybridLayerType: 0--LAYER_TYPE_NONE 1--LAYER_TYPE_SOFTWARE 2--LAYER_TYPE_HARDWARE
|
|
20
|
+
false, // supportScroll
|
|
21
|
+
false, // newCanvasMode
|
|
22
|
+
1, // compatible
|
|
23
|
+
'white',// clearColor
|
|
24
|
+
false // sameLevel: newCanvasMode = true && true => GCanvasView and Webview is same level
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
if (debug === true) {
|
|
28
|
+
GBridge.callEnableDebug();
|
|
29
|
+
}
|
|
30
|
+
if (disableComboCommands) {
|
|
31
|
+
GBridge.callEnableDisableCombo();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var canvas = new GCanvas(el.ref, { disableAutoSwap });
|
|
35
|
+
canvas.width = el.style.width;
|
|
36
|
+
canvas.height = el.style.height;
|
|
37
|
+
|
|
38
|
+
return canvas;
|
|
39
|
+
};
|