1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:47:45 +00:00

LibGfx+LibWeb: Use ref-counted object to store glyph run

...to avoid allocating a copy of glyph run for painting commands. We
can't simply save pointers to a glyph run in layout/paintable tree
because it should be safe to deallocate layout and paintable trees
after painting commands are recorded, if in the future we decide to
move command execution to a separate thread.
This commit is contained in:
Aliaksandr Kalenik 2024-03-01 16:37:44 +01:00 committed by Andreas Kling
parent cf6999f5f3
commit 06c176bbfb
9 changed files with 32 additions and 15 deletions

View file

@ -590,8 +590,8 @@ void paint_text_shadow(PaintContext& context, PaintableFragment const& fragment,
auto fragment_baseline = context.rounded_device_pixels(fragment.baseline()).value();
Vector<Gfx::DrawGlyphOrEmoji> scaled_glyph_run;
scaled_glyph_run.ensure_capacity(fragment.glyph_run().size());
for (auto glyph : fragment.glyph_run()) {
scaled_glyph_run.ensure_capacity(fragment.glyph_run().glyphs().size());
for (auto glyph : fragment.glyph_run().glyphs()) {
glyph.visit([&](auto& glyph) {
glyph.font = *glyph.font->with_size(glyph.font->point_size() * static_cast<float>(context.device_pixels_per_css_pixel()));
glyph.position = glyph.position.scaled(context.device_pixels_per_css_pixel());