mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
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.
This commit is contained in:
parent
4784ad66b2
commit
e3c64a0858
1 changed files with 1 additions and 1 deletions
|
@ -330,7 +330,7 @@ Color Color::mixed_with(Color other, float weight) const
|
||||||
// This is needed for linear-gradient()s in LibWeb.
|
// This is needed for linear-gradient()s in LibWeb.
|
||||||
auto mixed_alpha = mix<float>(alpha(), other.alpha(), weight);
|
auto mixed_alpha = mix<float>(alpha(), other.alpha(), weight);
|
||||||
auto premultiplied_mix_channel = [&](float channel, float other_channel, float weight) {
|
auto premultiplied_mix_channel = [&](float channel, float other_channel, float weight) {
|
||||||
return round_to<u8>(mix<float>(channel * (alpha() / 255.0f), other_channel * (other.alpha() / 255.0f), weight) / (mixed_alpha / 255.0f));
|
return round_to<u8>(mix<float>(channel * alpha(), other_channel * other.alpha(), weight) / mixed_alpha);
|
||||||
};
|
};
|
||||||
return Gfx::Color {
|
return Gfx::Color {
|
||||||
premultiplied_mix_channel(red(), other.red(), weight),
|
premultiplied_mix_channel(red(), other.red(), weight),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue