Bug 1521644 - In containerless mode, move handling of pres shell resolution from nsDisplayResolution to nsDisplayAsyncZoom. r=mstange
authorBotond Ballo <botond@mozilla.com>
Fri, 01 Feb 2019 18:30:50 +0000
changeset 456494 998c765c5a968fc8974a3a95028fdbaf1eb3cd02
parent 456493 50ed1bfe7f5ae5bd0edf65eeadbb6165845442fc
child 456495 3ba052addf07b21c78fafad0f2ae5e6f65f09bcd
push id111656
push userdvarga@mozilla.com
push dateSat, 02 Feb 2019 09:51:54 +0000
treeherdermozilla-inbound@d8cebb3b46cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1521644
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521644 - In containerless mode, move handling of pres shell resolution from nsDisplayResolution to nsDisplayAsyncZoom. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D17171
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2466,18 +2466,21 @@ FrameLayerBuilder* nsDisplayList::BuildL
 
     // Clear any ScrollMetadata that may have been set on the root layer on a
     // previous paint. This paint will set new metrics if necessary, and if we
     // don't clear the old one here, we may be left with extra metrics.
     if (Layer* rootLayer = aLayerManager->GetRoot()) {
       rootLayer->SetScrollMetadata(nsTArray<ScrollMetadata>());
     }
 
-    ContainerLayerParameters containerParameters(presShell->GetResolution(),
-                                                 presShell->GetResolution());
+    float rootLayerResolution = gfxPrefs::LayoutUseContainersForRootFrames()
+                                    ? presShell->GetResolution()
+                                    : 1.0f;
+    ContainerLayerParameters containerParameters(rootLayerResolution,
+                                                 rootLayerResolution);
 
     {
       PaintTelemetry::AutoRecord record(PaintTelemetry::Metric::Layerization);
 
       root = layerBuilder->BuildContainerLayerFor(aBuilder, aLayerManager,
                                                   frame, nullptr, this,
                                                   containerParameters, nullptr);
 
@@ -2487,20 +2490,22 @@ FrameLayerBuilder* nsDisplayList::BuildL
           pt->flbMs() = (TimeStamp::Now() - record.GetStart()).ToMilliseconds();
         }
       }
     }
 
     if (!root) {
       return nullptr;
     }
-    // Root is being scaled up by the X/Y resolution. Scale it back down.
-    root->SetPostScale(1.0f / containerParameters.mXScale,
-                       1.0f / containerParameters.mYScale);
-    root->SetScaleToResolution(containerParameters.mXScale);
+    if (gfxPrefs::LayoutUseContainersForRootFrames()) {
+      // Root is being scaled up by the X/Y resolution. Scale it back down.
+      root->SetPostScale(1.0f / containerParameters.mXScale,
+                         1.0f / containerParameters.mYScale);
+      root->SetScaleToResolution(containerParameters.mXScale);
+    }
 
     auto callback = [root](ScrollableLayerGuid::ViewID aScrollId) -> bool {
       return nsLayoutUtils::ContainsMetricsWithId(root, aScrollId);
     };
     if (Maybe<ScrollMetadata> rootMetadata = nsLayoutUtils::GetRootMetadata(
             aBuilder, root->Manager(), containerParameters, callback)) {
       root->SetScrollMetadata(rootMetadata.value());
     }
@@ -6568,25 +6573,32 @@ void nsDisplayResolution::HitTest(nsDisp
   nsRect rect = aRect.RemoveResolution(presShell->GetResolution());
   mList.HitTest(aBuilder, rect, aState, aOutFrames);
 }
 
 already_AddRefed<Layer> nsDisplayResolution::BuildLayer(
     nsDisplayListBuilder* aBuilder, LayerManager* aManager,
     const ContainerLayerParameters& aContainerParameters) {
   nsIPresShell* presShell = mFrame->PresShell();
+  float rootLayerResolution = gfxPrefs::LayoutUseContainersForRootFrames()
+                                  ? presShell->GetResolution()
+                                  : 1.0f;
   ContainerLayerParameters containerParameters(
-      presShell->GetResolution(), presShell->GetResolution(), nsIntPoint(),
+      rootLayerResolution, rootLayerResolution, nsIntPoint(),
       aContainerParameters);
 
   RefPtr<Layer> layer =
       nsDisplaySubDocument::BuildLayer(aBuilder, aManager, containerParameters);
-  layer->SetPostScale(1.0f / presShell->GetResolution(),
-                      1.0f / presShell->GetResolution());
-  layer->AsContainerLayer()->SetScaleToResolution(presShell->GetResolution());
+
+  if (gfxPrefs::LayoutUseContainersForRootFrames()) {
+    layer->SetPostScale(1.0f / presShell->GetResolution(),
+                        1.0f / presShell->GetResolution());
+    layer->AsContainerLayer()->SetScaleToResolution(presShell->GetResolution());
+  }
+
   return layer.forget();
 }
 
 nsDisplayFixedPosition::nsDisplayFixedPosition(
     nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList,
     const ActiveScrolledRoot* aActiveScrolledRoot,
     const ActiveScrolledRoot* aContainerASR)
     : nsDisplayOwnLayer(aBuilder, aFrame, aList, aActiveScrolledRoot),
@@ -7169,21 +7181,30 @@ nsDisplayAsyncZoom::nsDisplayAsyncZoom(
 nsDisplayAsyncZoom::~nsDisplayAsyncZoom() {
   MOZ_COUNT_DTOR(nsDisplayAsyncZoom);
 }
 #endif
 
 already_AddRefed<Layer> nsDisplayAsyncZoom::BuildLayer(
     nsDisplayListBuilder* aBuilder, LayerManager* aManager,
     const ContainerLayerParameters& aContainerParameters) {
+  nsIPresShell* presShell = mFrame->PresShell();
+  ContainerLayerParameters containerParameters(
+      presShell->GetResolution(), presShell->GetResolution(), nsIntPoint(),
+      aContainerParameters);
+
   RefPtr<Layer> layer =
-      nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, aContainerParameters);
+      nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, containerParameters);
 
   layer->SetIsAsyncZoomContainer(Some(mViewID));
 
+  layer->SetPostScale(1.0f / presShell->GetResolution(),
+                      1.0f / presShell->GetResolution());
+  layer->AsContainerLayer()->SetScaleToResolution(presShell->GetResolution());
+
   return layer.forget();
 }
 
 ///////////////////////////////////////////////////
 // nsDisplayTransform Implementation
 //
 
 // Write #define UNIFIED_CONTINUATIONS here and in