Bug 1083635. Part 3: Flush displaylist dump before calling PaintRoot. r=mattwoodrow
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 21 Oct 2014 10:32:10 +1300
changeset 214030 7e996612b3b14f58f720deb3e5c44ee61b546b61
parent 214029 dc63a7b6f073a6e958d856d886a4d77a70d6c8de
child 214031 0af9b31d714c5776756f03bafcc2ee9742985903
push id27771
push userryanvm@gmail.com
push dateWed, 05 Nov 2014 19:04:24 +0000
treeherdermozilla-central@305b4fecce99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1083635
milestone36.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 1083635. Part 3: Flush displaylist dump before calling PaintRoot. r=mattwoodrow
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3061,34 +3061,39 @@ nsLayoutUtils::PaintFrame(nsRenderingCon
 
   if (builder.GetHadToIgnorePaintSuppression()) {
     willFlushRetainedLayers = true;
   }
 
 #ifdef MOZ_DUMP_PAINTING
   FILE* savedDumpFile = gfxUtils::sDumpPaintFile;
 
-  std::stringstream ss;
+  UniquePtr<std::stringstream> ss = MakeUnique<std::stringstream>();
   if (gfxUtils::DumpPaintList() || gfxUtils::sDumpPainting) {
     if (gfxUtils::sDumpPaintingToFile) {
       nsCString string("dump-");
       string.AppendInt(gPaintCount);
       string.AppendLiteral(".html");
       gfxUtils::sDumpPaintFile = fopen(string.BeginReading(), "w");
     } else {
       gfxUtils::sDumpPaintFile = stderr;
     }
     if (gfxUtils::sDumpPaintingToFile) {
-      ss << "<html><head><script>var array = {}; function ViewImage(index) { window.location = array[index]; }</script></head><body>";
-    }
-    ss << nsPrintfCString("Painting --- before optimization (dirty %d,%d,%d,%d):\n",
+      *ss << "<html><head><script>var array = {}; function ViewImage(index) { window.location = array[index]; }</script></head><body>";
+    }
+    *ss << nsPrintfCString("Painting --- before optimization (dirty %d,%d,%d,%d):\n",
             dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height).get();
-    nsFrame::PrintDisplayList(&builder, list, ss, gfxUtils::sDumpPaintingToFile);
+    nsFrame::PrintDisplayList(&builder, list, *ss, gfxUtils::sDumpPaintingToFile);
     if (gfxUtils::sDumpPaintingToFile) {
-      ss << "<script>";
+      *ss << "<script>";
+    } else {
+      // Flush stream now to avoid reordering dump output relative to
+      // messages dumped by PaintRoot below.
+      fprint_stderr(gfxUtils::sDumpPaintFile, *ss);
+      ss = MakeUnique<std::stringstream>();
     }
   }
 #endif
 
   uint32_t flags = nsDisplayList::PAINT_DEFAULT;
   if (aFlags & PAINT_WIDGET_LAYERS) {
     flags |= nsDisplayList::PAINT_USE_WIDGET_LAYERS;
     if (willFlushRetainedLayers) {
@@ -3119,35 +3124,35 @@ nsLayoutUtils::PaintFrame(nsRenderingCon
     flags |= nsDisplayList::PAINT_COMPRESSED;
   }
 
   list.PaintRoot(&builder, aRenderingContext, flags);
 
 #ifdef MOZ_DUMP_PAINTING
   if (gfxUtils::DumpPaintList() || gfxUtils::sDumpPainting) {
     if (gfxUtils::sDumpPaintingToFile) {
-      ss << "</script>";
-    }
-    ss << "Painting --- after optimization:\n";
-    nsFrame::PrintDisplayList(&builder, list, ss, gfxUtils::sDumpPaintingToFile);
-
-    ss << "Painting --- retained layer tree:\n";
+      *ss << "</script>";
+    }
+    *ss << "Painting --- after optimization:\n";
+    nsFrame::PrintDisplayList(&builder, list, *ss, gfxUtils::sDumpPaintingToFile);
+
+    *ss << "Painting --- retained layer tree:\n";
     nsIWidget* widget = aFrame->GetNearestWidget();
     if (widget) {
       nsRefPtr<LayerManager> layerManager = widget->GetLayerManager();
       if (layerManager) {
-        FrameLayerBuilder::DumpRetainedLayerTree(layerManager, ss,
+        FrameLayerBuilder::DumpRetainedLayerTree(layerManager, *ss,
                                                  gfxUtils::sDumpPaintingToFile);
       }
     }
     if (gfxUtils::sDumpPaintingToFile) {
-      ss << "</body></html>";
-    }
-
-    fprint_stderr(gfxUtils::sDumpPaintFile, ss);
+      *ss << "</body></html>";
+    }
+
+    fprint_stderr(gfxUtils::sDumpPaintFile, *ss);
 
     if (gfxUtils::sDumpPaintingToFile) {
       fclose(gfxUtils::sDumpPaintFile);
     }
     gfxUtils::sDumpPaintFile = savedDumpFile;
     gPaintCount++;
   }
 #endif