Bug 1113837 - Build display-list dumping without MOZ_DUMP_PAINTING. r=mstange

This commit is contained in:
Benoit Girard 2014-12-31 15:17:39 -05:00
Родитель 1d11979703
Коммит 98b7cc0e56
12 изменённых файлов: 34 добавлений и 74 удалений

Просмотреть файл

@ -1438,17 +1438,19 @@ gfxUtils::CopyAsDataURI(DrawTarget* aDT)
}
}
#ifdef MOZ_DUMP_PAINTING
static bool sDumpPaintList = getenv("MOZ_DUMP_PAINT_LIST") != 0;
/* static */ bool
gfxUtils::DumpPaintList() {
return sDumpPaintList || gfxPrefs::LayoutDumpDisplayList();
gfxUtils::DumpDisplayList() {
return gfxPrefs::LayoutDumpDisplayList();
}
FILE *gfxUtils::sDumpPaintFile = stderr;
#ifdef MOZ_DUMP_PAINTING
bool gfxUtils::sDumpPainting = getenv("MOZ_DUMP_PAINT") != 0;
bool gfxUtils::sDumpPaintingToFile = getenv("MOZ_DUMP_PAINT_TO_FILE") != 0;
FILE *gfxUtils::sDumpPaintFile = nullptr;
#else
bool gfxUtils::sDumpPainting = false;
bool gfxUtils::sDumpPaintingToFile = false;
#endif
namespace mozilla {

Просмотреть файл

@ -291,13 +291,11 @@ public:
static void CopyAsDataURI(SourceSurface* aSourceSurface);
static void CopyAsDataURI(DrawTarget* aDT);
#ifdef MOZ_DUMP_PAINTING
static bool DumpPaintList();
static bool DumpDisplayList();
static bool sDumpPainting;
static bool sDumpPaintingToFile;
static FILE* sDumpPaintFile;
#endif
};
namespace mozilla {

Просмотреть файл

@ -455,7 +455,6 @@ DisplayItemClip::Shutdown()
gNoClip = nullptr;
}
#ifdef MOZ_DUMP_PAINTING
nsCString
DisplayItemClip::ToString() const
{
@ -473,6 +472,5 @@ DisplayItemClip::ToString() const
}
return str;
}
#endif
}

Просмотреть файл

@ -164,9 +164,7 @@ public:
void MoveBy(nsPoint aPoint);
#ifdef MOZ_DUMP_PAINTING
nsCString ToString() const;
#endif
/**
* Find the largest N such that the first N rounded rects in 'this' are

Просмотреть файл

@ -4423,7 +4423,6 @@ FrameLayerBuilder::PaintItems(nsTArray<ClippedDisplayItem>& aItems,
nsIFrame* frame = cdi->mItem->Frame();
frame->AddStateBits(NS_FRAME_PAINTED_THEBES);
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting) {
DebugPaintItem(aDrawTarget, aPresContext, cdi->mItem, aBuilder);
} else {
@ -4681,13 +4680,11 @@ FrameLayerBuilder::CheckDOMModified()
return true;
}
#ifdef MOZ_DUMP_PAINTING
/* static */ void
FrameLayerBuilder::DumpRetainedLayerTree(LayerManager* aManager, std::stringstream& aStream, bool aDumpHtml)
{
aManager->Dump(aStream, "", aDumpHtml);
}
#endif
gfx::Rect
CalculateBounds(const nsTArray<DisplayItemClip::RoundedRect>& aRects, int32_t A2D)

Просмотреть файл

