Skip to content

Commit

Permalink
Optimize code size: mark more properties as mangled. (#18265)
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar authored Feb 5, 2025
1 parent bc0a2b4 commit 85c28aa
Show file tree
Hide file tree
Showing 27 changed files with 83 additions and 7 deletions.
1 change: 1 addition & 0 deletions cocos/2d/components/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ export class Label extends UIRenderer {

/**
* @engineInternal
* @mangle
*/
public _updateBlendFunc (): void {
// override for BYTEDANCE
Expand Down
3 changes: 3 additions & 0 deletions cocos/2d/components/rich-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ export class RichText extends Component {

/**
* @engineInternal
* @mangle
*/
protected splitLongStringApproximatelyIn2048 (text: string, styleIndex: number): string[] {
const approxSize = text.length * this.fontSize;
Expand Down Expand Up @@ -625,6 +626,7 @@ export class RichText extends Component {

/**
* @engineInternal
* @mangle
*/
protected splitLongStringOver2048 (text: string, styleIndex: number): string[] {
const partStringArr: string[] = [];
Expand Down Expand Up @@ -746,6 +748,7 @@ export class RichText extends Component {

/**
* @engineInternal
* @mangle
*/
protected _calculateSize (out: Vec2, styleIndex: number, s: string): Vec2 {
let label: ISegment;
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/framework/sprite-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class SpriteRenderer extends ModelRenderer {
/**
* @engineInternal
*/
public _onRebuildPSO (idx: number, material: Material): void {
public override _onRebuildPSO (idx: number, material: Material): void {
if (!this._model || !this._model.inited) { return; }
this._model.setSubModelMaterial(idx, material);
this._onUpdateLocalDescriptorSet();
Expand Down
3 changes: 3 additions & 0 deletions cocos/2d/framework/ui-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class UIRenderer extends Renderer {
/**
* As can not set setter internal individually, so add setRenderData();
* @engineInternal
* @mangle
*/
setRenderData (renderData: RenderData | null): void {
this._renderData = renderData;
Expand Down Expand Up @@ -277,6 +278,7 @@ export class UIRenderer extends Renderer {
public _internalId = -1;
/**
* @engineInternal
* @mangle
*/
public _flagChangedVersion = -1;

Expand Down Expand Up @@ -470,6 +472,7 @@ export class UIRenderer extends Renderer {

/**
* @engineInternal
* @mangle
*/
public updateMaterial (): void {
if (this._customMaterial) {
Expand Down
2 changes: 2 additions & 0 deletions cocos/2d/framework/ui-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ export class UITransform extends Component {
/**
* @deprecated Since v3.7.0, this is an engine private interface that will be removed in the future.
* @engineInternal
* @mangle
*/
public static _sortSiblings (): void {
UITransform.priorityChangeNodeMap.forEach((node, ID): void => {
Expand All @@ -808,6 +809,7 @@ export class UITransform extends Component {
/**
* @deprecated Since v3.7.0, this is an engine private interface that will be removed in the future.
* @engineInternal
* @mangle
*/
public static _cleanChangeMap (): void {
UITransform.priorityChangeNodeMap.clear();
Expand Down
4 changes: 3 additions & 1 deletion cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ export class MeshRenderer extends ModelRenderer {

/**
* @engineInternal
* @mangle
*/
public clearGlobalStandardSkinObjectFlag (): void {
this._enabledGlobalStandardSkinObject = false;
Expand Down Expand Up @@ -1000,6 +1001,7 @@ export class MeshRenderer extends ModelRenderer {

/**
* @engineInternal
* @mangle
*/
public _detachFromScene (): void {
if (this._model && this._model.scene) {
Expand Down Expand Up @@ -1088,7 +1090,7 @@ export class MeshRenderer extends ModelRenderer {
/**
* @engineInternal
*/
public _onRebuildPSO (idx: number, material: Material): void {
public override _onRebuildPSO (idx: number, material: Material): void {
if (!this._model || !this._model.inited) { return; }
this._model.isDynamicBatching = this._isBatchingEnabled();
this._model.setSubModelMaterial(idx, material);
Expand Down
10 changes: 10 additions & 0 deletions cocos/3d/reflection-probe/reflection-probe-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public registerEvent (): void {
if (!this._registeredEvent) {
Expand Down Expand Up @@ -125,6 +126,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public clearPlanarReflectionMap (probe: ReflectionProbe): void {
for (const entry of this._usePlanarModels.entries()) {
Expand All @@ -136,6 +138,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public register (probe: ReflectionProbe): void {
const index = this._probes.indexOf(probe);
Expand All @@ -147,6 +150,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public unregister (probe: ReflectionProbe): void {
for (let i = 0; i < this._probes.length; i++) {
Expand All @@ -163,6 +167,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public exists (probeId: number): boolean {
if (this._probes.length === 0) return false;
Expand All @@ -176,6 +181,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public getNewReflectionProbeId (): number {
let probeId = 0;
Expand Down Expand Up @@ -212,13 +218,15 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public clearAll (): void {
this._probes = [];
}

/**
* @engineInternal
* @mangle
*/
public getProbeByCamera (camera: Camera): ReflectionProbe | null {
for (let i = 0; i < this._probes.length; i++) {
Expand Down Expand Up @@ -276,6 +284,7 @@ export class ReflectionProbeManager {
* @zh 更新使用反射探针进行平面反射的物体。
* @param probe update the model for reflection probe
* @engineInternal
* @mangle
*/
public selectPlanarReflectionProbe (model: Model): void {
if (!model.node || !model.worldBounds || model.reflectionProbeType !== ReflectionProbeType.PLANAR_REFLECTION) return;
Expand Down Expand Up @@ -494,6 +503,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public updateProbeOfModels (): void {
if (this._probes.length === 0) return;
Expand Down
7 changes: 7 additions & 0 deletions cocos/asset/asset-manager/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class Parser {

/**
* @engineInternal
* @mangle
*/
public parseImage (
file: HTMLImageElement | Blob,
Expand All @@ -98,6 +99,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parsePVRTex (
file: ArrayBuffer | ArrayBufferView,
Expand All @@ -117,6 +119,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parsePKMTex (
file: ArrayBuffer | ArrayBufferView,
Expand All @@ -136,6 +139,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parseASTCTex (
file: ArrayBuffer | ArrayBufferView,
Expand All @@ -155,6 +159,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parsePlist (
file: string,
Expand All @@ -169,6 +174,7 @@ export class Parser {

/**
* @engineInternal
* @mangle
*/
public parseImport (
file: Record<string, any> | CCON,
Expand All @@ -191,6 +197,7 @@ export class Parser {

/**
* @engineInternal
* @mangle
*/
public init (): void {
this._parsing.clear();
Expand Down
1 change: 1 addition & 0 deletions cocos/asset/asset-manager/request-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class RequestItem {

/**
* @engineInternal
* @mangle
*/
public static MAX_DEAD_NUM = 500;

Expand Down
1 change: 1 addition & 0 deletions cocos/asset/asset-manager/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface ITaskOption {
export default class Task {
/**
* @engineInternal
* @mangle
*/
public static MAX_DEAD_NUM = 500;

Expand Down
1 change: 1 addition & 0 deletions cocos/asset/assets/effect-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export class EffectAsset extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _precompile (): void {
if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) {
Expand Down
6 changes: 6 additions & 0 deletions cocos/asset/assets/image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export class ImageAsset extends Asset {
* @param type @zh 压缩纹理类型。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parseCompressedTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -340,6 +341,7 @@ export class ImageAsset extends Asset {
* @param endOffset @zh 压缩纹理结束时的偏移。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parsePVRTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -397,6 +399,7 @@ export class ImageAsset extends Asset {
* @param endOffset @zh 压缩纹理结束时的偏移。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parsePKMTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -436,6 +439,7 @@ export class ImageAsset extends Asset {
* @param endOffset @zh 压缩纹理结束时的偏移。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parseASTCTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -484,6 +488,7 @@ export class ImageAsset extends Asset {
/**
* @en extract the first mipmap from a compressed image asset
* @engineInternal
* @mangle
*/
public extractMipmap0 (): ImageAsset {
if (this.mipmapLevelDataSize && this.mipmapLevelDataSize.length > 0) {
Expand All @@ -509,6 +514,7 @@ export class ImageAsset extends Asset {
/**
* @en extract mipmaps from a compressed image asset
* @engineInternal
* @mangle
*/
public extractMipmaps (): ImageAsset[] {
const images: ImageAsset[] = [];
Expand Down
7 changes: 7 additions & 0 deletions cocos/asset/assets/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _fillInfo (info: IMaterialInfo): void {
if (info.technique !== undefined) { this._techIdx = info.technique; }
Expand All @@ -402,6 +403,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _prepareInfo (patch: Record<string, unknown> | Record<string, unknown>[], cur: Record<string, unknown>[]): void {
let patchArray = patch;
Expand All @@ -416,6 +418,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _createPasses (): Pass[] {
const tech = this._effectAsset!.techniques[this._techIdx || 0];
Expand Down Expand Up @@ -443,6 +446,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _update (keepProps = true): void {
if (this._effectAsset) {
Expand Down Expand Up @@ -470,6 +474,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _uploadProperty (pass: Pass, name: string, val: MaterialPropertyFull | MaterialPropertyFull[]): boolean {
const handle = pass.getHandle(name);
Expand Down Expand Up @@ -503,6 +508,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _bindTexture (pass: Pass, handle: number, val: MaterialPropertyFull, index?: number): void {
const binding = Pass.getBindingFromHandle(handle);
Expand All @@ -521,6 +527,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _doDestroy (): void {
if (this._passes && this._passes.length) {
Expand Down
Loading

0 comments on commit 85c28aa

Please sign in to comment.