Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the error and rendering problems of Label in the subdomain. #5763

Merged

Conversation

@caryliu1999
Copy link
Contributor

caryliu1999 commented Nov 19, 2019

Re: cocos-creator/2d-tasks#2091
Re: cocos-creator/2d-tasks#2090

修复子域中BMFont的渲染重叠及CacheMode的报错。

@@ -531,6 +530,11 @@ let Label = cc.Class({
this.cacheMode = CacheMode.BITMAP;
this._batchAsBitmap = false;
}

if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
// CacheMode is not supported in Canvas.

This comment has been minimized.

Copy link
@holycanvas

holycanvas Nov 20, 2019

Contributor

不支持的原因是?

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 Nov 21, 2019

Author Contributor

不支持的原因是?

动态图集用的是texSubImage来做的,Canvas模式下没做兼容,而且Canvas模式下也没必要,本来就没有合批的概念。

@@ -628,7 +632,7 @@ let Label = cc.Class({
this._frame = new LabelFrame();
}

if (this.cacheMode === CacheMode.CHAR && cc.sys.browserType !== cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB) {

This comment has been minimized.

Copy link
@holycanvas

holycanvas Nov 20, 2019

Contributor

之前在子域为什么不支持char模式

@@ -16,5 +16,7 @@ export default class RenderData {
v: 0.0,
};
}

this.vertices.length = v;

This comment has been minimized.

Copy link
@holycanvas

holycanvas Nov 20, 2019

Contributor
let originLength = this.vertices.length;
this.vertices.length = v;
for (let i = originLength; i < v; i++) {
        this.vertices[i] = {
            x: 0.0,
            y: 0.0,
            u: 0.0,
            v: 0.0,
        };
    }

应该这样比较好吧

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 Nov 21, 2019

Author Contributor

改了,不过也没区别,这里设置一下length主要是在新的值小于当前长度时要把多余数据清除掉。

This comment has been minimized.

Copy link
@holycanvas

holycanvas Nov 21, 2019

Contributor

this.vertices.length = v;
之前是复制之后才改长短,我比较担心 v 比较大导致了数组越界

@@ -520,6 +520,9 @@ export default class BmfontAssembler extends Assembler2D {
let node = _comp.node;

this.verticesCount = this.indicesCount = 0;

// Need to reset dataLength in Canvas rendering mode.
this._renderData && (this._renderData.dataLength = 0);

This comment has been minimized.

Copy link
@holycanvas

holycanvas Nov 20, 2019

Contributor

这个_updateQuads是只有在canvas renderer下才会执行的么

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 Nov 21, 2019

Author Contributor

这个_updateQuads是只有在canvas renderer下才会执行的么

_updateQuads是跟WebGL下共用的

This comment has been minimized.

Copy link
@holycanvas

holycanvas Nov 21, 2019

Contributor

那这样改后webgl也会受到影响,没事吧?

@holycanvas holycanvas merged commit dba242a into cocos-creator:v2.2.1-release Nov 21, 2019
1 check passed
1 check passed
ci/circleci: test Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.