Bug 1205087 - Cache AnimatedGeometryRoot on nsDisplayItem. r=roc

--HG--
extra : rebase_source : 75bf6cd82232dad91bfd35d2ef0f3bc5fcd3b26b
This commit is contained in:
Matt Woodrow 2015-09-17 21:05:20 -04:00
parent ad13620acc
commit 031080c187
4 changed files with 20 additions and 12 deletions

View File

@ -1029,7 +1029,7 @@ public:
MOZ_ASSERT_IF(isAtRoot, mContainerReferenceFrame == mBuilder->RootReferenceFrame());
mContainerAnimatedGeometryRoot = isAtRoot
? mContainerReferenceFrame
: nsLayoutUtils::GetAnimatedGeometryRootFor(aContainerItem, aBuilder);
: aContainerItem->AnimatedGeometryRoot();
MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDoc(mBuilder->RootReferenceFrame(),
mContainerAnimatedGeometryRoot));
NS_ASSERTION(!aContainerItem || !aContainerItem->ShouldFixToViewport(mBuilder),
@ -3636,8 +3636,7 @@ ContainerState::ChooseAnimatedGeometryRoot(const nsDisplayList& aList,
// Try using the actual active scrolled root of the backmost item, as that
// should result in the least invalidation when scrolling.
*aAnimatedGeometryRoot =
nsLayoutUtils::GetAnimatedGeometryRootFor(item, mBuilder);
*aAnimatedGeometryRoot = item->AnimatedGeometryRoot();
return true;
}
return false;
@ -3813,8 +3812,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
bool forceInactive;
const nsIFrame* animatedGeometryRoot;
const nsIFrame* animatedGeometryRootForScrollMetadata = nullptr;
const nsIFrame* realAnimatedGeometryRootOfItem =
nsLayoutUtils::GetAnimatedGeometryRootFor(item, mBuilder);
const nsIFrame* realAnimatedGeometryRootOfItem = item->AnimatedGeometryRoot();
if (mFlattenToSingleLayer) {
forceInactive = true;
animatedGeometryRoot = lastAnimatedGeometryRoot;

View File

@ -1984,11 +1984,15 @@ void nsDisplayList::Sort(nsDisplayListBuilder* aBuilder,
nsDisplayItem::nsDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
: mFrame(aFrame)
, mClip(aBuilder->ClipState().GetCurrentCombinedClip(aBuilder))
, mAnimatedGeometryRoot(nullptr)
#ifdef MOZ_DUMP_PAINTING
, mPainted(false)
#endif
{
mReferenceFrame = aBuilder->FindReferenceFrameFor(aFrame, &mToReferenceFrame);
// This can return the wrong result if the item override ShouldFixToViewport(),
// the item needs to set it again in its constructor.
mAnimatedGeometryRoot = nsLayoutUtils::GetAnimatedGeometryRootFor(this, aBuilder);
NS_ASSERTION(aBuilder->GetDirtyRect().width >= 0 ||
!aBuilder->IsForPainting(), "dirty rect not set");
// The dirty rect is for mCurrentFrame, so we have to use
@ -2128,6 +2132,9 @@ nsDisplayBackgroundImage::nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilde
MOZ_COUNT_CTOR(nsDisplayBackgroundImage);
mBounds = GetBoundsInternal(aBuilder);
if (ShouldFixToViewport(aBuilder)) {
mAnimatedGeometryRoot = nsLayoutUtils::GetAnimatedGeometryRootFor(this, aBuilder);
}
}
nsDisplayBackgroundImage::~nsDisplayBackgroundImage()
@ -3713,8 +3720,7 @@ RequiredLayerStateForChildren(nsDisplayListBuilder* aBuilder,
LayerState result = LAYER_INACTIVE;
for (nsDisplayItem* i = aList.GetBottom(); i; i = i->GetAbove()) {
if (result == LAYER_INACTIVE &&
nsLayoutUtils::GetAnimatedGeometryRootFor(i, aBuilder) !=
aExpectedAnimatedGeometryRootForChildren) {
i->AnimatedGeometryRoot() != aExpectedAnimatedGeometryRootForChildren) {
result = LAYER_ACTIVE;
}
@ -3971,8 +3977,7 @@ nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder,
if (NeedsActiveLayer(aBuilder))
return LAYER_ACTIVE;
return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList,
nsLayoutUtils::GetAnimatedGeometryRootFor(this, aBuilder));
return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, AnimatedGeometryRoot());
}
bool

View File

@ -1067,6 +1067,7 @@ public:
: mFrame(aFrame)
, mClip(nullptr)
, mReferenceFrame(nullptr)
, mAnimatedGeometryRoot(nullptr)
#ifdef MOZ_DUMP_PAINTING
, mPainted(false)
#endif
@ -1513,6 +1514,11 @@ public:
*/
virtual const nsIFrame* ReferenceFrameForChildren() const { return mReferenceFrame; }
nsIFrame* AnimatedGeometryRoot() const {
MOZ_ASSERT(mAnimatedGeometryRoot, "Must have cached AGR before accessing it!");
return mAnimatedGeometryRoot;
}
/**
* Checks if this display item (or any children) contains content that might
* be rendered with component alpha (e.g. subpixel antialiasing). Returns the
@ -1568,6 +1574,7 @@ protected:
const DisplayItemClip* mClip;
// Result of FindReferenceFrameFor(mFrame), if mFrame is non-null
const nsIFrame* mReferenceFrame;
nsIFrame* mAnimatedGeometryRoot;
// Result of ToReferenceFrame(mFrame), if mFrame is non-null
nsPoint mToReferenceFrame;
// This is the rectangle that needs to be painted.

View File

@ -162,9 +162,7 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
}
bool snap;
nsRect rect = aItem->GetBounds(aBuilder, &snap);
nsRect layerRect = rect -
nsLayoutUtils::GetAnimatedGeometryRootFor(aItem, aBuilder)->
GetOffsetToCrossDoc(aItem->ReferenceFrame());
nsRect layerRect = rect - aItem->AnimatedGeometryRoot()->GetOffsetToCrossDoc(aItem->ReferenceFrame());
nscolor color;
nsRect vis = aItem->GetVisibleRect();
nsRect component = aItem->GetComponentAlphaBounds(aBuilder);