Rendertrace improvements. r=runtime_config_only

This commit is contained in:
Benoit Girard 2012-02-24 11:35:04 -05:00
parent fd722ba218
commit bc41b4158d
4 changed files with 40 additions and 39 deletions

View File

@ -47,34 +47,30 @@ namespace layers {
static int colorId = 0;
// This should be done in the printf but android's printf is buggy
const char* colors[] = {
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19"
};
const char* layerName[] = {
"CANVAS", "COLOR", "CONTAINER", "IMAGE", "READBACK", "SHADOW", "THEBES"
};
static gfx3DMatrix GetRootTransform(Layer *aLayer) {
if (aLayer->GetParent() != NULL)
return GetRootTransform(aLayer->GetParent()) * aLayer->GetTransform();
return aLayer->GetTransform();
gfx3DMatrix layerTrans = aLayer->GetTransform();
if (aLayer->GetParent() != NULL) {
return GetRootTransform(aLayer->GetParent()) * layerTrans.ProjectTo2D();
}
return layerTrans.ProjectTo2D();
}
void RenderTraceLayers(Layer *aLayer, const char *aColor, gfx3DMatrix aRootTransform, bool aReset) {
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform, bool aReset) {
if (!aLayer)
return;
gfx3DMatrix trans = aRootTransform * aLayer->GetTransform();
nsIntRect clipRect = aLayer->GetEffectiveVisibleRegion().GetBounds();
clipRect.MoveBy((int)trans.ProjectTo2D()[3][0], (int)trans.ProjectTo2D()[3][1]);
gfxRect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
trans.TransformBounds(rect);
printf_stderr("%s RENDERTRACE %u rect #%s%s %i %i %i %i\n",
layerName[aLayer->GetType()], (int)PR_IntervalNow(),
colors[colorId%19], aColor,
clipRect.x, clipRect.y, clipRect.width, clipRect.height);
if (strcmp(aLayer->Name(), "ContainerLayer") != 0 &&
strcmp(aLayer->Name(), "ShadowContainerLayer") != 0) {
printf_stderr("%s RENDERTRACE %u rect #%02X%s %i %i %i %i\n",
aLayer->Name(), (int)PR_IntervalNow(),
colorId, aColor,
(int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
}
colorId++;
@ -86,14 +82,15 @@ void RenderTraceLayers(Layer *aLayer, const char *aColor, gfx3DMatrix aRootTrans
if (aReset) colorId = 0;
}
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, nsIntRect aRect) {
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect) {
gfx3DMatrix trans = GetRootTransform(aLayer);
aRect.MoveBy((int)trans.ProjectTo2D()[3][0], (int)trans.ProjectTo2D()[3][1]);
gfxRect rect(aRect.x, aRect.y, aRect.width, aRect.height);
trans.TransformBounds(rect);
printf_stderr("%s RENDERTRACE %u fillrect #%s%s %i %i %i %i\n",
layerName[aLayer->GetType()], (int)PR_IntervalNow(),
"FF", aColor,
aRect.x, aRect.y, aRect.width, aRect.height);
printf_stderr("%s RENDERTRACE %u fillrect #%s %i %i %i %i\n",
aLayer->Name(), (int)PR_IntervalNow(),
aColor,
(int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
}
void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor) {
// Clear with an empty rect

View File

@ -42,10 +42,10 @@
// For the front end see: https://github.com/staktrace/rendertrace
// Uncomment this line to enable RENDERTRACE
//#define MOZ_RENDERTRACE
#define MOZ_RENDERTRACE
#ifndef GFX_RENDERTRACE_H
#define GFX_RENDERTRACE_H
//#define GFX_RENDERTRACE_H
#include "gfx3DMatrix.h"
#include "nsRect.h"
@ -55,16 +55,16 @@ namespace layers {
class Layer;
void RenderTraceLayers(Layer *aLayer, const char *aColor, gfx3DMatrix aRootTransform = gfx3DMatrix(), bool aReset = true);
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform = gfx3DMatrix(), bool aReset = true);
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, nsIntRect aRect);
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect);
void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor);
#ifndef MOZ_RENDERTRACE
inline void RenderTraceLayers(Layer *aLayer, const char *aColor, gfx3DMatrix aRootTransform, bool aReset)
inline void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform, bool aReset)
{}
inline void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, nsIntRect aRect)
inline void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect)
{}
inline void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor)

