summaryrefslogtreecommitdiff
path: root/indra/llmath/v4coloru.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2016-12-05 17:01:38 -0500
committerNat Goodspeed <nat@lindenlab.com>2016-12-05 17:01:38 -0500
commit05d58c91ef55fd90ea2f3e0f1a1199ac5e690b30 (patch)
tree70ae80b97c738ceee3b4ba530454e97a8698b6cb /indra/llmath/v4coloru.h
parent68413474c4479eee9bdbeb34ea131475ba1d646e (diff)
parent4ca084f7a06acc4ef861c1f4df2f857f8836b85e (diff)
Automated merge with ssh://bitbucket.org/lindenlab/viewer-release
Diffstat (limited to 'indra/llmath/v4coloru.h')
-rw-r--r--indra/llmath/v4coloru.h32
1 files changed, 24 insertions, 8 deletions
diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h
index fddad34978..704ce852d9 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)
@@ -132,6 +125,9 @@ public:
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