Bug 775431 - Make MOZ_DUMP_PAINT_LIST output terminal-friendly. r=mattwoodrow

Only output in HTML if we're dumping to a file, otherwise output as it did
before the HTML output change was made.
This commit is contained in:
Chris Lord 2012-08-07 18:57:26 +01:00
parent 86ed7a66f6
commit e7e6823aa8
7 changed files with 96 additions and 49 deletions

View File

@ -871,17 +871,21 @@ void WriteSnapshotToDumpFile(LayerManager* aManager, gfxASurface* aSurf)
#endif
void
Layer::Dump(FILE* aFile, const char* aPrefix)
Layer::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
{
fprintf(aFile, "<li><a id=\"%p\" ", this);
if (aDumpHtml) {
fprintf(aFile, "<li><a id=\"%p\" ", this);
#ifdef MOZ_DUMP_PAINTING
if (GetType() == TYPE_CONTAINER || GetType() == TYPE_THEBES) {
WriteSnapshotLinkToDumpFile(this, aFile);
}
if (GetType() == TYPE_CONTAINER || GetType() == TYPE_THEBES) {
WriteSnapshotLinkToDumpFile(this, aFile);
}
#endif
fprintf(aFile, ">");
fprintf(aFile, ">");
}
DumpSelf(aFile, aPrefix);
fprintf(aFile, "</a>");
if (aDumpHtml) {
fprintf(aFile, "</a>");
}
if (Layer* mask = GetMaskLayer()) {
nsCAutoString pfx(aPrefix);
@ -892,14 +896,20 @@ Layer::Dump(FILE* aFile, const char* aPrefix)
if (Layer* kid = GetFirstChild()) {
nsCAutoString pfx(aPrefix);
pfx += " ";
fprintf(aFile, "<ul>");
if (aDumpHtml) {
fprintf(aFile, "<ul>");
}
kid->Dump(aFile, pfx.get());
fprintf(aFile, "</ul>");
if (aDumpHtml) {
fprintf(aFile, "</ul>");
}
}
fprintf(aFile, "</li>");
if (aDumpHtml) {
fprintf(aFile, "</li>");
}
if (Layer* next = GetNextSibling())
next->Dump(aFile, aPrefix);
next->Dump(aFile, aPrefix, aDumpHtml);
}
void
@ -1059,30 +1069,42 @@ ReadbackLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
// LayerManager
void
LayerManager::Dump(FILE* aFile, const char* aPrefix)
LayerManager::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
{
FILE* file = FILEOrDefault(aFile);
fprintf(file, "<ul><li><a ");
#ifdef MOZ_DUMP_PAINTING
WriteSnapshotLinkToDumpFile(this, file);
if (aDumpHtml) {
fprintf(file, "<ul><li><a ");
WriteSnapshotLinkToDumpFile(this, file);
fprintf(file, ">");
}
#endif
fprintf(file, ">");
DumpSelf(file, aPrefix);
#ifdef MOZ_DUMP_PAINTING
fprintf(file, "</a>");
if (aDumpHtml) {
fprintf(file, "</a>");
}
#endif
nsCAutoString pfx(aPrefix);
pfx += " ";
if (!GetRoot()) {
fprintf(file, "%s(null)</li></ul>", pfx.get());
fprintf(file, "%s(null)", pfx.get());
if (aDumpHtml) {
fprintf(file, "</li></ul>");
}
return;
}
fprintf(file, "<ul>");
GetRoot()->Dump(file, pfx.get());
fprintf(file, "</ul></li></ul>");
if (aDumpHtml) {
fprintf(file, "<ul>");
}
GetRoot()->Dump(file, pfx.get(), aDumpHtml);
if (aDumpHtml) {
fprintf(file, "</ul></li></ul>");
}
fputc('\n', file);
}
void
@ -1161,7 +1183,7 @@ PrintInfo(nsACString& aTo, ShadowLayer* aShadowLayer)
#else // !MOZ_LAYERS_HAVE_LOG
void Layer::Dump(FILE* aFile, const char* aPrefix) {}
void Layer::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml) {}
void Layer::DumpSelf(FILE* aFile, const char* aPrefix) {}
void Layer::Log(const char* aPrefix) {}
void Layer::LogSelf(const char* aPrefix) {}
@ -1197,7 +1219,7 @@ nsACString&
ReadbackLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
{ return aTo; }
void LayerManager::Dump(FILE* aFile, const char* aPrefix) {}
void LayerManager::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml) {}
void LayerManager::DumpSelf(FILE* aFile, const char* aPrefix) {}
void LayerManager::Log(const char* aPrefix) {}
void LayerManager::LogSelf(const char* aPrefix) {}

