Bug 844819 - Don't create DrawTargets for invalid cairo surfaces. r=Bas

This commit is contained in:
Matt Woodrow 2013-10-24 16:35:29 +02:00
parent f1e0403e39
commit 7eebb50480
2 changed files with 13 additions and 4 deletions

View File

@ -575,6 +575,10 @@ gfxContext::DrawSurface(gfxASurface *surface, const gfxSize& size)
RefPtr<SourceSurface> 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<SourceSurface> 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.

View File

@ -641,6 +641,10 @@ gfxPlatform::ClearSourceSurfaceForSurface(gfxASurface *aSurface)
RefPtr<SourceSurface>
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;
}