View File

@ -690,7 +690,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
nsIntRegion toDraw = IntersectWithClip(GetEffectiveVisibleRegion(), aContext);
RenderTraceInvalidateStart(this, "FF00", toDraw.GetBounds());
RenderTraceInvalidateStart(this, "FFFF00", toDraw.GetBounds());
if (!toDraw.IsEmpty() && !IsHidden()) {
if (!aCallback) {
@ -728,7 +728,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
aContext->Restore();
}
RenderTraceInvalidateEnd(this, "FF00");
RenderTraceInvalidateEnd(this, "FFFF00");
return;
}
@ -755,7 +755,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
nsIntRegion extendedDrawRegion = state.mRegionToDraw;
SetAntialiasingFlags(this, state.mContext);
RenderTraceInvalidateStart(this, "FF00", state.mRegionToDraw.GetBounds());
RenderTraceInvalidateStart(this, "FFFF00", state.mRegionToDraw.GetBounds());
PaintBuffer(state.mContext,
state.mRegionToDraw, extendedDrawRegion, state.mRegionToInvalidate,
@ -763,7 +763,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
aCallback, aCallbackData);
Mutated();
RenderTraceInvalidateEnd(this, "FF00");
RenderTraceInvalidateEnd(this, "FFFF00");
} else {
// It's possible that state.mRegionToInvalidate is nonempty here,
// if we are shrinking the valid region to nothing.

View File

@ -323,7 +323,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
static_cast<ShadowThebesLayer*>(shadow->AsLayer());
const ThebesBuffer& newFront = op.newFrontBuffer();
RenderTraceInvalidateStart(thebes, "00FF", op.updatedRegion().GetBounds());
RenderTraceInvalidateStart(thebes, "FF00FF", op.updatedRegion().GetBounds());
OptionalThebesBuffer newBack;
nsIntRegion newValidRegion;
@ -338,7 +338,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
newBack, newValidRegion,
readonlyFront, frontUpdatedRegion));
RenderTraceInvalidateEnd(thebes, "00FF");
RenderTraceInvalidateEnd(thebes, "FF00FF");
break;
}
case Edit::TOpPaintCanvas: {
@ -349,7 +349,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
ShadowCanvasLayer* canvas =
static_cast<ShadowCanvasLayer*>(shadow->AsLayer());
RenderTraceInvalidateStart(canvas, "00FF", canvas->GetVisibleRegion().GetBounds());
RenderTraceInvalidateStart(canvas, "FF00FF", canvas->GetVisibleRegion().GetBounds());
canvas->SetAllocator(this);
CanvasSurface newBack;
@ -358,7 +358,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
replyv.push_back(OpBufferSwap(shadow, NULL,
newBack));
RenderTraceInvalidateEnd(canvas, "00FF");
RenderTraceInvalidateEnd(canvas, "FF00FF");
break;
}
case Edit::TOpPaintImage: {
@ -369,12 +369,16 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
ShadowImageLayer* image =
static_cast<ShadowImageLayer*>(shadow->AsLayer());
RenderTraceInvalidateStart(image, "FF00FF", image->GetVisibleRegion().GetBounds());
image->SetAllocator(this);
SharedImage newBack;
image->Swap(op.newFrontBuffer(), &newBack);
replyv.push_back(OpImageSwap(shadow, NULL,
newBack));
RenderTraceInvalidateEnd(image, "FF00FF");
break;
}