Bug 943392 - Let MemoryTextureClient use a fallible allocation. r=BenWa

This commit is contained in:
Nicolas Silva 2013-12-06 16:30:50 +01:00
parent 267221ccf0
commit acd8439101
2 changed files with 11 additions and 3 deletions

View File

@ -213,7 +213,12 @@ bool
MemoryTextureClient::Allocate(uint32_t aSize)
{
MOZ_ASSERT(!mBuffer);
mBuffer = new uint8_t[aSize];
static const fallible_t fallible = fallible_t();
mBuffer = new(fallible) uint8_t[aSize];
if (!mBuffer) {
NS_WARNING("Failed to allocate buffer");
return false;
}
GfxMemoryImageReporter::DidAlloc(mBuffer);
mBufSize = aSize;
return true;

View File

@ -84,8 +84,11 @@ CreateSharedRGBImage(ImageContainer *aImageContainer,
return rgbImageDep.forget();
}
nsRefPtr<SharedRGBImage> rgbImage = static_cast<SharedRGBImage*>(image.get());
rgbImage->Allocate(gfx::ToIntSize(aSize),
gfx::ImageFormatToSurfaceFormat(aImageFormat));
if (!rgbImage->Allocate(gfx::ToIntSize(aSize),
gfx::ImageFormatToSurfaceFormat(aImageFormat))) {
NS_WARNING("Failed to allocate a shared image");
return nullptr;
}
return image.forget();
}