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

label processing string & remove shared label info #16292

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

LinYunMo
Copy link
Contributor

Re: #15890
#15693
https://github.com/cocos/3d-tasks/issues/17388

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@LinYunMo LinYunMo requested a review from SantyWang September 20, 2023 09:17
@LinYunMo
Copy link
Contributor Author

@cocos-robot run test cases

@github-actions
Copy link

github-actions bot commented Sep 20, 2023

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -60083,8 +60083,59 @@
              * @param {Number} y
              */
             drawTextureAt(image: ImageAsset, x: number, y: number): void;
         }
+        export interface _cocos_2d_assembler_label_font_utils__ILabelInfo {
+            fontSize: number;
+            fontFamily: string;
+            fontDesc: string;
+            color: math.Color;
+            isOutlined: boolean;
+            out: math.Color;
+            margin: number;
+            fontScale: number;
+        }
+        export class _cocos_2d_assembler_label_font_utils__LetterTexture {
+            image: ImageAsset | null;
+            labelInfo: _cocos_2d_assembler_label_font_utils__ILabelInfo;
+            char: string;
+            data: _cocos_2d_assembler_label_font_utils__ISharedLabelData | null;
+            canvas: HTMLCanvasElement | null;
+            context: CanvasRenderingContext2D | null;
+            width: number;
+            height: number;
+            offsetY: number;
+            hash: string;
+            constructor(char: string, labelInfo: _cocos_2d_assembler_label_font_utils__ILabelInfo, hash: string);
+            updateRenderData(): void;
+            destroy(): void;
+        }
+        export class _cocos_2d_assembler_label_font_utils__FontLetterDefinition {
+            u: number;
+            v: number;
+            w: number;
+            h: number;
+            texture: _cocos_2d_assembler_label_font_utils__LetterRenderTexture | null;
+            offsetX: number;
+            offsetY: number;
+            valid: boolean;
+            xAdvance: number;
+        }
+        export class _cocos_2d_assembler_label_font_utils__LetterAtlas {
+            get width(): number;
+            get height(): number;
+            fontDefDictionary: _cocos_2d_assets_bitmap_font__FontAtlas;
+            constructor(width: number, height: number);
+            insertLetterTexture(letterTexture: _cocos_2d_assembler_label_font_utils__LetterTexture): _cocos_2d_assembler_label_font_utils__FontLetterDefinition | null;
+            update(): void;
+            reset(): void;
+            destroy(): void;
+            getTexture(): any;
+            beforeSceneLoad(): void;
+            clearAllCache(): void;
+            getLetter(key: string): any;
+            getLetterDefinitionForChar(char: string, style: _cocos_2d_assembler_label_text_style__TextStyle, fontScale: number): any;
+        }
         export class _cocos_2d_assembler_label_text_style__TextStyle {
             isBold: boolean;
             isItalic: boolean;
             isUnderline: boolean;
@@ -60106,8 +60157,10 @@
             fontFamily: string;
             fontDesc: string;
             fntConfig: _cocos_2d_assets_bitmap_font__IConfig | null;
             spriteFrame: SpriteFrame | null;
+            hash: string;
+            fontAtlas: _cocos_2d_assets_bitmap_font__FontAtlas | _cocos_2d_assembler_label_font_utils__LetterAtlas | null;
             fontScale: number;
             reset(): void;
         }
         export class _cocos_2d_assembler_label_text_layout__TextLayout {
@@ -60146,15 +60199,24 @@
             uiTransAnchorX: number;
             uiTransAnchorY: number;
             reset(): void;
         }
+        export class _cocos_2d_assembler_label_text_processing__LetterInfo {
+            char: string;
+            valid: boolean;
+            x: number;
+            y: number;
+            line: number;
+            hash: string;
+        }
         export class _cocos_2d_assembler_label_text_output_data__TextOutputLayoutData {
             parsedString: string[];
             nodeContentSize: math.Size;
             canvasSize: math.Size;
             canvasPadding: math.Rect;
             contentSizeExtend: math.Size;
             startPosition: math.Vec2;
+            lettersInfo: _cocos_2d_assembler_label_text_processing__LetterInfo[];
             reset(): void;
         }
         export class _cocos_2d_renderer_native_2d__NativeBatcher2d {
             syncMeshBuffersToNative(accId: number, buffers: _cocos_2d_renderer_native_2d__NativeUIMeshBuffer[]): any;

@LinYunMo
Copy link
Contributor Author

@cocos-robot run test cases

@LinYunMo
Copy link
Contributor Author

@cocos-robot run test cases

@LinYunMo LinYunMo mentioned this pull request Sep 25, 2023
6 tasks
@@ -50,68 +50,6 @@ export const bmfont: IAssembler = {
// Fill All
fillMeshVertices3D(node, renderer, comp.renderData!, tempColor);
},

appendQuad (comp: Label, spriteFrame: SpriteFrame, rect: Rect, rotated: boolean, x: number, y: number, scale: number) {
const renderData = comp.renderData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里没用了么?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重复函数

outputRenderData.uiTransAnchorX = trans.anchorX;
outputRenderData.uiTransAnchorY = trans.anchorY;
const fontAsset = comp.font as BitmapFont;
style.fntConfig = fontAsset.fntConfig; // layout only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该直接把 font 传下来,不应该拆成多个传递


style.color.set(comp.color);
comp.actualFontSize = style.actualFontSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

组件上为什么要缓存这个变量

if (comp.renderData.vertDirty) {
_comp = comp;
_uiTrans = _comp.node._uiProps.uiTransformComp!;
this.updateLayoutData(comp);// Todo: move to layout manager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新渲染时,需要先更新布局?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要,只是在此PR中未进行流程分离,在流程分离 PR 中移除了此步

outputLayoutData,
outputRenderData,
comp.string,
this.generateVertexData,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么会需要回调?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

由于在两种类型中,顶点处理方式无法统一,所以使用回调函数

@minggo minggo requested a review from qiuguohua December 19, 2023 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants