From f029ed5c7d48510a691041fa24bc2365271d29a8 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 18 Jul 2014 18:48:23 +1200 Subject: [PATCH] Bug 1023677 - Don't flatten active transform layers. r=roc --- layout/base/FrameLayerBuilder.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 75e782ef87e..f6bca535c35 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -530,7 +530,7 @@ public: * @param aTextContentFlags if any child layer has CONTENT_COMPONENT_ALPHA, * set *aTextContentFlags to CONTENT_COMPONENT_ALPHA */ - void Finish(uint32_t *aTextContentFlags, LayerManagerData* aData); + void Finish(uint32_t *aTextContentFlags, LayerManagerData* aData, bool& aHasComponentAlphaChildren); nsRect GetChildrenBounds() { return mBounds; } @@ -3065,7 +3065,7 @@ ContainerState::CollectOldLayers() } void -ContainerState::Finish(uint32_t* aTextContentFlags, LayerManagerData* aData) +ContainerState::Finish(uint32_t* aTextContentFlags, LayerManagerData* aData, bool& aHasComponentAlphaChildren) { while (!mThebesLayerDataStack.IsEmpty()) { PopThebesLayerData(); @@ -3084,6 +3084,16 @@ ContainerState::Finish(uint32_t* aTextContentFlags, LayerManagerData* aData) textContentFlags |= layer->GetContentFlags() & (Layer::CONTENT_COMPONENT_ALPHA | Layer::CONTENT_COMPONENT_ALPHA_DESCENDANT); + + // Notify the parent of component alpha children unless it's coming from + // within a transformed child since we don't want flattening of component + // alpha layers to happen across transforms. Re-rendering the text during + // transform animations looks worse than losing subpixel-AA. + if ((layer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) && + (layer->GetType() != Layer::TYPE_CONTAINER || + layer->GetBaseTransform().IsIdentity())) { + aHasComponentAlphaChildren = true; + } } if (!layer->GetParent()) { @@ -3423,12 +3433,13 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, // Set CONTENT_COMPONENT_ALPHA if any of our children have it. // This is suboptimal ... a child could have text that's over transparent // pixels in its own layer, but over opaque parts of previous siblings. - state.Finish(&flags, data); + bool hasComponentAlphaChildren = false; + state.Finish(&flags, data, hasComponentAlphaChildren); bounds = state.GetChildrenBounds(); pixBounds = state.ScaleToOutsidePixels(bounds, false); appUnitsPerDevPixel = state.GetAppUnitsPerDevPixel(); - if ((flags & Layer::CONTENT_COMPONENT_ALPHA) && + if (hasComponentAlphaChildren && mRetainingManager && !mRetainingManager->AreComponentAlphaLayersEnabled() && containerLayer->HasMultipleChildren() &&