From b34f1941681a8ca5166e8019950dd2bdeab1f0e8 Mon Sep 17 00:00:00 2001 From: Oleg Sikorskiy Date: Sun, 4 Apr 2021 16:19:47 +0300 Subject: [PATCH] LibGfx: Avoid float->double->float when converting from linear to gamma Benchmark shows 5x speedup (from 644ms to 110ms). --- Userland/Libraries/LibGfx/Gamma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.