From d41fe1225c7dd63429020bf28e5b910f204dd952 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Sat, 30 Jun 2012 15:06:10 +1200 Subject: [PATCH] Bug 539356 - Revert changes made by bug 728983 --- layout/base/FrameLayerBuilder.cpp | 102 ++++++++---------------------- layout/base/FrameLayerBuilder.h | 5 +- 2 files changed, 28 insertions(+), 79 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 2aff2fbcefe..7e29afbf203 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -152,9 +152,9 @@ public: CollectOldLayers(); } - void AddInvalidThebesContent(const nsIntRegion& aRegion) + void SetInvalidThebesContent(const nsIntRegion& aRegion) { - mInvalidThebesContent.Or(mInvalidThebesContent, aRegion); + mInvalidThebesContent = aRegion; } void SetInvalidateAllThebesContent() { @@ -204,8 +204,6 @@ public: mAppUnitsPerDevPixel); } - const FrameLayerBuilder::ContainerParameters& ScaleParameters() { return mParameters; }; - protected: /** * We keep a stack of these to represent the ThebesLayers that are @@ -596,8 +594,6 @@ FrameLayerBuilder::Init(nsDisplayListBuilder* aBuilder) bool FrameLayerBuilder::DisplayItemDataEntry::HasNonEmptyContainerLayer() { - if (mIsSharingContainerLayer) - return true; for (PRUint32 i = 0; i < mData.Length(); ++i) { if (mData[i].mLayer->GetType() == Layer::TYPE_CONTAINER && mData[i].mLayerState != LAYER_ACTIVE_EMPTY) @@ -733,8 +729,7 @@ FrameLayerBuilder::WillEndTransaction(LayerManager* aManager) * region property. Otherwise set it to the frame's region property. */ static void -SetHasContainerLayer(nsIFrame* aFrame, nsPoint aOffsetToRoot, - RefCountedRegion** aThebesLayerInvalidRegion) +SetHasContainerLayer(nsIFrame* aFrame, nsPoint aOffsetToRoot) { aFrame->AddStateBits(NS_FRAME_HAS_CONTAINER_LAYER); for (nsIFrame* f = aFrame; @@ -751,24 +746,6 @@ SetHasContainerLayer(nsIFrame* aFrame, nsPoint aOffsetToRoot, } else { props.Set(ThebesLayerLastPaintOffsetProperty(), new nsPoint(aOffsetToRoot)); } - - // Reset or create the invalid region now so we can start collecting - // new dirty areas. - if (*aThebesLayerInvalidRegion) { - (*aThebesLayerInvalidRegion)->AddRef(); - props.Set(ThebesLayerInvalidRegionProperty(), *aThebesLayerInvalidRegion); - } else { - RefCountedRegion* invalidRegion = static_cast - (props.Get(ThebesLayerInvalidRegionProperty())); - if (invalidRegion) { - invalidRegion->mRegion.SetEmpty(); - } else { - invalidRegion = new RefCountedRegion(); - invalidRegion->AddRef(); - props.Set(ThebesLayerInvalidRegionProperty(), invalidRegion); - } - *aThebesLayerInvalidRegion = invalidRegion; - } } static void @@ -2091,36 +2068,6 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder, return result; } -static void -ApplyThebesLayerInvalidation(nsDisplayListBuilder* aBuilder, - nsIFrame* aContainerFrame, - nsDisplayItem* aContainerItem, - ContainerState& aState, - nsPoint* aCurrentOffset) -{ - *aCurrentOffset = aContainerItem ? aContainerItem->ToReferenceFrame() - : aBuilder->ToReferenceFrame(aContainerFrame); - - FrameProperties props = aContainerFrame->Properties(); - RefCountedRegion* invalidThebesContent = static_cast - (props.Get(ThebesLayerInvalidRegionProperty())); - if (invalidThebesContent) { - const FrameLayerBuilder::ContainerParameters& scaleParameters = aState.ScaleParameters(); - aState.AddInvalidThebesContent(invalidThebesContent->mRegion. - ScaleToOutsidePixels(scaleParameters.mXScale, scaleParameters.mYScale, - aState.GetAppUnitsPerDevPixel())); - // We have to preserve the current contents of invalidThebesContent - // because there might be multiple container layers for the same - // frame and we need to invalidate the ThebesLayer children of all - // of them. Also, multiple calls to ApplyThebesLayerInvalidation for the - // same layer can share the same region. - } else { - // The region was deleted to indicate that everything should be - // invalidated. - aState.SetInvalidateAllThebesContent(); - } -} - already_AddRefed FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, LayerManager* aManager, @@ -2130,6 +2077,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, const ContainerParameters& aParameters, const gfx3DMatrix* aTransform) { + FrameProperties props = aContainerFrame->Properties(); PRUint32 containerDisplayItemKey = aContainerItem ? aContainerItem->GetPerFrameKey() : 0; NS_ASSERTION(aContainerFrame, "Container display items here should have a frame"); @@ -2185,28 +2133,30 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, entry->mData.AppendElement( DisplayItemData(containerLayer, containerDisplayItemKey, LAYER_ACTIVE)); } - nsPoint currentOffset; - ApplyThebesLayerInvalidation(aBuilder, aContainerFrame, aContainerItem, state, - ¤tOffset); - RefCountedRegion* thebesLayerInvalidRegion = nsnull; - SetHasContainerLayer(aContainerFrame, currentOffset, &thebesLayerInvalidRegion); - nsAutoTArray mergedFrames; - if (aContainerItem) { - aContainerItem->GetMergedFrames(&mergedFrames); - } - for (PRUint32 i = 0; i < mergedFrames.Length(); ++i) { - nsIFrame* mergedFrame = mergedFrames[i]; - DisplayItemDataEntry* entry = mNewDisplayItemData.PutEntry(mergedFrame); - if (entry) { - // Ensure that UpdateDisplayItemDataForFrame recognizes that we - // still have a container layer associated with this frame. - entry->mIsSharingContainerLayer = true; - } - ApplyThebesLayerInvalidation(aBuilder, mergedFrame, nsnull, state, - ¤tOffset); - SetHasContainerLayer(mergedFrame, currentOffset, &thebesLayerInvalidRegion); + nsPoint* offsetAtLastPaint = static_cast + (props.Get(ThebesLayerLastPaintOffsetProperty())); + nsPoint currentOffset = aBuilder->ToReferenceFrame(aContainerFrame); + + nsRegion* invalidThebesContent(static_cast + (props.Get(ThebesLayerInvalidRegionProperty()))); + if (invalidThebesContent) { + nsPoint offset = offsetAtLastPaint ? *offsetAtLastPaint : currentOffset; + invalidThebesContent->MoveBy(offset); + state.SetInvalidThebesContent(invalidThebesContent-> + ScaleToOutsidePixels(scaleParameters.mXScale, scaleParameters.mYScale, + state.GetAppUnitsPerDevPixel())); + // We have to preserve the current contents of invalidThebesContent + // because there might be multiple container layers for the same + // frame and we need to invalidate the ThebesLayer children of all + // of them. + invalidThebesContent->MoveBy(-offset); + } else { + // The region was deleted to indicate that everything should be + // invalidated. + state.SetInvalidateAllThebesContent(); } + SetHasContainerLayer(aContainerFrame, currentOffset); } Clip clip; diff --git a/layout/base/FrameLayerBuilder.h b/layout/base/FrameLayerBuilder.h index 58c9d06752c..b9443b64e04 100644 --- a/layout/base/FrameLayerBuilder.h +++ b/layout/base/FrameLayerBuilder.h @@ -476,9 +476,9 @@ protected: */ class DisplayItemDataEntry : public nsPtrHashKey { public: - DisplayItemDataEntry(const nsIFrame *key) : nsPtrHashKey(key), mIsSharingContainerLayer(false) {} + DisplayItemDataEntry(const nsIFrame *key) : nsPtrHashKey(key) {} DisplayItemDataEntry(DisplayItemDataEntry &toCopy) : - nsPtrHashKey(toCopy.mKey), mIsSharingContainerLayer(toCopy.mIsSharingContainerLayer) + nsPtrHashKey(toCopy.mKey) { // This isn't actually a copy-constructor; notice that it steals toCopy's // array. Be careful. @@ -488,7 +488,6 @@ protected: bool HasNonEmptyContainerLayer(); nsAutoTArray mData; - bool mIsSharingContainerLayer; enum { ALLOW_MEMMOVE = false }; };