Bug 1219020 - Don't do layer tree comparisons for inactive layer trees that have changed layers since we'll invalidate it all anyway. r=roc
☠☠ backed out by 4919782c4f87 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 03 Nov 2015 16:48:42 +1300
changeset 270906 de50fec5c3a621d48b9ff21b928f01388c6e646d
parent 270905 ad08ab3d158e4ffd408f5716cb5c07cbeb875921
child 270907 19e021ef5ba1fbac2ad7820be8e9089c5f855c67
push id18459
push usercbook@mozilla.com
push dateTue, 03 Nov 2015 11:14:32 +0000
treeherderb2g-inbound@09173d8e6694 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1219020
milestone45.0a1
Bug 1219020 - Don't do layer tree comparisons for inactive layer trees that have changed layers since we'll invalidate it all anyway. r=roc
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -4427,20 +4427,22 @@ FrameLayerBuilder::AddPaintedDisplayItem
 {
   PaintedLayer* layer = aLayerData->mLayer;
   PaintedDisplayItemLayerUserData* paintedData =
     static_cast<PaintedDisplayItemLayerUserData*>
       (layer->GetUserData(&gPaintedDisplayItemLayerUserData));
   RefPtr<BasicLayerManager> tempManager;
   nsIntRect intClip;
   bool hasClip = false;
+  bool havePreviousData = false;
   if (aLayerState != LAYER_NONE) {
     DisplayItemData *data = GetDisplayItemDataForManager(aItem, layer->Manager());
     if (data) {
       tempManager = data->mInactiveManager;
+      havePreviousData = !!data->mGeometry;
     }
     if (!tempManager) {
       tempManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE);
     }
 
     // We need to grab these before calling AddLayerDisplayItem because it will overwrite them.
     nsRegion clip;
     DisplayItemClip* oldClip = nullptr;
@@ -4469,17 +4471,23 @@ FrameLayerBuilder::AddPaintedDisplayItem
       FrameLayerBuilder* layerBuilder = new FrameLayerBuilder();
       layerBuilder->Init(mDisplayListBuilder, tempManager, aLayerData);
 
       tempManager->BeginTransaction();
       if (mRetainingManager) {
         layerBuilder->DidBeginRetainedLayerTransaction(tempManager);
       }
 
-      UniquePtr<LayerProperties> props(LayerProperties::CloneFrom(tempManager->GetRoot()));
+      // If we have previous data for this item, then we need to track changes
+      // to the layer tree and invalidate them. If we don't have any previous
+      // data then ComputeGeometryChangeForItem will invalidate the item's bounds.
+      UniquePtr<LayerProperties> props;
+      if (havePreviousData) {
+        props = LayerProperties::CloneFrom(tempManager->GetRoot());
+      }
       RefPtr<Layer> tmpLayer =
         aItem->BuildLayer(mDisplayListBuilder, tempManager, ContainerLayerParameters());
       // We have no easy way of detecting if this transaction will ever actually get finished.
       // For now, I've just silenced the warning with nested transactions in BasicLayers.cpp
       if (!tmpLayer) {
         tempManager->EndTransaction(nullptr, nullptr);
         tempManager->SetUserData(&gLayerManagerLayerBuilder, nullptr);
         return;
@@ -4512,39 +4520,41 @@ FrameLayerBuilder::AddPaintedDisplayItem
       if (gfxUtils::DumpDisplayList() || gfxEnv::DumpPaint()) {
         fprintf_stderr(gfxUtils::sDumpPaintFile, "Basic layer tree for painting contents of display item %s(%p):\n", aItem->Name(), aItem->Frame());
         std::stringstream stream;
         tempManager->Dump(stream, "", gfxEnv::DumpPaintToFile());
         fprint_stderr(gfxUtils::sDumpPaintFile, stream);  // not a typo, fprint_stderr declared in LayersLogging.h
       }
 #endif
 
-      nsIntPoint offset = GetLastPaintOffset(layer) - GetTranslationForPaintedLayer(layer);
-      props->MoveBy(-offset);
-      nsIntRegion invalid = props->ComputeDifferences(tmpLayer, nullptr);
-      if (aLayerState == LAYER_SVG_EFFECTS) {
-        invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects(aItem->Frame(),
-                                                                        aItem->ToReferenceFrame(),
-                                                                        invalid);
-      }
-      if (!invalid.IsEmpty()) {
+      if (props) {
+        nsIntPoint offset = GetLastPaintOffset(layer) - GetTranslationForPaintedLayer(layer);
+        props->MoveBy(-offset);
+        nsIntRegion invalid = props->ComputeDifferences(tmpLayer, nullptr);
+        if (aLayerState == LAYER_SVG_EFFECTS) {
+          invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects(aItem->Frame(),
+                                                                          aItem->ToReferenceFrame(),
+                                                                          invalid);
+        }
+        if (!invalid.IsEmpty()) {
 #ifdef MOZ_DUMP_PAINTING
-        if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
-          printf_stderr("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), layer);
-        }
+          if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
+             printf_stderr("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), layer);
+          }
 #endif
-        invalid.ScaleRoundOut(paintedData->mXScale, paintedData->mYScale);
-
-        if (hasClip) {
-          invalid.And(invalid, intClip);
+          invalid.ScaleRoundOut(paintedData->mXScale, paintedData->mYScale);
+
+          if (hasClip) {
+            invalid.And(invalid, intClip);
+          }
+
+          InvalidatePostTransformRegion(layer, invalid,
+                                        GetTranslationForPaintedLayer(layer),
+                                        paintedData);
         }
-
-        InvalidatePostTransformRegion(layer, invalid,
-                                      GetTranslationForPaintedLayer(layer),
-                                      paintedData);
       }
     }
     ClippedDisplayItem* cdi =
       entry->mItems.AppendElement(ClippedDisplayItem(aItem,
                                                      mContainerLayerGeneration));
     cdi->mInactiveLayerManager = tempManager;
   }
 }