@hxa-rn/react-native-gcanvas 6.0.24-beta.1 → 6.0.26
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 +2 -2
- package/LICENSE +203 -21
- package/README.md +207 -207
- package/harmony/gcanvas/LICENSE +203 -21
- package/harmony/gcanvas/NOTICE +32 -32
- package/harmony/gcanvas/OAT.xml +37 -37
- package/harmony/gcanvas/build-profile.json5 +16 -16
- package/harmony/gcanvas/hvigorfile.ts +1 -1
- package/harmony/gcanvas/index.ets +1 -1
- package/harmony/gcanvas/oh-package.json5 +14 -14
- package/harmony/gcanvas/src/main/cpp/CMakeLists.txt +126 -126
- package/harmony/gcanvas/src/main/cpp/GCanvasNapi.cpp +485 -485
- package/harmony/gcanvas/src/main/cpp/GCanvasXComponent.cpp +106 -106
- package/harmony/gcanvas/src/main/cpp/GcanvasPackage.h +24 -24
- package/harmony/gcanvas/src/main/ets/GCanvasModuleTurboModule.ts +448 -448
- package/harmony/gcanvas/src/main/ets/GCanvasNativeEngine.ts +206 -206
- package/harmony/gcanvas/src/main/ets/components/GCanvasView.ets +64 -64
- package/harmony/gcanvas/src/main/module.json5 +21 -21
- package/harmony/gcanvas/src/main/resources/base/element/string.json +12 -12
- package/harmony/gcanvas/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/gcanvas/src/main/resources/zh_CN/element/string.json +12 -12
- package/harmony/gcanvas.har +0 -0
- package/package.json +4 -4
- package/packages/gcanvas/.babelrc +4 -4
- package/packages/gcanvas/.eslintrc.js +133 -133
- package/packages/gcanvas/package.json +19 -19
- package/packages/gcanvas/rollup.config.js +13 -13
- package/packages/gcanvas/src/bridge/react-native.js +286 -286
- package/packages/gcanvas/src/bridge/weex.js +210 -210
- package/packages/gcanvas/src/context/2d/FillStyleLinearGradient.js +16 -16
- package/packages/gcanvas/src/context/2d/FillStylePattern.js +7 -7
- package/packages/gcanvas/src/context/2d/FillStyleRadialGradient.js +16 -16
- package/packages/gcanvas/src/context/2d/OffScreenRenderingContext.js +48 -48
- package/packages/gcanvas/src/context/2d/RenderingContext.js +787 -787
- package/packages/gcanvas/src/context/webgl/ActiveInfo.js +10 -10
- package/packages/gcanvas/src/context/webgl/Buffer.js +20 -20
- package/packages/gcanvas/src/context/webgl/Framebuffer.js +20 -20
- package/packages/gcanvas/src/context/webgl/GLenum.js +300 -300
- package/packages/gcanvas/src/context/webgl/GLmethod.js +141 -141
- package/packages/gcanvas/src/context/webgl/GLtype.js +22 -22
- package/packages/gcanvas/src/context/webgl/Program.js +20 -20
- package/packages/gcanvas/src/context/webgl/Renderbuffer.js +20 -20
- package/packages/gcanvas/src/context/webgl/RenderingContext.js +1479 -1479
- package/packages/gcanvas/src/context/webgl/Shader.js +21 -21
- package/packages/gcanvas/src/context/webgl/ShaderPrecisionFormat.js +10 -10
- package/packages/gcanvas/src/context/webgl/Texture.js +21 -21
- package/packages/gcanvas/src/context/webgl/UniformLocation.js +21 -21
- package/packages/gcanvas/src/context/webgl/classUtils.js +2 -2
- package/packages/gcanvas/src/env/canvas.js +210 -210
- package/packages/gcanvas/src/env/image.js +76 -76
- package/packages/gcanvas/src/env/off-screen-canvas.js +74 -74
- package/packages/gcanvas/src/index.js +56 -56
- package/src/components/CanvasView.js +20 -20
- package/src/components/GCanvasComponent.js +408 -408
- package/src/index.js +69 -69
- package/src/packages/gcanvas/.babelrc +4 -4
- package/src/packages/gcanvas/.eslintrc.js +133 -133
- package/src/packages/gcanvas/package.json +19 -19
- package/src/packages/gcanvas/rollup.config.js +13 -13
- package/src/packages/gcanvas/src/bridge/react-native.js +288 -288
- package/src/packages/gcanvas/src/bridge/weex.js +210 -210
- package/src/packages/gcanvas/src/context/2d/FillStyleLinearGradient.js +16 -16
- package/src/packages/gcanvas/src/context/2d/FillStylePattern.js +7 -7
- package/src/packages/gcanvas/src/context/2d/FillStyleRadialGradient.js +16 -16
- package/src/packages/gcanvas/src/context/2d/OffScreenRenderingContext.js +48 -48
- package/src/packages/gcanvas/src/context/2d/RenderingContext.js +801 -801
- package/src/packages/gcanvas/src/context/webgl/ActiveInfo.js +10 -10
- package/src/packages/gcanvas/src/context/webgl/Buffer.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/Framebuffer.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/GLenum.js +300 -300
- package/src/packages/gcanvas/src/context/webgl/GLmethod.js +141 -141
- package/src/packages/gcanvas/src/context/webgl/GLtype.js +22 -22
- package/src/packages/gcanvas/src/context/webgl/Program.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/Renderbuffer.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/RenderingContext.js +1479 -1479
- package/src/packages/gcanvas/src/context/webgl/Shader.js +21 -21
- package/src/packages/gcanvas/src/context/webgl/ShaderPrecisionFormat.js +10 -10
- package/src/packages/gcanvas/src/context/webgl/Texture.js +21 -21
- package/src/packages/gcanvas/src/context/webgl/UniformLocation.js +21 -21
- package/src/packages/gcanvas/src/context/webgl/classUtils.js +2 -2
- package/src/packages/gcanvas/src/env/canvas.js +210 -210
- package/src/packages/gcanvas/src/env/image.js +76 -76
- package/src/packages/gcanvas/src/env/off-screen-canvas.js +74 -74
- package/src/packages/gcanvas/src/index.js +56 -56
- package/src/specs/v1/GCanvasViewNativeComponent.ts +42 -42
- package/src/specs/v1/NativeGCanvasModule.ts +140 -140
|
@@ -1,210 +1,210 @@
|
|
|
1
|
-
import GLmethod from '../context/webgl/GLmethod';
|
|
2
|
-
|
|
3
|
-
const isWeex = typeof WXEnvironment !== 'undefined';
|
|
4
|
-
const isWeexIOS = isWeex && /ios/i.test(WXEnvironment.platform);
|
|
5
|
-
const isWeexAndroid = isWeex && !isWeexIOS;
|
|
6
|
-
|
|
7
|
-
const GCanvasModule =
|
|
8
|
-
typeof weex !== 'undefined' && weex.requireModule ? weex.requireModule('gcanvas') :
|
|
9
|
-
typeof __weex_require__ !== 'undefined' ? __weex_require__('@weex-module/gcanvas') : {};
|
|
10
|
-
|
|
11
|
-
let isDebugging = false;
|
|
12
|
-
|
|
13
|
-
let isComboDisabled = false;
|
|
14
|
-
|
|
15
|
-
const logCommand = (function() {
|
|
16
|
-
const methodQuery = [];
|
|
17
|
-
Object.keys(GLmethod).forEach(key => {
|
|
18
|
-
methodQuery[GLmethod[key]] = key;
|
|
19
|
-
});
|
|
20
|
-
const queryMethod = (id) => {
|
|
21
|
-
return methodQuery[parseInt(id)] || 'NotFoundMethod';
|
|
22
|
-
};
|
|
23
|
-
const logCommand = (id, cmds) => {
|
|
24
|
-
const mId = cmds.split(',')[0];
|
|
25
|
-
const mName = queryMethod(mId);
|
|
26
|
-
console.log(`=== callNative - componentId:${id}; method: ${mName}; cmds: ${cmds}`);
|
|
27
|
-
};
|
|
28
|
-
return logCommand;
|
|
29
|
-
})();
|
|
30
|
-
|
|
31
|
-
function joinArray(arr, sep) {
|
|
32
|
-
let res = '';
|
|
33
|
-
for (let i = 0; i < arr.length; i++) {
|
|
34
|
-
if (i !== 0) {
|
|
35
|
-
res += sep;
|
|
36
|
-
}
|
|
37
|
-
res += arr[i];
|
|
38
|
-
}
|
|
39
|
-
return res;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const commandsCache = {};
|
|
43
|
-
|
|
44
|
-
const GBridge = {
|
|
45
|
-
|
|
46
|
-
callEnable: (ref, configArray) => {
|
|
47
|
-
commandsCache[ref] = [];
|
|
48
|
-
|
|
49
|
-
return GCanvasModule.enable({
|
|
50
|
-
componentId: ref,
|
|
51
|
-
config: configArray
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
callEnableDebug: () => {
|
|
56
|
-
isDebugging = true;
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
callEnableDisableCombo: () => {
|
|
60
|
-
isComboDisabled = true;
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
callSetContextType: function(componentId, context_type) {
|
|
64
|
-
GCanvasModule.setContextType(context_type, componentId);
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
callReset: function(componentId) {
|
|
68
|
-
GCanvasModule.resetComponent && GCanvasModule.resetComponent(componentId);
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
render: isWeexIOS ? function(componentId) {
|
|
72
|
-
return GCanvasModule.extendCallNative({
|
|
73
|
-
contextId: componentId,
|
|
74
|
-
type: 0x60000001
|
|
75
|
-
});
|
|
76
|
-
} : function(componentId) {
|
|
77
|
-
return callGCanvasLinkNative(componentId, 0x60000001, 'render');
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
render2d: isWeexIOS ? function(componentId, commands) {
|
|
81
|
-
if (isDebugging) {
|
|
82
|
-
console.log('>>> >>> render2d ===');
|
|
83
|
-
console.log('>>> commands: ' + commands);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
GCanvasModule.render(commands, componentId);
|
|
87
|
-
} : function(componentId, commands) {
|
|
88
|
-
if (isDebugging) {
|
|
89
|
-
console.log('>>> >>> render2d ===');
|
|
90
|
-
console.log('>>> commands: ' + commands);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
callGCanvasLinkNative(componentId, 0x20000001, commands);
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
callExtendCallNative: isWeexIOS ? function(componentId, cmdArgs) {
|
|
97
|
-
throw 'should not be here anymore ' + cmdArgs;
|
|
98
|
-
} : function(componentId, cmdArgs) {
|
|
99
|
-
throw 'should not be here anymore ' + cmdArgs;
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
flushNative: isWeexIOS ? function(componentId) {
|
|
104
|
-
const cmdArgs = joinArray(commandsCache[componentId], ';');
|
|
105
|
-
commandsCache[componentId] = [];
|
|
106
|
-
|
|
107
|
-
if (isDebugging) {
|
|
108
|
-
console.log('>>> >>> flush native ===');
|
|
109
|
-
console.log('>>> commands: ' + cmdArgs);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const result = GCanvasModule.extendCallNative({
|
|
113
|
-
'contextId': componentId,
|
|
114
|
-
'type': 0x60000000,
|
|
115
|
-
'args': cmdArgs
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const res = result && result.result;
|
|
119
|
-
|
|
120
|
-
if (isDebugging) {
|
|
121
|
-
console.log('>>> result: ' + res);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return res;
|
|
125
|
-
} : function(componentId) {
|
|
126
|
-
const cmdArgs = joinArray(commandsCache[componentId], ';');
|
|
127
|
-
commandsCache[componentId] = [];
|
|
128
|
-
|
|
129
|
-
if (isDebugging) {
|
|
130
|
-
console.log('>>> >>> flush native ===');
|
|
131
|
-
console.log('>>> commands: ' + cmdArgs);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const result = callGCanvasLinkNative(componentId, 0x60000000, cmdArgs);
|
|
135
|
-
|
|
136
|
-
if (isDebugging) {
|
|
137
|
-
console.log('>>> result: ' + result);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return result;
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
callNative: function(componentId, cmdArgs, cache) {
|
|
144
|
-
if (isDebugging) {
|
|
145
|
-
logCommand(componentId, cmdArgs);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
commandsCache[componentId].push(cmdArgs);
|
|
149
|
-
|
|
150
|
-
if (!cache || isComboDisabled) {
|
|
151
|
-
return GBridge.flushNative(componentId);
|
|
152
|
-
} else {
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
texImage2D(componentId, ...args) {
|
|
158
|
-
if (isWeexIOS) {
|
|
159
|
-
if (args.length === 6) {
|
|
160
|
-
const [target, level, internalformat, format, type, image] = args;
|
|
161
|
-
GBridge.callNative(
|
|
162
|
-
componentId,
|
|
163
|
-
GLmethod.texImage2D + ',' + 6 + ',' + target + ',' + level + ',' + internalformat + ',' + format + ',' + type + ',' + image.src
|
|
164
|
-
);
|
|
165
|
-
} else if (args.length === 9) {
|
|
166
|
-
const [target, level, internalformat, width, height, border, format, type, image] = args;
|
|
167
|
-
GBridge.callNative(
|
|
168
|
-
componentId,
|
|
169
|
-
GLmethod.texImage2D + ',' + 9 + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' +
|
|
170
|
-
+ format + ',' + type + ',' + (image ? image.src : 0)
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
} else if (isWeexAndroid) {
|
|
174
|
-
if (args.length === 6) {
|
|
175
|
-
const [target, level, internalformat, format, type, image] = args;
|
|
176
|
-
GCanvasModule.texImage2D(componentId, target, level, internalformat, format, type, image.src);
|
|
177
|
-
} else if (args.length === 9) {
|
|
178
|
-
const [target, level, internalformat, width, height, border, format, type, image] = args;
|
|
179
|
-
GCanvasModule.texImage2D(componentId, target, level, internalformat, width, height, border, format, type, image ? image.src : 0);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image) {
|
|
185
|
-
if (isWeexIOS) {
|
|
186
|
-
if (arguments.length === 8) {
|
|
187
|
-
GBridge.callNative(
|
|
188
|
-
componentId,
|
|
189
|
-
GLmethod.texSubImage2D + ',' + 6 + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset, + ',' + format + ',' + type + ',' + image.src
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
} else if (isWeexAndroid) {
|
|
193
|
-
GCanvasModule.texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image.src);
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
bindImageTexture(componentId, src, imageId) {
|
|
198
|
-
GCanvasModule.bindImageTexture([src, imageId], componentId);
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
preloadImage([url, id], callback) {
|
|
202
|
-
GCanvasModule.preLoadImage([url, id], function(image) {
|
|
203
|
-
image.url = url;
|
|
204
|
-
image.id = id;
|
|
205
|
-
callback(image);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
export default GBridge;
|
|
1
|
+
import GLmethod from '../context/webgl/GLmethod';
|
|
2
|
+
|
|
3
|
+
const isWeex = typeof WXEnvironment !== 'undefined';
|
|
4
|
+
const isWeexIOS = isWeex && /ios/i.test(WXEnvironment.platform);
|
|
5
|
+
const isWeexAndroid = isWeex && !isWeexIOS;
|
|
6
|
+
|
|
7
|
+
const GCanvasModule =
|
|
8
|
+
typeof weex !== 'undefined' && weex.requireModule ? weex.requireModule('gcanvas') :
|
|
9
|
+
typeof __weex_require__ !== 'undefined' ? __weex_require__('@weex-module/gcanvas') : {};
|
|
10
|
+
|
|
11
|
+
let isDebugging = false;
|
|
12
|
+
|
|
13
|
+
let isComboDisabled = false;
|
|
14
|
+
|
|
15
|
+
const logCommand = (function() {
|
|
16
|
+
const methodQuery = [];
|
|
17
|
+
Object.keys(GLmethod).forEach(key => {
|
|
18
|
+
methodQuery[GLmethod[key]] = key;
|
|
19
|
+
});
|
|
20
|
+
const queryMethod = (id) => {
|
|
21
|
+
return methodQuery[parseInt(id)] || 'NotFoundMethod';
|
|
22
|
+
};
|
|
23
|
+
const logCommand = (id, cmds) => {
|
|
24
|
+
const mId = cmds.split(',')[0];
|
|
25
|
+
const mName = queryMethod(mId);
|
|
26
|
+
console.log(`=== callNative - componentId:${id}; method: ${mName}; cmds: ${cmds}`);
|
|
27
|
+
};
|
|
28
|
+
return logCommand;
|
|
29
|
+
})();
|
|
30
|
+
|
|
31
|
+
function joinArray(arr, sep) {
|
|
32
|
+
let res = '';
|
|
33
|
+
for (let i = 0; i < arr.length; i++) {
|
|
34
|
+
if (i !== 0) {
|
|
35
|
+
res += sep;
|
|
36
|
+
}
|
|
37
|
+
res += arr[i];
|
|
38
|
+
}
|
|
39
|
+
return res;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const commandsCache = {};
|
|
43
|
+
|
|
44
|
+
const GBridge = {
|
|
45
|
+
|
|
46
|
+
callEnable: (ref, configArray) => {
|
|
47
|
+
commandsCache[ref] = [];
|
|
48
|
+
|
|
49
|
+
return GCanvasModule.enable({
|
|
50
|
+
componentId: ref,
|
|
51
|
+
config: configArray
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
callEnableDebug: () => {
|
|
56
|
+
isDebugging = true;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
callEnableDisableCombo: () => {
|
|
60
|
+
isComboDisabled = true;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
callSetContextType: function(componentId, context_type) {
|
|
64
|
+
GCanvasModule.setContextType(context_type, componentId);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
callReset: function(componentId) {
|
|
68
|
+
GCanvasModule.resetComponent && GCanvasModule.resetComponent(componentId);
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
render: isWeexIOS ? function(componentId) {
|
|
72
|
+
return GCanvasModule.extendCallNative({
|
|
73
|
+
contextId: componentId,
|
|
74
|
+
type: 0x60000001
|
|
75
|
+
});
|
|
76
|
+
} : function(componentId) {
|
|
77
|
+
return callGCanvasLinkNative(componentId, 0x60000001, 'render');
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
render2d: isWeexIOS ? function(componentId, commands) {
|
|
81
|
+
if (isDebugging) {
|
|
82
|
+
console.log('>>> >>> render2d ===');
|
|
83
|
+
console.log('>>> commands: ' + commands);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
GCanvasModule.render(commands, componentId);
|
|
87
|
+
} : function(componentId, commands) {
|
|
88
|
+
if (isDebugging) {
|
|
89
|
+
console.log('>>> >>> render2d ===');
|
|
90
|
+
console.log('>>> commands: ' + commands);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
callGCanvasLinkNative(componentId, 0x20000001, commands);
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
callExtendCallNative: isWeexIOS ? function(componentId, cmdArgs) {
|
|
97
|
+
throw 'should not be here anymore ' + cmdArgs;
|
|
98
|
+
} : function(componentId, cmdArgs) {
|
|
99
|
+
throw 'should not be here anymore ' + cmdArgs;
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
flushNative: isWeexIOS ? function(componentId) {
|
|
104
|
+
const cmdArgs = joinArray(commandsCache[componentId], ';');
|
|
105
|
+
commandsCache[componentId] = [];
|
|
106
|
+
|
|
107
|
+
if (isDebugging) {
|
|
108
|
+
console.log('>>> >>> flush native ===');
|
|
109
|
+
console.log('>>> commands: ' + cmdArgs);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const result = GCanvasModule.extendCallNative({
|
|
113
|
+
'contextId': componentId,
|
|
114
|
+
'type': 0x60000000,
|
|
115
|
+
'args': cmdArgs
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const res = result && result.result;
|
|
119
|
+
|
|
120
|
+
if (isDebugging) {
|
|
121
|
+
console.log('>>> result: ' + res);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return res;
|
|
125
|
+
} : function(componentId) {
|
|
126
|
+
const cmdArgs = joinArray(commandsCache[componentId], ';');
|
|
127
|
+
commandsCache[componentId] = [];
|
|
128
|
+
|
|
129
|
+
if (isDebugging) {
|
|
130
|
+
console.log('>>> >>> flush native ===');
|
|
131
|
+
console.log('>>> commands: ' + cmdArgs);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const result = callGCanvasLinkNative(componentId, 0x60000000, cmdArgs);
|
|
135
|
+
|
|
136
|
+
if (isDebugging) {
|
|
137
|
+
console.log('>>> result: ' + result);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return result;
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
callNative: function(componentId, cmdArgs, cache) {
|
|
144
|
+
if (isDebugging) {
|
|
145
|
+
logCommand(componentId, cmdArgs);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
commandsCache[componentId].push(cmdArgs);
|
|
149
|
+
|
|
150
|
+
if (!cache || isComboDisabled) {
|
|
151
|
+
return GBridge.flushNative(componentId);
|
|
152
|
+
} else {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
texImage2D(componentId, ...args) {
|
|
158
|
+
if (isWeexIOS) {
|
|
159
|
+
if (args.length === 6) {
|
|
160
|
+
const [target, level, internalformat, format, type, image] = args;
|
|
161
|
+
GBridge.callNative(
|
|
162
|
+
componentId,
|
|
163
|
+
GLmethod.texImage2D + ',' + 6 + ',' + target + ',' + level + ',' + internalformat + ',' + format + ',' + type + ',' + image.src
|
|
164
|
+
);
|
|
165
|
+
} else if (args.length === 9) {
|
|
166
|
+
const [target, level, internalformat, width, height, border, format, type, image] = args;
|
|
167
|
+
GBridge.callNative(
|
|
168
|
+
componentId,
|
|
169
|
+
GLmethod.texImage2D + ',' + 9 + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' +
|
|
170
|
+
+ format + ',' + type + ',' + (image ? image.src : 0)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
} else if (isWeexAndroid) {
|
|
174
|
+
if (args.length === 6) {
|
|
175
|
+
const [target, level, internalformat, format, type, image] = args;
|
|
176
|
+
GCanvasModule.texImage2D(componentId, target, level, internalformat, format, type, image.src);
|
|
177
|
+
} else if (args.length === 9) {
|
|
178
|
+
const [target, level, internalformat, width, height, border, format, type, image] = args;
|
|
179
|
+
GCanvasModule.texImage2D(componentId, target, level, internalformat, width, height, border, format, type, image ? image.src : 0);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image) {
|
|
185
|
+
if (isWeexIOS) {
|
|
186
|
+
if (arguments.length === 8) {
|
|
187
|
+
GBridge.callNative(
|
|
188
|
+
componentId,
|
|
189
|
+
GLmethod.texSubImage2D + ',' + 6 + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset, + ',' + format + ',' + type + ',' + image.src
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
} else if (isWeexAndroid) {
|
|
193
|
+
GCanvasModule.texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image.src);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
bindImageTexture(componentId, src, imageId) {
|
|
198
|
+
GCanvasModule.bindImageTexture([src, imageId], componentId);
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
preloadImage([url, id], callback) {
|
|
202
|
+
GCanvasModule.preLoadImage([url, id], function(image) {
|
|
203
|
+
image.url = url;
|
|
204
|
+
image.id = id;
|
|
205
|
+
callback(image);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export default GBridge;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
class FillStyleLinearGradient {
|
|
2
|
-
constructor(x0, y0, x1, y1) {
|
|
3
|
-
this._start_pos = { _x: x0, _y: y0 };
|
|
4
|
-
this._end_pos = { _x: x1, _y: y1 };
|
|
5
|
-
this._stop_count = 0;
|
|
6
|
-
this._stops = [0, 0, 0, 0, 0];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
addColorStop(pos, color) {
|
|
10
|
-
if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
|
|
11
|
-
this._stops[this._stop_count] = { _pos: pos, _color: color };
|
|
12
|
-
this._stop_count++;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
1
|
+
class FillStyleLinearGradient {
|
|
2
|
+
constructor(x0, y0, x1, y1) {
|
|
3
|
+
this._start_pos = { _x: x0, _y: y0 };
|
|
4
|
+
this._end_pos = { _x: x1, _y: y1 };
|
|
5
|
+
this._stop_count = 0;
|
|
6
|
+
this._stops = [0, 0, 0, 0, 0];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
addColorStop(pos, color) {
|
|
10
|
+
if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
|
|
11
|
+
this._stops[this._stop_count] = { _pos: pos, _color: color };
|
|
12
|
+
this._stop_count++;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
export default FillStyleLinearGradient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
class FillStylePattern {
|
|
2
|
-
constructor(img, pattern) {
|
|
3
|
-
this._style = pattern;
|
|
4
|
-
this._img = img;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
1
|
+
class FillStylePattern {
|
|
2
|
+
constructor(img, pattern) {
|
|
3
|
+
this._style = pattern;
|
|
4
|
+
this._img = img;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
8
|
export default FillStylePattern;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
class FillStyleRadialGradient {
|
|
2
|
-
constructor(x0, y0, r0, x1, y1, r1) {
|
|
3
|
-
this._start_pos = { _x: x0, _y: y0, _r: r0 };
|
|
4
|
-
this._end_pos = { _x: x1, _y: y1, _r: r1 };
|
|
5
|
-
this._stop_count = 0;
|
|
6
|
-
this._stops = [0, 0, 0, 0, 0];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
addColorStop(pos, color) {
|
|
10
|
-
if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
|
|
11
|
-
this._stops[this._stop_count] = { _pos: pos, _color: color };
|
|
12
|
-
this._stop_count++;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
1
|
+
class FillStyleRadialGradient {
|
|
2
|
+
constructor(x0, y0, r0, x1, y1, r1) {
|
|
3
|
+
this._start_pos = { _x: x0, _y: y0, _r: r0 };
|
|
4
|
+
this._end_pos = { _x: x1, _y: y1, _r: r1 };
|
|
5
|
+
this._stop_count = 0;
|
|
6
|
+
this._stops = [0, 0, 0, 0, 0];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
addColorStop(pos, color) {
|
|
10
|
+
if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
|
|
11
|
+
this._stops[this._stop_count] = { _pos: pos, _color: color };
|
|
12
|
+
this._stop_count++;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
export default FillStyleRadialGradient;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import GImage from '../env/image';
|
|
2
|
-
import GContext2D from './RenderingContext';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default class GOffScreenContext2D extends GContext2D {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this.className = 'OffScreenCanvasRenderingContext2D';
|
|
9
|
-
this.images = [];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
|
|
13
|
-
const numArgs = arguments.length;
|
|
14
|
-
function drawImageCommands() {
|
|
15
|
-
if (numArgs === 3) {
|
|
16
|
-
const x = parseFloat(sx) || 0.0;
|
|
17
|
-
const y = parseFloat(sy) || 0.0;
|
|
18
|
-
|
|
19
|
-
return 'd' + image._id + ',0,0,'
|
|
20
|
-
+ image.width + ',' + image.height + ','
|
|
21
|
-
+ x + ',' + y + ',' + image.width + ',' + image.height + ';';
|
|
22
|
-
} else if (numArgs === 5) {
|
|
23
|
-
const x = parseFloat(sx) || 0.0;
|
|
24
|
-
const y = parseFloat(sy) || 0.0;
|
|
25
|
-
const width = parseInt(sw) || image.width;
|
|
26
|
-
const height = parseInt(sh) || image.height;
|
|
27
|
-
|
|
28
|
-
return 'd' + image._id + ',0,0,'
|
|
29
|
-
+ image.width + ',' + image.height + ','
|
|
30
|
-
+ x + ',' + y + ',' + width + ',' + height + ';';
|
|
31
|
-
} else if (numArgs === 9) {
|
|
32
|
-
sx = parseFloat(sx) || 0.0;
|
|
33
|
-
sy = parseFloat(sy) || 0.0;
|
|
34
|
-
sw = parseInt(sw) || image.width;
|
|
35
|
-
sh = parseInt(sh) || image.height;
|
|
36
|
-
dx = parseFloat(dx) || 0.0;
|
|
37
|
-
dy = parseFloat(dy) || 0.0;
|
|
38
|
-
dw = parseInt(dw) || image.width;
|
|
39
|
-
dh = parseInt(dh) || image.height;
|
|
40
|
-
|
|
41
|
-
return 'd' + image._id + ','
|
|
42
|
-
+ sx + ',' + sy + ',' + sw + ',' + sh + ','
|
|
43
|
-
+ dx + ',' + dy + ',' + dw + ',' + dh + ';';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
this.images.push(image);
|
|
47
|
-
this._drawCommands += drawImageCommands();
|
|
48
|
-
}
|
|
1
|
+
import GImage from '../env/image';
|
|
2
|
+
import GContext2D from './RenderingContext';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default class GOffScreenContext2D extends GContext2D {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.className = 'OffScreenCanvasRenderingContext2D';
|
|
9
|
+
this.images = [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
|
|
13
|
+
const numArgs = arguments.length;
|
|
14
|
+
function drawImageCommands() {
|
|
15
|
+
if (numArgs === 3) {
|
|
16
|
+
const x = parseFloat(sx) || 0.0;
|
|
17
|
+
const y = parseFloat(sy) || 0.0;
|
|
18
|
+
|
|
19
|
+
return 'd' + image._id + ',0,0,'
|
|
20
|
+
+ image.width + ',' + image.height + ','
|
|
21
|
+
+ x + ',' + y + ',' + image.width + ',' + image.height + ';';
|
|
22
|
+
} else if (numArgs === 5) {
|
|
23
|
+
const x = parseFloat(sx) || 0.0;
|
|
24
|
+
const y = parseFloat(sy) || 0.0;
|
|
25
|
+
const width = parseInt(sw) || image.width;
|
|
26
|
+
const height = parseInt(sh) || image.height;
|
|
27
|
+
|
|
28
|
+
return 'd' + image._id + ',0,0,'
|
|
29
|
+
+ image.width + ',' + image.height + ','
|
|
30
|
+
+ x + ',' + y + ',' + width + ',' + height + ';';
|
|
31
|
+
} else if (numArgs === 9) {
|
|
32
|
+
sx = parseFloat(sx) || 0.0;
|
|
33
|
+
sy = parseFloat(sy) || 0.0;
|
|
34
|
+
sw = parseInt(sw) || image.width;
|
|
35
|
+
sh = parseInt(sh) || image.height;
|
|
36
|
+
dx = parseFloat(dx) || 0.0;
|
|
37
|
+
dy = parseFloat(dy) || 0.0;
|
|
38
|
+
dw = parseInt(dw) || image.width;
|
|
39
|
+
dh = parseInt(dh) || image.height;
|
|
40
|
+
|
|
41
|
+
return 'd' + image._id + ','
|
|
42
|
+
+ sx + ',' + sy + ',' + sw + ',' + sh + ','
|
|
43
|
+
+ dx + ',' + dy + ',' + dw + ',' + dh + ';';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
this.images.push(image);
|
|
47
|
+
this._drawCommands += drawImageCommands();
|
|
48
|
+
}
|
|
49
49
|
}
|