Bug 809273 - Make mUseIntermediateSurface and mSupportsComponentAlpha on BasicShadowableContainerLayers match the compositor. r=roc

This commit is contained in:
Matt Woodrow 2013-04-22 14:40:52 +12:00
parent f3afacc43a
commit ae1f55d9ad
3 changed files with 43 additions and 0 deletions

View File

@ -87,6 +87,15 @@ public:
BasicShadowableLayer::Disconnect(); BasicShadowableLayer::Disconnect();
} }
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) MOZ_OVERRIDE
{
if (HasShadow()) {
DefaultComputeEffectiveTransforms(aTransformToSurface);
} else {
BasicContainerLayer::ComputeEffectiveTransforms(aTransformToSurface);
}
}
private: private:
BasicShadowLayerManager* ShadowManager() BasicShadowLayerManager* ShadowManager()
{ {

View File

@ -234,6 +234,8 @@ public:
void ForceIntermediateSurface() { mUseIntermediateSurface = true; } void ForceIntermediateSurface() { mUseIntermediateSurface = true; }
void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; }
protected: protected:
BasicLayerManager* BasicManager() BasicLayerManager* BasicManager()
{ {

View File

@ -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 void
BasicLayerManager::PaintLayer(gfxContext* aTarget, BasicLayerManager::PaintLayer(gfxContext* aTarget,
Layer* aLayer, Layer* aLayer,
@ -907,6 +917,28 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
container->UseIntermediateSurface(), container->UseIntermediateSurface(),
"ContainerLayer with mask layer should force 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; gfxContextAutoSaveRestore contextSR;
gfxMatrix transform; gfxMatrix transform;
// Will return an identity matrix for 3d transforms, and is handled separately below. // Will return an identity matrix for 3d transforms, and is handled separately below.