mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
util/srgb: Add a float sRGB -> linear helper
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
cd5ce363e3
commit
b55077a8bc
1 changed files with 14 additions and 0 deletions
|
|
@ -54,6 +54,20 @@ 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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue