MAINT-6618 More checks

meow-7.2.2
AndreyL ProductEngine 2016-08-09 19:26:30 +03:00
parent d4b1db277c
commit 5e02d304f0
2 changed files with 40 additions and 4 deletions

View File

@ -1075,6 +1075,11 @@ void LLImageRaw::composite( LLImageRaw* src )
{
LLImageRaw* dst = this; // Just for clarity.
if (!validateSrcAndDst("LLImageRaw::composite", src, dst))
{
return;
}
llassert(3 == src->getComponents());
llassert(3 == dst->getComponents());
@ -1176,6 +1181,11 @@ void LLImageRaw::copyUnscaledAlphaMask( LLImageRaw* src, const LLColor4U& fill)
{
LLImageRaw* dst = this; // Just for clarity.
if (!validateSrcAndDst("LLImageRaw::copyUnscaledAlphaMask", src, dst))
{
return;
}
llassert( 1 == src->getComponents() );
llassert( 4 == dst->getComponents() );
llassert( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) );
@ -1242,14 +1252,13 @@ LLPointer<LLImageRaw> LLImageRaw::duplicate()
// Src and dst can be any size. Src and dst can each have 3 or 4 components.
void LLImageRaw::copy(LLImageRaw* src)
{
if (!src)
LLImageRaw* dst = this; // Just for clarity.
if (!validateSrcAndDst("LLImageRaw::copy", src, dst))
{
LL_WARNS() << "LLImageRaw::copy called with a null src pointer" << LL_ENDL;
return;
}
LLImageRaw* dst = this; // Just for clarity.
if( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) )
{
// No scaling needed
@ -1376,6 +1385,11 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
{
LLImageRaw* dst = this; // Just for clarity.
if (!validateSrcAndDst("LLImageRaw::copyScaled", src, dst))
{
return;
}
llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) );
llassert_always( src->getComponents() == dst->getComponents() );
@ -1709,6 +1723,25 @@ void LLImageRaw::compositeRowScaled4onto3( U8* in, U8* out, S32 in_pixel_len, S3
}
}
bool LLImageRaw::validateSrcAndDst(std::string func, LLImageRaw* src, LLImageRaw* dst)
{
if (!src || !dst || src->isBufferInvalid() || dst->isBufferInvalid())
{
LL_WARNS() << func << ": Source: ";
if (!src) LL_CONT << "Null pointer";
else if (src->isBufferInvalid()) LL_CONT << "Invalid buffer";
else LL_CONT << "OK";
LL_CONT << "; Destination: ";
if (!dst) LL_CONT << "Null pointer";
else if (dst->isBufferInvalid()) LL_CONT << "Invalid buffer";
else LL_CONT << "OK";
LL_CONT << "." << LL_ENDL;
return false;
}
return true;
}
//----------------------------------------------------------------------------

View File

@ -277,6 +277,9 @@ protected:
public:
static S32 sGlobalRawMemory;
static S32 sRawImageCount;
private:
bool validateSrcAndDst(std::string func, LLImageRaw* src, LLImageRaw* dst);
};
// Compressed representation of image.