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
commit 06c176bbfb
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00
9 changed files with 32 additions and 15 deletions

View file

@ -49,7 +49,7 @@ void CommandList::execute(CommandExecutor& executor)
auto& command = command_with_scroll_id.command;
if (command.has<DrawGlyphRun>()) {
auto scale = command.get<DrawGlyphRun>().scale;
for (auto const& glyph_or_emoji : command.get<DrawGlyphRun>().glyph_run) {
for (auto const& glyph_or_emoji : command.get<DrawGlyphRun>().glyph_run->glyphs()) {
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
auto const& glyph = glyph_or_emoji.get<Gfx::DrawGlyph>();
auto const& font = *glyph.font->with_size(glyph.font->point_size() * static_cast<float>(scale));
@ -89,7 +89,7 @@ void CommandList::execute(CommandExecutor& executor)
auto result = command.visit(
[&](DrawGlyphRun const& command) {
return executor.draw_glyph_run(command.glyph_run, command.color, command.translation, command.scale);
return executor.draw_glyph_run(command.glyph_run->glyphs(), command.color, command.translation, command.scale);
},
[&](DrawText const& command) {
return executor.draw_text(command.rect, command.raw_text, command.alignment, command.color,