Bug 1095925: Propagate the error up the chain. r=jmuizelaar
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -1475,18 +1475,19 @@ TemporaryRef<DrawTarget>
DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
{
cairo_surface_t* similar = cairo_surface_create_similar(mSurface,
GfxFormatToCairoContent(aFormat),
aSize.width, aSize.height);
if (!cairo_surface_status(similar)) {
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
- target->InitAlreadyReferenced(similar, aSize);
- return target.forget();
+ if (target->InitAlreadyReferenced(similar, aSize)) {
+ return target.forget();
+ }
}
gfxCriticalError() << "Failed to create similar cairo surface! Size: " << aSize << " Status: " << cairo_surface_status(similar);
return nullptr;
}
bool
@@ -1532,18 +1533,21 @@ DrawTargetCairo::CreateShadowDrawTarget(
if (cairo_surface_status(similar)) {
return nullptr;
}
// If we don't have a blur then we can use the RGBA mask and keep all the
// operations in graphics memory.
if (aSigma == 0.0F) {
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
- target->InitAlreadyReferenced(similar, aSize);
- return target.forget();
+ if (target->InitAlreadyReferenced(similar, aSize)) {
+ return target.forget();
+ } else {
+ return nullptr;
+ }
}
cairo_surface_t* blursurf = cairo_image_surface_create(CAIRO_FORMAT_A8,
aSize.width,
aSize.height);
if (cairo_surface_status(blursurf)) {
return nullptr;
@@ -1555,18 +1559,20 @@ DrawTargetCairo::CreateShadowDrawTarget(
cairo_surface_destroy(similar);
return nullptr;
}
cairo_tee_surface_add(tee, similar);
cairo_surface_destroy(similar);
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
- target->InitAlreadyReferenced(tee, aSize);
- return target.forget();
+ if (target->InitAlreadyReferenced(tee, aSize)) {
+ return target.forget();
+ }
+ return nullptr;
}
bool
DrawTargetCairo::Init(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
{
cairo_surface_reference(aSurface);
return InitAlreadyReferenced(aSurface, aSize, aFormat);
}
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -706,17 +706,17 @@ BufferTextureClient::GetAllocator() cons
return mAllocator;
}
bool
BufferTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
{
MOZ_ASSERT(IsValid());
MOZ_ASSERT(mFormat != gfx::SurfaceFormat::YUV, "This textureClient cannot use YCbCr data");
- MOZ_ASSERT(aSize.width * aSize.height);
+ MOZ_ASSERT(aSize.width > 0 && aSize.height > 0);
int bufSize
= ImageDataSerializer::ComputeMinBufferSize(aSize, mFormat);
if (!Allocate(bufSize)) {
return false;
}
if (aFlags & ALLOC_CLEAR_BUFFER) {