Skip to content

Commit 2ec7bb4

Browse files
committed
User orderDirty to check whether refresh bake cache, improve performance
1 parent 8d7f1f4 commit 2ec7bb4

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

cocos2d/core/layers/CCLayerCanvasRenderCmd.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,30 @@
5353
}
5454
};
5555

56+
proto.updateStatus = function () {
57+
var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag;
58+
if (locFlag & flags.orderDirty) {
59+
this._cacheDirty = true;
60+
if(this._updateCache === 0)
61+
this._updateCache = 2;
62+
this._dirtyFlag = this._dirtyFlag & flags.orderDirty ^ this._dirtyFlag;
63+
}
64+
65+
cc.Node.RenderCmd.prototype.updateStatus.call(this);
66+
};
67+
68+
proto._syncStatus = function () {
69+
var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag;
70+
if (locFlag & flags.orderDirty) {
71+
this._cacheDirty = true;
72+
if(this._updateCache === 0)
73+
this._updateCache = 2;
74+
this._dirtyFlag = this._dirtyFlag & flags.orderDirty ^ this._dirtyFlag;
75+
}
76+
77+
cc.Node.RenderCmd.prototype._syncStatus.call(this);
78+
};
79+
5680
proto.transform = function (parentCmd, recursive) {
5781
var wt = this._worldTransform;
5882
var a = wt.a, b = wt.b, c = wt.c, d = wt.d, tx = wt.tx, ty = wt.ty;
@@ -149,9 +173,6 @@
149173

150174
this._syncStatus(parentCmd);
151175
cc.renderer.pushRenderCommand(this);
152-
this._cacheDirty = true;
153-
if(this._updateCache === 0)
154-
this._updateCache = 2;
155176

156177
//the bakeSprite is drawing
157178
this._bakeSprite.visit(this);
@@ -338,7 +359,6 @@
338359
cc.LayerGradient.RenderCmd = {
339360
updateStatus: function () {
340361
var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag;
341-
var colorDirty = locFlag & flags.colorDirty;
342362
if (locFlag & flags.gradientDirty) {
343363
this._dirtyFlag |= flags.colorDirty;
344364
this._dirtyFlag = this._dirtyFlag & flags.gradientDirty ^ this._dirtyFlag;
@@ -392,7 +412,6 @@
392412

393413
proto._syncStatus = function (parentCmd) {
394414
var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag;
395-
var colorDirty = locFlag & flags.colorDirty;
396415
if (locFlag & flags.gradientDirty) {
397416
this._dirtyFlag |= flags.colorDirty;
398417
this._dirtyFlag = locFlag & flags.gradientDirty ^ locFlag;

0 commit comments

Comments
 (0)