Bug 982275 - Part 2: Add a pref for drawing layer-info inside layers. r=jrmuizel

This commit is contained in:
Bas Schouten 2014-03-12 03:27:33 +01:00
Родитель 73c060630a
Коммит b2b52ae04e
4 изменённых файлов: 40 добавлений и 8 удалений

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

@ -1308,6 +1308,13 @@ public:
*/
void LogSelf(const char* aPrefix="");
// Print interesting information about this into aTo. Internally
// used to implement Dump*() and Log*(). If subclasses have
// additional interesting properties, they should override this with
// an implementation that first calls the base implementation then
// appends additional info to aTo.
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
static bool IsLogEnabled() { return LayerManager::IsLogEnabled(); }
/**
@ -1351,13 +1358,6 @@ public:
protected:
Layer(LayerManager* aManager, void* aImplData);
// Print interesting information about this into aTo. Internally
// used to implement Dump*() and Log*(). If subclasses have
// additional interesting properties, they should override this with
// an implementation that first calls the base implementation then
// appends additional info to aTo.
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
/**
* We can snap layer transforms for two reasons:
* 1) To avoid unnecessary resampling when a transform is a translation

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

@ -31,6 +31,7 @@
#include "nsRect.h" // for nsIntRect
#include "nsRegion.h" // for nsIntRegion
#include "nsTArray.h" // for nsAutoTArray
#include "TextRenderer.h" // for TextRenderer
#include <vector>
namespace mozilla {
@ -120,6 +121,32 @@ static gfx::Point GetScrollData(Layer* aLayer) {
return origin;
}
static void DrawLayerInfo(const nsIntRect& aClipRect,
LayerManagerComposite* aManager,
Layer* aLayer)
{
if (aLayer->GetType() == Layer::LayerType::TYPE_CONTAINER) {
// XXX - should figure out a way to render this, but for now this
// is hard to do, since it will often get superimposed over the first
// child of the layer, which is bad.
return;
}
nsAutoCString layerInfo;
aLayer->PrintInfo(layerInfo, "");
nsIntRegion visibleRegion = aLayer->GetVisibleRegion();
uint32_t maxWidth = visibleRegion.GetBounds().width < 500 ? visibleRegion.GetBounds().width : 500;
nsIntPoint topLeft = visibleRegion.GetBounds().TopLeft();
aManager->GetTextRenderer()->RenderText(layerInfo.get(), gfx::IntPoint(topLeft.x, topLeft.y),
aLayer->GetEffectiveTransform(), 16,
maxWidth);
}
static LayerVelocityUserData* GetVelocityData(Layer* aLayer) {
static char sLayerVelocityUserDataKey;
void* key = reinterpret_cast<void*>(&sLayerVelocityUserDataKey);
@ -361,6 +388,10 @@ ContainerRender(ContainerT* aContainer,
if (gfxPrefs::LayersScrollGraph()) {
DrawVelGraph(clipRect, aManager, layerToRender->GetLayer());
}
if (gfxPrefs::DrawLayerInfo()) {
DrawLayerInfo(clipRect, aManager, layerToRender->GetLayer());
}
// invariant: our GL context should be current here, I don't think we can
// assert it though
}

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

@ -51,7 +51,7 @@
#include <android/log.h>
#endif
#include "GeckoProfiler.h"
#include "TextRenderer.h"
#include "TextRenderer.h" // for TextRenderer
class gfxASurface;
class gfxContext;

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

@ -154,6 +154,7 @@ private:
DECL_GFX_PREF(Live, "layers.draw-bigimage-borders", DrawBigImageBorders, bool, false);
DECL_GFX_PREF(Live, "layers.draw-borders", DrawLayerBorders, bool, false);
DECL_GFX_PREF(Live, "layers.draw-tile-borders", DrawTileBorders, bool, false);
DECL_GFX_PREF(Live, "layers.draw-layer-info", DrawLayerInfo, bool, false);
DECL_GFX_PREF(Once, "layers.dump", LayersDump, bool, false);
DECL_GFX_PREF(Once, "layers.enable-tiles", LayersTilesEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.simple-tiles", LayersUseSimpleTiles, bool, false);