Bug 942483 - Port paint-dumping to android/b2g. r=gal

This commit is contained in:
Benoit Girard 2013-11-23 17:44:18 -05:00
parent e97d6701d0
commit f8fd653be7
15 changed files with 156 additions and 134 deletions

View File

@ -1139,7 +1139,7 @@ void WriteSnapshotLinkToDumpFile(T* aObj, FILE* aFile)
nsCString string(aObj->Name());
string.Append("-");
string.AppendInt((uint64_t)aObj);
fprintf(aFile, "href=\"javascript:ViewImage('%s')\"", string.BeginReading());
fprintf_stderr(aFile, "href=\"javascript:ViewImage('%s')\"", string.BeginReading());
}
template <typename T>
@ -1148,11 +1148,13 @@ void WriteSnapshotToDumpFile_internal(T* aObj, gfxASurface* aSurf)
nsCString string(aObj->Name());
string.Append("-");
string.AppendInt((uint64_t)aObj);
if (gfxUtils::sDumpPaintFile)
fprintf(gfxUtils::sDumpPaintFile, "array[\"%s\"]=\"", string.BeginReading());
if (gfxUtils::sDumpPaintFile) {
fprintf_stderr(gfxUtils::sDumpPaintFile, "array[\"%s\"]=\"", string.BeginReading());
}
aSurf->DumpAsDataURL(gfxUtils::sDumpPaintFile);
if (gfxUtils::sDumpPaintFile)
fprintf(gfxUtils::sDumpPaintFile, "\";");
if (gfxUtils::sDumpPaintFile) {
fprintf_stderr(gfxUtils::sDumpPaintFile, "\";");
}
}
void WriteSnapshotToDumpFile(Layer* aLayer, gfxASurface* aSurf)
@ -1176,13 +1178,13 @@ void
Layer::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
{
if (aDumpHtml) {
fprintf(aFile, "<li><a id=\"%p\" ", this);
fprintf_stderr(aFile, "<li><a id=\"%p\" ", this);
#ifdef MOZ_DUMP_PAINTING
if (GetType() == TYPE_CONTAINER || GetType() == TYPE_THEBES) {
WriteSnapshotLinkToDumpFile(this, aFile);
}
#endif
fprintf(aFile, ">");
fprintf_stderr(aFile, ">");
}
DumpSelf(aFile, aPrefix);
@ -1193,7 +1195,7 @@ Layer::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
#endif
if (aDumpHtml) {
fprintf(aFile, "</a>");
fprintf_stderr(aFile, "</a>");
}
if (Layer* mask = GetMaskLayer()) {
@ -1206,16 +1208,16 @@ Layer::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
nsAutoCString pfx(aPrefix);
pfx += " ";
if (aDumpHtml) {
fprintf(aFile, "<ul>");
fprintf_stderr(aFile, "<ul>");
}
kid->Dump(aFile, pfx.get(), aDumpHtml);
if (aDumpHtml) {
fprintf(aFile, "</ul>");
fprintf_stderr(aFile, "</ul>");
}
}
if (aDumpHtml) {
fprintf(aFile, "</li>");
fprintf_stderr(aFile, "</li>");
}
if (Layer* next = GetNextSibling())
next->Dump(aFile, aPrefix, aDumpHtml);
@ -1226,11 +1228,7 @@ Layer::DumpSelf(FILE* aFile, const char* aPrefix)
{
nsAutoCString str;
PrintInfo(str, aPrefix);
if (!aFile || aFile == stderr) {
printf_stderr("%s\n", str.get());
} else {
fprintf(aFile, "%s\n", str.get());
}
fprintf_stderr(aFile, "%s\n", str.get());
}
void
@ -1407,34 +1405,34 @@ LayerManager::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml)
#ifdef MOZ_DUMP_PAINTING
if (aDumpHtml) {
fprintf(file, "<ul><li><a ");
fprintf_stderr(file, "<ul><li><a ");
WriteSnapshotLinkToDumpFile(this, file);
fprintf(file, ">");
fprintf_stderr(file, ">");
}
#endif
DumpSelf(file, aPrefix);
#ifdef MOZ_DUMP_PAINTING
if (aDumpHtml) {
fprintf(file, "</a>");
fprintf_stderr(file, "</a>");
}
#endif
nsAutoCString pfx(aPrefix);
pfx += " ";
if (!GetRoot()) {
fprintf(file, "%s(null)", pfx.get());
fprintf_stderr(file, "%s(null)", pfx.get());
if (aDumpHtml) {
fprintf(file, "</li></ul>");
fprintf_stderr(file, "</li></ul>");
}
return;
}
if (aDumpHtml) {
fprintf(file, "<ul>");
fprintf_stderr(file, "<ul>");
}
GetRoot()->Dump(file, pfx.get(), aDumpHtml);
if (aDumpHtml) {
fprintf(file, "</ul></li></ul>");
fprintf_stderr(file, "</ul></li></ul>");
}
fputc('\n', file);
}
@ -1444,7 +1442,7 @@ LayerManager::DumpSelf(FILE* aFile, const char* aPrefix)
{
nsAutoCString str;
PrintInfo(str, aPrefix);
fprintf(FILEOrDefault(aFile), "%s\n", str.get());
fprintf_stderr(FILEOrDefault(aFile), "%s\n", str.get());
}
void

