mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibGfx: Improve glyph rendering speed for vector fonts
The glyph bitmap is a grayscale image that is multiplied with the requested color provided to `Gfx::Painter::draw_glyph()` to get the final glyph bitmap that can be blitted. Using `Gfx::Color::multiply()` is unnecessary however: by simply taking the destination color and copying over the glyph bitmap's alpha value, we can prevent four multiplications and divisions per pixel. In an artifical benchmark I wrote, this improved glyph rendering performance by ~9%.
This commit is contained in:
parent
8a40b49b8b
commit
5339b54b5d
Notes:
sideshowbarker
2024-07-17 20:58:35 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/5339b54b5d Pull-request: https://github.com/SerenityOS/serenity/pull/19189
1 changed files with 1 additions and 1 deletions
|
@ -1432,7 +1432,7 @@ FLATTEN void Painter::draw_glyph(FloatPoint point, u32 code_point, Font const& f
|
||||||
draw_scaled_bitmap(rect.to_rounded<int>(), *glyph.bitmap(), glyph.bitmap()->rect(), 1.0f, ScalingMode::BilinearBlend);
|
draw_scaled_bitmap(rect.to_rounded<int>(), *glyph.bitmap(), glyph.bitmap()->rect(), 1.0f, ScalingMode::BilinearBlend);
|
||||||
} else {
|
} else {
|
||||||
blit_filtered(glyph_position.blit_position, *glyph.bitmap(), glyph.bitmap()->rect(), [color](Color pixel) -> Color {
|
blit_filtered(glyph_position.blit_position, *glyph.bitmap(), glyph.bitmap()->rect(), [color](Color pixel) -> Color {
|
||||||
return pixel.multiply(color);
|
return color.with_alpha(pixel.alpha());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue