From 025867f5d97facb41fcea815c4fb1162cd62ecef Mon Sep 17 00:00:00 2001 From: Bas Schouten Date: Thu, 5 Jan 2012 08:17:52 +0100 Subject: [PATCH] Bug 711063 - Part 10: Adjust BasicLayers code for Azure-Thebes wrapper. r=roc --- gfx/layers/basic/BasicLayers.cpp | 51 +++++++++++++++++++------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/gfx/layers/basic/BasicLayers.cpp b/gfx/layers/basic/BasicLayers.cpp index 4c76bcba342a..e1a84903307b 100644 --- a/gfx/layers/basic/BasicLayers.cpp +++ b/gfx/layers/basic/BasicLayers.cpp @@ -609,6 +609,11 @@ IntersectWithClip(const nsIntRegion& aRegion, gfxContext* aContext) static void SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget) { + if (!aTarget->IsCairo()) { + // Azure targets don't contain antialiasing flags at this point. + return; + } + nsRefPtr surface = aTarget->CurrentSurface(); if (surface->GetContentType() != gfxASurface::CONTENT_COLOR_ALPHA) { // Destination doesn't have alpha channel; no need to set any special flags @@ -933,14 +938,16 @@ BasicImageLayer::PaintContext(gfxPattern* aPattern, // outside the bounds of the video image. gfxPattern::GraphicsExtend extend = gfxPattern::EXTEND_PAD; - // PAD is slow with X11 and Quartz surfaces, so prefer speed over correctness - // and use NONE. - nsRefPtr target = aContext->CurrentSurface(); - gfxASurface::gfxSurfaceType type = target->GetType(); - if (type == gfxASurface::SurfaceTypeXlib || - type == gfxASurface::SurfaceTypeXcb || - type == gfxASurface::SurfaceTypeQuartz) { - extend = gfxPattern::EXTEND_NONE; + if (aContext->IsCairo()) { + // PAD is slow with X11 and Quartz surfaces, so prefer speed over correctness + // and use NONE. + nsRefPtr target = aContext->CurrentSurface(); + gfxASurface::gfxSurfaceType type = target->GetType(); + if (type == gfxASurface::SurfaceTypeXlib || + type == gfxASurface::SurfaceTypeXcb || + type == gfxASurface::SurfaceTypeQuartz) { + extend = gfxPattern::EXTEND_NONE; + } } if (!aTileSourceRect) { @@ -1337,7 +1344,8 @@ already_AddRefed BasicLayerManager::PushGroupWithCachedSurface(gfxContext *aTarget, gfxASurface::gfxContentType aContent) { - if (mCachedSurfaceInUse) { + if (mCachedSurfaceInUse || !aTarget->IsCairo()) { + // We can't cache Azure DrawTargets at this point. aTarget->PushGroup(aContent); nsRefPtr result = aTarget; return result.forget(); @@ -1363,7 +1371,7 @@ BasicLayerManager::PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxCon if (!aTarget) return; nsRefPtr current = aPushed->CurrentSurface(); - if (mCachedSurface.IsSurface(current)) { + if (aTarget->IsCairo() && mCachedSurface.IsSurface(current)) { gfxContextMatrixAutoSaveRestore saveMatrix(aTarget); aTarget->IdentityMatrix(); aTarget->SetSource(current); @@ -1852,17 +1860,20 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget, bool pushedTargetOpaqueRect = false; nsRefPtr currentSurface = aTarget->CurrentSurface(); - const gfxRect& targetOpaqueRect = currentSurface->GetOpaqueRect(); - - // Try to annotate currentSurface with a region of pixels that have been - // (or will be) painted opaque, if no such region is currently set. const nsIntRect& bounds = visibleRegion.GetBounds(); - if (targetOpaqueRect.IsEmpty() && visibleRegion.GetNumRects() == 1 && - (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) && - !transform.HasNonAxisAlignedTransform()) { - currentSurface->SetOpaqueRect( - aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height))); - pushedTargetOpaqueRect = true; + + if (aTarget->IsCairo()) { + const gfxRect& targetOpaqueRect = currentSurface->GetOpaqueRect(); + + // Try to annotate currentSurface with a region of pixels that have been + // (or will be) painted opaque, if no such region is currently set. + if (targetOpaqueRect.IsEmpty() && visibleRegion.GetNumRects() == 1 && + (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) && + !transform.HasNonAxisAlignedTransform()) { + currentSurface->SetOpaqueRect( + aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height))); + pushedTargetOpaqueRect = true; + } } nsRefPtr groupTarget;