mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibAccelGfx: Skip glyph atlas rebuild if all needed glyphs are present
Before this change, every repaint required a glyph atlas update, which took 10-20% of the total painting time according to my testing on different websites. This change improves that significantly by skipping atlas updated when all glyphs are already present in the texture.
This commit is contained in:
parent
28723d8be1
commit
c68a9b2cfe
1 changed files with 7 additions and 2 deletions
|
@ -20,20 +20,25 @@ GlyphAtlas& GlyphAtlas::the()
|
|||
|
||||
void GlyphAtlas::update(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_glyphs)
|
||||
{
|
||||
auto need_to_rebuild_texture = false;
|
||||
HashMap<GlyphsTextureKey, NonnullRefPtr<Gfx::Bitmap>> glyph_bitmaps;
|
||||
for (auto const& [font, code_points] : unique_glyphs) {
|
||||
for (auto const& code_point : code_points) {
|
||||
auto glyph = font->glyph(code_point);
|
||||
auto atlas_key = GlyphsTextureKey { font, code_point };
|
||||
if (!m_glyphs_texture_map.contains(atlas_key))
|
||||
need_to_rebuild_texture = true;
|
||||
if (glyph.bitmap()) {
|
||||
auto atlas_key = GlyphsTextureKey { font, code_point };
|
||||
glyph_bitmaps.set(atlas_key, *glyph.bitmap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (glyph_bitmaps.is_empty())
|
||||
if (!need_to_rebuild_texture || glyph_bitmaps.is_empty())
|
||||
return;
|
||||
|
||||
m_glyphs_texture_map.clear();
|
||||
|
||||
Vector<GlyphsTextureKey> glyphs_sorted_by_height;
|
||||
glyphs_sorted_by_height.ensure_capacity(glyph_bitmaps.size());
|
||||
for (auto const& [atlas_key, bitmap] : glyph_bitmaps) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue