diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 116fd4bbafbc..200b819da2ac 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -575,6 +575,10 @@ gfxContext::DrawSurface(gfxASurface *surface, const gfxSize& size) RefPtr surf = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mDT, surface); + if (!surf) { + return; + } + Rect rect(0, 0, Float(size.width), Float(size.height)); rect.Intersect(Rect(0, 0, Float(surf->GetSize().width), Float(surf->GetSize().height))); @@ -1389,6 +1393,7 @@ gfxContext::SetSource(gfxASurface *surface, const gfxPoint& offset) CurrentState().sourceSurfCairo = surface; CurrentState().sourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mDT, surface); + CurrentState().color = Color(0, 0, 0, 0); } } @@ -1492,6 +1497,10 @@ gfxContext::Mask(gfxASurface *surface, const gfxPoint& offset) RefPtr sourceSurf = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mDT, surface); + if (!sourceSurf) { + return; + } + gfxPoint pt = surface->GetDeviceOffset(); // We clip here to bind to the mask surface bounds, see above. diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 949a59246c75..ba8e1f8385af 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -641,6 +641,10 @@ gfxPlatform::ClearSourceSurfaceForSurface(gfxASurface *aSurface) RefPtr gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurface) { + if (!aSurface->CairoSurface() || aSurface->CairoStatus()) { + return nullptr; + } + void *userData = aSurface->GetData(&kSourceSurface); if (userData) { @@ -737,10 +741,6 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa // alive. This is true if gfxASurface actually -is- an ImageSurface or // if it is a gfxWindowsSurface which supports GetAsImageSurface. if (imgSurface != aSurface && !isWin32ImageSurf) { - // This shouldn't happen for now, it can be easily supported by making - // a copy. For now let's just abort. - NS_RUNTIMEABORT("Attempt to create unsupported SourceSurface from" - "non-image surface."); return nullptr; }