View File

@ -260,20 +260,20 @@ ContentHostBase::Dump(FILE* aFile,
if (!aFile) {
aFile = stderr;
}
fprintf(aFile, "<ul>");
fprintf_stderr(aFile, "<ul>");
if (mDeprecatedTextureHost) {
fprintf(aFile, "%s", aPrefix);
fprintf(aFile, "<li> <a href=");
fprintf_stderr(aFile, "%s", aPrefix);
fprintf_stderr(aFile, "<li> <a href=");
DumpDeprecatedTextureHost(aFile, mDeprecatedTextureHost);
fprintf(aFile, "> Front buffer </a></li> ");
fprintf_stderr(aFile, "> Front buffer </a></li> ");
}
if (mDeprecatedTextureHostOnWhite) {
fprintf(aFile, "%s", aPrefix);
fprintf(aFile, "<li> <a href=");
fprintf_stderr(aFile, "%s", aPrefix);
fprintf_stderr(aFile, "<li> <a href=");
DumpDeprecatedTextureHost(aFile, mDeprecatedTextureHostOnWhite);
fprintf(aFile, "> Front buffer on white </a> </li> ");
fprintf_stderr(aFile, "> Front buffer on white </a> </li> ");
}
fprintf(aFile, "</ul>");
fprintf_stderr(aFile, "</ul>");
}
#endif
@ -816,20 +816,20 @@ ContentHostDoubleBuffered::Dump(FILE* aFile,
if (!aFile) {
aFile = stderr;
}
fprintf(aFile, "<ul>");
fprintf_stderr(aFile, "<ul>");
if (mBackHost) {
fprintf(aFile, "%s", aPrefix);
fprintf(aFile, "<li> <a href=");
fprintf_stderr(aFile, "%s", aPrefix);
fprintf_stderr(aFile, "<li> <a href=");
DumpDeprecatedTextureHost(aFile, mBackHost);
fprintf(aFile, " >Back buffer</a></li>");
fprintf_stderr(aFile, " >Back buffer</a></li>");
}
if (mBackHostOnWhite) {
fprintf(aFile, "%s", aPrefix);
fprintf(aFile, "<li> <a href=");
fprintf_stderr(aFile, "%s", aPrefix);
fprintf_stderr(aFile, "<li> <a href=");
DumpDeprecatedTextureHost(aFile, mBackHostOnWhite);
fprintf(aFile, " >Back buffer on white</a> </li>");
fprintf_stderr(aFile, " >Back buffer on white</a> </li>");
}
fprintf(aFile, "</ul>");
fprintf_stderr(aFile, "</ul>");
}
#endif

View File

