1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:07:45 +00:00

LibGfx: Add ALWAYS_INLINE to Color::mixed_with()/interpolate()

I can see small speedup of about 6-7% with this for some gradient
painting, though Tim has been able to see an ~30% speedup in some
resizing cases so this seems like a worthwhile change.

Co-authored-by: Tim Ledbetter <timledbetter@gmail.com>
This commit is contained in:
MacDue 2023-02-18 13:40:10 +00:00 committed by Jelle Raaijmakers
parent 3cc074c1b0
commit 6ceb185865

View file

@ -237,7 +237,7 @@ public:
#endif #endif
} }
Color mixed_with(Color other, float weight) const ALWAYS_INLINE Color mixed_with(Color other, float weight) const
{ {
if (alpha() == other.alpha() || with_alpha(0) == other.with_alpha(0)) if (alpha() == other.alpha() || with_alpha(0) == other.with_alpha(0))
return interpolate(other, weight); return interpolate(other, weight);
@ -255,7 +255,7 @@ public:
}; };
} }
Color interpolate(Color other, float weight) const noexcept ALWAYS_INLINE Color interpolate(Color other, float weight) const noexcept
{ {
return Gfx::Color { return Gfx::Color {
round_to<u8>(mix<float>(red(), other.red(), weight)), round_to<u8>(mix<float>(red(), other.red(), weight)),