weex-gcanvas
Advanced tools
Comparing version 0.5.10 to 0.5.12
@@ -40,2 +40,5 @@ var GBridge = require("./gutil").GBridge; | ||
this._checkVersionFlag = false; | ||
this._useOldAPIFlag = false; | ||
} | ||
@@ -675,51 +678,124 @@ | ||
}else if(numArgs === 5){ | ||
var x = parseFloat(sx) || 0; | ||
var y = parseFloat(sy) || 0; | ||
var width = parseInt(sw) || imageInfo.width; | ||
var height = parseInt(sh) || imageInfo.height; | ||
this._drawCommands += ("d" + imageInfo.id + ",0,0," | ||
+ imageInfo.width + "," + imageInfo.height + "," | ||
+ x + "," + y + "," + width + "," + height + ";"); | ||
}else if(numArgs === 9){ | ||
var sx = parseFloat(sx) || 0; | ||
var sy = parseFloat(sy) || 0; | ||
var sw = parseInt(sw) || imageInfo.width; | ||
var sh = parseInt(sh) || imageInfo.height; | ||
var dx = parseFloat(dx) || 0; | ||
var dy = parseFloat(dy) || 0; | ||
var dw = parseInt(dw) || imageInfo.width; | ||
var dh = parseInt(dh) || imageInfo.height; | ||
this._drawCommands += ("d" + imageInfo.id + "," | ||
+ sx + "," + sy + "," + sw + "," + sh + "," | ||
+ dx + "," + dy + "," + dw + "," + dh + ";"); | ||
} | ||
}; | ||
//------------------------------------------------- | ||
// iOS bindImageTexture 增加版本检测 | ||
// 手淘小于6.12.0, 天猫小于6.4.2 使用老接口 | ||
// 之后这段逻辑可以去掉 | ||
//------------------------------------------------- | ||
//ver1 < ver2, return true | ||
function versionLessThen(ver1, ver2) | ||
{ | ||
var arr1 = ver1.split('.'); | ||
var arr2 = ver2.split('.'); | ||
for (var i = 0; i < arr2.length; i++) //判断3位即可, 6.12.0.1 这种可定是新接口 | ||
{ | ||
if( parseInt(arr1[i]) < parseInt(arr2[i]) ) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function useOldAPI() | ||
{ | ||
var appName = weex.config.env.appName; | ||
var appVersion = weex.config.env.appVersion; | ||
if( (appName == "TB") && versionLessThen(appVersion, "6.12.0") ) //低于6.12.0的使用老接口 | ||
{ | ||
return true; | ||
} | ||
else if(appName == "TM" && versionLessThen(appVersion, "6.4.2") ) //低于6.5.0的使用老接口 | ||
{ | ||
return true; | ||
} | ||
//其他的都使用新接口 | ||
return false; | ||
} | ||
GContext2D.prototype.drawImage = function(image, // image | ||
sx, sy, sw, sh, // source (or destination if fewer args) | ||
dx, dy, dw, dh) { // destination | ||
sx, sy, sw, sh, // source (or destination if fewer args) | ||
dx, dy, dw, dh) { // destination | ||
//GLog.d("[GContext2D.drawImage] start..."); | ||
//GLog.d("[GContext2D.drawImage] start..."); | ||
var that = this; | ||
var numArgs = arguments.length; | ||
var that = this; | ||
var numArgs = arguments.length; | ||
var cacheKey = image.id; | ||
var cacheKey = image.id; | ||
// var imageCache = this._getImageTexture(image.src); | ||
var imageCache = this._getImageTexture(cacheKey); | ||
if (imageCache) { | ||
this._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh); | ||
return; | ||
} | ||
// var imageCache = this._getImageTexture(image.src); | ||
var imageCache = this._getImageTexture(cacheKey); | ||
if (imageCache) { | ||
this._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh); | ||
return; | ||
} | ||
if( GBridge.isIOS() ) | ||
{ | ||
GBridge.bindImageTexture(that.componentId, [image.src, image.id], function(){}); | ||
if( GBridge.isIOS() ) | ||
{ | ||
if( !that._checkVersionFlag ) | ||
{ | ||
that._useOldAPIFlag = useOldAPI(); | ||
that._checkVersionFlag = true; | ||
} | ||
if( that._useOldAPIFlag ){ | ||
GBridge.bindImageTexture(that.componentId, image.src, function(){}); | ||
}else{ | ||
GBridge.bindImageTexture(that.componentId, [image.src, image.id], function(){}); | ||
} | ||
that._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh); | ||
// that._saveImageTexture(image.src, image); | ||
that._saveImageTexture(cacheKey, image); | ||
} | ||
else | ||
{ | ||
GBridge.bindImageTexture(that.componentId, image.src, function(e){ | ||
if( !e.error ) | ||
{ | ||
if(image.width === 0 && e.width > 0){ | ||
image.width = e.width; | ||
} | ||
GBridge.bindImageTexture(that.componentId, image.src, function(e){ | ||
if( !e.error ) | ||
{ | ||
if(image.width === 0 && e.width > 0){ | ||
image.width = e.width; | ||
} | ||
if(image.height === 0 && e.height > 0){ | ||
image.height = e.height; | ||
} | ||
that._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh); | ||
// that._saveImageTexture(image.src, image); | ||
that._saveImageTexture(cacheKey, image); | ||
if(image.height === 0 && e.height > 0){ | ||
image.height = e.height; | ||
} | ||
that._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh); | ||
// that._saveImageTexture(image.src, image); | ||
that._saveImageTexture(cacheKey, image); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
}; | ||
GContext2D.prototype._getImageTexture = function(url){ | ||
@@ -726,0 +802,0 @@ if( url ) |
@@ -54,3 +54,8 @@ ///////////////////////////////////////////////////////////////// | ||
}else{ | ||
callGCanvasLinkNative(componentId, 0x20000001, commands); | ||
if(typeof callGCanvasLinkNative != 'undefined') { | ||
GLog.d('bridge#callRender()'); | ||
callGCanvasLinkNative(componentId, 0x20000001, commands); | ||
} else { | ||
canvasModule.render && canvasModule.render( commands, componentId ); | ||
} | ||
} | ||
@@ -57,0 +62,0 @@ }, |
@@ -44,3 +44,3 @@ var GBridge = require("./gutil").GBridge; | ||
var type = 0x60000000; //ContextType.ContextWebGL << 30 | MethodType.Sync << 29 | ||
GLog.d("WebGLCallNative command: " + cmdArgs); | ||
//GLog.d("WebGLCallNative command: " + cmdArgs); | ||
@@ -64,3 +64,3 @@ if(GBridge.isIOS()) { | ||
var result = callGCanvasLinkNative(componentId,type,cmdArgs); | ||
GLog.d("WebGLCallNative result: " + result); | ||
//GLog.d("WebGLCallNative result: " + result); | ||
return result; | ||
@@ -772,3 +772,3 @@ } | ||
if(!GBridge.isIOS()) { | ||
GBridge.setAlpha(this.componentId,alpha); | ||
//GBridge.setAlpha(this.componentId,alpha); | ||
} | ||
@@ -775,0 +775,0 @@ WebGLCallNative(this.componentId, cmd); |
{ | ||
"name": "weex-gcanvas", | ||
"version": "0.5.10", | ||
"version": "0.5.12", | ||
"main":"gcanvas.js", | ||
@@ -5,0 +5,0 @@ "platform": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202648
15
5543