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
Родитель b9c3d10afd
Коммит b721789ba1
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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;
}