diff options
Diffstat (limited to 'indra/llmath/v4coloru.h')
-rw-r--r-- | indra/llmath/v4coloru.h | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h index fddad34978..0f2eff3d14 100644 --- a/indra/llmath/v4coloru.h +++ b/indra/llmath/v4coloru.h @@ -47,14 +47,7 @@ class LLColor4U { public: - union - { - U8 mV[LENGTHOFCOLOR4U]; - U32 mAll; - LLColor4* mSources; - LLColor4U* mSourcesU; - }; - + U8 mV[LENGTHOFCOLOR4U]; LLColor4U(); // Initializes LLColor4U to (0, 0, 0, 1) LLColor4U(U8 r, U8 g, U8 b); // Initializes LLColor4U to (r, g, b, 1) @@ -127,11 +120,14 @@ public: static BOOL parseColor4U(const std::string& buf, LLColor4U* value); // conversion - operator const LLColor4() const + operator LLColor4() const { return LLColor4(*this); } + U32 asRGBA() const; + void fromRGBA( U32 aVal ); + static LLColor4U white; static LLColor4U black; static LLColor4U red; @@ -565,6 +561,26 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color) mV[3] = 255; } +inline U32 LLColor4U::asRGBA() const +{ + // Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here + + return (mV[3] << 24) | (mV[2] << 16) | (mV[1] << 8) | mV[0]; +} + +inline void LLColor4U::fromRGBA( U32 aVal ) +{ + // Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here + + mV[ 0 ] = aVal & 0xFF; + aVal >>= 8; + mV[ 1 ] = aVal & 0xFF; + aVal >>= 8; + mV[ 2 ] = aVal & 0xFF; + aVal >>= 8; + mV[ 3 ] = aVal & 0xFF; +} + #endif |