summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2016-12-08 14:27:40 -0500
committerNat Goodspeed <nat@lindenlab.com>2016-12-08 14:27:40 -0500
commitb6dc755786fb06ab109eb36f402a25edaf24ce14 (patch)
tree04f465dd42a555f15bf2729ad4a2fcea181db1c9 /indra/llimage
parent5bb456d80cfbcdfe87526510f3b8297d315afdd8 (diff)
parenta65b586b184d9837e0586b4df0d2e758ccce63f6 (diff)
Automated merge with ssh://bitbucket.org/lindenlab/viewer-skip-llcorehttp-test
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp39
-rw-r--r--indra/llimage/llimage.h2
2 files changed, 25 insertions, 16 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index f71607096c..a07ea14621 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -705,18 +705,21 @@ void LLImageBase::deleteData()
// virtual
U8* LLImageBase::allocateData(S32 size)
{
+ //make this function thread-safe.
+ static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16; //256 MB
+ mBadBufferAllocation = false;
+
if (size < 0)
{
size = mWidth * mHeight * mComponents;
if (size <= 0)
{
- LL_ERRS() << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,(S32)mComponents) << LL_ENDL;
+ LL_WARNS() << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,(S32)mComponents) << LL_ENDL;
+ mBadBufferAllocation = true;
}
- }
-
- //make this function thread-safe.
- static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16 ; //256 MB
- if (size < 1 || size > MAX_BUFFER_SIZE)
+ }
+
+ if (!mBadBufferAllocation && (size < 1 || size > MAX_BUFFER_SIZE))
{
LL_INFOS() << "width: " << mWidth << " height: " << mHeight << " components: " << mComponents << LL_ENDL ;
if(mAllowOverSize)
@@ -725,25 +728,31 @@ U8* LLImageBase::allocateData(S32 size)
}
else
{
- LL_ERRS() << "LLImageBase::allocateData: bad size: " << size << LL_ENDL;
+ LL_WARNS() << "LLImageBase::allocateData: bad size: " << size << LL_ENDL;
+ mBadBufferAllocation = true;
}
}
- if (!mData || size != mDataSize)
+
+ if (!mBadBufferAllocation && (!mData || size != mDataSize))
{
deleteData(); // virtual
- mBadBufferAllocation = false ;
mData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
if (!mData)
{
LL_WARNS() << "Failed to allocate image data size [" << size << "]" << LL_ENDL;
- size = 0 ;
- mWidth = mHeight = 0 ;
- mBadBufferAllocation = true ;
+ mBadBufferAllocation = true;
}
- mDataSize = size;
- claimMem(mDataSize);
}
+ if (mBadBufferAllocation)
+ {
+ size = 0;
+ mWidth = mHeight = 0;
+ mData = NULL;
+ }
+ mDataSize = size;
+ claimMem(mDataSize);
+
return mData;
}
@@ -791,7 +800,7 @@ U8* LLImageBase::getData()
return mData;
}
-bool LLImageBase::isBufferInvalid()
+bool LLImageBase::isBufferInvalid() const
{
return mBadBufferAllocation || mData == NULL ;
}
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 9cc7431a9c..d0bd4a2aef 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -141,7 +141,7 @@ public:
const U8 *getData() const ;
U8 *getData() ;
- bool isBufferInvalid() ;
+ bool isBufferInvalid() const;
void setSize(S32 width, S32 height, S32 ncomponents);
U8* allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 size = -1); // setSize() + allocateData()