Skip to content

Commit

Permalink
delete ui static component (#16288)
Browse files Browse the repository at this point in the history
* delete ui static component

* fix

* delete all

* change import
  • Loading branch information
LinYunMo authored Sep 20, 2023
1 parent e93d117 commit 138feca
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 213 deletions.
32 changes: 32 additions & 0 deletions cocos/2d/components/deprecated-3.9.0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (c) 2020-2023 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { deprecateModuleExportedName } from '../../core';

deprecateModuleExportedName({
UIStaticBatch: {
since: '3.9.0',
removed: true,
},
});
10 changes: 2 additions & 8 deletions cocos/2d/components/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
THE SOFTWARE.
*/

import { cclegacy } from '@base/global';
import { Mask, MaskType } from './mask';
import { Label } from './label';
import { LabelOutline } from './label-outline';
import { RichText } from './rich-text';
import { Sprite } from './sprite';
import { UIMeshRenderer } from './ui-mesh-renderer';
import { Graphics } from './graphics';
import { UIStaticBatch } from './ui-static-batch';
import { UIOpacity } from './ui-opacity';
import { js, replaceProperty } from '../../core';
import { cclegacy } from '@base/global';
import './deprecated-3.9.0';

/**
* Alias of [[Mask]]
Expand Down Expand Up @@ -84,12 +84,6 @@ js.setClassAlias(UIMeshRenderer, 'cc.UIModelComponent');
export { Graphics as GraphicsComponent };
cclegacy.GraphicsComponent = Graphics;
js.setClassAlias(Graphics, 'cc.GraphicsComponent');
/**
* Alias of [[UIStaticBatch]]
* @deprecated Since v1.2
*/
export { UIStaticBatch as UIStaticBatchComponent };
js.setClassAlias(UIStaticBatch, 'cc.UIStaticBatchComponent');
/**
* Alias of [[UIOpacity]]
* @deprecated Since v1.2
Expand Down
1 change: 0 additions & 1 deletion cocos/2d/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export { Sprite } from './sprite';
export { UIMeshRenderer } from './ui-mesh-renderer';
export { LabelOutline } from './label-outline';
export { Graphics } from './graphics';
export { UIStaticBatch } from './ui-static-batch';
export { LabelShadow } from './label-shadow';
export { UIOpacity } from './ui-opacity';

Expand Down
142 changes: 0 additions & 142 deletions cocos/2d/components/ui-static-batch.ts

This file was deleted.

66 changes: 15 additions & 51 deletions cocos/2d/renderer/batcher-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
*/

import { DEBUG, JSB } from 'internal:constants';
import { cclegacy } from '@base/global';
import { Camera, Model } from '../../render-scene/scene';
import type { UIStaticBatch } from '../components/ui-static-batch';
import { Material } from '../../asset/assets/material';
import { RenderRoot2D, UIRenderer } from '../framework';
import { Texture, Device, Attribute, Sampler, DescriptorSetInfo, Buffer, BufferInfo, BufferUsageBit, MemoryUsageBit, DescriptorSet, InputAssembler, deviceManager, PrimitiveMode } from '../../gfx';
import { Texture, Device, Attribute, Sampler, DescriptorSetInfo, Buffer, BufferInfo, BufferUsageBit,
MemoryUsageBit, DescriptorSet, InputAssembler, deviceManager, PrimitiveMode } from '../../gfx';
import { CachedArray, Pool, Mat4, assertIsTrue, assert, approx, EPSILON } from '../../core';
import { cclegacy } from '@base/global';
import { Root } from '../../root';
import { Node } from '../../scene-graph';
import { Stage, StencilManager } from './stencil-manager';
Expand Down Expand Up @@ -73,14 +73,6 @@ export class Batcher2D implements IBatcher {
return this._batches;
}

set currStaticRoot (value: UIStaticBatch | null) {
this._currStaticRoot = value;
}

set currIsStatic (value: boolean) {
this._currIsStatic = value;
}

public device: Device;
private _screens: RenderRoot2D[] = [];
private _staticVBBuffer: StaticVBAccessor | null = null;
Expand All @@ -96,14 +88,12 @@ export class Batcher2D implements IBatcher {
private _currMaterial: Material = this._emptyMaterial;
private _currTexture: Texture | null = null;
private _currSampler: Sampler | null = null;
private _currStaticRoot: UIStaticBatch | null = null;
private _currComponent: UIRenderer | null = null;
private _currTransform: Node | null = null;
private _currTextureHash = 0;
private _currSamplerHash = 0;
private _currLayer = 0;
private _currDepthStencilStateStage: any | null = null;
private _currIsStatic = false;
private _currHash = 0;

//for middleware
Expand Down Expand Up @@ -296,10 +286,6 @@ export class Batcher2D implements IBatcher {
} else {
for (let i = 0; i < this._batches.length; ++i) {
const batch = this._batches.array[i];
if (batch.isStatic) {
continue;
}

batch.clear();
this._drawBatchPool.free(batch);
}
Expand Down Expand Up @@ -462,7 +448,7 @@ export class Batcher2D implements IBatcher {
dssHash = StencilManager.sharedManager!.getStencilHash(renderComp.stencilStage);
}

const curDrawBatch = this._currStaticRoot ? this._currStaticRoot._requireDrawBatch() : this._drawBatchPool.alloc();
const curDrawBatch = this._drawBatchPool.alloc();
curDrawBatch.visFlags = renderComp.node.layer;
curDrawBatch.inputAssembler = ia;
curDrawBatch.useLocalData = transform || null;
Expand Down Expand Up @@ -490,8 +476,15 @@ export class Batcher2D implements IBatcher {
* @param mat - The material used
* @param enableBatch - component support multi draw batch or not
*/
public commitMiddleware (comp: UIRenderer, meshBuffer: MeshBuffer, indexOffset: number,
indexCount: number, tex: TextureBase, mat: Material, enableBatch: boolean): void {
public commitMiddleware (
comp: UIRenderer,
meshBuffer: MeshBuffer,
indexOffset: number,
indexCount: number,
tex: TextureBase,
mat: Material,
enableBatch: boolean,
): void {
// check if need merge draw batch
const texture = tex.getGFXTexture();
if (enableBatch && this._middlewareEnableBatch && this._middlewareBuffer === meshBuffer
Expand Down Expand Up @@ -579,35 +572,6 @@ export class Batcher2D implements IBatcher {
}
}

public setupStaticBatch (staticComp: UIStaticBatch, bufferAccessor: StaticVBAccessor): void {
this.finishMergeBatches();
this._staticVBBuffer = bufferAccessor;
this.currStaticRoot = staticComp;
}

public endStaticBatch (): void {
this.finishMergeBatches();
this.currStaticRoot = null;
// Clear linear buffer to switch to the correct internal accessor
this._staticVBBuffer = null;
this.switchBufferAccessor();
}

/**
* @en
* Submit separate render data.
* This data does not participate in the batch.
*
* @zh
* 提交独立渲染数据.
* @param comp @en The UIStaticBatch component.
* @zh 静态组件
*/
public commitStaticBatch (comp: UIStaticBatch): void {
this._batches.concat(comp.drawBatchList);
this.finishMergeBatches();
}

/**
* @en
* End a section of render data and submit according to the batch condition.
Expand Down Expand Up @@ -669,7 +633,7 @@ export class Batcher2D implements IBatcher {
dssHash = StencilManager.sharedManager!.getStencilHash(renderComp.stencilStage);
}

const curDrawBatch = this._currStaticRoot ? this._currStaticRoot._requireDrawBatch() : this._drawBatchPool.alloc();
const curDrawBatch = this._drawBatchPool.alloc();
curDrawBatch.visFlags = this._currLayer;
curDrawBatch.texture = this._currTexture!;
curDrawBatch.sampler = this._currSampler;
Expand All @@ -693,7 +657,7 @@ export class Batcher2D implements IBatcher {
}
dssHash = StencilManager.sharedManager!.getStencilHash(renderComp.stencilStage);

const curDrawBatch = this._currStaticRoot ? this._currStaticRoot._requireDrawBatch() : this._drawBatchPool.alloc();
const curDrawBatch = this._drawBatchPool.alloc();
curDrawBatch.visFlags = renderComp.node.layer;
const ia = this._middlewareBuffer!.requireFreeIA(this.device);
ia.firstIndex = this._middlewareIndexStart;
Expand Down
4 changes: 1 addition & 3 deletions cocos/2d/renderer/draw-batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
THE SOFTWARE.
*/

import { cclegacy } from '@base/global';
import { Material } from '../../asset/assets/material';
import { Texture, Sampler, InputAssembler, DescriptorSet, Shader } from '../../gfx';
import { Node } from '../../scene-graph';
import { Model } from '../../render-scene/scene/model';
import { Layers } from '../../scene-graph/layers';
import { cclegacy } from '@base/global';
import { Pass } from '../../render-scene/core/pass';
import { IBatcher } from './i-batcher';

Expand Down Expand Up @@ -71,7 +71,6 @@ export class DrawBatch2D {
public texture: Texture | null = null;
public sampler: Sampler | null = null;
public useLocalData: Node | null = null;
public isStatic = false; // use less,remove when remove Static batch
public textureHash = 0;
public samplerHash = 0;
private _passes: Pass[] = [];
Expand All @@ -95,7 +94,6 @@ export class DrawBatch2D {
this.textureHash = 0;
this.samplerHash = 0;
this.model = null;
this.isStatic = false;
this.useLocalData = null;
this.visFlags = UI_VIS_FLAG;
// this.renderScene = null;
Expand Down
Loading

0 comments on commit 138feca

Please sign in to comment.