mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
LibWeb: Use glyph run to store text paint command in RecordingPainter
Representing a text run panting command as a vector of glyphs, rather than as a string simplifies collecting of unique glyphs which is a prerequisite for `prepare_glyphs_texture()` call.
This commit is contained in:
parent
32ea11d45c
commit
ee28ba0c93
6 changed files with 23 additions and 17 deletions
|
@ -207,11 +207,10 @@ void RecordingPainter::draw_signed_distance_field(Gfx::IntRect const& dst_rect,
|
|||
|
||||
void RecordingPainter::draw_text_run(Gfx::IntPoint baseline_start, Utf8View string, Gfx::Font const& font, Color color, Gfx::IntRect const& rect)
|
||||
{
|
||||
push_command(DrawTextRun {
|
||||
auto glyph_run = Gfx::get_glyph_run(state().translation.map(baseline_start).to_type<float>(), string, font);
|
||||
push_command(DrawGlyphRun {
|
||||
.glyph_run = glyph_run,
|
||||
.color = color,
|
||||
.baseline_start = state().translation.map(baseline_start),
|
||||
.string = String::from_utf8(string.as_string()).release_value_but_fixme_should_propagate_errors(),
|
||||
.font = font,
|
||||
.rect = state().translation.map(rect),
|
||||
});
|
||||
}
|
||||
|
@ -427,8 +426,8 @@ void RecordingPainter::execute(PaintingCommandExecutor& executor)
|
|||
}
|
||||
|
||||
auto result = command.visit(
|
||||
[&](DrawTextRun const& command) {
|
||||
return executor.draw_text_run(command.color, command.baseline_start, command.string, command.font);
|
||||
[&](DrawGlyphRun const& command) {
|
||||
return executor.draw_glyph_run(command.glyph_run, command.color);
|
||||
},
|
||||
[&](DrawText const& command) {
|
||||
return executor.draw_text(command.rect, command.raw_text, command.alignment, command.color, command.elision, command.wrapping, command.font);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue