weex-gcanvas
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -114,3 +114,3 @@ /** | ||
GCanvas.idCounter = 0; | ||
GCanvas.canvasMap = new GHashMap(); | ||
// GCanvas.canvasMap = new GHashMap(); | ||
@@ -149,5 +149,6 @@ //----------------------------- | ||
config.push(GSupport.sameLevel); | ||
GCanvas.enableRet = GBridge.callEnable(el.ref, config); | ||
GBridge.callEnable(el.ref, config); | ||
var canvas = new GCanvas(el.ref); | ||
GCanvas.canvasMap.put(el.ref, canvas); | ||
// GCanvas.canvasMap.put(el.ref, canvas); | ||
return canvas; | ||
@@ -182,3 +183,3 @@ } | ||
if (contextID.match(/webgl/i)){ | ||
context = new GContextWebGL(GCanvas.enableRet); | ||
context = new GContextWebGL(); | ||
context_type = 1; | ||
@@ -185,0 +186,0 @@ }else{ |
127
gwebgl.js
@@ -30,5 +30,8 @@ var GBridge = require("./gutil").GBridge; | ||
var G_UseGBridge = 1; | ||
var G_NeedRender = false; | ||
function WebGLCallNative(componentId, cmdArgs) | ||
{ | ||
G_NeedRender = true; | ||
var type = 0x60000000; //ContextType.ContextWebGL << 30 | MethodType.Sync << 29 | ||
@@ -55,3 +58,3 @@ GLog.d("WebGLCallNative command: " + cmdArgs); | ||
function GContextWebGL(params){ | ||
function GContextWebGL(){ | ||
GInitWebGLFuncId(this); | ||
@@ -63,41 +66,5 @@ GInitWebGLEnum(this); | ||
GInitWebGLParams(params); | ||
this._drawCommands = ""; | ||
this._globalAlpha = 1.0; | ||
this._fillStyle = "rgb(0,0,0)"; | ||
this._strokeStyle = "rgb(0,0,0)"; | ||
this._lineWidth = 1; | ||
this._lineCap = "butt"; | ||
this._lineJoin= "miter"; | ||
this._miterLimit = 10; | ||
this._globalCompositeOperation = "source-over"; | ||
this._textAlign = "start"; | ||
this._textBaseline = "alphabetic"; | ||
this._font = "10px sans-serif"; | ||
this._images = {}; | ||
this._canvases1 = {}; | ||
this._canvases2 = {}; | ||
this._getImageData = new Array(); | ||
this._uniformMgr = {}; | ||
this._uniformCount = 3; | ||
this._savedGlobalAlpha =[]; | ||
this.componentId = null; | ||
this.componentId = null; | ||
} | ||
function GInitWebGLParams(params) | ||
{ | ||
// if( !params || params.length == 0 ) | ||
// return; | ||
// var u8ar = Gbase64ToArr(params); | ||
// GCanvas._glParams = new Int32Array(u8ar.buffer); | ||
// console.log("GInitWebGLParams:"+GCanvas._glParams); | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
@@ -107,3 +74,3 @@ | ||
var i=1; | ||
obj.activeTextureId=(i++)+","; | ||
obj.activeTextureId=(i++)+","; //1 | ||
obj.attachShaderId=(i++)+","; | ||
@@ -117,3 +84,3 @@ obj.bindAttribLocationId=(i++)+","; | ||
obj.blendEquationId=(i++)+","; | ||
obj.blendEquationSeparateId=(i++)+","; | ||
obj.blendEquationSeparateId=(i++)+","; //10 | ||
obj.blendFuncId=(i++)+","; | ||
@@ -128,3 +95,3 @@ obj.blendFuncSeparateId=(i++)+","; | ||
obj.clearStencilId=(i++)+","; | ||
obj.colorMaskId=(i++)+","; | ||
obj.colorMaskId=(i++)+","; //20 | ||
obj.compileShaderId=(i++)+","; | ||
@@ -139,3 +106,3 @@ obj.compressedTexImage2DId=(i++)+","; | ||
obj.createRenderbufferId=(i++)+","; | ||
obj.createShaderId=(i++)+","; | ||
obj.createShaderId=(i++)+","; //30 | ||
obj.createTextureId=(i++)+","; | ||
@@ -150,3 +117,3 @@ obj.cullFaceId=(i++)+","; | ||
obj.depthFuncId=(i++)+","; | ||
obj.depthMaskId=(i++)+","; | ||
obj.depthMaskId=(i++)+","; //40 | ||
obj.depthRangeId=(i++)+","; | ||
@@ -161,4 +128,3 @@ obj.detachShaderId=(i++)+","; | ||
obj.enableId=(i++)+","; | ||
obj.enableVertexAttribArrayId=(i++)+","; | ||
//finish | ||
obj.enableVertexAttribArrayId=(i++)+","; //50 | ||
obj.flushId=(i++)+","; | ||
@@ -173,3 +139,3 @@ obj.framebufferRenderbufferId=(i++)+","; | ||
obj.getAttribLocationId=(i++)+","; | ||
obj.getBufferParameterId=(i++)+","; | ||
obj.getBufferParameterId=(i++)+","; //60 | ||
obj.getContextAttributesId=(i++)+","; | ||
@@ -184,3 +150,3 @@ obj.getErrorId=(i++)+","; | ||
obj.getShaderInfoLogId=(i++)+","; | ||
obj.getShaderParameterId=(i++)+","; | ||
obj.getShaderParameterId=(i++)+","; //70 | ||
obj.getShaderPrecisionFormatId=(i++)+","; | ||
@@ -194,5 +160,4 @@ obj.getShaderSourceId=(i++)+","; | ||
obj.getVertexAttribOffsetId=(i++)+","; | ||
//hint | ||
obj.isBufferId=(i++)+","; | ||
obj.isContextLostId=(i++)+","; | ||
obj.isContextLostId=(i++)+","; //80 | ||
obj.isEnabledId=(i++)+","; | ||
@@ -207,3 +172,3 @@ obj.isFramebufferId=(i++)+","; | ||
obj.pixelStoreiId=(i++)+","; | ||
obj.polygonOffsetId=(i++)+","; | ||
obj.polygonOffsetId=(i++)+","; //90 | ||
obj.readPixelsId=(i++)+","; | ||
@@ -218,3 +183,3 @@ obj.renderbufferStorageId=(i++)+","; | ||
obj.stencilMaskSeparateId=(i++)+","; | ||
obj.stencilOpId=(i++)+","; | ||
obj.stencilOpId=(i++)+","; //100 | ||
obj.stencilOpSeparateId=(i++)+","; | ||
@@ -229,3 +194,3 @@ obj.texImage2DId=(i++)+","; | ||
obj.uniform1ivId=(i++)+","; | ||
obj.uniform2fId=(i++)+","; | ||
obj.uniform2fId=(i++)+","; //110 | ||
obj.uniform2fvId=(i++)+","; | ||
@@ -240,3 +205,3 @@ obj.uniform2iId=(i++)+","; | ||
obj.uniform4fvId=(i++)+","; | ||
obj.uniform4iId=(i++)+","; | ||
obj.uniform4iId=(i++)+","; //120 | ||
obj.uniform4ivId=(i++)+","; | ||
@@ -251,3 +216,3 @@ obj.uniformMatrix2fvId=(i++)+","; | ||
obj.vertexAttrib3fId=(i++)+","; //new | ||
obj.vertexAttrib4fId=(i++)+","; //new | ||
obj.vertexAttrib4fId=(i++)+","; //new //130 | ||
obj.vertexAttrib1fvId=(i++)+","; //new | ||
@@ -263,4 +228,8 @@ obj.vertexAttrib2fvId=(i++)+","; //new | ||
//GL Constant Define | ||
obj.NO_ERROR = 0x0; | ||
obj.ZERO = 0x0; | ||
obj.NONE = 0x0; | ||
obj.ONE = 0x1; | ||
obj.LINES = 0x1; | ||
obj.LINE_LOOP = 0x2; | ||
@@ -619,4 +588,2 @@ obj.LINE_STRIP = 0x3; | ||
} | ||
// GLog.d("GarrToBase64(), before: "+ str); | ||
// GLog.d("GarrToBase64(), after : "+ btoa(str)); | ||
return btoa(str); | ||
@@ -627,13 +594,5 @@ } | ||
{ | ||
// GLog.d("base64:" + base64); | ||
var binary_string = atob(base64); | ||
// GLog.d("binary_string:" + binary_string); | ||
var array = binary_string.slice(); | ||
return array; | ||
// var len = binary_string.length; | ||
// var bytes = new Uint8Array( len ); | ||
// for (var i = 0; i < len; i++) { | ||
// bytes[i] = binary_string.charCodeAt(i); | ||
// } | ||
// return bytes.buffer; | ||
} | ||
@@ -700,9 +659,9 @@ | ||
GContextWebGL.prototype.render = function() { | ||
var commands = this._drawCommands; | ||
this._drawCommands = ""; | ||
if (commands != null && commands != "") { | ||
// GLog.d("GContextWebGL#render() called, commands is "+ commands); | ||
//GCanvas._toNative(null, null, 'GCanvas', 'render', [ commands ]); | ||
GBridge.callRender(this.componentId, commands) | ||
GContextWebGL.prototype.render = function() | ||
{ | ||
if( G_NeedRender ) | ||
{ | ||
G_NeedRender = true; | ||
var type = 0x60000000; //ContextType.ContextWebGL << 30 | MethodType.Sync << 29 | ||
var result = GBridge.callExtendCallNative({"className":"WXGCanvasCallNative", "contextId": this.componentId, "type":type, "args":"render"}); | ||
} | ||
@@ -749,3 +708,3 @@ }; | ||
GContextWebGL.prototype.blendColor = function(red, green, blue, alpha){ | ||
var cmd = (this.bindRenderbufferId + red + "," + green + ","+ blue + "," + alpha + ";"); | ||
var cmd = (this.blendColorId + red + "," + green + ","+ blue + "," + alpha + ";"); | ||
WebGLCallNative(this.componentId, cmd); | ||
@@ -780,3 +739,2 @@ } | ||
GContextWebGL.prototype.bufferData = function(target, array, usage){ | ||
var cmd = (this.bufferDataId + target + "," + GetArrayType(array) + "," + GarrToBase64(array) + "," + usage + ";"); | ||
@@ -1095,4 +1053,9 @@ WebGLCallNative(this.componentId, cmd); | ||
*/ | ||
if( !resultString ) return null; | ||
var resultArray = resultString.split(","); | ||
switch( resultArray[0] ) | ||
if( resultArray.length <2 ) return null; | ||
var retType = parseInt(resultArray[0]); | ||
switch( retType ) | ||
{ | ||
@@ -1105,3 +1068,3 @@ case 1: return parseInt(resultArray[1]) == 1; | ||
{ | ||
var array = resultArray.subarray(1,-1); | ||
var array = resultArray.slice(1); | ||
return array; | ||
@@ -1390,8 +1353,12 @@ } | ||
var type = arguments[5]; | ||
var imgData = arguments[6]; | ||
var imageData = arguments[6]; | ||
//TODO imageData | ||
var cmd = (this.texSubImage2DId + argc + "," + target + "," + level + "," + xoffset + "," + | ||
yoffset + "," + type + "," + imgData + ";"); | ||
WebGLCallNative(this.componentId, cmd); | ||
//imageData is GCanvasImage | ||
if(imageData instanceof GCanvasImage) | ||
{ | ||
var cmd = (this.texSubImage2DId + argc + "," + target + "," + level + "," + xoffset + "," + | ||
yoffset + "," + type + "," + imageData.src + ";"); | ||
WebGLCallNative(this.componentId, cmd); | ||
} | ||
} | ||
@@ -1398,0 +1365,0 @@ else if( argc == 9) |
{ | ||
"name": "weex-gcanvas", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"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
115454
3205