mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibWeb: Remove glyph run allocation in paint_text_fragment()
Instead of allocating a new glyph run to scale glyph positions and fonts, a scale factor could be encoded in a paint command and applied later during command execution.
This commit is contained in:
parent
aeb5a0d9e8
commit
cf6999f5f3
11 changed files with 25 additions and 27 deletions
|
@ -31,13 +31,16 @@ CommandExecutorGPU::~CommandExecutorGPU()
|
|||
painter().flush(m_target_bitmap);
|
||||
}
|
||||
|
||||
CommandResult CommandExecutorGPU::draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color, Gfx::FloatPoint translation)
|
||||
CommandResult CommandExecutorGPU::draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color, Gfx::FloatPoint translation, double scale)
|
||||
{
|
||||
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.visit([&](auto& glyph) {
|
||||
glyph.position = glyph.position.scaled(scale).translated(translation);
|
||||
glyph.font = *glyph.font->with_size(glyph.font->point_size() * static_cast<float>(scale));
|
||||
});
|
||||
transformed_glyph_run.append(transformed_glyph);
|
||||
}
|
||||
painter().draw_glyph_run(transformed_glyph_run, color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue