Skip to content

Commit f964da8

Browse files
committed
Merge branch 'Iss2416_RefactorRenderer' of https://github.com/dingpinglv/cocos2d-html5 into Iss2416_RefactorRenderer
2 parents c8096c4 + 7c2a565 commit f964da8

8 files changed

+25
-14
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/core/sprites/CCSpriteBatchNode.js

+1
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{
422422
// XXX: so, it should be AFTER the insertQuad
423423
sprite.dirty = true;
424424
sprite.updateTransform();
425+
this._renderCmd.cutting(sprite, index);
425426
},
426427

427428
/**

cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@
4141
this._texture = texture;
4242
};
4343

44-
proto.insertQuad = function(sprite, index){
45-
var node = this._node;
46-
node._children.splice(index, 0, sprite);
47-
//sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd
48-
};
44+
proto.insertQuad = function(sprite, index){};
4945

5046
proto.increaseAtlasCapacity = function(){};
5147

@@ -69,4 +65,10 @@
6965
proto.getTextureAtlas = function(){};
7066

7167
proto.setTextureAtlas = function(textureAtlas){};
68+
69+
proto.cutting = function(sprite, index){
70+
var node = this._node;
71+
//sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd
72+
node._children.splice(index, 0, sprite);
73+
}
7274
})();

cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js

+2
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,6 @@
225225
this._textureAtlas = textureAtlas;
226226
}
227227
};
228+
229+
proto.cutting = function(){};
228230
})();

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)