From 3f9d3853cdaac7f139df7a5d35bba9cdaf56d0df Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 6 Sep 2021 23:12:03 +0000 Subject: [PATCH] Bug 1728232 - Remove RestoreState. r=miko Differential Revision: https://phabricator.services.mozilla.com/D124006 --- layout/generic/TextDrawTarget.h | 2 +- layout/generic/TextOverflow.cpp | 3 - layout/generic/nsPageFrame.cpp | 2 +- .../painting/RetainedDisplayListBuilder.cpp | 7 -- layout/painting/nsDisplayList.cpp | 14 +--- layout/painting/nsDisplayList.h | 64 ++++--------------- layout/svg/SVGTextFrame.cpp | 3 - layout/xul/nsTextBoxFrame.cpp | 3 - layout/xul/tree/nsTreeBodyFrame.cpp | 3 - 9 files changed, 18 insertions(+), 83 deletions(-) diff --git a/layout/generic/TextDrawTarget.h b/layout/generic/TextDrawTarget.h index 0ee67354888d..c388da0bed0b 100644 --- a/layout/generic/TextDrawTarget.h +++ b/layout/generic/TextDrawTarget.h @@ -76,7 +76,7 @@ class TextDrawTarget : public DrawTarget { mHasUnsupportedFeatures = false; mHasShadows = false; - SetPermitSubpixelAA(!aItem->IsSubpixelAADisabled()); + SetPermitSubpixelAA(true); // Compute clip/bounds auto appUnitsPerDevPixel = diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 0cac4b41db84..b88a702fa211 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -209,9 +209,6 @@ static void PaintTextShadowCallback(gfxContext* aCtx, nsPoint aShadowOffset, void nsDisplayTextOverflowMarker::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { - DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(), - IsSubpixelAADisabled()); - nscolor foregroundColor = nsLayoutUtils::GetColor(mFrame, &nsStyleText::mWebkitTextFillColor); diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index b425b8511102..a72fd142aaff 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -407,7 +407,7 @@ class nsDisplayHeaderFooter final : public nsPaintedDisplayItem { MOZ_ASSERT(pageFrame, "We should have an nsPageFrame"); #endif static_cast(mFrame)->PaintHeaderFooter( - *aCtx, ToReferenceFrame(), IsSubpixelAADisabled()); + *aCtx, ToReferenceFrame(), false); } NS_DISPLAY_DECL_NAME("HeaderFooter", TYPE_HEADER_FOOTER) diff --git a/layout/painting/RetainedDisplayListBuilder.cpp b/layout/painting/RetainedDisplayListBuilder.cpp index a4ab2905e73e..abd67b969d01 100644 --- a/layout/painting/RetainedDisplayListBuilder.cpp +++ b/layout/painting/RetainedDisplayListBuilder.cpp @@ -280,13 +280,6 @@ bool RetainedDisplayListBuilder::PreProcessDisplayList( mBuilder.MarkFrameForDisplayIfVisible(f, mBuilder.RootReferenceFrame()); } - // TODO: This is here because we sometimes reuse the previous display list - // completely. For optimization, we could only restore the state for reused - // display items. - if (item->RestoreState()) { - item->InvalidateItemCacheEntry(); - } - // If we're going to keep this linked list and not merge it, then mark the // item as used and put it back into the list. if (aKeepLinked) { diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 281b984a6cf6..6d6432d33889 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -2830,11 +2830,6 @@ void nsDisplayItem::SetClipChain(const DisplayItemClipChain* aClipChain, bool aStore) { mClipChain = aClipChain; mClip = DisplayItemClipChain::ClipForASR(aClipChain, mActiveScrolledRoot); - - if (aStore) { - mState.mClipChain = mClipChain; - mState.mClip = mClip; - } } Maybe nsDisplayItem::GetClipWithRespectToASR( @@ -4782,6 +4777,7 @@ nsDisplayWrapList::nsDisplayWrapList( mListPtr = &mList; mListPtr->AppendToTop(aList); + mOriginalClipChain = mClipChain; nsDisplayWrapList::UpdateBounds(aBuilder); #ifdef DEBUG @@ -4810,6 +4806,7 @@ nsDisplayWrapList::nsDisplayWrapList(nsDisplayListBuilder* aBuilder, mListPtr = &mList; mListPtr->AppendToTop(aItem); + mOriginalClipChain = mClipChain; nsDisplayWrapList::UpdateBounds(aBuilder); if (!aFrame || !aFrame->IsTransformed()) { @@ -5863,8 +5860,7 @@ void nsDisplayStickyPosition::SetClipChain( "with it."); if (aStore) { - mState.mClipChain = aClipChain; - mState.mClip = mClip; + mOriginalClipChain = aClipChain; } } @@ -6404,7 +6400,6 @@ void nsDisplayTransform::SetReferenceFrameToAncestor( void nsDisplayTransform::Init(nsDisplayListBuilder* aBuilder, nsDisplayList* aChildren) { - mShouldFlatten = false; mChildren.AppendToTop(aChildren); UpdateBounds(aBuilder); } @@ -7818,9 +7813,6 @@ bool nsDisplayText::CanApplyOpacity(WebRenderLayerManager* aManager, void nsDisplayText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { AUTO_PROFILER_LABEL("nsDisplayText::Paint", GRAPHICS); - - DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(), - IsSubpixelAADisabled()); RenderToContext(aCtx, aBuilder); } diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index dae999bb09c3..f595cc17bc12 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -2402,9 +2402,6 @@ class nsDisplayItem : public nsDisplayItemLink { if (aOther.ForceNotVisible()) { mItemFlags += ItemFlag::ForceNotVisible; } - if (aOther.IsSubpixelAADisabled()) { - mItemFlags += ItemFlag::DisableSubpixelAA; - } if (mFrame->In3DContextAndBackfaceIsHidden()) { mItemFlags += ItemFlag::BackfaceHidden; } @@ -2439,24 +2436,6 @@ class nsDisplayItem : public nsDisplayItemLink { nsDisplayItem() = delete; nsDisplayItem(const nsDisplayItem&) = delete; - /** - * Roll back side effects carried out by processing the display list. - * - * @return true if the rollback actually modified anything, to help the caller - * decide whether to invalidate cached information about this node. - */ - virtual bool RestoreState() { - if (mClipChain == mState.mClipChain && mClip == mState.mClip && - !mItemFlags.contains(ItemFlag::DisableSubpixelAA)) { - return false; - } - - mClipChain = mState.mClipChain; - mClip = mState.mClip; - mItemFlags -= ItemFlag::DisableSubpixelAA; - return true; - } - /** * Invalidate cached information that depends on this node's contents, after * a mutation of those contents. @@ -2861,16 +2840,6 @@ class nsDisplayItem : public nsDisplayItemLink { return nsRect(); } - /** - * Disable usage of component alpha. Currently only relevant for items that - * have text. - */ - void DisableComponentAlpha() { mItemFlags += ItemFlag::DisableSubpixelAA; } - - bool IsSubpixelAADisabled() const { - return mItemFlags.contains(ItemFlag::DisableSubpixelAA); - } - /** * Check if we can add async animations to the layer for this display item. */ @@ -2969,7 +2938,6 @@ class nsDisplayItem : public nsDisplayItemLink { #endif BackfaceHidden, Combines3DTransformWithAncestors, - DisableSubpixelAA, ForceNotVisible, HasHitTestInfo, IsGlassItem, @@ -3011,11 +2979,6 @@ class nsDisplayItem : public nsDisplayItemLink { RefPtr mClipChain; const DisplayItemClip* mClip = nullptr; - struct { - RefPtr mClipChain; - const DisplayItemClip* mClip; - } mState; - #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED public: bool IsMergedItem() const { @@ -4898,6 +4861,7 @@ class nsDisplayWrapList : public nsPaintedDisplayItem { MOZ_COUNT_CTOR(nsDisplayWrapList); mBaseBuildingRect = GetBuildingRect(); mListPtr = &mList; + mOriginalClipChain = mClipChain; } nsDisplayWrapList() = delete; @@ -4915,6 +4879,7 @@ class nsDisplayWrapList : public nsPaintedDisplayItem { mMergedFrames(aOther.mMergedFrames.Clone()), mBounds(aOther.mBounds), mBaseBuildingRect(aOther.mBaseBuildingRect), + mOriginalClipChain(aOther.mClipChain), mOverrideZIndex(aOther.mOverrideZIndex), mHasZIndexOverride(aOther.mHasZIndexOverride), mClearingClipChain(aOther.mClearingClipChain) { @@ -4946,7 +4911,7 @@ class nsDisplayWrapList : public nsPaintedDisplayItem { // Clear the clip chain up to the asr, but don't store it, so that we'll // recover it when we reuse the item. if (mClearingClipChain) { - const DisplayItemClipChain* clip = mState.mClipChain; + const DisplayItemClipChain* clip = mOriginalClipChain; while (clip && ActiveScrolledRoot::IsAncestor(GetActiveScrolledRoot(), clip->mASR)) { clip = clip->mParent; @@ -4968,6 +4933,15 @@ class nsDisplayWrapList : public nsPaintedDisplayItem { SetBuildingRect(buildingRect); } + void SetClipChain(const DisplayItemClipChain* aClipChain, + bool aStore) override { + nsDisplayItem::SetClipChain(aClipChain, aStore); + + if (aStore) { + mOriginalClipChain = mClipChain; + } + } + void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, HitTestState* aState, nsTArray* aOutFrames) override; nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; @@ -5091,6 +5065,7 @@ class nsDisplayWrapList : public nsPaintedDisplayItem { // Displaylist building rect contributed by this display item itself. // Our mBuildingRect may include the visible areas of children. nsRect mBaseBuildingRect; + RefPtr mOriginalClipChain; int32_t mOverrideZIndex; bool mHasZIndexOverride; bool mClearingClipChain = false; @@ -6238,15 +6213,6 @@ class nsDisplayTransform : public nsPaintedDisplayItem { NS_DISPLAY_DECL_NAME("nsDisplayTransform", TYPE_TRANSFORM) - bool RestoreState() override { - if (!nsPaintedDisplayItem::RestoreState() && !mShouldFlatten) { - return false; - } - - mShouldFlatten = false; - return true; - } - void UpdateBounds(nsDisplayListBuilder* aBuilder) override; /** @@ -6316,8 +6282,6 @@ class nsDisplayTransform : public nsPaintedDisplayItem { } } - bool NeedsGeometryUpdates() const override { return mShouldFlatten; } - const nsIFrame* ReferenceFrameForChildren() const override { // If we were created using a transform-getter, then we don't // belong to a transformed frame, and aren't a reference frame @@ -6583,8 +6547,6 @@ class nsDisplayTransform : public nsPaintedDisplayItem { // parent context unintendedly if the root of the child preserves3d context // doesn't create a transform item. bool mIsTransformSeparator : 1; - // True if this nsDisplayTransform should get flattened - bool mShouldFlatten : 1; // True if we have a transform getter. bool mHasTransformGetter : 1; }; diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index 37a4704be3f7..c8c03a108664 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -2714,9 +2714,6 @@ void DisplaySVGText::HitTest(nsDisplayListBuilder* aBuilder, } void DisplaySVGText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { - DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(), - IsSubpixelAADisabled()); - uint32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel(); // ToReferenceFrame includes our mRect offset, but painting takes diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 0fb9e7ae91bd..7af40fcd912c 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -263,9 +263,6 @@ static void PaintTextShadowCallback(gfxContext* aCtx, nsPoint aShadowOffset, void nsDisplayXULTextBox::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { - DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(), - IsSubpixelAADisabled()); - // Paint the text shadow before doing any foreground stuff nsRect drawRect = static_cast(mFrame)->mTextDrawRect + ToReferenceFrame(); diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 211dfee0f8aa..97106960033e 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -2525,9 +2525,6 @@ class nsDisplayTreeBody final : public nsPaintedDisplayItem { virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override { MOZ_ASSERT(aBuilder); - DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(), - IsSubpixelAADisabled()); - ImgDrawResult result = static_cast(mFrame)->PaintTreeBody( *aCtx, GetPaintRect(aBuilder, aCtx), ToReferenceFrame(), aBuilder);