@ -268,13 +268,11 @@ public:
const nsIntRegion& aRegionToInvalidate,
void* aCallbackData);
#ifdef MOZ_DUMP_PAINTING
/**
* Dumps this FrameLayerBuilder's retained layer manager's retained
* layer tree. Defaults to dumping to stdout in non-HTML format.
*/
static void DumpRetainedLayerTree(LayerManager* aManager, std::stringstream& aStream, bool aDumpHtml = false);
#endif
/******* PRIVATE METHODS to FrameLayerBuilder.cpp ********/
/* These are only in the public section because they need

Просмотреть файл

@ -2052,7 +2052,6 @@ nsDisplaySolidColor::Paint(nsDisplayListBuilder* aBuilder,
drawTarget->FillRect(rect, ColorPattern(ToDeviceColor(mColor)));
}
#ifdef MOZ_DUMP_PAINTING
void
nsDisplaySolidColor::WriteDebugInfo(std::stringstream& aStream)
{
@ -2062,7 +2061,6 @@ nsDisplaySolidColor::WriteDebugInfo(std::stringstream& aStream)
<< (int)NS_GET_B(mColor) << ","
<< (int)NS_GET_A(mColor) << ")";
}
#endif
static void
RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
@ -2768,13 +2766,11 @@ nsDisplayThemedBackground::~nsDisplayThemedBackground()
#endif
}
#ifdef MOZ_DUMP_PAINTING
void
nsDisplayThemedBackground::WriteDebugInfo(std::stringstream& aStream)
{
aStream << " (themed, appearance:" << (int)mAppearance << ")";
}
#endif
void
nsDisplayThemedBackground::HitTest(nsDisplayListBuilder* aBuilder,
@ -2973,14 +2969,12 @@ nsDisplayBackgroundColor::HitTest(nsDisplayListBuilder* aBuilder,
aOutFrames->AppendElement(mFrame);
}
#ifdef MOZ_DUMP_PAINTING
void
nsDisplayBackgroundColor::WriteDebugInfo(std::stringstream& aStream)
{
aStream << " (rgba " << mColor.r << "," << mColor.g << ","
<< mColor.b << "," << mColor.a << ")";
}
#endif
already_AddRefed<Layer>
nsDisplayClearBackground::BuildLayer(nsDisplayListBuilder* aBuilder,
@ -3098,7 +3092,6 @@ nsDisplayLayerEventRegions::AddInactiveScrollPort(const nsRect& aRect)
mDispatchToContentHitRegion.Or(mDispatchToContentHitRegion, aRect);
}
#ifdef MOZ_DUMP_PAINTING
void
nsDisplayLayerEventRegions::WriteDebugInfo(std::stringstream& aStream)
{
@ -3112,7 +3105,6 @@ nsDisplayLayerEventRegions::WriteDebugInfo(std::stringstream& aStream)
AppendToString(aStream, mDispatchToContentHitRegion, " (dispatchToContentRegion ", ")");
}
}
#endif
nsDisplayCaret::nsDisplayCaret(nsDisplayListBuilder* aBuilder,
nsIFrame* aCaretFrame)
@ -3810,13 +3802,11 @@ bool nsDisplayOpacity::TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* a
return true;
}
#ifdef MOZ_DUMP_PAINTING
void
nsDisplayOpacity::WriteDebugInfo(std::stringstream& aStream)
{
aStream << " (opacity " << mOpacity << ")";
}
#endif
nsDisplayMixBlendMode::nsDisplayMixBlendMode(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList,
@ -4575,14 +4565,12 @@ nsDisplayScrollLayer::GetScrollLayerCount()
#endif
}
#ifdef MOZ_DUMP_PAINTING
void
nsDisplayScrollLayer::WriteDebugInfo(std::stringstream& aStream)
{
aStream << " (scrollframe " << mScrollFrame
<< " scrolledFrame " << mScrolledFrame << ")";
}
#endif
nsDisplayScrollInfoLayer::nsDisplayScrollInfoLayer(
nsDisplayListBuilder* aBuilder,
@ -5763,13 +5751,11 @@ bool nsDisplayTransform::UntransformVisibleRect(nsDisplayListBuilder* aBuilder,
return true;
}
#ifdef MOZ_DUMP_PAINTING
void
nsDisplayTransform::WriteDebugInfo(std::stringstream& aStream)
{
AppendToString(aStream, GetTransform());
}
#endif
nsDisplaySVGEffects::nsDisplaySVGEffects(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList)

Просмотреть файл

@ -99,14 +99,9 @@ typedef mozilla::EnumSet<mozilla::gfx::CompositionOp> BlendModeSet;
*/
// All types are defined in nsDisplayItemTypes.h
#ifdef MOZ_DUMP_PAINTING
#define NS_DISPLAY_DECL_NAME(n, e) \
virtual const char* Name() { return n; } \
virtual Type GetType() { return e; }
#else
#define NS_DISPLAY_DECL_NAME(n, e) \
virtual Type GetType() { return e; }
#endif
/**
* This manages a display list and is passed as a parameter to
@ -1378,15 +1373,13 @@ public:
const DisplayItemClip* aClip) {
return false;
}
#ifdef MOZ_DUMP_PAINTING
/**
* For debugging and stuff
*/
virtual const char* Name() = 0;
virtual void WriteDebugInfo(std::stringstream& aStream) {}
#endif
nsDisplayItem* GetAbove() { return mAbove; }
@ -1949,9 +1942,7 @@ public:
nsDisplayGeneric(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
PaintCallback aPaint, const char* aName, Type aType)
: nsDisplayItem(aBuilder, aFrame), mPaint(aPaint)
#ifdef MOZ_DUMP_PAINTING
, mName(aName)
#endif
, mType(aType)
{
MOZ_COUNT_CTOR(nsDisplayGeneric);
@ -1978,9 +1969,7 @@ public:
protected:
PaintCallback mPaint;
#ifdef MOZ_DUMP_PAINTING
const char* mName;
#endif
Type mType;
};
@ -2204,9 +2193,7 @@ public:
ComputeInvalidationRegionDifference(aBuilder, geometry, aInvalidRegion);
}
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) MOZ_OVERRIDE;
#endif
NS_DISPLAY_DECL_NAME("SolidColor", TYPE_SOLID_COLOR)
@ -2365,9 +2352,7 @@ public:
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) MOZ_OVERRIDE;
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) MOZ_OVERRIDE;
#endif
protected:
nsRect GetBoundsInternal();
@ -2428,9 +2413,7 @@ public:
}
NS_DISPLAY_DECL_NAME("BackgroundColor", TYPE_BACKGROUND_COLOR)
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) MOZ_OVERRIDE;
#endif
protected:
const nsStyleBackground* mBackgroundStyle;
@ -2669,9 +2652,7 @@ public:
const nsRegion& MaybeHitRegion() { return mMaybeHitRegion; }
const nsRegion& DispatchToContentHitRegion() { return mDispatchToContentHitRegion; }
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) MOZ_OVERRIDE;
#endif
private:
// Relative to aFrame's reference frame.
@ -2879,9 +2860,7 @@ public:
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
bool NeedsActiveLayer(nsDisplayListBuilder* aBuilder);
NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY)
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) MOZ_OVERRIDE;
#endif
bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
@ -3177,9 +3156,7 @@ public:
virtual nsIFrame* GetScrollFrame() { return mScrollFrame; }
virtual nsIFrame* GetScrolledFrame() { return mScrolledFrame; }
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) MOZ_OVERRIDE;
#endif
bool IsDisplayPortOpaque() { return mDisplayPortContentsOpaque; }
@ -3588,9 +3565,7 @@ public:
*/
bool ShouldPrerender(nsDisplayListBuilder* aBuilder);
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) MOZ_OVERRIDE;
#endif
private:
void SetReferenceFrameToAncestor(nsDisplayListBuilder* aBuilder);

