glyph-brush-0.4
-
Use queue call counting & fine grained hashing to match up previous calls with current calls figuring out what has changed allowing optimised use of
recalculate_glyphs
for fast layouts.- Compute if just geometry (ie section position) has changed ->
GlyphChange::Geometry
. - Compute if just color has changed ->
GlyphChange::Color
. - Compute if just alpha has changed ->
GlyphChange::Alpha
.
Provides much faster re-layout performance in these common change scenarios.
- Compute if just geometry (ie section position) has changed ->
-
GlyphBrush
now generates & caches vertices avoiding regeneration of individual unchanged sections, when another section change forces regeneration of the complete vertex array. The user vertex typeV
is now in the struct signature.pub struct DownstreamGlyphBrush<'font, H = DefaultSectionHasher> { // previously: glyph_brush::GlyphBrush<'font, H>, inner: glyph_brush::GlyphBrush<'font, DownstreamGlyphVertex, H>, ... }
These changes result in a big performance improvement for changes to sections amongst other unchanging sections, which is a fairly common thing to want to do. Fully cached (everything unchanging) & worst-case (everything changing/new) are not significantly affected.
name control ns/iter change ns/iter diff ns/iter diff % speedup
continually_modify_alpha_of_1_of_3 854,554 349,165 -505,389 -59.14% x 2.45
continually_modify_bounds_of_1_of_3 865,162 643,341 -221,821 -25.64% x 1.34
continually_modify_color_of_1_of_3 855,189 344,501 -510,688 -59.72% x 2.48
continually_modify_end_text_of_1_of_3 857,913 647,491 -210,422 -24.53% x 1.32
continually_modify_middle_text_of_1_of_3 856,383 642,055 -214,328 -25.03% x 1.33
continually_modify_position_of_1_of_3 866,298 355,794 -510,504 -58.93% x 2.43
continually_modify_start_text_of_1_of_3 872,081 654,887 -217,194 -24.91% x 1.33
no_cache_render_3_medium_sections_fully 1,480,556 1,500,286 19,730 1.33% x 0.99
render_3_medium_sections_fully 1,136 1,066 -70 -6.16% x 1.07