class Tessell::Text::CachingMeasurer

Overview

缓存装饰器(issue #56 重构):两层缓存 + 分段 LRU。

Defined in:

tessell/text/measurer.cr

Constant Summary

CACHE_CAP = 8192
SEGMENT_CAP = 2048
SHAPE_CAP = 2048

Constructors

Instance Method Summary

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) : Size
measure(key : MeasureKey) : Size
measure
, shape_run(text : String, font_id : Int32, size : Float32) : ShapeRun | Nil shape_run

Constructor Detail

def self.new(inner : Measurer) #

[View source]

Instance Method Detail

def clear : Nil #

[View source]
def invalidate_font(font_id : Int32) : Nil #

[View source]
def l1_size : Int32 #

[View source]
def measure(text : String, font_id : Int32, size : Float32, max_width : Float32) : Size #
Description copied from class Tessell::Text::Measurer

主接口:按文本内容、字体、字号、可用宽测量


[View source]
def measure(key : MeasureKey) : Size #
Description copied from class Tessell::Text::Measurer

可选接口:按缓存键测量,内部使用;默认未实现


[View source]
def shape_cache_size : Int32 #

观测面(issue #56):L1 命中率之外的 shape/reflow 计数。


[View source]
def stats : NamedTuple(hits: Int32, misses: Int32, evictions: Int32, shapes: Int32, reflows: Int32) #

[View source]