summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rwxr-xr-xindra/llimage/llimage.cpp28
-rwxr-xr-xindra/llimage/llimageworker.cpp16
-rwxr-xr-xindra/llimage/tests/llimageworker_test.cpp1
3 files changed, 37 insertions, 8 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index c8a05e1fae..183620f9bc 100755
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -230,7 +230,7 @@ const U8* LLImageBase::getData() const
{
if(mBadBufferAllocation)
{
- llerrs << "Bad memory allocation for the image buffer!" << llendl ;
+ llwarns << "Bad memory allocation for the image buffer!" << llendl ;
}
return mData;
@@ -240,7 +240,7 @@ U8* LLImageBase::getData()
{
if(mBadBufferAllocation)
{
- llerrs << "Bad memory allocation for the image buffer!" << llendl ;
+ llwarns << "Bad memory allocation for the image buffer!" << llendl ;
}
return mData;
@@ -293,7 +293,7 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components, bool no_c
{
setDataAndSize(data, width, height, components);
}
- else if(allocateDataSize(width, height, components))
+ else if(allocateDataSize(width, height, components) && getData())
{
memcpy(getData(), data, width*height*components);
}
@@ -431,6 +431,11 @@ void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a)
// Reverses the order of the rows in the image
void LLImageRaw::verticalFlip()
{
+ if (!getData())
+ {
+ return;
+ }
+
S32 row_bytes = getWidth() * getComponents();
llassert(row_bytes > 0);
std::vector<U8> line_buffer(row_bytes);
@@ -666,6 +671,11 @@ void LLImageRaw::copyUnscaledAlphaMask( LLImageRaw* src, const LLColor4U& fill)
// Fill the buffer with a constant color
void LLImageRaw::fill( const LLColor4U& color )
{
+ if (!getData())
+ {
+ return;
+ }
+
S32 pixels = getWidth() * getHeight();
if( 4 == getComponents() )
{
@@ -867,6 +877,11 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
{
+ if (!getData())
+ {
+ return FALSE;
+ }
+
llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) );
S32 old_width = getWidth();
@@ -901,7 +916,7 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
copyLineScaled( &temp_buffer[0] + (getComponents() * old_width * row), new_buffer + (getComponents() * new_width * row), old_width, new_width, 1, 1 );
}
}
- else
+ else if (getData())
{
// copy out existing image data
S32 temp_data_size = old_width * old_height * getComponents();
@@ -1564,6 +1579,11 @@ BOOL LLImageFormatted::load(const std::string &filename, int load_size)
BOOL LLImageFormatted::save(const std::string &filename)
{
+ if (!getData())
+ {
+ return FALSE;
+ }
+
resetLastError();
LLAPRFile outfile ;
diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index ad2eb0f69c..148cf4fa55 100755
--- a/indra/llimage/llimageworker.cpp
+++ b/indra/llimage/llimageworker.cpp
@@ -142,8 +142,12 @@ bool LLImageDecodeThread::ImageRequest::processRequest()
mFormattedImage->getHeight(),
mFormattedImage->getComponents());
}
- done = mFormattedImage->decode(mDecodedImageRaw, decode_time_slice); // 1ms
- mDecodedRaw = done;
+
+ if (mDecodedImageRaw->getData())
+ {
+ done = mFormattedImage->decode(mDecodedImageRaw, decode_time_slice); // 1ms
+ mDecodedRaw = done;
+ }
}
if (done && mNeedsAux && !mDecodedAux && mFormattedImage.notNull())
{
@@ -154,8 +158,12 @@ bool LLImageDecodeThread::ImageRequest::processRequest()
mFormattedImage->getHeight(),
1);
}
- done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4); // 1ms
- mDecodedAux = done;
+
+ if (mDecodedImageAux->getData())
+ {
+ done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4); // 1ms
+ mDecodedAux = done;
+ }
}
return done;
diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp
index e255d65b43..f6fb8f54b4 100755
--- a/indra/llimage/tests/llimageworker_test.cpp
+++ b/indra/llimage/tests/llimageworker_test.cpp
@@ -58,6 +58,7 @@ void LLImageBase::sanityCheck() { }
void LLImageBase::deleteData() { }
U8* LLImageBase::allocateData(S32 size) { return NULL; }
U8* LLImageBase::reallocateData(S32 size) { return NULL; }
+U8* LLImageBase::getData() { return NULL; }
LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components) { }
LLImageRaw::~LLImageRaw() { }