diff options
author | Jason Ekstrand <[email protected]> | 2014-07-24 12:32:49 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2014-08-04 11:07:20 -0700 |
commit | e97498ef811b49b8fb894bd167503109151a1fc8 (patch) | |
tree | 61acffa231367ef3da8fb69524658240024c4a86 /src/util/format_srgb.h | |
parent | 992e1ea8e4290cf14d59f89415bfd13e0920aad7 (diff) |
mesa/main: Use the RGB <-> sRGB conversion functions in libmesautil
Signed-off-by: Jason Ekstrand <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/util/format_srgb.h')
-rw-r--r-- | src/util/format_srgb.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util/format_srgb.h b/src/util/format_srgb.h index 8e92c38f461..17ba2835f9f 100644 --- a/src/util/format_srgb.h +++ b/src/util/format_srgb.h @@ -38,6 +38,7 @@ #define U_FORMAT_SRGB_H_ #include <stdint.h> +#include <math.h> extern const float util_format_srgb_8unorm_to_linear_float_table[256]; @@ -52,6 +53,20 @@ extern const unsigned util_format_linear_to_srgb_helper_table[104]; +static inline float +util_format_linear_to_srgb_float(float cl) +{ + if (cl < 0.0f) + return 0.0f; + else if (cl < 0.0031308f) + return 12.92f * cl; + else if (cl < 1.0f) + return 1.055f * powf(cl, 0.41666f) - 0.055f; + else + return 1.0f; +} + + /** * Convert a unclamped linear float to srgb value in the [0,255]. */ |