View File

@ -419,7 +419,7 @@ public:
* Dump information about this layer manager and its managed tree to
* aFile, which defaults to stderr.
*/
void Dump(FILE* aFile=NULL, const char* aPrefix="");
void Dump(FILE* aFile=NULL, const char* aPrefix="", bool aDumpHtml=false);
/**
* Dump information about just this layer manager itself to aFile,
* which defaults to stderr.
@ -880,7 +880,7 @@ public:
* Dump information about this layer manager and its managed tree to
* aFile, which defaults to stderr.
*/
void Dump(FILE* aFile=NULL, const char* aPrefix="");
void Dump(FILE* aFile=NULL, const char* aPrefix="", bool aDumpHtml=false);
/**
* Dump information about just this layer manager itself to aFile,
* which defaults to stderr.

View File

@ -2827,9 +2827,9 @@ FrameLayerBuilder::CheckDOMModified()
#ifdef MOZ_DUMP_PAINTING
/* static */ void
FrameLayerBuilder::DumpRetainedLayerTree(LayerManager* aManager, FILE* aFile)
FrameLayerBuilder::DumpRetainedLayerTree(LayerManager* aManager, FILE* aFile, bool aDumpHtml)
{
aManager->Dump(aFile);
aManager->Dump(aFile, "", aDumpHtml);
}
#endif

View File

@ -285,9 +285,9 @@ public:
#ifdef MOZ_DUMP_PAINTING
/**
* Dumps this FrameLayerBuilder's retained layer manager's retained
* layer tree to stderr.
* layer tree. Defaults to dumping to stdout in non-HTML format.
*/
static void DumpRetainedLayerTree(LayerManager* aManager, FILE* aFile = stdout);
static void DumpRetainedLayerTree(LayerManager* aManager, FILE* aFile = stdout, bool aDumpHtml = false);
#endif
/******* PRIVATE METHODS to FrameLayerBuilder.cpp ********/

View File

@ -119,18 +119,26 @@ nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
#endif
#ifdef MOZ_DUMP_PAINTING
static int sPrintDisplayListIndent = 0;
static void
PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
FILE* aOutput)
FILE* aOutput, bool aDumpHtml)
{
fprintf(aOutput, "<ul>");
if (aDumpHtml) {
fprintf(aOutput, "<ul>");
}
for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
#ifdef DEBUG
if (aList.DidComputeVisibility() && i->GetVisibleRect().IsEmpty())
continue;
#endif
fprintf(aOutput, "<li>");
if (aDumpHtml) {
fprintf(aOutput, "<li>");
} else {
sPrintDisplayListIndent ++;
}
nsIFrame* f = i->GetUnderlyingFrame();
nsAutoString fName;
#ifdef DEBUG
@ -164,7 +172,7 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
opaque = i->GetOpaqueRegion(aBuilder, &snap);
}
#endif
if (i->Painted()) {
if (aDumpHtml && i->Painted()) {
nsCString string(i->Name());
string.Append("-");
string.AppendInt((PRUint64)i);
@ -179,15 +187,19 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
nsRegionRectIterator iter(opaque);
for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
printf("(opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
}
if (i->Painted()) {
}
if (aDumpHtml && i->Painted()) {
fprintf(aOutput, "</a>");
}
if (f) {
PRUint32 key = i->GetPerFrameKey();
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
if (layer) {
fprintf(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
if (aDumpHtml) {
fprintf(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
} else {
fprintf(aOutput, " layer=%p", layer);
}
}
}
if (i->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
@ -195,20 +207,27 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
}
fputc('\n', aOutput);
if (list) {
PrintDisplayListTo(aBuilder, *list, aOutput);
PrintDisplayListTo(aBuilder, *list, aOutput, aDumpHtml);
}
if (aDumpHtml) {
fprintf(aOutput, "</li>");
} else {
sPrintDisplayListIndent --;
}
fprintf(aOutput, "</li>");
}
fprintf(aOutput, "</ul>");
if (aDumpHtml) {
fprintf(aOutput, "</ul>");
}
}
void
nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayList& aList,
FILE* aFile)
FILE* aFile,
bool aDumpHtml)
{
PrintDisplayListTo(aBuilder, aList, aFile);
PrintDisplayListTo(aBuilder, aList, aFile, aDumpHtml);
}
#endif

