/ 5 Motivation Quoting the TDF wiki: • All over the code base assumes shaping text is cheap • We can do it over and over again • Want to measure the text? Shape it and discard the output afterwards. Want to measure part of the same text? Shape again. Want to find line breaks? Shape again. Want to finally draw it? Shape again. • In contrast, other toolkits typically calculate the layout explicitly: • e.g. GtkLabel has an explicit PangoLayout, etc.
/ 5 Work done: Writer Good news • Everything goes through SwFntObj • Can cache GetTextArray(), DrawTextArray(), GetTextWidth(), GetTextBreak() calls on OutputDevice Bad news • Need a cache: SwFntObj typically doesn’t have a good idea about the lifecycle of the created text layout • For now: SwTextGlyphsKey stores which subset of which text was laid out on which output device • Storing the full output device state is too expensive • Can’t handle everything transparently in VCL
/ 5 Results Metric: # of layout calls • GenericSalLayout::LayoutText() Measured: one Writer scenario (equivalent of UITests in sw) • 55793 layout calls initially • 18126 layout calls now • Only 32% of the original work is performed baseline sw draw cache ruler cache sw break cache listbox cache 0 10000 20000 30000 40000 50000 60000 # of layouts