diff --git a/gfx/layers/LayerAttributes.h b/gfx/layers/LayerAttributes.h index 39d42e42176e..a536a5525f32 100644 --- a/gfx/layers/LayerAttributes.h +++ b/gfx/layers/LayerAttributes.h @@ -44,13 +44,6 @@ public: // All set methods return true if values changed, false otherwise. // - bool SetLayerBounds(const gfx::IntRect& aLayerBounds) { - if (mLayerBounds.IsEqualEdges(aLayerBounds)) { - return false; - } - mLayerBounds = aLayerBounds; - return true; - } bool SetPostScale(float aXScale, float aYScale) { if (mPostXScale == aXScale && mPostYScale == aYScale) { return false; @@ -174,9 +167,6 @@ public: // Getters. // - const gfx::IntRect& LayerBounds() const { - return mLayerBounds; - } float PostXScale() const { return mPostXScale; } @@ -244,8 +234,7 @@ public: } bool operator ==(const SimpleLayerAttributes& aOther) const { - return mLayerBounds == aOther.mLayerBounds && - mTransform == aOther.mTransform && + return mTransform == aOther.mTransform && mTransformIsPerspective == aOther.mTransformIsPerspective && mScrolledClip == aOther.mScrolledClip && mPostXScale == aOther.mPostXScale && @@ -262,7 +251,6 @@ public: } private: - gfx::IntRect mLayerBounds; gfx::Matrix4x4 mTransform; bool mTransformIsPerspective; Maybe mScrolledClip; diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index fe2979a79dcc..363f1dfb608e 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -576,8 +576,7 @@ Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect) return currentClip; } - if (GetLocalVisibleRegion().IsEmpty() && - !(AsHostLayer() && AsHostLayer()->NeedToDrawCheckerboarding())) { + if (GetLocalVisibleRegion().IsEmpty()) { // When our visible region is empty, our parent may not have created the // intermediate surface that we would require for correct clipping; however, // this does not matter since we are invisible. @@ -1855,9 +1854,6 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix) if (GetTransformIsPerspective()) { aStream << " [perspective]"; } - if (!GetLayerBounds().IsEmpty()) { - AppendToString(aStream, GetLayerBounds(), " [bounds=", "]"); - } if (!mVisibleRegion.IsEmpty()) { AppendToString(aStream, mVisibleRegion.ToUnknownRegion(), " [visible=", "]"); } else { diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 0bebd20265bc..fa667536b39c 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -897,22 +897,6 @@ public: } } - /** - * CONSTRUCTION PHASE ONLY - * The union of the bounds of all the display item that got flattened - * into this layer. This is intended to be an approximation to the - * size of the layer if the nearest scrollable ancestor had an infinitely - * large displayport. Computing this more exactly is too expensive, - * but this approximation is sufficient for what we need to use it for. - */ - virtual void SetLayerBounds(const gfx::IntRect& aLayerBounds) - { - if (mSimpleAttrs.SetLayerBounds(aLayerBounds)) { - MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) LayerBounds", this)); - MutatedSimple(); - } - } - /** * CONSTRUCTION PHASE ONLY * Tell this layer which region will be visible. The visible region @@ -1339,7 +1323,6 @@ public: const Maybe& GetScrolledClip() const { return mSimpleAttrs.ScrolledClip(); } Maybe GetScrolledClipRect() const; uint32_t GetContentFlags() { return mSimpleAttrs.ContentFlags(); } - const gfx::IntRect& GetLayerBounds() const { return mSimpleAttrs.LayerBounds(); } const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; } const ScrollMetadata& GetScrollMetadata(uint32_t aIndex) const; const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const; diff --git a/gfx/layers/client/ClientTiledPaintedLayer.cpp b/gfx/layers/client/ClientTiledPaintedLayer.cpp index 7ed5c84f25b3..4873f09da604 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.cpp +++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp @@ -169,7 +169,7 @@ ClientTiledPaintedLayer::BeginPaint() ParentLayerToLayerMatrix4x4 transformDisplayPortToLayer = GetTransformToAncestorsParentLayer(this, displayPortAncestor).Inverse(); - LayerRect layerBounds = ViewAs(Rect(GetLayerBounds())); + LayerRect layerBounds(GetVisibleRegion().GetBounds()); // Compute the critical display port that applies to this layer in the // LayoutDevice space of this layer, but only if there is no OMT animation diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 3335607f8c39..ccb20c0c9397 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -1218,7 +1218,7 @@ ClientMultiTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& a GetCompositorSideCompositionBounds(scrollAncestor, aPaintData->mTransformToCompBounds, viewTransform, - ViewAs(Rect(mPaintedLayer.GetLayerBounds()))); + LayerRect(mPaintedLayer.GetVisibleRegion().GetBounds())); if (!transformedCompositionBounds) { aPaintData->mPaintFinished = true; diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index ab38bbfd3f9f..b60512f8438a 100755 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -209,8 +209,7 @@ ContainerPrepare(ContainerT* aContainer, // We don't want to skip container layers because otherwise their mPrepared // may be null which is not allowed. if (!layerToRender->GetLayer()->AsContainerLayer()) { - if (!layerToRender->GetLayer()->IsVisible() && - !layerToRender->NeedToDrawCheckerboarding(nullptr)) { + if (!layerToRender->GetLayer()->IsVisible()) { CULLING_LOG("Sublayer %p has no effective visible region\n", layerToRender->GetLayer()); continue; } @@ -419,24 +418,6 @@ RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager, } } - Color color; - if (layerToRender->NeedToDrawCheckerboarding(&color)) { - if (gfxPrefs::APZHighlightCheckerboardedAreas()) { - color = Color(255 / 255.f, 188 / 255.f, 217 / 255.f, 1.f); // "Cotton Candy" - } - // Ideally we would want to intersect the checkerboard region from the APZ with the layer bounds - // and only fill in that area. However the layer bounds takes into account the base translation - // for the painted layer whereas the checkerboard region does not. One does not simply - // intersect areas in different coordinate spaces. So we do this a little more permissively - // and only fill in the background when we know there is checkerboard, which in theory - // should only occur transiently. - EffectChain effectChain(layer); - effectChain.mPrimaryEffect = new EffectSolidColor(color); - aManager->GetCompositor()->DrawGeometry(gfx::Rect(layer->GetLayerBounds()), clipRect, - effectChain, layer->GetEffectiveOpacity(), - layer->GetEffectiveTransform(), Nothing()); - } - if (layerToRender->HasLayerBeenComposited()) { // Composer2D will compose this layer so skip GPU composition // this time. The flag will be reset for the next composition phase diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index 336669a2d0c1..33b1962448f1 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -1450,35 +1450,6 @@ LayerComposite::HasStaleCompositor() const return mCompositeManager->GetCompositor() != mCompositor; } -static bool -LayerHasCheckerboardingAPZC(Layer* aLayer, Color* aOutColor) -{ - bool answer = false; - for (LayerMetricsWrapper i(aLayer, LayerMetricsWrapper::StartAt::BOTTOM); i; i = i.GetParent()) { - if (!i.Metrics().IsScrollable()) { - continue; - } - if (i.GetApzc() && i.GetApzc()->IsCurrentlyCheckerboarding()) { - if (aOutColor) { - *aOutColor = i.Metadata().GetBackgroundColor(); - } - answer = true; - break; - } - break; - } - return answer; -} - -bool -LayerComposite::NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor) -{ - return GetLayer()->Manager()->AsyncPanZoomEnabled() && - (GetLayer()->GetContentFlags() & Layer::CONTENT_OPAQUE) && - GetLayer()->IsOpaqueForVisibility() && - LayerHasCheckerboardingAPZC(GetLayer(), aOutCheckerboardingColor); -} - #ifndef MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS /*static*/ bool diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index 718f869c9903..3c1f2d1c1bc6 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -565,12 +565,6 @@ public: bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; } bool GetShadowOpacitySetByAnimation() { return mShadowOpacitySetByAnimation; } - /** - * Return true if a checkerboarding background color needs to be drawn - * for this layer. - */ - virtual bool NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor = nullptr) { return false; } - protected: HostLayerManager* mCompositorManager; @@ -670,8 +664,6 @@ public: */ virtual nsIntRegion GetFullyRenderedRegion(); - virtual bool NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor = nullptr); - protected: LayerManagerComposite* mCompositeManager; diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 0fb3a17d3a79..a7a53c3f881d 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -5352,20 +5352,29 @@ PresShell::AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder, // color background behind a scrolled transparent background. Instead, // we'll try to move the color background into the scrolled content // by making nsDisplayCanvasBackground paint it. + bool addedScrollingBackgroundColor = false; if (!aFrame->GetParent()) { nsIScrollableFrame* sf = aFrame->PresContext()->PresShell()->GetRootScrollFrameAsScrollable(); if (sf) { nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame()); if (canvasFrame && canvasFrame->IsVisibleForPainting(&aBuilder)) { - if (AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor)) - return; + addedScrollingBackgroundColor = + AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor); } } } - aList.AppendNewToBottom( - new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor)); + if (!addedScrollingBackgroundColor || + (nsLayoutUtils::UsesAsyncScrolling(aFrame) && NS_GET_A(bgcolor) == 255)) { + // With async scrolling, we'd like to have two instances of the background + // color: one that scrolls with the content (for the reasons stated above), + // and one underneath which does not scroll with the content, but which can + // be shown during checkerboarding and overscroll. + // We can only do that if the color is opaque. + aList.AppendNewToBottom( + new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor)); + } } static bool IsTransparentContainerElement(nsPresContext* aPresContext) diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index 15a7d1a99229..1d617d0cf855 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -651,10 +651,6 @@ public: * in mItemClip). */ void UpdateCommonClipCount(const DisplayItemClip& aCurrentClip); - /** - * The union of all the bounds of the display items in this layer. - */ - nsIntRect mBounds; /** * The region of visible content above the layer and below the * next PaintedLayerData currently in the stack, if any. @@ -3275,10 +3271,6 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB SetOuterVisibleRegionForLayer(layer, data->mVisibleRegion); } - nsIntRect layerBounds = data->mBounds; - layerBounds.MoveBy(-GetTranslationForPaintedLayer(data->mLayer)); - layer->SetLayerBounds(layerBounds); - #ifdef MOZ_DUMP_PAINTING if (!data->mLog.IsEmpty()) { if (PaintedLayerData* containingPld = mLayerBuilder->GetContainingPaintedLayerData()) { @@ -3475,10 +3467,6 @@ PaintedLayerData::Accumulate(ContainerState* aState, { FLB_LOG_PAINTED_LAYER_DECISION(this, "Accumulating dp=%s(%p), f=%p against pld=%p\n", aItem->Name(), aItem, aItem->Frame(), this); - bool snap; - nsRect itemBounds = aItem->GetBounds(aState->mBuilder, &snap); - mBounds = mBounds.Union(aState->ScaleToOutsidePixels(itemBounds, snap)); - if (aState->mBuilder->NeedToForceTransparentSurfaceForItem(aItem)) { mForceTransparentSurface = true; } @@ -3798,7 +3786,7 @@ ContainerState::GetDisplayPortForAnimatedGeometryRoot(AnimatedGeometryRoot* aAni } nsIScrollableFrame* sf = nsLayoutUtils::GetScrollableFrameFor(*aAnimatedGeometryRoot); - if (sf == nullptr) { + if (sf == nullptr || nsLayoutUtils::UsesAsyncScrolling(*aAnimatedGeometryRoot)) { return nsRect(); } diff --git a/layout/reftests/async-scrolling/checkerboard-2-ref.html b/layout/reftests/async-scrolling/checkerboard-2-ref.html index d1927e43d294..6a12210c0542 100644 --- a/layout/reftests/async-scrolling/checkerboard-2-ref.html +++ b/layout/reftests/async-scrolling/checkerboard-2-ref.html @@ -1,6 +1,7 @@ +
diff --git a/layout/reftests/async-scrolling/checkerboard-3-ref.html b/layout/reftests/async-scrolling/checkerboard-3-ref.html index bba831e93dcb..d00946ada6c4 100644 --- a/layout/reftests/async-scrolling/checkerboard-3-ref.html +++ b/layout/reftests/async-scrolling/checkerboard-3-ref.html @@ -1,5 +1,6 @@ +