diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index ac5c0d6c5c55..bf677ca14d10 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -40,10 +40,10 @@ public: FrameMetrics() : mCompositionBounds(0, 0, 0, 0) - , mDisplayPort(0, 0, 0, 0) , mCriticalDisplayPort(0, 0, 0, 0) , mScrollableRect(0, 0, 0, 0) , mPresShellResolution(1) + , mDisplayPort(0, 0, 0, 0) , mCumulativeResolution(1) , mDevPixelsPerCSSPixel(1) , mMayHaveTouchListeners(false) @@ -256,19 +256,6 @@ public: // space, so each is explained separately. // - // The area of a frame's contents that has been painted, relative to - // mCompositionBounds. - // - // Note that this is structured in such a way that it doesn't depend on the - // method layout uses to scroll content. - // - // May be larger or smaller than |mScrollableRect|. - // - // To pre-render a margin of 100 CSS pixels around the window, - // { x = -100, y = - 100, - // width = window.innerWidth + 200, height = window.innerHeight + 200 } - CSSRect mDisplayPort; - // If non-empty, the area of a frame's contents that is considered critical // to paint. Area outside of this area (i.e. area inside mDisplayPort, but // outside of mCriticalDisplayPort) is considered low-priority, and may be @@ -304,6 +291,16 @@ public: float mPresShellResolution; public: + void SetDisplayPort(const CSSRect& aDisplayPort) + { + mDisplayPort = aDisplayPort; + } + + CSSRect GetDisplayPort() const + { + return mDisplayPort; + } + void SetCumulativeResolution(const LayoutDeviceToLayerScale& aCumulativeResolution) { mCumulativeResolution = aCumulativeResolution; @@ -532,6 +529,19 @@ public: } private: + // The area of a frame's contents that has been painted, relative to + // mCompositionBounds. + // + // Note that this is structured in such a way that it doesn't depend on the + // method layout uses to scroll content. + // + // May be larger or smaller than |mScrollableRect|. + // + // To pre-render a margin of 100 CSS pixels around the window, + // { x = -100, y = - 100, + // width = window.innerWidth + 200, height = window.innerHeight + 200 } + CSSRect mDisplayPort; + // The cumulative resolution that the current frame has been painted at. // This is the product of the pres-shell resolutions of the document // containing this scroll frame and its ancestors, and any css-driven diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp index b98b1ec8ed25..0379df187cda 100644 --- a/gfx/layers/LayersLogging.cpp +++ b/gfx/layers/LayersLogging.cpp @@ -175,7 +175,7 @@ AppendToString(std::stringstream& aStream, const FrameMetrics& m, if (m.GetDoSmoothScroll()) { AppendToString(aStream, m.GetSmoothScrollOffset(), "] [ss="); } - AppendToString(aStream, m.mDisplayPort, "] [dp="); + AppendToString(aStream, m.GetDisplayPort(), "] [dp="); AppendToString(aStream, m.mCriticalDisplayPort, "] [cdp="); AppendToString(aStream, m.GetBackgroundColor(), "] [color="); if (!detailed) { diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 42a0f3ad7f55..14d2f0ab197c 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -2620,12 +2620,12 @@ ViewTransform AsyncPanZoomController::GetCurrentAsyncTransform() const { // If checkerboarding has been disallowed, clamp the scroll position to stay // within rendered content. if (!gfxPrefs::APZAllowCheckerboarding() && - !mLastContentPaintMetrics.mDisplayPort.IsEmpty()) { + !mLastContentPaintMetrics.GetDisplayPort().IsEmpty()) { CSSSize compositedSize = mLastContentPaintMetrics.CalculateCompositedSizeInCssPixels(); CSSPoint maxScrollOffset = lastPaintScrollOffset + - CSSPoint(mLastContentPaintMetrics.mDisplayPort.XMost() - compositedSize.width, - mLastContentPaintMetrics.mDisplayPort.YMost() - compositedSize.height); - CSSPoint minScrollOffset = lastPaintScrollOffset + mLastContentPaintMetrics.mDisplayPort.TopLeft(); + CSSPoint(mLastContentPaintMetrics.GetDisplayPort().XMost() - compositedSize.width, + mLastContentPaintMetrics.GetDisplayPort().YMost() - compositedSize.height); + CSSPoint minScrollOffset = lastPaintScrollOffset + mLastContentPaintMetrics.GetDisplayPort().TopLeft(); if (minScrollOffset.x < maxScrollOffset.x) { currentScrollOffset.x = clamped(currentScrollOffset.x, minScrollOffset.x, maxScrollOffset.x); @@ -2681,7 +2681,7 @@ bool AsyncPanZoomController::IsCurrentlyCheckerboarding() const { } CSSPoint currentScrollOffset = mFrameMetrics.GetScrollOffset() + mTestAsyncScrollOffset; - CSSRect painted = mLastContentPaintMetrics.mDisplayPort + mLastContentPaintMetrics.GetScrollOffset(); + CSSRect painted = mLastContentPaintMetrics.GetDisplayPort() + mLastContentPaintMetrics.GetScrollOffset(); painted.Inflate(CSSMargin::FromAppUnits(nsMargin(1, 1, 1, 1))); // fuzz for rounding error CSSRect visible = CSSRect(currentScrollOffset, mFrameMetrics.CalculateCompositedSizeInCssPixels()); return !painted.Contains(visible); @@ -2702,7 +2702,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri LogRendertraceRect(GetGuid(), "page", "brown", aLayerMetrics.mScrollableRect); LogRendertraceRect(GetGuid(), "painted displayport", "lightgreen", - aLayerMetrics.mDisplayPort + aLayerMetrics.GetScrollOffset()); + aLayerMetrics.GetDisplayPort() + aLayerMetrics.GetScrollOffset()); if (!aLayerMetrics.mCriticalDisplayPort.IsEmpty()) { LogRendertraceRect(GetGuid(), "painted critical displayport", "darkgreen", aLayerMetrics.mCriticalDisplayPort + aLayerMetrics.GetScrollOffset()); diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 3ea4ce5041eb..d266e34adade 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -753,7 +753,7 @@ ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, CSSToLayerScale paintScale = aMetrics.LayersPixelsPerCSSPixel(); const CSSRect& metricsDisplayPort = (aDrawingCritical && !aMetrics.mCriticalDisplayPort.IsEmpty()) ? - aMetrics.mCriticalDisplayPort : aMetrics.mDisplayPort; + aMetrics.mCriticalDisplayPort : aMetrics.GetDisplayPort(); LayerRect displayPort = (metricsDisplayPort + aMetrics.GetScrollOffset()) * paintScale; ParentLayerPoint scrollOffset; diff --git a/gfx/layers/client/ClientTiledPaintedLayer.cpp b/gfx/layers/client/ClientTiledPaintedLayer.cpp index 5452d8e81397..d3190b209866 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.cpp +++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp @@ -91,7 +91,7 @@ ClientTiledPaintedLayer::GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncest if (!scrollAncestor && metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) { scrollAncestor = ancestor; } - if (!metrics.mDisplayPort.IsEmpty()) { + if (!metrics.GetDisplayPort().IsEmpty()) { displayPortAncestor = ancestor; // Any layer that has a displayport must be scrollable, so we can break // here. @@ -191,7 +191,7 @@ ClientTiledPaintedLayer::UseFastPath() || gfxPrefs::UseLowPrecisionBuffer() || !parentMetrics.mCriticalDisplayPort.IsEmpty(); bool isFixed = GetIsFixedPosition() || GetParent()->GetIsFixedPosition(); - return !multipleTransactionsNeeded || isFixed || parentMetrics.mDisplayPort.IsEmpty(); + return !multipleTransactionsNeeded || isFixed || parentMetrics.GetDisplayPort().IsEmpty(); } bool diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index c893cbb9bd6c..5d49a54f0707 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -213,10 +213,10 @@ SharedFrameMetricsHelper::UpdateFromCompositorFrameMetrics( // an endless updating cycle. if (fabsf(contentMetrics.GetScrollOffset().x - compositorMetrics.GetScrollOffset().x) <= 2 && fabsf(contentMetrics.GetScrollOffset().y - compositorMetrics.GetScrollOffset().y) <= 2 && - fabsf(contentMetrics.mDisplayPort.x - compositorMetrics.mDisplayPort.x) <= 2 && - fabsf(contentMetrics.mDisplayPort.y - compositorMetrics.mDisplayPort.y) <= 2 && - fabsf(contentMetrics.mDisplayPort.width - compositorMetrics.mDisplayPort.width) <= 2 && - fabsf(contentMetrics.mDisplayPort.height - compositorMetrics.mDisplayPort.height) <= 2) { + fabsf(contentMetrics.GetDisplayPort().x - compositorMetrics.GetDisplayPort().x) <= 2 && + fabsf(contentMetrics.GetDisplayPort().y - compositorMetrics.GetDisplayPort().y) <= 2 && + fabsf(contentMetrics.GetDisplayPort().width - compositorMetrics.GetDisplayPort().width) <= 2 && + fabsf(contentMetrics.GetDisplayPort().height - compositorMetrics.GetDisplayPort().height) <= 2) { return false; } @@ -258,7 +258,7 @@ SharedFrameMetricsHelper::AboutToCheckerboard(const FrameMetrics& aContentMetric // This process can introduce some rounding error, so we inflate the rect by one app unit // to account for that. CSSRect painted = (aContentMetrics.mCriticalDisplayPort.IsEmpty() - ? aContentMetrics.mDisplayPort + ? aContentMetrics.GetDisplayPort() : aContentMetrics.mCriticalDisplayPort) + aContentMetrics.GetScrollOffset(); painted.Inflate(CSSMargin::FromAppUnits(nsMargin(1, 1, 1, 1))); diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index e81ee0d41e6c..263aa36437cc 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -605,7 +605,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer) const FrameMetrics& metrics = aLayer->GetFrameMetrics(i); CSSToLayerScale paintScale = metrics.LayersPixelsPerCSSPixel(); CSSRect displayPort(metrics.mCriticalDisplayPort.IsEmpty() ? - metrics.mDisplayPort : metrics.mCriticalDisplayPort); + metrics.GetDisplayPort() : metrics.mCriticalDisplayPort); ScreenPoint offset(0, 0); // XXX this call to SyncFrameMetrics is not currently being used. It will be cleaned // up as part of bug 776030 or one of its dependencies. @@ -860,7 +860,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer) // Calculate the absolute display port to send to Java LayerIntRect displayPort = RoundedToInt( (metrics.mCriticalDisplayPort.IsEmpty() - ? metrics.mDisplayPort + ? metrics.GetDisplayPort() : metrics.mCriticalDisplayPort ) * geckoZoom); displayPort += scrollOffsetLayerPixels; diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index 634a8a272099..eeed50adab1e 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -935,13 +935,13 @@ LayerManagerComposite::ComputeRenderIntegrity() } // Work out how much of the display-port covers the screen - if (!metrics.mDisplayPort.IsEmpty()) { + if (!metrics.GetDisplayPort().IsEmpty()) { if (hasLowPrecision) { lowPrecisionMultiplier = - GetDisplayportCoverage(metrics.mDisplayPort, transform, screenRect); + GetDisplayportCoverage(metrics.GetDisplayPort(), transform, screenRect); } else { lowPrecisionMultiplier = highPrecisionMultiplier = - GetDisplayportCoverage(metrics.mDisplayPort, transform, screenRect); + GetDisplayportCoverage(metrics.GetDisplayPort(), transform, screenRect); } } } diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index ebb193e8130a..f171e8a693e0 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -223,7 +223,7 @@ TestFrameMetrics() { FrameMetrics fm; - fm.mDisplayPort = CSSRect(0, 0, 10, 10); + fm.SetDisplayPort(CSSRect(0, 0, 10, 10)); fm.mCompositionBounds = ParentLayerRect(0, 0, 10, 10); fm.mCriticalDisplayPort = CSSRect(0, 0, 10, 10); fm.mScrollableRect = CSSRect(0, 0, 100, 100); @@ -816,7 +816,7 @@ TEST_F(APZCBasicTester, ComplexTransform) { FrameMetrics metrics; metrics.mCompositionBounds = ParentLayerRect(0, 0, 24, 24); - metrics.mDisplayPort = CSSRect(-1, -1, 6, 6); + metrics.SetDisplayPort(CSSRect(-1, -1, 6, 6)); metrics.SetScrollOffset(CSSPoint(10, 10)); metrics.mScrollableRect = CSSRect(0, 0, 50, 50); metrics.SetCumulativeResolution(LayoutDeviceToLayerScale(2)); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 6a4b2a12859f..a6090fce8c8b 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -716,9 +716,9 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame, } nsRect dp; if (nsLayoutUtils::GetDisplayPort(content, &dp)) { - metrics.mDisplayPort = CSSRect::FromAppUnits(dp); + metrics.SetDisplayPort(CSSRect::FromAppUnits(dp)); nsLayoutUtils::LogTestDataForPaint(aLayer->Manager(), scrollId, "displayport", - metrics.mDisplayPort); + metrics.GetDisplayPort()); } if (nsLayoutUtils::GetCriticalDisplayPort(content, &dp)) { metrics.mCriticalDisplayPort = CSSRect::FromAppUnits(dp);