diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2023-05-31 22:01:43 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-06-01 06:18:57 +0200 |
commit | 5339b54b5dbe9a26d4e20fb75f5ed20a7fcef495 (patch) | |
tree | ffa87d25ccb99a2427b56b45712e394e3fc19be8 /Userland | |
parent | 8a40b49b8b3040d02a9530699d8254edf109d7e1 (diff) | |
download | serenity-5339b54b5dbe9a26d4e20fb75f5ed20a7fcef495.zip |
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%.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 39f7414308..7f28634f98 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -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); } else { 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()); }); } } |