@ -181,11 +181,11 @@ ImageHost::Dump(FILE* aFile,
aFile = stderr;
}
if (mFrontBuffer) {
fprintf(aFile, "%s", aPrefix);
fprintf(aFile, aDumpHtml ? "<ul><li>TextureHost: "
fprintf_stderr(aFile, "%s", aPrefix);
fprintf_stderr(aFile, aDumpHtml ? "<ul><li>TextureHost: "
: "TextureHost: ");
DumpTextureHost(aFile, mFrontBuffer);
fprintf(aFile, aDumpHtml ? " </li></ul> " : " ");
fprintf_stderr(aFile, aDumpHtml ? " </li></ul> " : " ");
}
}
#endif
@ -391,11 +391,11 @@ DeprecatedImageHostSingle::Dump(FILE* aFile,
aFile = stderr;
}
if (mDeprecatedTextureHost) {
fprintf(aFile, "%s", aPrefix);
fprintf(aFile, aDumpHtml ? "<ul><li>DeprecatedTextureHost: "
fprintf_stderr(aFile, "%s", aPrefix);
fprintf_stderr(aFile, aDumpHtml ? "<ul><li>DeprecatedTextureHost: "
: "DeprecatedTextureHost: ");
DumpDeprecatedTextureHost(aFile, mDeprecatedTextureHost);
fprintf(aFile, aDumpHtml ? " </li></ul> " : " ");
fprintf_stderr(aFile, aDumpHtml ? " </li></ul> " : " ");
}
}

View File

@ -331,16 +331,16 @@ TiledContentHost::Dump(FILE* aFile,
TiledLayerBufferComposite::Iterator it = mVideoMemoryTiledBuffer.TilesBegin();
TiledLayerBufferComposite::Iterator stop = mVideoMemoryTiledBuffer.TilesEnd();
if (aDumpHtml) {
fprintf(aFile, "<ul>");
fprintf_stderr(aFile, "<ul>");
}
for (;it != stop; ++it) {
fprintf(aFile, "%s", aPrefix);
fprintf(aFile, aDumpHtml ? "<li> <a href=" : "Tile ");
fprintf_stderr(aFile, "%s", aPrefix);
fprintf_stderr(aFile, aDumpHtml ? "<li> <a href=" : "Tile ");
DumpDeprecatedTextureHost(aFile, it->mDeprecatedTextureHost);
fprintf(aFile, aDumpHtml ? " >Tile</a></li>" : " ");
fprintf_stderr(aFile, aDumpHtml ? " >Tile</a></li>" : " ");
}
if (aDumpHtml) {
fprintf(aFile, "</ul>");
fprintf_stderr(aFile, "</ul>");
}
}
#endif

View File

@ -554,8 +554,8 @@ CompositorParent::CompositeInTransaction()
#ifdef MOZ_DUMP_PAINTING
static bool gDumpCompositorTree = false;
if (gDumpCompositorTree) {
fprintf(stdout, "Painting --- compositing layer tree:\n");
mLayerManager->Dump(stdout, "", false);
printf_stderr("Painting --- compositing layer tree:\n");
mLayerManager->Dump();
}
#endif
mLayerManager->EndEmptyTransaction();

View File

@ -6,10 +6,6 @@
#ifndef GFX_ASURFACE_H
#define GFX_ASURFACE_H
#ifdef MOZ_DUMP_PAINTING
#define MOZ_DUMP_IMAGES
#endif
#include "mozilla/MemoryReporting.h"
#include "gfxTypes.h"
#include "mozilla/Scoped.h"

View File

