From ae1f55d9ad84e6e86b13cbac8433f4cf838e59af Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 22 Apr 2013 14:40:52 +1200 Subject: [PATCH] Bug 809273 - Make mUseIntermediateSurface and mSupportsComponentAlpha on BasicShadowableContainerLayers match the compositor. r=roc --- gfx/layers/basic/BasicContainerLayer.cpp | 9 +++++++ gfx/layers/basic/BasicContainerLayer.h | 2 ++ gfx/layers/basic/BasicLayerManager.cpp | 32 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/gfx/layers/basic/BasicContainerLayer.cpp b/gfx/layers/basic/BasicContainerLayer.cpp index ce4a187e6c6..ef609149b4e 100644 --- a/gfx/layers/basic/BasicContainerLayer.cpp +++ b/gfx/layers/basic/BasicContainerLayer.cpp @@ -87,6 +87,15 @@ public: BasicShadowableLayer::Disconnect(); } + virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) MOZ_OVERRIDE + { + if (HasShadow()) { + DefaultComputeEffectiveTransforms(aTransformToSurface); + } else { + BasicContainerLayer::ComputeEffectiveTransforms(aTransformToSurface); + } + } + private: BasicShadowLayerManager* ShadowManager() { diff --git a/gfx/layers/basic/BasicContainerLayer.h b/gfx/layers/basic/BasicContainerLayer.h index e7e9a30e32d..de52a5846ab 100644 --- a/gfx/layers/basic/BasicContainerLayer.h +++ b/gfx/layers/basic/BasicContainerLayer.h @@ -234,6 +234,8 @@ public: void ForceIntermediateSurface() { mUseIntermediateSurface = true; } + void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; } + protected: BasicLayerManager* BasicManager() { diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 23f38111f3a..c4ada48eb5a 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -873,6 +873,16 @@ BasicLayerManager::FlushGroup(PaintLayerContext& aPaintContext, bool aNeedsClipT } } +static bool +HasOpaqueAncestorLayer(Layer* aLayer) +{ + for (Layer* l = aLayer->GetParent(); l; l = l->GetParent()) { + if (l->GetContentFlags() & Layer::CONTENT_OPAQUE) + return true; + } + return false; +} + void BasicLayerManager::PaintLayer(gfxContext* aTarget, Layer* aLayer, @@ -907,6 +917,28 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget, container->UseIntermediateSurface(), "ContainerLayer with mask layer should force UseIntermediateSurface"); + // If we're a shadowable ContainerLayer, then setup mSupportsComponentAlphaChildren + // in the same way that ContainerLayerComposite will do. Otherwise leave it set to + // true. + ShadowableLayer* shadow = aLayer->AsShadowableLayer(); + if (aLayer->GetFirstChild() && shadow && shadow->HasShadow()) { + if (needsGroup) { + if (container->GetEffectiveVisibleRegion().GetNumRects() != 1 || + !(container->GetContentFlags() & Layer::CONTENT_OPAQUE)) + { + const gfx3DMatrix& transform3D = container->GetEffectiveTransform(); + gfxMatrix transform; + if (HasOpaqueAncestorLayer(container) && + transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) { + container->SetSupportsComponentAlphaChildren(gfxPlatform::GetPlatform()->UsesSubpixelAATextRendering()); + } + } + } else { + container->SetSupportsComponentAlphaChildren((container->GetContentFlags() & Layer::CONTENT_OPAQUE) || + (container->GetParent() && container->GetParent()->SupportsComponentAlphaChildren())); + } + } + gfxContextAutoSaveRestore contextSR; gfxMatrix transform; // Will return an identity matrix for 3d transforms, and is handled separately below.