summaryrefslogtreecommitdiff
path: root/indra/llmath/v4coloru.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath/v4coloru.h')
-rw-r--r--indra/llmath/v4coloru.h371
1 files changed, 142 insertions, 229 deletions
diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h
index 29128a08a7..e1a0206461 100644
--- a/indra/llmath/v4coloru.h
+++ b/indra/llmath/v4coloru.h
@@ -28,104 +28,93 @@
#define LL_V4COLORU_H
#include "llerror.h"
-//#include "vmath.h"
#include "llmath.h"
-//#include "v4color.h"
#include "v3color.h"
#include "v4color.h"
-//class LLColor3U;
class LLColor4;
// LLColor4U = | red green blue alpha |
-static const U32 LENGTHOFCOLOR4U = 4;
-
+static constexpr U32 LENGTHOFCOLOR4U = 4;
class LLColor4U
{
public:
-
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)
- LLColor4U(U8 r, U8 g, U8 b, U8 a); // Initializes LLColor4U to (r. g, b, a)
- LLColor4U(const U8 *vec); // Initializes LLColor4U to (vec[0]. vec[1], vec[2], 1)
- explicit LLColor4U(const LLSD& sd)
- {
- setValue(sd);
- }
+ LLColor4U(); // Initializes LLColor4U to (0, 0, 0, 1)
+ LLColor4U(U8 r, U8 g, U8 b); // Initializes LLColor4U to (r, g, b, 1)
+ LLColor4U(U8 r, U8 g, U8 b, U8 a); // Initializes LLColor4U to (r. g, b, a)
+ LLColor4U(const U8* vec); // Initializes LLColor4U to (vec[0]. vec[1], vec[2], 1)
+ explicit LLColor4U(const LLSD& sd) { setValue(sd); }
void setValue(const LLSD& sd)
{
- mV[0] = sd[0].asInteger();
- mV[1] = sd[1].asInteger();
- mV[2] = sd[2].asInteger();
- mV[3] = sd[3].asInteger();
+ mV[VRED] = sd[0].asInteger();
+ mV[VGREEN] = sd[1].asInteger();
+ mV[VBLUE] = sd[2].asInteger();
+ mV[VALPHA] = sd[3].asInteger();
}
LLSD getValue() const
{
LLSD ret;
- ret[0] = mV[0];
- ret[1] = mV[1];
- ret[2] = mV[2];
- ret[3] = mV[3];
+ ret[0] = mV[VRED];
+ ret[1] = mV[VGREEN];
+ ret[2] = mV[VBLUE];
+ ret[3] = mV[VALPHA];
return ret;
}
- const LLColor4U& setToBlack(); // zero LLColor4U to (0, 0, 0, 1)
- const LLColor4U& setToWhite(); // zero LLColor4U to (0, 0, 0, 1)
+ const LLColor4U& setToBlack(); // zero LLColor4U to (0, 0, 0, 1)
+ const LLColor4U& setToWhite(); // zero LLColor4U to (0, 0, 0, 1)
- const LLColor4U& set(U8 r, U8 g, U8 b, U8 a);// Sets LLColor4U to (r, g, b, a)
- const LLColor4U& set(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a)
- const LLColor4U& set(const LLColor4U &vec); // Sets LLColor4U to vec
- const LLColor4U& set(const U8 *vec); // Sets LLColor4U to vec
+ const LLColor4U& set(U8 r, U8 g, U8 b, U8 a); // Sets LLColor4U to (r, g, b, a)
+ const LLColor4U& set(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a)
+ const LLColor4U& set(const LLColor4U& vec); // Sets LLColor4U to vec
+ const LLColor4U& set(const U8* vec); // Sets LLColor4U to vec
- const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // deprecated -- use set()
- const LLColor4U& setVec(U8 r, U8 g, U8 b); // deprecated -- use set()
- const LLColor4U& setVec(const LLColor4U &vec); // deprecated -- use set()
- const LLColor4U& setVec(const U8 *vec); // deprecated -- use set()
+ const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // deprecated -- use set()
+ const LLColor4U& setVec(U8 r, U8 g, U8 b); // deprecated -- use set()
+ const LLColor4U& setVec(const LLColor4U& vec); // deprecated -- use set()
+ const LLColor4U& setVec(const U8* vec); // deprecated -- use set()
- const LLColor4U& setAlpha(U8 a);
+ const LLColor4U& setAlpha(U8 a);
- F32 magVec() const; // deprecated -- use length()
- F32 magVecSquared() const; // deprecated -- use lengthSquared()
+ F32 magVec() const; // deprecated -- use length()
+ F32 magVecSquared() const; // deprecated -- use lengthSquared()
- F32 length() const; // Returns magnitude squared of LLColor4U
- F32 lengthSquared() const; // Returns magnitude squared of LLColor4U
+ F32 length() const; // Returns magnitude squared of LLColor4U
+ F32 lengthSquared() const; // Returns magnitude squared of LLColor4U
- friend std::ostream& operator<<(std::ostream& s, const LLColor4U &a); // Print a
- friend LLColor4U operator+(const LLColor4U &a, const LLColor4U &b); // Return vector a + b
- friend LLColor4U operator-(const LLColor4U &a, const LLColor4U &b); // Return vector a minus b
- friend LLColor4U operator*(const LLColor4U &a, const LLColor4U &b); // Return a * b
- friend bool operator==(const LLColor4U &a, const LLColor4U &b); // Return a == b
- friend bool operator!=(const LLColor4U &a, const LLColor4U &b); // Return a != b
+ friend std::ostream& operator<<(std::ostream& s, const LLColor4U& a); // Print a
+ friend LLColor4U operator+(const LLColor4U& a, const LLColor4U& b); // Return vector a + b
+ friend LLColor4U operator-(const LLColor4U& a, const LLColor4U& b); // Return vector a minus b
+ friend LLColor4U operator*(const LLColor4U& a, const LLColor4U& b); // Return a * b
+ friend bool operator==(const LLColor4U& a, const LLColor4U& b); // Return a == b
+ friend bool operator!=(const LLColor4U& a, const LLColor4U& b); // Return a != b
- friend const LLColor4U& operator+=(LLColor4U &a, const LLColor4U &b); // Return vector a + b
- friend const LLColor4U& operator-=(LLColor4U &a, const LLColor4U &b); // Return vector a minus b
- friend const LLColor4U& operator*=(LLColor4U &a, U8 k); // Return rgb times scaler k (no alpha change)
- friend const LLColor4U& operator%=(LLColor4U &a, U8 k); // Return alpha times scaler k (no rgb change)
+ friend const LLColor4U& operator+=(LLColor4U& a, const LLColor4U& b); // Return vector a + b
+ friend const LLColor4U& operator-=(LLColor4U& a, const LLColor4U& b); // Return vector a minus b
+ friend const LLColor4U& operator*=(LLColor4U& a, U8 k); // Return rgb times scaler k (no alpha change)
+ friend const LLColor4U& operator%=(LLColor4U& a, U8 k); // Return alpha times scaler k (no rgb change)
- LLColor4U addClampMax(const LLColor4U &color); // Add and clamp the max
+ LLColor4U addClampMax(const LLColor4U& color); // Add and clamp the max
- LLColor4U multAll(const F32 k); // Multiply ALL channels by scalar k
+ LLColor4U multAll(const F32 k); // Multiply ALL channels by scalar k
- inline void setVecScaleClamp(const LLColor3 &color);
- inline void setVecScaleClamp(const LLColor4 &color);
+ inline void setVecScaleClamp(const LLColor3& color);
+ inline void setVecScaleClamp(const LLColor4& color);
static bool parseColor4U(const std::string& buf, LLColor4U* value);
// conversion
- operator LLColor4() const
- {
- return LLColor4(*this);
- }
+ operator LLColor4() const { return LLColor4(*this); }
- U32 asRGBA() const;
- void fromRGBA( U32 aVal );
+ U32 asRGBA() const;
+ void fromRGBA(U32 aVal);
static LLColor4U white;
static LLColor4U black;
@@ -134,104 +123,95 @@ public:
static LLColor4U blue;
};
-
// Non-member functions
-F32 distVec(const LLColor4U &a, const LLColor4U &b); // Returns distance between a and b
-F32 distVec_squared(const LLColor4U &a, const LLColor4U &b); // Returns distance squared between a and b
-
+F32 distVec(const LLColor4U& a, const LLColor4U& b); // Returns distance between a and b
+F32 distVec_squared(const LLColor4U& a, const LLColor4U& b); // Returns distance squared between a and b
inline LLColor4U::LLColor4U()
{
- mV[VRED] = 0;
+ mV[VRED] = 0;
mV[VGREEN] = 0;
- mV[VBLUE] = 0;
+ mV[VBLUE] = 0;
mV[VALPHA] = 255;
}
inline LLColor4U::LLColor4U(U8 r, U8 g, U8 b)
{
- mV[VRED] = r;
+ mV[VRED] = r;
mV[VGREEN] = g;
- mV[VBLUE] = b;
+ mV[VBLUE] = b;
mV[VALPHA] = 255;
}
inline LLColor4U::LLColor4U(U8 r, U8 g, U8 b, U8 a)
{
- mV[VRED] = r;
+ mV[VRED] = r;
mV[VGREEN] = g;
- mV[VBLUE] = b;
+ mV[VBLUE] = b;
mV[VALPHA] = a;
}
-inline LLColor4U::LLColor4U(const U8 *vec)
+inline LLColor4U::LLColor4U(const U8* vec)
{
- mV[VRED] = vec[VRED];
+ mV[VRED] = vec[VRED];
mV[VGREEN] = vec[VGREEN];
- mV[VBLUE] = vec[VBLUE];
+ mV[VBLUE] = vec[VBLUE];
mV[VALPHA] = vec[VALPHA];
}
-/*
-inline LLColor4U::operator LLColor4()
-{
- return(LLColor4((F32)mV[VRED]/255.f,(F32)mV[VGREEN]/255.f,(F32)mV[VBLUE]/255.f,(F32)mV[VALPHA]/255.f));
-}
-*/
-
inline const LLColor4U& LLColor4U::setToBlack(void)
{
- mV[VRED] = 0;
+ mV[VRED] = 0;
mV[VGREEN] = 0;
- mV[VBLUE] = 0;
+ mV[VBLUE] = 0;
mV[VALPHA] = 255;
return (*this);
}
inline const LLColor4U& LLColor4U::setToWhite(void)
{
- mV[VRED] = 255;
+ mV[VRED] = 255;
mV[VGREEN] = 255;
- mV[VBLUE] = 255;
+ mV[VBLUE] = 255;
mV[VALPHA] = 255;
return (*this);
}
inline const LLColor4U& LLColor4U::set(const U8 x, const U8 y, const U8 z)
{
- mV[VRED] = x;
+ mV[VRED] = x;
mV[VGREEN] = y;
- mV[VBLUE] = z;
+ mV[VBLUE] = z;
-// no change to alpha!
-// mV[VALPHA] = 255;
+ // no change to alpha!
+ // mV[VALPHA] = 255;
return (*this);
}
inline const LLColor4U& LLColor4U::set(const U8 r, const U8 g, const U8 b, U8 a)
{
- mV[0] = r;
- mV[1] = g;
- mV[2] = b;
- mV[3] = a;
+ mV[VRED] = r;
+ mV[VGREEN] = g;
+ mV[VBLUE] = b;
+ mV[VALPHA] = a;
return (*this);
}
-inline const LLColor4U& LLColor4U::set(const LLColor4U &vec)
+inline const LLColor4U& LLColor4U::set(const LLColor4U& vec)
{
- mV[VRED] = vec.mV[VRED];
+ mV[VRED] = vec.mV[VRED];
mV[VGREEN] = vec.mV[VGREEN];
- mV[VBLUE] = vec.mV[VBLUE];
+ mV[VBLUE] = vec.mV[VBLUE];
mV[VALPHA] = vec.mV[VALPHA];
return (*this);
}
-inline const LLColor4U& LLColor4U::set(const U8 *vec)
+inline const LLColor4U& LLColor4U::set(const U8* vec)
{
- mV[VRED] = vec[VRED];
+ mV[VRED] = vec[VRED];
mV[VGREEN] = vec[VGREEN];
- mV[VBLUE] = vec[VBLUE];
+ mV[VBLUE] = vec[VBLUE];
mV[VALPHA] = vec[VALPHA];
return (*this);
}
@@ -239,12 +219,12 @@ inline const LLColor4U& LLColor4U::set(const U8 *vec)
// deprecated
inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)
{
- mV[VRED] = x;
+ mV[VRED] = x;
mV[VGREEN] = y;
- mV[VBLUE] = z;
+ mV[VBLUE] = z;
-// no change to alpha!
-// mV[VALPHA] = 255;
+ // no change to alpha!
+ // mV[VALPHA] = 255;
return (*this);
}
@@ -252,29 +232,29 @@ inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)
// deprecated
inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a)
{
- mV[0] = r;
- mV[1] = g;
- mV[2] = b;
- mV[3] = a;
+ mV[VRED] = r;
+ mV[VGREEN] = g;
+ mV[VBLUE] = b;
+ mV[VALPHA] = a;
return (*this);
}
// deprecated
-inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec)
+inline const LLColor4U& LLColor4U::setVec(const LLColor4U& vec)
{
- mV[VRED] = vec.mV[VRED];
+ mV[VRED] = vec.mV[VRED];
mV[VGREEN] = vec.mV[VGREEN];
- mV[VBLUE] = vec.mV[VBLUE];
+ mV[VBLUE] = vec.mV[VBLUE];
mV[VALPHA] = vec.mV[VALPHA];
return (*this);
}
// deprecated
-inline const LLColor4U& LLColor4U::setVec(const U8 *vec)
+inline const LLColor4U& LLColor4U::setVec(const U8* vec)
{
- mV[VRED] = vec[VRED];
+ mV[VRED] = vec[VRED];
mV[VGREEN] = vec[VGREEN];
- mV[VBLUE] = vec[VBLUE];
+ mV[VBLUE] = vec[VBLUE];
mV[VALPHA] = vec[VALPHA];
return (*this);
}
@@ -287,131 +267,68 @@ inline const LLColor4U& LLColor4U::setAlpha(U8 a)
// LLColor4U Magnitude and Normalization Functions
-inline F32 LLColor4U::length(void) const
+inline F32 LLColor4U::length() const
{
- return (F32) sqrt( ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE] );
+ return sqrt(((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE]);
}
-inline F32 LLColor4U::lengthSquared(void) const
+inline F32 LLColor4U::lengthSquared() const
{
return ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE];
}
// deprecated
-inline F32 LLColor4U::magVec(void) const
+inline F32 LLColor4U::magVec() const
{
- return (F32) sqrt( ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE] );
+ return sqrt(((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE]);
}
// deprecated
-inline F32 LLColor4U::magVecSquared(void) const
+inline F32 LLColor4U::magVecSquared() const
{
return ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE];
}
-inline LLColor4U operator+(const LLColor4U &a, const LLColor4U &b)
+inline LLColor4U operator+(const LLColor4U& a, const LLColor4U& b)
{
- return LLColor4U(
- a.mV[VRED] + b.mV[VRED],
- a.mV[VGREEN] + b.mV[VGREEN],
- a.mV[VBLUE] + b.mV[VBLUE],
- a.mV[VALPHA] + b.mV[VALPHA]);
+ return LLColor4U(a.mV[VRED] + b.mV[VRED], a.mV[VGREEN] + b.mV[VGREEN], a.mV[VBLUE] + b.mV[VBLUE], a.mV[VALPHA] + b.mV[VALPHA]);
}
-inline LLColor4U operator-(const LLColor4U &a, const LLColor4U &b)
+inline LLColor4U operator-(const LLColor4U& a, const LLColor4U& b)
{
- return LLColor4U(
- a.mV[VRED] - b.mV[VRED],
- a.mV[VGREEN] - b.mV[VGREEN],
- a.mV[VBLUE] - b.mV[VBLUE],
- a.mV[VALPHA] - b.mV[VALPHA]);
+ return LLColor4U(a.mV[VRED] - b.mV[VRED], a.mV[VGREEN] - b.mV[VGREEN], a.mV[VBLUE] - b.mV[VBLUE], a.mV[VALPHA] - b.mV[VALPHA]);
}
-inline LLColor4U operator*(const LLColor4U &a, const LLColor4U &b)
+inline LLColor4U operator*(const LLColor4U& a, const LLColor4U& b)
{
- return LLColor4U(
- a.mV[VRED] * b.mV[VRED],
- a.mV[VGREEN] * b.mV[VGREEN],
- a.mV[VBLUE] * b.mV[VBLUE],
- a.mV[VALPHA] * b.mV[VALPHA]);
+ return LLColor4U(a.mV[VRED] * b.mV[VRED], a.mV[VGREEN] * b.mV[VGREEN], a.mV[VBLUE] * b.mV[VBLUE], a.mV[VALPHA] * b.mV[VALPHA]);
}
-inline LLColor4U LLColor4U::addClampMax(const LLColor4U &color)
+inline LLColor4U LLColor4U::addClampMax(const LLColor4U& color)
{
return LLColor4U(llmin((S32)mV[VRED] + color.mV[VRED], 255),
- llmin((S32)mV[VGREEN] + color.mV[VGREEN], 255),
- llmin((S32)mV[VBLUE] + color.mV[VBLUE], 255),
- llmin((S32)mV[VALPHA] + color.mV[VALPHA], 255));
+ llmin((S32)mV[VGREEN] + color.mV[VGREEN], 255),
+ llmin((S32)mV[VBLUE] + color.mV[VBLUE], 255),
+ llmin((S32)mV[VALPHA] + color.mV[VALPHA], 255));
}
inline LLColor4U LLColor4U::multAll(const F32 k)
{
// Round to nearest
- return LLColor4U(
- (U8)ll_round(mV[VRED] * k),
- (U8)ll_round(mV[VGREEN] * k),
- (U8)ll_round(mV[VBLUE] * k),
- (U8)ll_round(mV[VALPHA] * k));
-}
-/*
-inline LLColor4U operator*(const LLColor4U &a, U8 k)
-{
- // only affects rgb (not a!)
- return LLColor4U(
- a.mV[VRED] * k,
- a.mV[VGREEN] * k,
- a.mV[VBLUE] * k,
- a.mV[VALPHA]);
+ return LLColor4U((U8)ll_round(mV[VRED] * k), (U8)ll_round(mV[VGREEN] * k), (U8)ll_round(mV[VBLUE] * k), (U8)ll_round(mV[VALPHA] * k));
}
-inline LLColor4U operator*(U8 k, const LLColor4U &a)
+inline bool operator==(const LLColor4U& a, const LLColor4U& b)
{
- // only affects rgb (not a!)
- return LLColor4U(
- a.mV[VRED] * k,
- a.mV[VGREEN] * k,
- a.mV[VBLUE] * k,
- a.mV[VALPHA]);
+ return ((a.mV[VRED] == b.mV[VRED]) && (a.mV[VGREEN] == b.mV[VGREEN]) && (a.mV[VBLUE] == b.mV[VBLUE]) && (a.mV[VALPHA] == b.mV[VALPHA]));
}
-inline LLColor4U operator%(U8 k, const LLColor4U &a)
+inline bool operator!=(const LLColor4U& a, const LLColor4U& b)
{
- // only affects alpha (not rgb!)
- return LLColor4U(
- a.mV[VRED],
- a.mV[VGREEN],
- a.mV[VBLUE],
- a.mV[VALPHA] * k );
+ return ((a.mV[VRED] != b.mV[VRED]) || (a.mV[VGREEN] != b.mV[VGREEN]) || (a.mV[VBLUE] != b.mV[VBLUE]) || (a.mV[VALPHA] != b.mV[VALPHA]));
}
-inline LLColor4U operator%(const LLColor4U &a, U8 k)
-{
- // only affects alpha (not rgb!)
- return LLColor4U(
- a.mV[VRED],
- a.mV[VGREEN],
- a.mV[VBLUE],
- a.mV[VALPHA] * k );
-}
-*/
-
-inline bool operator==(const LLColor4U &a, const LLColor4U &b)
-{
- return ( (a.mV[VRED] == b.mV[VRED])
- &&(a.mV[VGREEN] == b.mV[VGREEN])
- &&(a.mV[VBLUE] == b.mV[VBLUE])
- &&(a.mV[VALPHA] == b.mV[VALPHA]));
-}
-
-inline bool operator!=(const LLColor4U &a, const LLColor4U &b)
-{
- return ( (a.mV[VRED] != b.mV[VRED])
- ||(a.mV[VGREEN] != b.mV[VGREEN])
- ||(a.mV[VBLUE] != b.mV[VBLUE])
- ||(a.mV[VALPHA] != b.mV[VALPHA]));
-}
-
-inline const LLColor4U& operator+=(LLColor4U &a, const LLColor4U &b)
+inline const LLColor4U& operator+=(LLColor4U& a, const LLColor4U& b)
{
a.mV[VRED] += b.mV[VRED];
a.mV[VGREEN] += b.mV[VGREEN];
@@ -420,7 +337,7 @@ inline const LLColor4U& operator+=(LLColor4U &a, const LLColor4U &b)
return a;
}
-inline const LLColor4U& operator-=(LLColor4U &a, const LLColor4U &b)
+inline const LLColor4U& operator-=(LLColor4U& a, const LLColor4U& b)
{
a.mV[VRED] -= b.mV[VRED];
a.mV[VGREEN] -= b.mV[VGREEN];
@@ -429,7 +346,7 @@ inline const LLColor4U& operator-=(LLColor4U &a, const LLColor4U &b)
return a;
}
-inline const LLColor4U& operator*=(LLColor4U &a, U8 k)
+inline const LLColor4U& operator*=(LLColor4U& a, U8 k)
{
// only affects rgb (not a!)
a.mV[VRED] *= k;
@@ -438,20 +355,20 @@ inline const LLColor4U& operator*=(LLColor4U &a, U8 k)
return a;
}
-inline const LLColor4U& operator%=(LLColor4U &a, U8 k)
+inline const LLColor4U& operator%=(LLColor4U& a, U8 k)
{
// only affects alpha (not rgb!)
a.mV[VALPHA] *= k;
return a;
}
-inline F32 distVec(const LLColor4U &a, const LLColor4U &b)
+inline F32 distVec(const LLColor4U& a, const LLColor4U& b)
{
LLColor4U vec = a - b;
return (vec.length());
}
-inline F32 distVec_squared(const LLColor4U &a, const LLColor4U &b)
+inline F32 distVec_squared(const LLColor4U& a, const LLColor4U& b)
{
LLColor4U vec = a - b;
return (vec.lengthSquared());
@@ -460,13 +377,13 @@ inline F32 distVec_squared(const LLColor4U &a, const LLColor4U &b)
void LLColor4U::setVecScaleClamp(const LLColor4& color)
{
F32 color_scale_factor = 255.f;
- F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]);
+ F32 max_color = llmax(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE]);
if (max_color > 1.f)
{
color_scale_factor /= max_color;
}
- const S32 MAX_COLOR = 255;
- S32 r = ll_round(color.mV[0] * color_scale_factor);
+ constexpr S32 MAX_COLOR = 255;
+ S32 r = ll_round(color.mV[VRED] * color_scale_factor);
if (r > MAX_COLOR)
{
r = MAX_COLOR;
@@ -475,9 +392,9 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
{
r = 0;
}
- mV[0] = r;
+ mV[VRED] = r;
- S32 g = ll_round(color.mV[1] * color_scale_factor);
+ S32 g = ll_round(color.mV[VGREEN] * color_scale_factor);
if (g > MAX_COLOR)
{
g = MAX_COLOR;
@@ -486,9 +403,9 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
{
g = 0;
}
- mV[1] = g;
+ mV[VGREEN] = g;
- S32 b = ll_round(color.mV[2] * color_scale_factor);
+ S32 b = ll_round(color.mV[VBLUE] * color_scale_factor);
if (b > MAX_COLOR)
{
b = MAX_COLOR;
@@ -497,10 +414,10 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
{
b = 0;
}
- mV[2] = b;
+ mV[VBLUE] = b;
// Alpha shouldn't be scaled, just clamped...
- S32 a = ll_round(color.mV[3] * MAX_COLOR);
+ S32 a = ll_round(color.mV[VALPHA] * MAX_COLOR);
if (a > MAX_COLOR)
{
a = MAX_COLOR;
@@ -509,44 +426,42 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)
{
a = 0;
}
- mV[3] = a;
+ mV[VALPHA] = a;
}
void LLColor4U::setVecScaleClamp(const LLColor3& color)
{
F32 color_scale_factor = 255.f;
- F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]);
+ F32 max_color = llmax(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE]);
if (max_color > 1.f)
{
color_scale_factor /= max_color;
}
const S32 MAX_COLOR = 255;
- S32 r = ll_round(color.mV[0] * color_scale_factor);
+ S32 r = ll_round(color.mV[VRED] * color_scale_factor);
if (r > MAX_COLOR)
{
r = MAX_COLOR;
}
- else
- if (r < 0)
+ else if (r < 0)
{
r = 0;
}
- mV[0] = r;
+ mV[VRED] = r;
- S32 g = ll_round(color.mV[1] * color_scale_factor);
+ S32 g = ll_round(color.mV[VGREEN] * color_scale_factor);
if (g > MAX_COLOR)
{
g = MAX_COLOR;
}
- else
- if (g < 0)
+ else if (g < 0)
{
g = 0;
}
- mV[1] = g;
+ mV[VGREEN] = g;
- S32 b = ll_round(color.mV[2] * color_scale_factor);
+ S32 b = ll_round(color.mV[VBLUE] * color_scale_factor);
if (b > MAX_COLOR)
{
b = MAX_COLOR;
@@ -555,31 +470,29 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color)
{
b = 0;
}
- mV[2] = b;
+ mV[VBLUE] = b;
- mV[3] = 255;
+ mV[VALPHA] = 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];
+ return (mV[VALPHA] << 24) | (mV[VBLUE] << 16) | (mV[VGREEN] << 8) | mV[VRED];
}
-inline void LLColor4U::fromRGBA( U32 aVal )
+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;
+ mV[0] = aVal & 0xFF;
aVal >>= 8;
- mV[ 1 ] = aVal & 0xFF;
+ mV[1] = aVal & 0xFF;
aVal >>= 8;
- mV[ 2 ] = aVal & 0xFF;
+ mV[2] = aVal & 0xFF;
aVal >>= 8;
- mV[ 3 ] = aVal & 0xFF;
+ mV[3] = aVal & 0xFF;
}
-
#endif
-