Merge pull request #1048 from pandamicro/v1.2

Fix Label render command break BMFont batching
This commit is contained in:
Wang Nan
2016-08-19 10:13:11 +08:00
committed by GitHub
4 changed files with 17 additions and 2 deletions
+6
View File
@@ -969,6 +969,12 @@ var Node = cc.Class({
// activate
cc.director.getActionManager().resumeTarget(this);
cc.eventManager.resumeTarget(this);
if (this._touchListener) {
this._touchListener.mask = _searchMaskParent(this);
}
if (this._mouseListener) {
this._mouseListener.mask = _searchMaskParent(this);
}
}
else {
// deactivate
+3
View File
@@ -359,6 +359,7 @@ _ccsg.Label = _ccsg.Node.extend({
this._fontHandle = fontHandle;
this._labelType = _ccsg.Label.Type.SystemFont;
this._blendFunc = cc.BlendFunc._alphaPremultiplied();
this._renderCmd._needDraw = true;
this._notifyLabelSkinDirty();
this.emit('load');
return;
@@ -367,11 +368,13 @@ _ccsg.Label = _ccsg.Node.extend({
if (extName === ".ttf") {
this._labelType = _ccsg.Label.Type.TTF;
this._blendFunc = cc.BlendFunc._alphaPremultiplied();
this._renderCmd._needDraw = true;
this._fontHandle = this._loadTTFFont(fontHandle);
} else if (extName === ".fnt") {
//todo add bmfont here
this._labelType = _ccsg.Label.Type.BMFont;
this._blendFunc = cc.BlendFunc._alphaNonPremultiplied();
this._renderCmd._needDraw = false;
this._initBMFontWithString(this._string, fontHandle, textureUrl);
}
this._notifyLabelSkinDirty();
@@ -69,7 +69,8 @@ proto._updateDisplayOpacity = function (parentOpacity) {
proto.transform = function (parentCmd, recursive) {
this.originTransform(parentCmd, recursive);
var lx = 0, rx = this._labelCanvas.width,
var node = this._node,
lx = 0, rx = this._labelCanvas.width,
by = 0, ty = this._labelCanvas.height,
wt = this._worldTransform;
@@ -83,6 +84,12 @@ proto.transform = function (parentCmd, recursive) {
vert[3].x = rx * wt.a + by * wt.c + wt.tx; // br
vert[3].y = rx * wt.b + by * wt.d + wt.ty;
if (!node._string || (node._labelType !== _ccsg.Label.Type.TTF &&
node._labelType !== _ccsg.Label.Type.SystemFont)) {
// No culling for bmfont
return;
}
var rect = cc.visibleRect,
vl = rect.left.x, vr = rect.right.x, vt = rect.top.y, vb = rect.bottom.y;
if (((vert[0].x-vl) & (vert[1].x-vl) & (vert[2].x-vl) & (vert[3].x-vl)) >> 31 || // All outside left
-1
View File
@@ -96,7 +96,6 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
this._isGray = false;
}
else if (cc._renderType === game.RENDER_TYPE_WEBGL) {
this._hasPremultipliedAlpha = false;
this._pixelFormat = Texture2D.defaultPixelFormat;
this._hasPremultipliedAlpha = false;
this._hasMipmaps = false;