optimization label memory on qqplay and wechatgame (#2643)

This commit is contained in:
Knox
2018-05-08 11:14:16 +08:00
committed by pandamicro
parent fbaf432017
commit e3735ce0b8
3 changed files with 8 additions and 8 deletions
+2 -4
View File
@@ -157,7 +157,7 @@ _ccsg.Label = _ccsg.Node.extend({
_ccsg.Node.prototype.ctor.call(this);
this.setAnchorPoint(0.5, 0.5);
_ccsg.Node.prototype.setContentSize.call(this, 128, 128);
_ccsg.Node.prototype.setContentSize.call(this, 10, 10);
this._blendFunc = cc.BlendFunc._alphaNonPremultiplied();
this._imageOffset = cc.p(0, 0);
@@ -1270,8 +1270,6 @@ _ccsg.Label.pool = new JS.Pool(function (label) {
label._fontHandle = "";
label._labelType = 0;
label._resetBMFont();
label._renderCmd._labelCanvas.width = 1;
label._renderCmd._labelCanvas.height = 1;
label._renderCmd._texture.releaseTexture();
if (CC_DEV) {
cc.assert(!label._parent, 'Recycling label\'s parent should be null!');
@@ -1294,7 +1292,7 @@ _ccsg.Label.pool.get = function (string, fontAsset) {
label._position.x = 0;
label._position.y = 0;
label.setAnchorPoint(0.5, 0.5);
_ccsg.Node.prototype.setContentSize.call(label, 128, 128);
_ccsg.Node.prototype.setContentSize.call(label, 10, 10);
if (isAsset) {
label.setFontAsset(fontAsset);
@@ -399,7 +399,7 @@
};
proto._updateTexture = function() {
this._labelContext.clearRect(0, 0, this._labelCanvas.width, this._labelCanvas.height);
this._labelContext.clearRect(0, 0, this._canvasSize.width, this._canvasSize.height);
this._labelContext.font = this._fontDesc;
@@ -30,12 +30,14 @@
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
var _sharedLabelCanvas;
_ccsg.Label.WebGLRenderCmd = function(renderableObject){
this._rootCtor(renderableObject);
this._needDraw = true;
this._texture = new cc.Texture2D();
this._labelCanvas = document.createElement("canvas");
_sharedLabelCanvas = _sharedLabelCanvas || document.createElement('canvas');
this._labelCanvas = _sharedLabelCanvas;
this._texture.initWithElement(this._labelCanvas);
this._labelContext = this._labelCanvas.getContext("2d");
@@ -65,8 +67,8 @@ proto.updateTransform = function (parentCmd) {
this.originUpdateTransform(parentCmd);
var node = this._node,
lx = 0, rx = this._labelCanvas.width,
by = 0, ty = this._labelCanvas.height,
lx = 0, rx = this._node.width,
by = 0, ty = this._node.height,
wt = this._worldTransform;
var vert = this._vertices;