summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rwxr-xr-xindra/llimage/llimage.cpp30
-rwxr-xr-xindra/llimage/llimagepng.cpp7
-rwxr-xr-xindra/llimage/llimageworker.cpp16
3 files changed, 44 insertions, 9 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index c8a05e1fae..55609deb2b 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();
@@ -1478,7 +1493,7 @@ void LLImageFormatted::sanityCheck()
BOOL LLImageFormatted::copyData(U8 *data, S32 size)
{
- if ( data && ((data != getData()) || (size != getDataSize())) )
+ if ( data && getData() && ((data != getData()) || (size != getDataSize())) )
{
deleteData();
allocateData(size);
@@ -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/llimagepng.cpp b/indra/llimage/llimagepng.cpp
index 294f68b122..525aa8d78c 100755
--- a/indra/llimage/llimagepng.cpp
+++ b/indra/llimage/llimagepng.cpp
@@ -94,6 +94,13 @@ BOOL LLImagePNG::decode(LLImageRaw* raw_image, F32 decode_time)
return FALSE;
}
+ // Check to make sure that this instance has been initialized with data
+ if (!raw_image->getData())
+ {
+ setLastError("LLImagePNG trying to decode an image into unallocated LLImageRaw!");
+ return FALSE;
+ }
+
// Decode the PNG data into the raw image
LLPngWrapper pngWrapper;
if (!pngWrapper.isValidPng(getData()))
diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index ad2eb0f69c..e425823c59 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;