View File

@ -1819,10 +1819,12 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
} else {
gfxUtils::sDumpPaintFile = stdout;
}
fprintf(gfxUtils::sDumpPaintFile, "<html><head><script>var array = {}; function ViewImage(index) { window.location = array[index]; }</script></head><body>");
if (gfxUtils::sDumpPaintingToFile) {
fprintf(gfxUtils::sDumpPaintFile, "<html><head><script>var array = {}; function ViewImage(index) { window.location = array[index]; }</script></head><body>");
}
fprintf(gfxUtils::sDumpPaintFile, "Painting --- before optimization (dirty %d,%d,%d,%d):\n",
dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
nsFrame::PrintDisplayList(&builder, list, gfxUtils::sDumpPaintFile);
nsFrame::PrintDisplayList(&builder, list, gfxUtils::sDumpPaintFile, gfxUtils::sDumpPaintingToFile);
if (gfxUtils::sDumpPaintingToFile) {
fprintf(gfxUtils::sDumpPaintFile, "<script>");
}
@ -1875,20 +1877,23 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintList || gfxUtils::sDumpPainting) {
fprintf(gfxUtils::sDumpPaintFile, "</script>Painting --- after optimization:\n");
nsFrame::PrintDisplayList(&builder, list, gfxUtils::sDumpPaintFile);
if (gfxUtils::sDumpPaintingToFile) {
fprintf(gfxUtils::sDumpPaintFile, "</script>");
}
fprintf(gfxUtils::sDumpPaintFile, "Painting --- after optimization:\n");
nsFrame::PrintDisplayList(&builder, list, gfxUtils::sDumpPaintFile, gfxUtils::sDumpPaintingToFile);
fprintf(gfxUtils::sDumpPaintFile, "Painting --- retained layer tree:\n");
nsIWidget* widget = aFrame->GetNearestWidget();
if (widget) {
nsRefPtr<LayerManager> layerManager = widget->GetLayerManager();
if (layerManager) {
FrameLayerBuilder::DumpRetainedLayerTree(layerManager, gfxUtils::sDumpPaintFile);
FrameLayerBuilder::DumpRetainedLayerTree(layerManager, gfxUtils::sDumpPaintFile,
gfxUtils::sDumpPaintingToFile);
}
}
fprintf(gfxUtils::sDumpPaintFile, "</body></html>");
if (gfxUtils::sDumpPaintingToFile) {
fprintf(gfxUtils::sDumpPaintFile, "</body></html>");
fclose(gfxUtils::sDumpPaintFile);
}
gfxUtils::sDumpPaintFile = NULL;

View File

@ -707,7 +707,8 @@ public:
static void PrintDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayList& aList,
FILE* aFile = stdout);
FILE* aFile = stdout,
bool aDumpHtml = false);
#endif
};