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

LibWeb: Remove glyph run allocation in RecordingPainter::draw_text_run

Instead of allocating a new glyph run solely to shift each glyph by the
painter's offset, this offset could be encoded in a paint command and
applied later during command execution.
This commit is contained in:
Aliaksandr Kalenik 2024-03-01 13:22:35 +01:00 committed by Andreas Kling
parent 79fd8eb28d
commit aeb5a0d9e8
8 changed files with 21 additions and 16 deletions

View file

@ -31,9 +31,16 @@ CommandExecutorGPU::~CommandExecutorGPU()
painter().flush(m_target_bitmap);
}
CommandResult CommandExecutorGPU::draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color)
CommandResult CommandExecutorGPU::draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color, Gfx::FloatPoint translation)
{
painter().draw_glyph_run(glyph_run, color);
Vector<Gfx::DrawGlyphOrEmoji> transformed_glyph_run;
transformed_glyph_run.ensure_capacity(glyph_run.size());
for (auto& glyph : glyph_run) {
auto transformed_glyph = glyph;
transformed_glyph.visit([&](auto& glyph) { glyph.position.translate_by(translation); });
transformed_glyph_run.append(transformed_glyph);
}
painter().draw_glyph_run(transformed_glyph_run, color);
return CommandResult::Continue;
}