summaryrefslogtreecommitdiff
path: root/indra/llimage/llimage.cpp
diff options
context:
space:
mode:
authorEuclid Linden <euclid@lindenlab.com>2022-02-02 00:34:05 +0000
committerMichael Pohoreski <ptolemy@lindenlab.com>2022-02-02 00:34:05 +0000
commite6d44588d00d32e8ded5a69c29cd9ab5d78407df (patch)
tree0ee6880004038bd6af925b9e8bd0b1d4cd4f4cd3 /indra/llimage/llimage.cpp
parent0b850360f5f3e520fa3bd321e2e105c24d1f46f0 (diff)
parentfdc4a81b578f26ce573d6b60760c8235312a6372 (diff)
Merged in revert-16418 (pull request #854)
Revert SL-16418 commits Approved-by: Michael Pohoreski
Diffstat (limited to 'indra/llimage/llimage.cpp')
-rw-r--r--indra/llimage/llimage.cpp96
1 files changed, 35 insertions, 61 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index ba7ee0b465..15b07e5318 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -925,73 +925,47 @@ bool LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height,
void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a)
{
- LL_PROFILE_ZONE_SCOPED;
- S8 components = getComponents();
- llassert( components > 0 && components <= 4 );
-
- // This is fairly bogus, but it'll do for now.
- if (isBufferInvalid())
- {
- LL_WARNS() << "Invalid image buffer" << LL_ENDL;
- return;
- }
+ llassert( getComponents() <= 4 );
+ // This is fairly bogus, but it'll do for now.
+ if (isBufferInvalid())
+ {
+ LL_WARNS() << "Invalid image buffer" << LL_ENDL;
+ return;
+ }
- switch (components)
- {
- case 1:
- {
- U8 *dst = getData();
- S32 count = getWidth() * getHeight();
- llassert(count == getDataSize());
- std::fill_n(dst, count, r);
- break;
- }
- case 2:
- {
- U16 *dst = (U16 *)getData();
- S32 count = getWidth() * getHeight();
- llassert(count == getDataSize() / 2);
-#ifdef LL_LITTLE_ENDIAN
- U16 val = (U16)(r | g << 8);
-#else
- U16 val = (U16)(r << 8 | g);
-#endif
- std::fill_n(dst, count, val);
- break;
- }
- case 3:
- {
- U8 *dst = getData();
- S32 count = getWidth() * getHeight();
- llassert(count == getDataSize() / 3);
- for (S32 i = 0; i < count; i++)
- {
- *dst++ = r;
- *dst++ = g;
- *dst++ = b;
- }
- break;
- }
- case 4:
- {
- U32 *dst = (U32 *)getData();
- S32 count = getWidth() * getHeight();
- llassert(count == getDataSize() / 4);
-#ifdef LL_LITTLE_ENDIAN
- U32 val = (U32)(r | g << 8 | b << 16 | a << 24);
-#else
- U32 val = (U32)(r << 24 | g << 16 | b << 8 | a);
-#endif
- std::fill_n(dst, count, val);
- break;
- }
- }
+ U8 *pos = getData();
+ U32 x, y;
+ for (x = 0; x < getWidth(); x++)
+ {
+ for (y = 0; y < getHeight(); y++)
+ {
+ *pos = r;
+ pos++;
+ if (getComponents() == 1)
+ {
+ continue;
+ }
+ *pos = g;
+ pos++;
+ if (getComponents() == 2)
+ {
+ continue;
+ }
+ *pos = b;
+ pos++;
+ if (getComponents() == 3)
+ {
+ continue;
+ }
+ *pos = a;
+ pos++;
+ }
+ }
}
// Reverses the order of the rows in the image
void LLImageRaw::verticalFlip()
{
- LL_PROFILE_ZONE_SCOPED;
S32 row_bytes = getWidth() * getComponents();
llassert(row_bytes > 0);
std::vector<U8> line_buffer(row_bytes);