weex-gcanvas
Advanced tools
Comparing version 0.5.45 to 0.5.46
@@ -0,1 +1,25 @@ | ||
/** | ||
gcanvas.js使用说明: | ||
1、引入gcanvas库 | ||
2、调用gcanvas库的createElement(component)接口,创建一个canvas对象。 | ||
3、调用canvas对象的getContext(param),获取用于渲染的context。 | ||
扩展用法: | ||
1、对于Android环境,部分机型可能无法运行。建议在页面入口处调用gcanvas库的start(successCallback, errorCallback)函数,进行黑白名单判断。 | ||
2、默认每16ms,会自动下发一次渲染指令。某些特殊场景下,希望自行控制下发频率的,可直接调用context.render()接口。调用后会关闭自动下发的操作,切换成每次主动调用render时才下发。 | ||
完整示例如下: | ||
var libGCanvas = require('../../core/gcanvas'); | ||
libGCanvas.start(function(){ | ||
nativeLog('gcanvas.start success'); | ||
var canvasObj = libGCanvas.createElement(gcanvasComponent); | ||
var context = canvasObj.getContext('2d'); | ||
//do any action here | ||
},function(){ | ||
nativeLog('gcanvas.start failed'); | ||
}); | ||
*/ | ||
var GImage = require('./gcanvasimage.js'); | ||
@@ -96,6 +120,23 @@ var GBridge = require("./gutil").GBridge; | ||
//----------------------------- | ||
GLog.d('gcanvas#=====>>>version: 0.5.45'); | ||
GLog.d('gcanvas#=====>>>version: 0.5.44'); | ||
GCanvas.start = function(el){ | ||
GLog.d('gcanvas#start=====>>>'); | ||
if( weex.supports('@weex-module/userTrack') ) | ||
{ | ||
try { | ||
var userTrack; | ||
if(weex && weex.requireModule) { | ||
userTrack = weex.requireModule('userTrack'); | ||
}else if(__weex_require__) { | ||
userTrack = __weex_require__('@weex-module/userTrack'); | ||
} | ||
if(userTrack){ | ||
userTrack.commitut("expose", 2201, "", '', '/gcanvas.gcanvasweex.start', '', '', {}); | ||
} | ||
} catch(e) { | ||
console.error(e) | ||
} | ||
} | ||
@@ -102,0 +143,0 @@ if (typeof WXEnvironment === 'object' && /ios/i.test(WXEnvironment.platform)) { |
@@ -39,2 +39,6 @@ var GBridge = require("./gutil").GBridge; | ||
this._firstBindFlag = true; | ||
this._checkVersionFlag = false; | ||
this._useNewAPIFlag = true; | ||
} | ||
@@ -674,2 +678,44 @@ | ||
//------------------------------------------------- | ||
// iOS bindImageTexture 增加版本检测 | ||
// 手淘小于6.11.2.3, 天猫小于6.4.2 使用老接口 | ||
// 之后这段逻辑可以去掉 | ||
//------------------------------------------------- | ||
//ver1 < ver2, return true | ||
function versionLessThen(ver1, ver2) | ||
{ | ||
var arr1 = ver1.split('.'); | ||
var arr2 = ver2.split('.'); | ||
var len = Math.min(arr1.length, arr2.length); | ||
for (var i = 0; i < len; i++) | ||
{ | ||
var v1 = parseInt(arr1[i]); | ||
var v2 = parseInt(arr2[i]); | ||
if( v1 < v2 ) return true; | ||
else if( v1 > v2 ) return false; | ||
} | ||
return arr1.length < arr2.length; | ||
} | ||
function useNewAPI() | ||
{ | ||
var appName = WXEnvironment.appName.toUpperCase(); | ||
var appVersion = WXEnvironment.appVersion; | ||
if( (appName == "TB") && versionLessThen(appVersion, "6.11.2.3") ) //低于6.11.2.3的使用老接口 | ||
{ | ||
return false; | ||
} | ||
else if(appName == "TM" && versionLessThen(appVersion, "6.4.1.2") ) //低于6.4.1.2的使用老接口 | ||
{ | ||
return false; | ||
} | ||
//其他的都使用新接口 | ||
return true; | ||
} | ||
GContext2D.prototype.drawImage = function(image, // image | ||
@@ -696,3 +742,13 @@ sx, sy, sw, sh, // source (or destination if fewer args) | ||
{ | ||
GBridge.bindImageTexture(that.componentId, [image.src, image.id], function(){}); | ||
if( !that._checkVersionFlag ) | ||
{ | ||
that._useNewAPIFlag = useNewAPI(); | ||
that._checkVersionFlag = true; | ||
} | ||
if( that._useNewAPIFlag ){ | ||
GBridge.bindImageTexture(that.componentId, [image.src, image.id], function(){}); | ||
}else{ | ||
GBridge.bindImageTexture(that.componentId, image.src, function(){}); | ||
} | ||
that._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh); | ||
@@ -699,0 +755,0 @@ // that._saveImageTexture(image.src, image); |
{ | ||
"name": "weex-gcanvas", | ||
"version": "0.5.45", | ||
"version": "0.5.46", | ||
"main":"gcanvas.js", | ||
@@ -14,3 +14,5 @@ "platform": [ | ||
], | ||
"license": "Apache 2.0" | ||
"license": "Apache 2.0", | ||
"dependencies": { | ||
} | ||
} |
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
167913
14
4582