Просмотреть файл

@ -121,7 +121,6 @@ nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
}
#endif
#ifdef MOZ_DUMP_PAINTING
std::ostream& operator<<(std::ostream& os, const nsPrintfCString& rhs) {
os << rhs.get();
return os;
@ -158,12 +157,14 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
nsDisplayList* list = aItem->GetChildren();
const DisplayItemClip& clip = aItem->GetClip();
nsRegion opaque = aItem->GetOpaqueRegion(aBuilder, &snap);
#ifdef MOZ_DUMP_PAINTING
if (aDumpHtml && aItem->Painted()) {
nsCString string(aItem->Name());
string.Append('-');
string.AppendInt((uint64_t)aItem);
aStream << nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
}
#endif
aStream << nsPrintfCString("%s p=0x%p f=0x%p(%s) %sbounds(%d,%d,%d,%d) layerBounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s",
aItem->Name(), aItem, (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
(aItem->ZIndex() ? nsPrintfCString("z=%d ", aItem->ZIndex()).get() : ""),
@ -197,9 +198,11 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
// Display item specific debug info
aItem->WriteDebugInfo(aStream);
#ifdef MOZ_DUMP_PAINTING
if (aDumpHtml && aItem->Painted()) {
aStream << "</a>";
}
#endif
uint32_t key = aItem->GetPerFrameKey();
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
if (layer) {
@ -209,11 +212,13 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
aStream << nsPrintfCString(" layer=0x%p", layer);
}
}
#ifdef MOZ_DUMP_PAINTING
if (aItem->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
nsCString str;
(static_cast<nsDisplaySVGEffects*>(aItem))->PrintEffects(str);
aStream << str.get();
}
#endif
aStream << "\n";
if (aDumpSublist && list) {
@ -263,6 +268,7 @@ nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
PrintDisplayListTo(aBuilder, aList, aStream, 0, aDumpHtml);
}
#ifdef MOZ_DUMP_PAINTING
static void
PrintDisplayListSetItem(nsDisplayListBuilder* aBuilder,
const char* aItemName,

Просмотреть файл

@ -3103,14 +3103,17 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
willFlushRetainedLayers = true;
}
#ifdef MOZ_DUMP_PAINTING
FILE* savedDumpFile = gfxUtils::sDumpPaintFile;
bool profilerNeedsDisplayList = profiler_feature_active("displaylistdump");
bool consoleNeedsDisplayList = gfxUtils::DumpPaintList() || gfxUtils::sDumpPainting;
bool consoleNeedsDisplayList = gfxUtils::DumpDisplayList() || gfxUtils::sDumpPainting;
#ifdef MOZ_DUMP_PAINTING
FILE* savedDumpFile = gfxUtils::sDumpPaintFile;
#endif
UniquePtr<std::stringstream> ss = MakeUnique<std::stringstream>();
UniquePtr<std::stringstream> ss;
if (consoleNeedsDisplayList || profilerNeedsDisplayList) {
ss = MakeUnique<std::stringstream>();
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintingToFile) {
nsCString string("dump-");
string.AppendInt(gPaintCount);
@ -3122,6 +3125,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
if (gfxUtils::sDumpPaintingToFile) {
*ss << "<html><head><script>var array = {}; function ViewImage(index) { window.location = array[index]; }</script></head><body>";
}
#endif
*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);
@ -3139,7 +3143,6 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
ss = MakeUnique<std::stringstream>();
}
}
#endif
uint32_t flags = nsDisplayList::PAINT_DEFAULT;
if (aFlags & PAINT_WIDGET_LAYERS) {
@ -3178,11 +3181,12 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
Telemetry::AccumulateTimeDelta(Telemetry::PAINT_RASTERIZE_TIME,
paintStart);
#ifdef MOZ_DUMP_PAINTING
if (consoleNeedsDisplayList || profilerNeedsDisplayList) {
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintingToFile) {
*ss << "</script>";
}
#endif
*ss << "Painting --- after optimization:\n";
nsFrame::PrintDisplayList(&builder, list, *ss, gfxUtils::sDumpPaintingToFile);
@ -3191,9 +3195,6 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
FrameLayerBuilder::DumpRetainedLayerTree(layerManager, *ss,
gfxUtils::sDumpPaintingToFile);
}
if (gfxUtils::sDumpPaintingToFile) {
*ss << "</body></html>";
}
if (profilerNeedsDisplayList && !consoleNeedsDisplayList) {
profiler_log(ss->str().c_str());
@ -3202,13 +3203,17 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
fprint_stderr(gfxUtils::sDumpPaintFile, *ss);
}
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPaintingToFile) {
*ss << "</body></html>";
}
if (gfxUtils::sDumpPaintingToFile) {
fclose(gfxUtils::sDumpPaintFile);
}
gfxUtils::sDumpPaintFile = savedDumpFile;
gPaintCount++;
}
#endif
}
// Update the widget's opaque region information. This sets
// glass boundaries on Windows. Also set up the window dragging region

Просмотреть файл

@ -731,7 +731,7 @@ public:
static bool GetShowEventTargetFrameBorder();
#endif
#ifdef MOZ_DUMP_PAINTING
public:
static void PrintDisplayItem(nsDisplayListBuilder* aBuilder,
@ -757,7 +757,6 @@ public:
std::stringstream& aStream,
bool aDumpHtml = false);
#endif
};
// Start Display Reflow Debugging

Просмотреть файл

@ -2224,10 +2224,8 @@ pref("layout.interruptible-reflow.enabled", true);
// specific information is available).
pref("layout.frame_rate", -1);
// pref to dump the display list to the log. Useful for debugging invalidation problems.
#ifdef MOZ_DUMP_PAINTING
// pref to dump the display list to the log. Useful for debugging drawing.
pref("layout.display-list.dump", false);
#endif
// pref to control precision of the frame rate timer. When true,
// we use a "precise" timer, which means each notification fires