Bug 949360 - Check for Image AllocateBuffer() failures. r=nical

Relanded on a CLOSED TREE
This commit is contained in:
Chris Peterson 2013-12-10 22:58:51 -08:00
parent 1aec92c6ff
commit 223f9eb3e9
2 changed files with 22 additions and 14 deletions

View File

@ -490,14 +490,17 @@ PlanarYCbCrImage::CopyData(const Data& aData)
mData = aData;
// update buffer size
mBufferSize = mData.mCbCrStride * mData.mCbCrSize.height * 2 +
size_t size = mData.mCbCrStride * mData.mCbCrSize.height * 2 +
mData.mYStride * mData.mYSize.height;
// get new buffer
mBuffer = AllocateBuffer(mBufferSize);
mBuffer = AllocateBuffer(size);
if (!mBuffer)
return;
// update buffer size
mBufferSize = size;
mData.mYChannel = mBuffer;
mData.mCbChannel = mData.mYChannel + mData.mYStride * mData.mYSize.height;
mData.mCrChannel = mData.mCbChannel + mData.mCbCrStride * mData.mCbCrSize.height;
@ -536,11 +539,12 @@ PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
uint8_t*
PlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
{
// get new buffer
mBuffer = AllocateBuffer(aSize);
if (mBuffer) {
// update buffer size
mBufferSize = aSize;
// get new buffer
mBuffer = AllocateBuffer(mBufferSize);
}
return mBuffer;
}

View File

@ -126,14 +126,16 @@ SharedPlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
{
NS_ABORT_IF_FALSE(!mTextureClient->IsAllocated(), "This image already has allocated data");
size_t size = YCbCrImageDataSerializer::ComputeMinBufferSize(aSize);
// get new buffer _without_ setting mBuffer.
if (!mTextureClient->Allocate(size)) {
return nullptr;
}
// update buffer size
mBufferSize = size;
// get new buffer _without_ setting mBuffer.
bool status = mTextureClient->Allocate(mBufferSize);
MOZ_ASSERT(status);
YCbCrImageDataSerializer serializer(mTextureClient->GetBuffer());
return serializer.GetData();
}
@ -248,17 +250,19 @@ DeprecatedSharedPlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
{
NS_ABORT_IF_FALSE(!mAllocated, "This image already has allocated data");
size_t size = YCbCrImageDataSerializer::ComputeMinBufferSize(aSize);
// get new buffer _without_ setting mBuffer.
if (!AllocateBuffer(size)) {
return nullptr;
}
// update buffer size
mBufferSize = size;
// get new buffer _without_ setting mBuffer.
AllocateBuffer(mBufferSize);
YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
return serializer.GetData();
}
void
DeprecatedSharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
{