summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
authorEuclid Linden <euclid@lindenlab.com>2022-01-28 16:46:58 +0000
committerEuclid Linden <euclid@lindenlab.com>2022-01-28 16:46:58 +0000
commit40fe5277e1390c975d9a3184ff8fc46d69dfb450 (patch)
tree5f0432b7f1c3fe6b0b373fdf904bda4f5e58cf5e /indra/llimage
parentaf830e5fc5840194be95140f644a27011b9b7e06 (diff)
parentd28a271fa819c076e2cedb87d9f305468e436b25 (diff)
Merged in euclid-16418 (pull request #846)
SL-16418 move media texture updates to background thread Approved-by: Dave Parks
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp96
1 files changed, 61 insertions, 35 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 15b07e5318..ba7ee0b465 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -925,47 +925,73 @@ bool LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height,
void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a)
{
- llassert( getComponents() <= 4 );
- // This is fairly bogus, but it'll do for now.
- if (isBufferInvalid())
- {
- LL_WARNS() << "Invalid image buffer" << LL_ENDL;
- return;
- }
+ LL_PROFILE_ZONE_SCOPED;
+ S8 components = getComponents();
+ llassert( components > 0 && components <= 4 );
- 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++;
- }
- }
+ // 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;
+ }
+ }
}
// 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);