class
Tessell::Text::CachingMeasurer
- Tessell::Text::CachingMeasurer
- Tessell::Text::Measurer
- Reference
- Object
Overview
缓存装饰器(issue #56 重构):两层缓存 + 分段 LRU。
- L1:结果缓存 (font_id, size, text_hash, max_width) → Size, 按 font_id 分段,段内 tick-LRU(段容量 SEGMENT_CAP),总量 CACHE_CAP。 一次 resize 风暴只挤占该字体自己的段,不再全有全无清空(旧口径)。
- L2:宽度无关 shaping 缓存 (font_id, size, text_hash) → ShapeRun (advance 序列 + 行高)。宽度变化只走 reflow(计 reflows),不重 shape。 不支持 shape_run 的底层(桩、计数桩)自动走全量 measure 路径。 断行口径唯一来源:Tessell::Text.reflow_run(FtMeasurer#measure 与本层共用)。
Defined in:
tessell/text/measurer.crConstant Summary
-
CACHE_CAP =
8192 -
SEGMENT_CAP =
2048 -
SHAPE_CAP =
2048
Constructors
Instance Method Summary
- #clear : Nil
- #invalidate_font(font_id : Int32) : Nil
- #l1_size : Int32
-
#measure(text : String, font_id : Int32, size : Float32, max_width : Float32) : Size
主接口:按文本内容、字体、字号、可用宽测量
-
#measure(key : MeasureKey) : Size
可选接口:按缓存键测量,内部使用;默认未实现
-
#shape_cache_size : Int32
观测面(issue #56):L1 命中率之外的 shape/reflow 计数。
- #stats : NamedTuple(hits: Int32, misses: Int32, evictions: Int32, shapes: Int32, reflows: Int32)
Instance methods inherited from class Tessell::Text::Measurer
font_metrics(font_id : Int32, size : Float32) : FontMetrics
font_metrics,
measure(text : String, font_id : Int32, size : Float32, max_width : Float32) : Sizemeasure(key : MeasureKey) : Size measure, shape_run(text : String, font_id : Int32, size : Float32) : ShapeRun | Nil shape_run
Constructor Detail
Instance Method Detail
Description copied from class Tessell::Text::Measurer
主接口:按文本内容、字体、字号、可用宽测量
Description copied from class Tessell::Text::Measurer
可选接口:按缓存键测量,内部使用;默认未实现
def stats : NamedTuple(hits: Int32, misses: Int32, evictions: Int32, shapes: Int32, reflows: Int32)
#