Module: Mesa
Branch: master
Commit: b55077a8bc1e85400b43141f9ed4a1f4a322b420
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b55077a8bc1e85400b43141f9ed4a1f4a322b420

Author: Jason Ekstrand <jason.ekstr...@intel.com>
Date:   Thu Jun 22 20:00:47 2017 -0700

util/srgb: Add a float sRGB -> linear helper

Reviewed-by: Nanley Chery <nanley.g.ch...@intel.com>
Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

---

 src/util/format_srgb.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/util/format_srgb.h b/src/util/format_srgb.h
index 34b50afe3d..596af56f4c 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)

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to