import { CanvasTexture } from './CanvasTexture'; export interface GlyphSlot { texture: CanvasTexture; u0: number; v0: number; u1: number; v1: number; } export type GlyphRasterFn = (ctx: CanvasRenderingContext2D) => void; interface AtlasPage { texture: CanvasTexture; ctx: CanvasRenderingContext2D; penX: number; penY: number; rowH: number; } /** * 共享字形 atlas:把每个唯一字形(字 + 字体 + 字号桶 + 字重 + 斜体 + 颜色)只栅格化一次到 * 共享纹理页,文字渲染时改为「逐字形 quad 批渲染」(见 Element2DText._atlasDraw)。同一纹理的 * quad 经 GlBatch2DSystem 自动塌缩进 ~1 个 draw call,编辑/缩放/resize 只重定位 quad,不再整篇重栅。 */ export declare class GlyphAtlas { readonly superSample = 2; protected _pages: AtlasPage[]; protected _slots: Map; protected _newPage(): AtlasPage; /** * 取(必要时栅格化)一个字形 slot。`inkW/inkH` 为字形 ink 盒的逻辑尺寸;`raster` 在 * 已预置变换的 2D 上下文里绘制该字形。返回 null 表示该字形超过单页容量(调用方应回退到整段栅格)。 */ acquire(key: string, inkW: number, inkH: number, raster: GlyphRasterFn): GlyphSlot | null; clear(): void; } export declare const sharedGlyphAtlas: GlyphAtlas; export {};