From c32e6b12c39b165ec91a67b6c3859d6c4f565ef7 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 30 Jun 2016 16:46:36 +0800 Subject: [PATCH] remove unused code in clippingNode and remove scaleX scaleY --- .../CCClippingNodeCanvasRenderCmd.js | 64 +------------------ 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js index 834b1f8ec5..9ddea90042 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -27,8 +27,6 @@ cc.ClippingNode.CanvasRenderCmd = function(renderable){ _ccsg.Node.CanvasRenderCmd.call(this, renderable); this._needDraw = false; - this._clipElemType = false; - this._rendererClipCmd = new cc.CustomRenderCmd(this, this._drawStencilCommand); this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._restoreCmdCallback); }; @@ -43,69 +41,18 @@ proto.setStencil = function(stencil){ this._node._stencil = stencil; - // For shape stencil, rewrite the draw of stencil ,only init the clip path and draw nothing. - //else if (stencil instanceof cc.DrawNode) { - if(stencil._buffer){ - for(var i=0; i 0; j--) - context.lineTo(vertices[j].x * scaleX, -vertices[j].y * scaleY); - } - }; }else{ cc.error('do not support other type as stencil'); - //stencil._parent = this._node; - } -}; - -proto._setStencilCompositionOperation = function(stencil){ - if(!stencil) - return; - var node = this._node; - if(stencil._renderCmd && stencil._renderCmd._blendFuncStr) //it is a hack way. - stencil._renderCmd._blendFuncStr = (node.inverted ? "destination-out" : "destination-in"); - - if(!stencil._children) - return; - var children = stencil._children; - for(var i = 0, len = children.length; i < len; i++){ - this._setStencilCompositionOperation(children[i]); } }; proto._restoreCmdCallback = function (ctx) { - var locCache = cc.ClippingNode.CanvasRenderCmd._getSharedCache(); - var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); + var wrapper = ctx || cc._renderContext; wrapper.restore(); }; -proto.transform = function(parentCmd, recursive){ - _ccsg.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd, recursive); - var node = this._node; - if(node._stencil && node._stencil._renderCmd) - node._stencil._renderCmd.transform(this, recursive); -}; - proto._drawStencilCommand = function (ctx, scaleX, scaleY) { var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); wrapper.save(); @@ -117,9 +64,9 @@ proto._drawStencilCommand = function (ctx, scaleX, scaleY) { for(var index = 0; index < stencilBuffer.length; ++index) { var vertices = stencilBuffer[index].verts; if(vertices.length < 3) continue; - context.moveTo(vertices[0].x * scaleX, -vertices[0].y * scaleY); + context.moveTo(vertices[0].x, -vertices[0].y); for(var vIndex = 1; vIndex < vertices.length; ++vIndex) { - context.lineTo(vertices[vIndex].x * scaleX, -vertices[vIndex].y * scaleY); + context.lineTo(vertices[vIndex].x, -vertices[vIndex].y); } } //end draw elements @@ -154,9 +101,4 @@ proto.visit = function(parentCmd){ cc.renderer.pushRenderCommand(this._rendererRestoreCmd); } this._dirtyFlag = 0; -}; - -cc.ClippingNode.CanvasRenderCmd._sharedCache = null; -cc.ClippingNode.CanvasRenderCmd._getSharedCache = function () { - return (cc.ClippingNode.CanvasRenderCmd._sharedCache) || (cc.ClippingNode.CanvasRenderCmd._sharedCache = document.createElement("canvas")); }; \ No newline at end of file