From 898768b9d9e8c3e3a334ac6c8b5b5cdbb6f7c1b6 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 29 Aug 2012 17:38:58 +1200 Subject: [PATCH] Bug 539356 - Revert changes made by bug 728983 --- layout/base/FrameLayerBuilder.cpp | 90 +++++++++---------------------- layout/base/FrameLayerBuilder.h | 3 -- 2 files changed, 24 insertions(+), 69 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 0127964c85c2..1e7d75d7f682 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -164,9 +164,9 @@ public: NO_COMPONENT_ALPHA = 0x01, }; - void AddInvalidThebesContent(const nsIntRegion& aRegion) + void SetInvalidThebesContent(const nsIntRegion& aRegion) { - mInvalidThebesContent.Or(mInvalidThebesContent, aRegion); + mInvalidThebesContent = aRegion; } void SetInvalidateAllThebesContent() { @@ -231,8 +231,6 @@ public: mAppUnitsPerDevPixel); } - const FrameLayerBuilder::ContainerParameters& ScaleParameters() { return mParameters; }; - protected: /** * We keep a stack of these to represent the ThebesLayers that are @@ -655,8 +653,6 @@ FrameLayerBuilder::Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager) bool FrameLayerBuilder::DisplayItemDataEntry::HasNonEmptyContainerLayer() { - if (mIsSharingContainerLayer) - return true; for (uint32_t i = 0; i < mData.Length(); ++i) { if (mData[i].mLayer->GetType() == Layer::TYPE_CONTAINER && mData[i].mLayerState != LAYER_ACTIVE_EMPTY) @@ -2283,58 +2279,6 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder, return result; } -static void -ApplyThebesLayerInvalidation(nsDisplayListBuilder* aBuilder, - nsIFrame* aContainerFrame, - nsDisplayItem* aContainerItem, - ContainerState& aState, - nsPoint* aCurrentOffset, - nsDisplayTransform* aTransform) -{ - *aCurrentOffset = aContainerItem ? aContainerItem->ToReferenceFrame() - : aBuilder->ToReferenceFrame(aContainerFrame); - - FrameProperties props = aContainerFrame->Properties(); - RefCountedRegion* invalidThebesContent = static_cast - (props.Get(ThebesLayerInvalidRegionProperty())); - const FrameLayerBuilder::ContainerParameters& scaleParameters = aState.ScaleParameters(); - - nsRegion invalidRegion; - if (invalidThebesContent) { - if (invalidThebesContent->mIsInfinite) { - // The region was marked as infinite to indicate that everything should be - // invalidated. - aState.SetInvalidateAllThebesContent(); - return; - } - - invalidRegion = invalidThebesContent->mRegion; - } else { - // The region doesn't exist, so this is a newly visible frame. Invalidate - // the frame area. - invalidRegion = - aContainerFrame->GetVisualOverflowRectRelativeToSelf() + *aCurrentOffset; - } - - if (aTransform) { - // XXX We're simplifying the transform by only using the bounds of the - // region. This may have performance implications. - invalidRegion = aTransform-> - TransformRectOut(invalidRegion.GetBounds(), - aTransform->GetUnderlyingFrame(), -(*aCurrentOffset)); - } - - aState.AddInvalidThebesContent(invalidRegion. - 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. -} - /* static */ PLDHashOperator FrameLayerBuilder::RestoreDisplayItemData(DisplayItemDataEntry* aEntry, void* aUserArg) { @@ -2412,6 +2356,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, const ContainerParameters& aParameters, const gfx3DMatrix* aTransform) { + FrameProperties props = aContainerFrame->Properties(); uint32_t containerDisplayItemKey = aContainerItem ? aContainerItem->GetPerFrameKey() : 0; NS_ASSERTION(aContainerFrame, "Container display items here should have a frame"); @@ -2510,15 +2455,28 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, } if (aManager == mRetainingManager) { - // If the container frame has a transform and it's contained in the - // container item's sub-tree, we need to transform the invalid region - // before applying it. - nsDisplayTransform* transformItem = - FindTransformForContainerFrame(aContainerFrame, aContainerItem); + nsPoint* offsetAtLastPaint = static_cast + (props.Get(ThebesLayerLastPaintOffsetProperty())); + nsPoint currentOffset = aBuilder->ToReferenceFrame(aContainerFrame); - nsPoint currentOffset; - ApplyThebesLayerInvalidation(aBuilder, aContainerFrame, aContainerItem, state, - ¤tOffset, transformItem); + 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); nsAutoTArray mergedFrames; diff --git a/layout/base/FrameLayerBuilder.h b/layout/base/FrameLayerBuilder.h index 53cdda1ca1ca..aa927a895100 100644 --- a/layout/base/FrameLayerBuilder.h +++ b/layout/base/FrameLayerBuilder.h @@ -493,11 +493,9 @@ protected: public: DisplayItemDataEntry(const nsIFrame *key) : nsPtrHashKey(key) - , mIsSharingContainerLayer(false) {} DisplayItemDataEntry(DisplayItemDataEntry &toCopy) : nsPtrHashKey(toCopy.mKey) - , mIsSharingContainerLayer(toCopy.mIsSharingContainerLayer) { // This isn't actually a copy-constructor; notice that it steals toCopy's // array and invalid region. Be careful. @@ -511,7 +509,6 @@ protected: nsAutoTArray mData; nsRefPtr mInvalidRegion; uint32_t mContainerLayerGeneration; - bool mIsSharingContainerLayer; enum { ALLOW_MEMMOVE = false }; };