util: fix possible fd leaks in os_socket_listen_abstract
[mesa.git] / src / util / format_srgb.h
index 4a8d73f125fc82927b97a848d3904a045b99a9f4..596af56f4cd84af182010a774a96e54c1d8acd8e 100644 (file)
@@ -54,10 +54,24 @@ extern const unsigned
 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)
+   if (cl <= 0.0f)
       return 0.0f;
    else if (cl < 0.0031308f)
       return 12.92f * cl;