Bug 913443 - Extract layer hint calculation. r=roc
authorMarkus Stange <mstange@themasta.com>
Mon, 02 Mar 2015 19:24:18 -0500
changeset 231931 cfed9e01504d8a1a2cf02db2271b94d5a140dc18
parent 231930 add34200e05c612b6c9cf0142b5e73d0aa278325
child 231932 396bfdd497cdf18095424236b1a811c14b18229f
push id28364
push usercbook@mozilla.com
push dateThu, 05 Mar 2015 14:12:01 +0000
treeherdermozilla-central@fa59461863f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs913443
milestone39.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 913443 - Extract layer hint calculation. r=roc
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -693,16 +693,19 @@ public:
   void AddHoistedItem(nsDisplayItem* aItem)
   {
     mHoistedItems.AppendToTop(aItem);
   }
 
 protected:
   friend class PaintedLayerData;
 
+  LayerManager::PaintedLayerCreationHint
+    GetLayerCreationHint(const nsIFrame* aAnimatedGeometryRoot);
+
   /**
    * Grab the next recyclable PaintedLayer, or create one if there are no
    * more recyclable PaintedLayers. Does any necessary invalidation of
    * a recycled PaintedLayer, and sets up the transform on the PaintedLayer
    * to account for scrolling.
    */
   already_AddRefed<PaintedLayer> CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoot,
                                                              const nsIFrame *aReferenceFrame,
@@ -1676,38 +1679,47 @@ InvalidateEntirePaintedLayer(PaintedLaye
   }
 #endif
   nsIntRect invalidate = aLayer->GetValidRegion().GetBounds();
   aLayer->InvalidateRegion(invalidate);
   aLayer->SetInvalidRectToVisibleRegion();
   ResetScrollPositionForLayerPixelAlignment(aAnimatedGeometryRoot);
 }
 
+LayerManager::PaintedLayerCreationHint
+ContainerState::GetLayerCreationHint(const nsIFrame* aAnimatedGeometryRoot)
+{
+  // Check whether the layer will be scrollable. This is used as a hint to
+  // influence whether tiled layers are used or not.
+  if (mParameters.mInLowPrecisionDisplayPort) {
+    return LayerManager::SCROLLABLE;
+  }
+  nsIFrame* animatedGeometryRootParent = aAnimatedGeometryRoot->GetParent();
+  if (animatedGeometryRootParent &&
+      animatedGeometryRootParent->GetType() == nsGkAtoms::scrollFrame) {
+    return LayerManager::SCROLLABLE;
+  }
+  return LayerManager::NONE;
+}
+
 already_AddRefed<PaintedLayer>
 ContainerState::CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoot,
                                             const nsIFrame* aReferenceFrame,
                                             const nsPoint& aTopLeft)
 {
   // We need a new painted layer
   nsRefPtr<PaintedLayer> layer;
   PaintedDisplayItemLayerUserData* data;
   bool layerRecycled = false;
   bool didResetScrollPositionForLayerPixelAlignment = false;
 
   // Check whether the layer will be scrollable. This is used as a hint to
   // influence whether tiled layers are used or not.
-  LayerManager::PaintedLayerCreationHint creationHint = LayerManager::NONE;
-  if (mParameters.mInLowPrecisionDisplayPort ) {
-    creationHint = LayerManager::SCROLLABLE;
-  }
-  nsIFrame* animatedGeometryRootParent = aAnimatedGeometryRoot->GetParent();
-  if (animatedGeometryRootParent &&
-      animatedGeometryRootParent->GetType() == nsGkAtoms::scrollFrame) {
-    creationHint = LayerManager::SCROLLABLE;
-  }
+  LayerManager::PaintedLayerCreationHint creationHint =
+    GetLayerCreationHint(aAnimatedGeometryRoot);
 
   if (mNextFreeRecycledPaintedLayer < mRecycledPaintedLayers.Length()) {
     // Try to recycle a layer
     layer = mRecycledPaintedLayers[mNextFreeRecycledPaintedLayer];
     ++mNextFreeRecycledPaintedLayer;
 
     // Check if the layer hint has changed and whether or not the layer should
     // be recreated because of it.