Bug 735178 - Add debug coloring of sorted 3d layers to help identification. r=roc

This commit is contained in:
Matt Woodrow 2012-04-27 12:24:53 +12:00
Родитель 9c1d34a2ad
Коммит 96a8de15d8
3 изменённых файлов: 89 добавлений и 3 удалений

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

@ -166,10 +166,61 @@ static LayerSortOrder CompareDepth(Layer* aOne, Layer* aTwo) {
#ifdef DEBUG
static bool gDumpLayerSortList = getenv("MOZ_DUMP_LAYER_SORT_LIST") != 0;
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7
//#define USE_XTERM_COLORING
#ifdef USE_XTERM_COLORING
#define RESET 0
#define BRIGHT 1
#define DIM 2
#define UNDERLINE 3
#define BLINK 4
#define REVERSE 7
#define HIDDEN 8
static void SetTextColor(PRUint32 aColor)
{
char command[13];
/* Command is the control command to the terminal */
sprintf(command, "%c[%d;%d;%dm", 0x1B, RESET, aColor + 30, BLACK + 40);
printf("%s", command);
}
static void print_layer_internal(FILE* aFile, Layer* aLayer, PRUint32 aColor)
{
SetTextColor(aColor);
fprintf(aFile, "%p", aLayer);
SetTextColor(GREEN);
}
#else
const char *colors[] = { "Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White" };
static void print_layer_internal(FILE* aFile, Layer* aLayer, PRUint32 aColor)
{
fprintf(aFile, "%p(%s)", aLayer, colors[aColor]);
}
#endif
static void print_layer(FILE* aFile, Layer* aLayer)
{
print_layer_internal(aFile, aLayer, aLayer->GetDebugColorIndex());
}
static void DumpLayerList(nsTArray<Layer*>& aLayers)
{
for (PRUint32 i = 0; i < aLayers.Length(); i++) {
fprintf(stderr, "%p, ", aLayers.ElementAt(i));
print_layer(stderr, aLayers.ElementAt(i));
fprintf(stderr, " ");
}
fprintf(stderr, "\n");
}
@ -179,7 +230,11 @@ static void DumpEdgeList(DirectedGraph<Layer*>& aGraph)
nsTArray<DirectedGraph<Layer*>::Edge> edges = aGraph.GetEdgeList();
for (PRUint32 i = 0; i < edges.Length(); i++) {
fprintf(stderr, "From: %p, To: %p\n", edges.ElementAt(i).mFrom, edges.ElementAt(i).mTo);
fprintf(stderr, "From: ");
print_layer(stderr, edges.ElementAt(i).mFrom);
fprintf(stderr, ", To: ");
print_layer(stderr, edges.ElementAt(i).mTo);
fprintf(stderr, "\n");
}
}
#endif
@ -189,6 +244,9 @@ static void DumpEdgeList(DirectedGraph<Layer*>& aGraph)
// depth buffering for the scene in this case.
#define MAX_SORTABLE_LAYERS 100
PRUint32 gColorIndex = 1;
void SortLayersBy3DZOrder(nsTArray<Layer*>& aLayers)
{
PRUint32 nodeCount = aLayers.Length();
@ -199,6 +257,14 @@ void SortLayersBy3DZOrder(nsTArray<Layer*>& aLayers)
#ifdef DEBUG
if (gDumpLayerSortList) {
for (PRUint32 i = 0; i < nodeCount; i++) {
if (aLayers.ElementAt(i)->GetDebugColorIndex() == 0) {
aLayers.ElementAt(i)->SetDebugColorIndex(gColorIndex++);
if (gColorIndex > 7) {
gColorIndex = 1;
}
}
}
fprintf(stderr, " --- Layers before sorting: --- \n");
DumpLayerList(aLayers);
}

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

@ -891,6 +891,11 @@ public:
static bool IsLogEnabled() { return LayerManager::IsLogEnabled(); }
#ifdef DEBUG
void SetDebugColorIndex(PRUint32 aIndex) { mDebugColorIndex = aIndex; }
PRUint32 GetDebugColorIndex() { return mDebugColorIndex; }
#endif
protected:
Layer(LayerManager* aManager, void* aImplData) :
mManager(aManager),
@ -902,7 +907,8 @@ protected:
mContentFlags(0),
mUseClipRect(false),
mUseTileSourceRect(false),
mIsFixedPosition(false)
mIsFixedPosition(false),
mDebugColorIndex(0)
{}
void Mutated() { mManager->Mutated(this); }
@ -951,6 +957,7 @@ protected:
bool mUseClipRect;
bool mUseTileSourceRect;
bool mIsFixedPosition;
DebugOnly<PRUint32> mDebugColorIndex;
};
/**

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

@ -1909,6 +1909,19 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
gfxPoint offset;
bool dontBlit = needsClipToVisibleRegion || mTransactionIncomplete ||
aLayer->GetEffectiveOpacity() != 1.0f;
#ifdef DEBUG
if (aLayer->GetDebugColorIndex() != 0) {
gfxRGBA color((aLayer->GetDebugColorIndex() & 1) ? 1.0 : 0.0,
(aLayer->GetDebugColorIndex() & 2) ? 1.0 : 0.0,
(aLayer->GetDebugColorIndex() & 4) ? 1.0 : 0.0,
1.0);
nsRefPtr<gfxContext> temp = new gfxContext(untransformedSurface);
temp->SetColor(color);
temp->Paint();
}
#endif
nsRefPtr<gfxASurface> result =
Transform3D(untransformedSurface, aTarget, bounds,
effectiveTransform, offset, dontBlit);