@ -180,7 +180,7 @@ public:
#ifdef DEBUG_DISPLAY_ITEM_DATA
void Dump(const char *aPrefix = "") {
printf("%sLayerManagerData %p\n", aPrefix, this);
printf_stderr("%sLayerManagerData %p\n", aPrefix, this);
nsAutoCString prefix;
prefix += aPrefix;
prefix += " ";
@ -899,7 +899,7 @@ InvalidatePostTransformRegion(ThebesLayer* aLayer, const nsIntRegion& aRegion,
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
nsAutoCString str;
AppendToString(str, rgn);
printf("Invalidating layer %p: %s\n", aLayer, str.get());
printf_stderr("Invalidating layer %p: %s\n", aLayer, str.get());
}
#endif
}
@ -967,7 +967,7 @@ FrameLayerBuilder::RemoveFrameFromLayerManager(nsIFrame* aFrame,
while (rootData->mParent) {
rootData = rootData->mParent;
}
printf("Removing frame %p - dumping display data\n", aFrame);
printf_stderr("Removing frame %p - dumping display data\n", aFrame);
rootData->Dump();
}
#endif
@ -1057,7 +1057,7 @@ FrameLayerBuilder::ProcessRemovedDisplayItems(nsRefPtrHashKey<DisplayItemData>*
if (t) {
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Invalidating unused display item (%i) belonging to frame %p from layer %p\n", data->mDisplayItemKey, data->mFrameList[0], t);
printf_stderr("Invalidating unused display item (%i) belonging to frame %p from layer %p\n", data->mDisplayItemKey, data->mFrameList[0], t);
}
#endif
InvalidatePostTransformRegion(t,
@ -1116,11 +1116,11 @@ FrameLayerBuilder::DumpDisplayItemDataForFrame(nsRefPtrHashKey<DisplayItemData>*
}
str += "\n";
printf("%s", str.get());
printf_stderr("%s", str.get());
if (data->mInactiveManager) {
prefix += " ";
printf("%sDumping inactive layer info:\n", prefix.get());
printf_stderr("%sDumping inactive layer info:\n", prefix.get());
LayerManagerData* lmd = static_cast<LayerManagerData*>
(data->mInactiveManager->GetUserData(&gLayerManagerUserData));
lmd->Dump(prefix.get());
@ -1352,7 +1352,7 @@ InvalidateEntireThebesLayer(ThebesLayer* aLayer, const nsIFrame* aAnimatedGeomet
{
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Invalidating entire layer %p\n", aLayer);
printf_stderr("Invalidating entire layer %p\n", aLayer);
}
#endif
nsIntRect invalidate = aLayer->GetValidRegion().GetBounds();
@ -1402,7 +1402,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot
if (!data->mRegionToInvalidate.IsEmpty()) {
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Invalidating deleted frame content from layer %p\n", layer.get());
printf_stderr("Invalidating deleted frame content from layer %p\n", layer.get());
}
#endif
layer->InvalidateRegion(data->mRegionToInvalidate);
@ -1410,7 +1410,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
nsAutoCString str;
AppendToString(str, data->mRegionToInvalidate);
printf("Invalidating layer %p: %s\n", layer.get(), str.get());
printf_stderr("Invalidating layer %p: %s\n", layer.get(), str.get());
}
#endif
data->mRegionToInvalidate.SetEmpty();
@ -2053,9 +2053,9 @@ DumpPaintedImage(nsDisplayItem* aItem, gfxASurface* aSurf)
nsCString string(aItem->Name());
string.Append("-");
string.AppendInt((uint64_t)aItem);
fprintf(gfxUtils::sDumpPaintFile, "array[\"%s\"]=\"", string.BeginReading());
fprintf_stderr(gfxUtils::sDumpPaintFile, "array[\"%s\"]=\"", string.BeginReading());
aSurf->DumpAsDataURL(gfxUtils::sDumpPaintFile);
fprintf(gfxUtils::sDumpPaintFile, "\";");
fprintf_stderr(gfxUtils::sDumpPaintFile, "\";");
}
#endif
@ -2396,7 +2396,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
// or a new scale here
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Display item type %s(%p) changed layers %p to %p!\n", aItem->Name(), aItem->Frame(), t, aNewLayer);
printf_stderr("Display item type %s(%p) changed layers %p to %p!\n", aItem->Name(), aItem->Frame(), t, aNewLayer);
}
#endif
InvalidatePostTransformRegion(t,
@ -2439,7 +2439,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
combined = aClip.ApplyNonRoundedIntersection(aGeometry->ComputeInvalidationRegion());
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Display item type %s(%p) added to layer %p!\n", aItem->Name(), aItem->Frame(), aNewLayer);
printf_stderr("Display item type %s(%p) added to layer %p!\n", aItem->Name(), aItem->Frame(), aNewLayer);
}
#endif
} else if (isInvalid || (aItem->IsInvalid(invalid) && invalid.IsEmpty())) {
@ -2449,7 +2449,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
combined.Or(combined, aClip.ApplyNonRoundedIntersection(aGeometry->ComputeInvalidationRegion()));
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Display item type %s(%p) (in layer %p) belongs to an invalidated frame!\n", aItem->Name(), aItem->Frame(), aNewLayer);
printf_stderr("Display item type %s(%p) (in layer %p) belongs to an invalidated frame!\n", aItem->Name(), aItem->Frame(), aNewLayer);
}
#endif
} else {
@ -2476,7 +2476,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem,
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
if (!combined.IsEmpty()) {
printf("Display item type %s(%p) (in layer %p) changed geometry!\n", aItem->Name(), aItem->Frame(), aNewLayer);
printf_stderr("Display item type %s(%p) (in layer %p) changed geometry!\n", aItem->Name(), aItem->Frame(), aNewLayer);
}
}
#endif
@ -2583,7 +2583,7 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayer* aLayer,
if (!invalid.IsEmpty()) {
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), aLayer);
printf_stderr("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), aLayer);
}
#endif
if (hasClip) {

View File

@ -2234,7 +2234,7 @@ nsDisplayThemedBackground::~nsDisplayThemedBackground()
void
nsDisplayThemedBackground::WriteDebugInfo(FILE *aOutput)
{
fprintf(aOutput, "(themed, appearance:%d) ", mAppearance);
fprintf_stderr(aOutput, "(themed, appearance:%d) ", mAppearance);
}
#endif
@ -4713,32 +4713,32 @@ nsDisplaySVGEffects::PrintEffects(FILE* aOutput)
bool isOK = true;
nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame(&isOK);
bool first = true;
fprintf(aOutput, " effects=(");
fprintf_stderr(aOutput, " effects=(");
if (mFrame->StyleDisplay()->mOpacity != 1.0f) {
first = false;
fprintf(aOutput, "opacity(%f)", mFrame->StyleDisplay()->mOpacity);
fprintf_stderr(aOutput, "opacity(%f)", mFrame->StyleDisplay()->mOpacity);
}
if (clipPathFrame) {
if (!first) {
fprintf(aOutput, ", ");
fprintf_stderr(aOutput, ", ");
}
fprintf(aOutput, "clip(%s)", clipPathFrame->IsTrivial() ? "trivial" : "non-trivial");
fprintf_stderr(aOutput, "clip(%s)", clipPathFrame->IsTrivial() ? "trivial" : "non-trivial");
first = false;
}
if (effectProperties.GetFilterFrame(&isOK)) {
if (!first) {
fprintf(aOutput, ", ");
fprintf_stderr(aOutput, ", ");
}
fprintf(aOutput, "filter");
fprintf_stderr(aOutput, "filter");
first = false;
}
if (effectProperties.GetMaskFrame(&isOK)) {
if (!first) {
fprintf(aOutput, ", ");
fprintf_stderr(aOutput, ", ");
}
fprintf(aOutput, "mask");
fprintf_stderr(aOutput, "mask");
}
fprintf(aOutput, ")");
fprintf_stderr(aOutput, ")");
}
#endif

