class Tessell::Render::TextRenderer

Defined in:

tessell/render/text_renderer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(atlas : Text::GlyphAtlas, rasterizer : Text::Rasterizer) #

[View source]

Instance Method Detail

def append_text_cached(placement_sink : Array(Text::GlyphPlacement), text : String, x : Float32, y : Float32, size_px : Int32, viewport_w : Int32, viewport_h : Int32, rgba : UInt32 = 255_u32) : Float32 #

追加文本四边形到当前缓冲(不清零),用于同帧多段文本合批/拼场景。 placement_sink 由调用方复用;每段 shape_run_into 会覆写 placement_sink 后再转顶点。


[View source]
def batch_count : Int32 #

[View source]
def batch_runs : Array(TextBatch) #

返回当前有效批次的逻辑视图(按 batch_count 截断)。


[View source]
def build_text(placement_sink : Array(Text::GlyphPlacement), text : String, x : Float32, y : Float32, size_px : Int32, viewport_w : Int32, viewport_h : Int32, rgba : UInt32 = 255_u32) : Float32 #

生成文本四边形(M3-WP1:不再接受纹理 id;批次携带 page,由后端解析纹理)。 placement_sink: 调用方复用的 GlyphPlacement 缓冲。text/x/y: baseline 起点(y-down)。 size_px: 字号。viewport_w/h: 视口尺寸(当前用于边界安全,顶点仍为屏幕坐标)。 返回 pen 末端 x(Float32)。 Uses per-call HB/FT shaping path (rasterize_into) to preserve existing behavior/stats.


[View source]
def build_text(placement_sink : Array(Text::GlyphPlacement), text : String, x : Float32, y : Float32, size_px : Int32, viewport_w : Int32, viewport_h : Int32, page_texture_ids : Array(Int32), rgba : UInt32 = 255_u32) : Float32 #

兼容重载:接受并忽略 page_texture_ids(纹理由后端占有)。


[View source]
def build_text_cached(placement_sink : Array(Text::GlyphPlacement), text : String, x : Float32, y : Float32, size_px : Int32, viewport_w : Int32, viewport_h : Int32, rgba : UInt32 = 255_u32) : Float32 #

M2-WP4/task-73: uses Rasterizer shaped-run cache (shape_run_into) to skip HB/FT shaping on hit. placement_sink is still reused; on cache hit only placement copy + vertex emission occur.


[View source]
def build_text_cached(placement_sink : Array(Text::GlyphPlacement), text : String, x : Float32, y : Float32, size_px : Int32, viewport_w : Int32, viewport_h : Int32, page_texture_ids : Array(Int32), rgba : UInt32 = 255_u32) : Float32 #

兼容重载:接受并忽略 page_texture_ids(纹理由后端占有)。


[View source]
def quad_capacity : Int32 #

[View source]
def reserve_batches(n : Int32) : Nil #

[View source]
def reserve_quads(n : Int32) : Nil #

预留容量以支持稳态零分配(可选:首次/扩容帧调用,热路径不应增长)。


[View source]
def reset : Nil #

逻辑清零(复用缓冲,稳态不分配)。


[View source]
def stats : NamedTuple(quads: Int32, batches: Int32) #

[View source]
def vertex_count : Int32 #

[View source]
def vertices : Array(Vertex) #

[View source]