summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-06-22 20:00:47 -0700
committerNanley Chery <[email protected]>2018-04-24 13:41:14 -0700
commitb55077a8bc1e85400b43141f9ed4a1f4a322b420 (patch)
tree3c95d662b9e0060a3301b46ad9d805b095c23130 /src/util
parentcd5ce363e3fcf975c05a5f325292e95df8322cfb (diff)
util/srgb: Add a float sRGB -> linear helper
Reviewed-by: Nanley Chery <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/format_srgb.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/format_srgb.h b/src/util/format_srgb.h
index 34b50afe3d1..596af56f4cd 100644
--- a/src/util/format_srgb.h
+++ b/src/util/format_srgb.h
@@ -55,6 +55,20 @@ util_format_linear_to_srgb_helper_table[104];
static inline float
+util_format_srgb_to_linear_float(float cs)
+{
+ if (cs <= 0.0f)
+ return 0.0f;
+ else if (cs <= 0.04045f)
+ return cs / 12.92f;
+ else if (cs < 1.0f)
+ return powf((cs + 0.055) / 1.055f, 2.4f);
+ else
+ return 1.0f;
+}
+
+
+static inline float
util_format_linear_to_srgb_float(float cl)
{
if (cl <= 0.0f)