diff options
author | Oleg Sikorskiy <olegsik@gmail.com> | 2021-04-04 16:19:47 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-04 17:33:35 +0200 |
commit | b34f1941681a8ca5166e8019950dd2bdeab1f0e8 (patch) | |
tree | 73494abd82fbb26b3f8fb20873748ff3362ad774 | |
parent | c0eacf4cc1d398ad2975e84a1728dd47254852a5 (diff) | |
download | serenity-b34f1941681a8ca5166e8019950dd2bdeab1f0e8.zip |
LibGfx: Avoid float->double->float when converting from linear to gamma
Benchmark shows 5x speedup (from 644ms to 110ms).
-rw-r--r-- | Userland/Libraries/LibGfx/Gamma.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/Gamma.h b/Userland/Libraries/LibGfx/Gamma.h index f6be93b8fe..f0f3b86f25 100644 --- a/Userland/Libraries/LibGfx/Gamma.h +++ b/Userland/Libraries/LibGfx/Gamma.h @@ -106,7 +106,7 @@ inline float linear_to_gamma(float x) constexpr float a = 0.00279491; constexpr float b = 1.15907984; float c = (b / sqrt(1 + a)) - 1; - return ((b / __builtin_sqrt(x + a)) - c) * x; + return ((b / __builtin_sqrtf(x + a)) - c) * x; } // Linearize v1 and v2, lerp them by mix factor, then convert back. |