import type { BufferLikeObject, GeometryAttributeLike, GeometryLikeObject, ShaderLikeObject, TextureLike } from '../shared'; import type { Batch2DEffect } from './Batch2DEffect'; import type { GlDrawOptions } from './geometry'; import type { WebGLRenderer } from './WebGLRenderer'; import { GlBlendMode, GlState } from './state'; import { GlSystem } from './system'; export interface Batchable2D { vertices: Float32Array; indices: Uint32Array; uvs?: Float32Array; size?: { width: number; height: number; }; texture?: TextureLike; modulate?: number[]; blendMode?: GlBlendMode; roundPixels?: boolean; clipOutsideUv?: boolean; /** 本次绘制钳制图片边缘;不修改共享纹理,平铺绘制仍使用纹理原有采样方式。 */ clampTexture?: boolean; /** * Effect flag bits (bit 1+ of the aTextureParams.y byte; bit 0 is reserved * for clipOutsideUv). Semantics are defined by the registered * {@link Batch2DEffect}s — e.g. {@link FLAG_STROKE_AA}. 0/undefined = none. */ effectFlags?: number; /** * Effect scalar parameter (the spare aTextureParams.w byte, 0-255; 0 = off). * Encoding is defined by the effect that consumes it — e.g. the flow streak * effect's {@link encodeFlowSpeed}. Costs no extra vertex attribute. */ effectParam?: number; } type DrawCall = Required & { id: number; textures: TextureLike[]; textureLocationMap: Map; textureClampMap: Map; blendMode: GlBlendMode; }; interface BatchProgram { shader: ShaderLikeObject; samplers: Int32Array; /** merged `uniformDefaults` of the effects compiled into this program */ uniformDefaults: Record; } /** * Per-flush GPU + staging resources, addressed by flush ordinal within a frame. * Dedicated (not pooled/shared) so an unchanged flush can skip both the CPU * vertex rewrite and the GPU upload and just re-issue its draw calls — the GL * buffers still hold exactly this flush's data. `refs` snapshots what the * buffer content was built from (see {@link GlBatch2DSystem.flush}). */ interface BatchSlot { buffer: BufferLikeObject; indexBuffer: BufferLikeObject; geometry: GeometryLikeObject; attrData?: ArrayBuffer; f32?: Float32Array; u8?: Uint8Array; indexData?: Uint32Array; refs: any[]; drawCalls: DrawCall[]; /** 上次重建时的效果修订号;效果注册变更(含 flow uv 归一化模式)后强制失效。 */ effectsRevision?: number; } export declare class GlBatch2DSystem extends GlSystem { install(renderer: WebGLRenderer): void; protected _state: GlState; protected _batchSize: number; protected _batchables: Batchable2D[]; protected _vertexCount: number; protected _indexCount: number; protected _programs: Map; /** * Registered shader effects, composed into the batch program at compile time * (see {@link Batch2DEffect}). Re-registering by name replaces and triggers a * program rebuild on the next flush. */ protected _effects: Batch2DEffect[]; protected _effectsRevision: number; /** * Host-written uniform values for effect snippets (e.g. `uFlowColor`). * Merged over each effect's `uniformDefaults` on every draw. */ effectUniforms: Record; registerEffect(effect: Batch2DEffect): void; protected _slots: BatchSlot[]; protected _slotIndex: number; /** * Marks the start of a frame: flush ordinals restart so each flush lines up * with the slot holding its previous content. Without this call slots keep * advancing and simply never reuse (capped at {@link MAX_SLOTS}). */ beginFrame(): void; protected _attributes: Record>; protected _vertexSize: number; protected _getProgram(maxTextureUnits: number): BatchProgram; protected _createProgram(maxTextureUnits: number): BatchProgram; protected _getSlot(): BatchSlot; protected _drawSlot(program: BatchProgram, slot: BatchSlot, options: GlDrawOptions): void; protected _issueDrawCalls(program: BatchProgram, slot: BatchSlot): void; render(batchable: Batchable2D): void; flush(): void; reset(): void; } export declare function nextPow2(v: number): number; export declare function log2(v: number): number; export {};