From e3c64a08585247875906acd372273c8fd080bca5 Mon Sep 17 00:00:00 2001 From: MacDue Date: Sat, 17 Dec 2022 19:51:20 +0000 Subject: [PATCH] LibGfx: Remove unnecessary divides in Color::mixed_with() This is mathematically the same thing, but the compiler can't optimize these out without -Ofast, so let's give it a hand. --- Userland/Libraries/LibGfx/Color.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/Color.cpp b/Userland/Libraries/LibGfx/Color.cpp index af74aa4215..2438ae3c7f 100644 --- a/Userland/Libraries/LibGfx/Color.cpp +++ b/Userland/Libraries/LibGfx/Color.cpp @@ -330,7 +330,7 @@ Color Color::mixed_with(Color other, float weight) const // This is needed for linear-gradient()s in LibWeb. auto mixed_alpha = mix(alpha(), other.alpha(), weight); auto premultiplied_mix_channel = [&](float channel, float other_channel, float weight) { - return round_to(mix(channel * (alpha() / 255.0f), other_channel * (other.alpha() / 255.0f), weight) / (mixed_alpha / 255.0f)); + return round_to(mix(channel * alpha(), other_channel * other.alpha(), weight) / mixed_alpha); }; return Gfx::Color { premultiplied_mix_channel(red(), other.red(), weight),