Bug 1318156 - Add an option to minimize empty area in PaintedLayers. r=mstange
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 24 Nov 2016 18:11:30 +1300
changeset 324158 426dd5fc9e8a8c02df9dc55e638c7dcdc4708332
parent 324157 c92c581e9de36dcaa7d8a818e5cd6b4b30c6bfb8
child 324159 d62a25f542531de9fb6e269a5c9a7fa39ad86c25
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmstange
bugs1318156
milestone53.0a1
Bug 1318156 - Add an option to minimize empty area in PaintedLayers. r=mstange
gfx/thebes/gfxPrefs.h
layout/painting/FrameLayerBuilder.cpp
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -533,16 +533,17 @@ private:
   DECL_GFX_PREF(Live, "layout.display-list.dump",              LayoutDumpDisplayList, bool, false);
   DECL_GFX_PREF(Live, "layout.display-list.dump-content",      LayoutDumpDisplayListContent, bool, false);
   DECL_GFX_PREF(Live, "layout.event-regions.enabled",          LayoutEventRegionsEnabledDoNotUseDirectly, bool, false);
   DECL_GFX_PREF(Once, "layout.frame_rate",                     LayoutFrameRate, int32_t, -1);
   DECL_GFX_PREF(Once, "layout.paint_rects_separately",         LayoutPaintRectsSeparately, bool, true);
 
   // This and code dependent on it should be removed once containerless scrolling looks stable.
   DECL_GFX_PREF(Once, "layout.scroll.root-frame-containers",   LayoutUseContainersForRootFrames, bool, true);
+  DECL_GFX_PREF(Live, "layout.smaller-painted-layers",         LayoutSmallerPaintedLayers, bool, false);
 
   DECL_GFX_PREF(Once, "media.hardware-video-decoding.force-enabled",
                                                                HardwareVideoDecodingForceEnabled, bool, false);
 #ifdef XP_WIN
   DECL_GFX_PREF(Live, "media.windows-media-foundation.allow-d3d11-dxva", PDMWMFAllowD3D11, bool, true);
   DECL_GFX_PREF(Live, "media.windows-media-foundation.max-dxva-videos", PDMWMFMaxDXVAVideos, uint32_t, 8);
   DECL_GFX_PREF(Live, "media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false);
   DECL_GFX_PREF(Live, "media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false);
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -2774,18 +2774,27 @@ PaintedLayerDataNode::FindPaintedLayerFo
       // will be hoisted out into their own layer.
       // For performance reasons, we check the intersection with the bounds
       // of the event-regions.
       if (!mTree.ContState().IsInInactiveLayer() &&
           (data.mScaledHitRegionBounds.Intersects(aVisibleRect) ||
            data.mScaledMaybeHitRegionBounds.Intersects(aVisibleRect))) {
         break;
       }
+      // If the visible region intersects with the current layer then we
+      // can't possibly use any of the layers below it, so stop the search
+      // now.
+      //
+      // If we're trying to minimize painted layer size and we don't
+      // intersect the current visible region, then make sure we don't
+      // use this painted layer.
       if (visibleRegion.Intersects(aVisibleRect)) {
         break;
+      } else if (gfxPrefs::LayoutSmallerPaintedLayers()) {
+        lowestUsableLayer = nullptr;
       }
     }
     if (lowestUsableLayer) {
       return lowestUsableLayer;
     }
   }
   return mPaintedLayerDataStack.AppendElement(aNewPaintedLayerCallback());
 }