View File

@ -2155,7 +2155,7 @@ public:
NS_DISPLAY_DECL_NAME("BackgroundColor", TYPE_BACKGROUND_COLOR)
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(FILE *aOutput) MOZ_OVERRIDE {
fprintf(aOutput, "(rgba %d,%d,%d,%d)",
fprintf_stderr(aOutput, "(rgba %d,%d,%d,%d)",
NS_GET_R(mColor), NS_GET_G(mColor),
NS_GET_B(mColor), NS_GET_A(mColor));
@ -2489,7 +2489,7 @@ public:
NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY)
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(FILE *aOutput) MOZ_OVERRIDE {
fprintf(aOutput, "(opacity %f)", mFrame->StyleDisplay()->mOpacity);
fprintf_stderr(aOutput, "(opacity %f)", mFrame->StyleDisplay()->mOpacity);
}
#endif

View File

@ -127,16 +127,16 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
FILE* aOutput, bool aDumpHtml)
{
if (aDumpHtml) {
fprintf(aOutput, "<ul>");
fprintf_stderr(aOutput, "<ul>");
}
for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
if (aDumpHtml) {
fprintf(aOutput, "<li>");
fprintf_stderr(aOutput, "<li>");
} else {
sPrintDisplayListIndent ++;
for (int indent = 0; indent < sPrintDisplayListIndent; indent++) {
fprintf(aOutput, " ");
fprintf_stderr(aOutput, " ");
}
}
nsIFrame* f = i->Frame();
@ -161,9 +161,9 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
nsCString string(i->Name());
string.Append("-");
string.AppendInt((uint64_t)i);
fprintf(aOutput, "<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
fprintf_stderr(aOutput, "<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
}
fprintf(aOutput, "%s %p(%s) bounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s",
fprintf_stderr(aOutput, "%s %p(%s) bounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s",
i->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
rect.x, rect.y, rect.width, rect.height,
vis.x, vis.y, vis.width, vis.height,
@ -172,19 +172,19 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
i->IsUniform(aBuilder, &color) ? " uniform" : "");
nsRegionRectIterator iter(opaque);
for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
fprintf(aOutput, " (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
fprintf_stderr(aOutput, " (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
}
i->WriteDebugInfo(aOutput);
if (aDumpHtml && i->Painted()) {
fprintf(aOutput, "</a>");
fprintf_stderr(aOutput, "</a>");
}
uint32_t key = i->GetPerFrameKey();
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
if (layer) {
if (aDumpHtml) {
fprintf(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
fprintf_stderr(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
} else {
fprintf(aOutput, " layer=%p", layer);
fprintf_stderr(aOutput, " layer=%p", layer);
}
}
if (i->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
@ -195,14 +195,14 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
PrintDisplayListTo(aBuilder, *list, aOutput, aDumpHtml);
}
if (aDumpHtml) {
fprintf(aOutput, "</li>");
fprintf_stderr(aOutput, "</li>");
} else {
sPrintDisplayListIndent --;
}
}
if (aDumpHtml) {
fprintf(aOutput, "</ul>");
fprintf_stderr(aOutput, "</ul>");
}
}

View File

@ -2086,7 +2086,7 @@ nsLayoutUtils::GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect,
#ifdef MOZ_DUMP_PAINTING
if (gDumpEventList) {
fprintf(stdout, "Event handling --- (%d,%d):\n", aRect.x, aRect.y);
fprintf_stderr(stderr, "Event handling --- (%d,%d):\n", aRect.x, aRect.y);
nsFrame::PrintDisplayList(&builder, list);
}
#endif
@ -2277,16 +2277,16 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
string.Append(".html");
gfxUtils::sDumpPaintFile = fopen(string.BeginReading(), "w");
} else {
gfxUtils::sDumpPaintFile = stdout;
gfxUtils::sDumpPaintFile = stderr;
}
if (gfxUtils::sDumpPaintingToFile) {
fprintf(gfxUtils::sDumpPaintFile, "<html><head><script>var array = {}; function ViewImage(index) { window.location = array[index]; }</script></head><body>");
fprintf_stderr(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",
fprintf_stderr(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, gfxUtils::sDumpPaintingToFile);
if (gfxUtils::sDumpPaintingToFile) {
fprintf(gfxUtils::sDumpPaintFile, "<script>");
fprintf_stderr(gfxUtils::sDumpPaintFile, "<script>");
}
}
#endif
@ -2327,12 +2327,12 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintList || gfxUtils::sDumpPainting) {
if (gfxUtils::sDumpPaintingToFile) {
fprintf(gfxUtils::sDumpPaintFile, "</script>");
fprintf_stderr(gfxUtils::sDumpPaintFile, "</script>");
}
fprintf(gfxUtils::sDumpPaintFile, "Painting --- after optimization:\n");
fprintf_stderr(gfxUtils::sDumpPaintFile, "Painting --- after optimization:\n");
nsFrame::PrintDisplayList(&builder, list, gfxUtils::sDumpPaintFile, gfxUtils::sDumpPaintingToFile);
fprintf(gfxUtils::sDumpPaintFile, "Painting --- retained layer tree:\n");
fprintf_stderr(gfxUtils::sDumpPaintFile, "Painting --- retained layer tree:\n");
nsIWidget* widget = aFrame->GetNearestWidget();
if (widget) {
nsRefPtr<LayerManager> layerManager = widget->GetLayerManager();
@ -2947,9 +2947,9 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext,
NS_PRECONDITION(aType == MIN_WIDTH || aType == PREF_WIDTH, "bad type");
#ifdef DEBUG_INTRINSIC_WIDTH
nsFrame::IndentBy(stdout, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stdout);
printf(" %s intrinsic width for container:\n",
nsFrame::IndentBy(stderr, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stderr);
printf_stderr(" %s intrinsic width for container:\n",
aType == MIN_WIDTH ? "min" : "pref");
#endif
@ -3007,9 +3007,9 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext,
result = aFrame->GetPrefWidth(aRenderingContext);
#ifdef DEBUG_INTRINSIC_WIDTH
--gNoiseIndent;
nsFrame::IndentBy(stdout, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stdout);
printf(" %s intrinsic width from frame is %d.\n",
nsFrame::IndentBy(stderr, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stderr);
printf_stderr(" %s intrinsic width from frame is %d.\n",
aType == MIN_WIDTH ? "min" : "pref", result);
#endif
@ -3196,9 +3196,9 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext,
}
#ifdef DEBUG_INTRINSIC_WIDTH
nsFrame::IndentBy(stdout, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stdout);
printf(" %s intrinsic width for container is %d twips.\n",
nsFrame::IndentBy(stderr, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stderr);
printf_stderr(" %s intrinsic width for container is %d twips.\n",
aType == MIN_WIDTH ? "min" : "pref", result);
#endif

View File

@ -1199,7 +1199,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
if (mViewManagerFlushIsPending) {
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Starting ProcessPendingUpdates\n");
printf_stderr("Starting ProcessPendingUpdates\n");
}
#endif
#ifndef MOZ_WIDGET_GONK
@ -1215,7 +1215,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
vm->ProcessPendingUpdates();
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("Ending ProcessPendingUpdates\n");
printf_stderr("Ending ProcessPendingUpdates\n");
}
#endif
}

View File

@ -309,7 +309,7 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
#ifdef DEBUG_roc
nsRect viewRect = aView->GetDimensions();
nsRect damageRect = damageRegion.GetBounds();
printf("XXX Damage rectangle (%d,%d,%d,%d) does not intersect the widget's view (%d,%d,%d,%d)!\n",
printf_stderr("XXX Damage rectangle (%d,%d,%d,%d) does not intersect the widget's view (%d,%d,%d,%d)!\n",
damageRect.x, damageRect.y, damageRect.width, damageRect.height,
viewRect.x, viewRect.y, viewRect.width, viewRect.height);
#endif
@ -337,7 +337,7 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
if (mPresShell) {
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("--COMPOSITE-- %p\n", mPresShell);
printf_stderr("--COMPOSITE-- %p\n", mPresShell);
}
#endif
uint32_t paintFlags = nsIPresShell::PAINT_COMPOSITE;
@ -350,7 +350,7 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
}
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("--ENDCOMPOSITE--\n");
printf_stderr("--ENDCOMPOSITE--\n");
}
#endif
mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT);
@ -411,7 +411,7 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
printf_stderr("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
}
#endif
nsAutoScriptBlocker scriptBlocker;
@ -421,7 +421,7 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
nsIPresShell::PAINT_LAYERS);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf("---- PAINT END ----\n");
printf_stderr("---- PAINT END ----\n");
}
#endif

View File

@ -268,16 +268,19 @@ void NS_MakeRandomString(char *aBuf, int32_t aBufLen)
#endif
#if defined(XP_WIN)
#define va_copy(dest, src) (dest = src)
void
printf_stderr(const char *fmt, ...)
vprintf_stderr(const char *fmt, va_list args)
{
if (IsDebuggerPresent()) {
char buf[2048];
va_list args;
va_start(args, fmt);
vsnprintf(buf, sizeof(buf), fmt, args);
va_list argsCpy;
va_copy(argsCpy, args);
vsnprintf(buf, sizeof(buf), fmt, argsCpy);
buf[sizeof(buf) - 1] = '\0';
va_end(args);
va_end(argsCpy);
OutputDebugStringA(buf);
}
@ -285,29 +288,47 @@ printf_stderr(const char *fmt, ...)
if (!fp)
return;
va_list args;
va_start(args, fmt);
vfprintf(fp, fmt, args);
va_end(args);
fclose(fp);
}
#undef va_copy
#elif defined(ANDROID)
void
printf_stderr(const char *fmt, ...)
vprintf_stderr(const char *fmt, va_list args)
{
va_list args;
va_start(args, fmt);
__android_log_vprint(ANDROID_LOG_INFO, "Gecko", fmt, args);
va_end(args);
}
#else
void
vprintf_stderr(const char *fmt, va_list args)
{
vfprintf(stderr, fmt, args);
}
#endif
void
printf_stderr(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
vprintf_stderr(fmt, args);
va_end(args);
}
#endif
void
fprintf_stderr(FILE* aFile, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
if (aFile == stderr) {
vprintf_stderr(fmt, args);
} else {
vfprintf(aFile, fmt, args);
}
va_end(args);
}

View File

@ -398,6 +398,13 @@ extern "C" {
NS_COM_GLUE void
printf_stderr(const char *fmt, ...);
NS_COM_GLUE void
vprintf_stderr(const char *fmt, va_list args);
// fprintf with special handling for stderr to print to the console
NS_COM_GLUE void
fprintf_stderr(FILE* aFile, const char *fmt, ...);
#ifdef __cplusplus
}
#endif