diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2020-05-06 16:06:26 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2020-05-06 16:06:26 -0400 |
commit | ca6f09292925a7bd936338cb598efb3ddc8524bf (patch) | |
tree | 3f27e75fc8443b84e91fcac400084fd83dfed26a /indra/llmath/v4color.h | |
parent | 4768d092f611576b4e4e95574e9b16192e7ced5e (diff) | |
parent | 4a7fd0117a43dca9e30c58c6417ebdf6862561f6 (diff) |
DRTVWR-476: Merge branch 'master' of lindenlab/viewer into DRTVWR-476-boost-1.72
Diffstat (limited to 'indra/llmath/v4color.h')
-rw-r--r-- | indra/llmath/v4color.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 8f353ead5a..175edf1471 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -114,9 +114,11 @@ class LLColor4 friend LLColor4 operator-(const LLColor4 &a, const LLColor4 &b); // Return vector a minus b friend LLColor4 operator*(const LLColor4 &a, const LLColor4 &b); // Return component wise a * b friend LLColor4 operator*(const LLColor4 &a, F32 k); // Return rgb times scaler k (no alpha change) + friend LLColor4 operator/(const LLColor4 &a, F32 k); // Return rgb divided by scalar k (no alpha change) friend LLColor4 operator*(F32 k, const LLColor4 &a); // Return rgb times scaler k (no alpha change) friend LLColor4 operator%(const LLColor4 &a, F32 k); // Return alpha times scaler k (no rgb change) friend LLColor4 operator%(F32 k, const LLColor4 &a); // Return alpha times scaler k (no rgb change) + friend bool operator==(const LLColor4 &a, const LLColor4 &b); // Return a == b friend bool operator!=(const LLColor4 &a, const LLColor4 &b); // Return a != b @@ -477,6 +479,15 @@ inline LLColor4 operator*(const LLColor4 &a, F32 k) a.mV[VW]); } +inline LLColor4 operator/(const LLColor4 &a, F32 k) +{ + return LLColor4( + a.mV[VX] / k, + a.mV[VY] / k, + a.mV[VZ] / k, + a.mV[VW]); +} + inline LLColor4 operator*(F32 k, const LLColor4 &a) { // only affects rgb (not a!) @@ -645,5 +656,29 @@ void LLColor4::clamp() } } +// Return the given linear space color value in gamma corrected (sRGB) space +inline const LLColor4 srgbColor4(const LLColor4 &a) { + LLColor4 srgbColor; + + srgbColor.mV[0] = linearTosRGB(a.mV[0]); + srgbColor.mV[1] = linearTosRGB(a.mV[1]); + srgbColor.mV[2] = linearTosRGB(a.mV[2]); + srgbColor.mV[3] = a.mV[3]; + + return srgbColor; +} + +// Return the given gamma corrected (sRGB) color in linear space +inline const LLColor4 linearColor4(const LLColor4 &a) +{ + LLColor4 linearColor; + linearColor.mV[0] = sRGBtoLinear(a.mV[0]); + linearColor.mV[1] = sRGBtoLinear(a.mV[1]); + linearColor.mV[2] = sRGBtoLinear(a.mV[2]); + linearColor.mV[3] = a.mV[3]; + + return linearColor; +} + #endif |