From dd86fa4d26661a1f9ecc9428f7237143050a784c Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 27 Aug 2014 22:13:42 -0400 Subject: [PATCH] Bug 1055760 - Update some more bits of compositor layer code to deal with multiple FrameMetrics. r=BenWa,botond --- gfx/layers/Layers.cpp | 9 +++++++ gfx/layers/Layers.h | 1 + .../composite/ContainerLayerComposite.cpp | 24 ++++++++++++++----- .../composite/LayerManagerComposite.cpp | 8 ++++++- gfx/layers/composite/ThebesLayerComposite.cpp | 13 ---------- gfx/layers/composite/ThebesLayerComposite.h | 2 -- gfx/layers/composite/TiledContentHost.cpp | 3 ++- 7 files changed, 37 insertions(+), 23 deletions(-) diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index c95e73373c4..e5d0f660c99 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -713,6 +713,15 @@ Layer::HasScrollableFrameMetrics() const return false; } +bool +Layer::IsScrollInfoLayer() const +{ + // A scrollable container layer with no children + return AsContainerLayer() + && HasScrollableFrameMetrics() + && !GetFirstChild(); +} + const Matrix4x4 Layer::GetTransform() const { diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index c95cbab0bdb..305a30fd6f9 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1203,6 +1203,7 @@ public: uint32_t GetFrameMetricsCount() const { return mFrameMetrics.Length(); } const nsTArray& GetAllFrameMetrics() { return mFrameMetrics; } bool HasScrollableFrameMetrics() const; + bool IsScrollInfoLayer() const; const EventRegions& GetEventRegions() const { return mEventRegions; } ContainerLayer* GetParent() { return mParent; } Layer* GetNextSibling() { return mNextSibling; } diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index d3d3c8a3fa8..ecbb9cb88ee 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -23,6 +23,7 @@ #include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget #include "mozilla/layers/AsyncPanZoomController.h" // for AsyncPanZoomController #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform +#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper #include "mozilla/mozalloc.h" // for operator delete, etc #include "nsAutoPtr.h" // for nsRefPtr #include "nsDebug.h" // for NS_ASSERTION @@ -254,10 +255,18 @@ RenderLayers(ContainerT* aContainer, // composited area. If the layer has a background color, fill these areas // with the background color by drawing a rectangle of the background color // over the entire composited area before drawing the container contents. - if (AsyncPanZoomController* apzc = aContainer->GetAsyncPanZoomController()) { - // Make sure not to do this on a "scrollinfo" layer (one with an empty visible - // region) because it's just a placeholder for APZ purposes. - if (apzc->IsOverscrolled() && !aContainer->GetVisibleRegion().IsEmpty()) { + // Make sure not to do this on a "scrollinfo" layer because it's just a + // placeholder for APZ purposes. + if (aContainer->HasScrollableFrameMetrics() && !aContainer->IsScrollInfoLayer()) { + bool overscrolled = false; + for (uint32_t i = 0; i < aContainer->GetFrameMetricsCount(); i++) { + AsyncPanZoomController* apzc = aContainer->GetAsyncPanZoomController(i); + if (apzc && apzc->IsOverscrolled()) { + overscrolled = true; + break; + } + } + if (overscrolled) { gfxRGBA color = aContainer->GetBackgroundColor(); // If the background is completely transparent, there's no point in // drawing anything for it. Hopefully the layers behind, if any, will @@ -421,8 +430,11 @@ ContainerRender(ContainerT* aContainer, } aContainer->mPrepared = nullptr; - if (aContainer->GetFrameMetrics().IsScrollable()) { - const FrameMetrics& frame = aContainer->GetFrameMetrics(); + for (uint32_t i = 0; i < aContainer->GetFrameMetricsCount(); i++) { + if (!aContainer->GetFrameMetrics(i).IsScrollable()) { + continue; + } + const FrameMetrics& frame = aContainer->GetFrameMetrics(i); LayerRect layerBounds = frame.mCompositionBounds * ParentLayerToLayerScale(1.0); gfx::Rect rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height); gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height); diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index 7c76b62e515..2ce8b0745e1 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -797,7 +797,13 @@ LayerManagerComposite::ComputeRenderIntegrity() return 1.f; } - const FrameMetrics& rootMetrics = root->GetFrameMetrics(); + FrameMetrics rootMetrics = LayerMetricsWrapper::TopmostScrollableMetrics(root); + if (!rootMetrics.IsScrollable()) { + // The root may not have any scrollable metrics, in which case rootMetrics + // will just be an empty FrameMetrics. Instead use the actual metrics from + // the root layer. + rootMetrics = LayerMetricsWrapper(root).Metrics(); + } ParentLayerIntRect bounds = RoundedToInt(rootMetrics.mCompositionBounds); nsIntRect screenRect(bounds.x, bounds.y, diff --git a/gfx/layers/composite/ThebesLayerComposite.cpp b/gfx/layers/composite/ThebesLayerComposite.cpp index f876bd5f224..8b1b7bc2803 100644 --- a/gfx/layers/composite/ThebesLayerComposite.cpp +++ b/gfx/layers/composite/ThebesLayerComposite.cpp @@ -172,19 +172,6 @@ ThebesLayerComposite::GenEffectChain(EffectChain& aEffect) aEffect.mPrimaryEffect = mBuffer->GenEffect(GetEffectFilter()); } -CSSToScreenScale -ThebesLayerComposite::GetEffectiveResolution() -{ - for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) { - const FrameMetrics& metrics = parent->GetFrameMetrics(); - if (metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) { - return metrics.GetZoom(); - } - } - - return CSSToScreenScale(1.0); -} - void ThebesLayerComposite::PrintInfo(std::stringstream& aStream, const char* aPrefix) { diff --git a/gfx/layers/composite/ThebesLayerComposite.h b/gfx/layers/composite/ThebesLayerComposite.h index 5d64fbc4c86..71defa3a573 100644 --- a/gfx/layers/composite/ThebesLayerComposite.h +++ b/gfx/layers/composite/ThebesLayerComposite.h @@ -86,8 +86,6 @@ protected: private: gfx::Filter GetEffectFilter() { return gfx::Filter::LINEAR; } - CSSToScreenScale GetEffectiveResolution(); - private: RefPtr mBuffer; }; diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index b30cbfa4405..1e0d23c58a2 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -9,6 +9,7 @@ #include "mozilla/gfx/Matrix.h" // for Matrix4x4 #include "mozilla/layers/Compositor.h" // for Compositor #include "mozilla/layers/Effects.h" // for TexturedEffect, Effect, etc +#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL #include "nsAString.h" #include "nsDebug.h" // for NS_WARNING @@ -367,7 +368,7 @@ TiledContentHost::Composite(EffectChain& aEffectChain, // Background colors are only stored on scrollable layers. Grab // the one from the nearest scrollable ancestor layer. for (Layer* ancestor = GetLayer(); ancestor; ancestor = ancestor->GetParent()) { - if (ancestor->GetFrameMetrics().IsScrollable()) { + if (ancestor->HasScrollableFrameMetrics()) { backgroundColor = ancestor->GetBackgroundColor(); break; }