Skip to content

Commit 7c2a565

Browse files
committed
Merge pull request #42 from VisualSJ/Iss2416_RefactorRenderer
Iss2416 refactor renderer
2 parents a764daf + 81b04d6 commit 7c2a565

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js

+2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
context.globalCompositeOperation = "destination-over";
143143
context.drawImage(locCache, 0, 0);
144144
context.restore();
145+
this._dirtyFlag = 0;
145146
} else {
146147
context.restore();
147148
}
@@ -209,6 +210,7 @@
209210
}
210211

211212
cc.renderer.pushRenderCommand(this._rendererRestoreCmd);
213+
this._dirtyFlag = 0;
212214
};
213215

214216
cc.ClippingNode.CanvasRenderCmd._sharedCache = null;

cocos2d/core/layers/CCLayerCanvasRenderCmd.js

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127

128128
//the bakeSprite is drawing
129129
this._bakeSprite.visit(this);
130+
this._dirtyFlag = 0;
130131
};
131132

132133
proto._bakeForAddChild = function(child){
@@ -290,6 +291,7 @@
290291
//the bakeSprite is drawing
291292
this._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);
292293
this._bakeSprite.visit(this);
294+
this._dirtyFlag = 0;
293295
};
294296

295297
proto._getBoundingBoxForBake = function(){

cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108
proto.visit = function(parentCmd){
109109
var node = this._node;
110110
this._syncStatus(parentCmd);
111-
node.sprite.visit(parentCmd);
111+
node.sprite.visit(this);
112+
this._dirtyFlag = 0;
112113
};
113114

114115
proto.draw = function(){
@@ -130,7 +131,7 @@
130131
for (var i = 0; i < childrenLen; i++) {
131132
var getChild = locChildren[i];
132133
if (getChild != selfSprite)
133-
getChild.visit();
134+
getChild.visit(this);
134135
}
135136
node.end();
136137
};

cocos2d/tilemap/CCTMXLayer.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
125125
return this._renderCmd.getTexture();
126126
},
127127

128-
//set the cache dirty flag for canvas
129-
_setNodeDirtyForCache: function () {
130-
this._renderCmd._cacheDirty = true;
131-
this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);
132-
},
133-
134128
/**
135129
* Gets layer size.
136130
* @return {cc.Size}
@@ -360,6 +354,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
360354
tile.anchorX = 0;
361355
tile.anchorY = 0;
362356
tile.opacity = this._opacity;
357+
tile._renderCmd._cachedParent = this._renderCmd;
363358

364359
var indexForZ = this._atlasIndexForExistantZ(z);
365360
this.addSpriteWithoutQuad(tile, indexForZ, z);
@@ -859,7 +854,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
859854
this._reusedTile.initWithTexture(this._renderCmd._texture, rect, false);
860855
this._reusedTile.batchNode = this;
861856
this._reusedTile.parent = this;
862-
this._reusedTile._cachedParent = this._renderCmd;
857+
this._reusedTile._renderCmd._cachedParent = this._renderCmd;
863858
}
864859
return this._reusedTile;
865860
},

cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js

+6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
}
5757
};
5858

59+
//set the cache dirty flag for canvas
60+
proto._setNodeDirtyForCache = function () {
61+
this._cacheDirty = true;
62+
};
63+
5964
proto._renderingChildToCache = function (scaleX, scaleY) {
6065
if (this._cacheDirty) {
6166
var locCacheCmds = this._childrenRenderCmds, locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas;
@@ -174,6 +179,7 @@
174179
this._cacheDirty = false
175180
}
176181
cc.renderer.pushRenderCommand(this);
182+
this._dirtyFlag = 0;
177183
};
178184

179185
proto.initImageSize = function(){

0 commit comments

Comments
 (0)