From 435b895c4ebced80d657ca9e3a5f30cfc0bbb192 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 13 Jan 2017 11:44:09 +0800 Subject: [PATCH 1/2] fix label opacity performance issue --- cocos2d/core/label/CCSGLabelCanvasRenderCmd.js | 2 +- cocos2d/core/label/CCSGLabelWebGLRenderCmd.js | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js index f4a9dbb03b..5b6d659b7f 100644 --- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js @@ -46,7 +46,7 @@ this._dirtyFlag &= ~dirtyFlags.contentDirty; } - if (colorDirty || opacityDirty || (locFlag & flags.textDirty)) { + if (colorDirty || (locFlag & flags.textDirty)) { this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty); this._rebuildLabelSkin(); } diff --git a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js index e2b07f1008..ee4c8d3a07 100644 --- a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js @@ -61,11 +61,6 @@ cc.js.mixin(proto, _ccsg.Label.TTFLabelBaker.prototype); proto.constructor = _ccsg.Label.WebGLRenderCmd; -proto._updateDisplayOpacity = function (parentOpacity) { - _ccsg.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); - this._rebuildLabelSkin(); -}; - proto.transform = function (parentCmd, recursive) { this.originTransform(parentCmd, recursive); From 069e5432a04e955a9141cc7b6e668c5f6a8a8fb0 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 16 Jan 2017 10:04:26 +0800 Subject: [PATCH 2/2] add _notifyRegionStatus call --- cocos2d/core/label/CCSGLabelCanvasRenderCmd.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js index 5b6d659b7f..1b9fd3ec46 100644 --- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js @@ -36,10 +36,14 @@ var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; - if (colorDirty) + if (colorDirty) { this._updateDisplayColor(); - if (opacityDirty) + } + + if (opacityDirty) { this._updateDisplayOpacity(); + this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty); + } if(locFlag & dirtyFlags.contentDirty) { this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty);