Bug 860146 - Add layers.draw-borders pref to see how a page is layered. r=jrmuizel

This commit is contained in:
Nicolas Silva 2013-03-21 18:08:01 +01:00
parent e74e1edc83
commit 113ecfe4a3
13 changed files with 103 additions and 1 deletions

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/layers/Compositor.h"
#include "mozilla/layers/Effects.h"
namespace mozilla {
namespace layers {
@ -15,5 +16,41 @@ Compositor::GetBackend()
return sBackend;
}
void
Compositor::DrawDiagnostics(const gfx::Color& aColor,
const gfx::Rect& rect,
const gfx::Rect& aClipRect,
const gfx::Matrix4x4& aTransform,
const gfx::Point& aOffset)
{
if (!mDrawColoredBorders) {
return;
}
EffectChain effects;
effects.mPrimaryEffect = new EffectSolidColor(aColor);
int lWidth = 1;
float opacity = 0.8;
// left
this->DrawQuad(gfx::Rect(rect.x, rect.y,
lWidth, rect.height),
aClipRect, effects, opacity,
aTransform, aOffset);
// top
this->DrawQuad(gfx::Rect(rect.x + lWidth, rect.y,
rect.width - 2 * lWidth, lWidth),
aClipRect, effects, opacity,
aTransform, aOffset);
// right
this->DrawQuad(gfx::Rect(rect.x + rect.width - lWidth, rect.y,
lWidth, rect.height),
aClipRect, effects, opacity,
aTransform, aOffset);
// bottom
this->DrawQuad(gfx::Rect(rect.x + lWidth, rect.y + rect.height-lWidth,
rect.width - 2 * lWidth, lWidth),
aClipRect, effects, opacity,
aTransform, aOffset);
}
} // namespace
} // namespace

View File

@ -170,6 +170,7 @@ class Compositor : public RefCounted<Compositor>
public:
Compositor()
: mCompositorID(0)
, mDrawColoredBorders(false)
{
MOZ_COUNT_CTOR(Compositor);
}
@ -322,6 +323,22 @@ public:
*/
virtual bool SupportsPartialTextureUpdate() = 0;
void EnableColoredBorders()
{
mDrawColoredBorders = true;
}
void DisableColoredBorders()
{
mDrawColoredBorders = false;
}
void DrawDiagnostics(const gfx::Color& color,
const gfx::Rect& visibleRect,
const gfx::Rect& aClipRect,
const gfx::Matrix4x4& transform,
const gfx::Point& aOffset);
#ifdef MOZ_DUMP_PAINTING
virtual const char* Name() const = 0;
#endif // MOZ_DUMP_PAINTING
@ -380,6 +397,7 @@ public:
protected:
uint32_t mCompositorID;
static LayersBackend sBackend;
bool mDrawColoredBorders;
};
} // namespace layers

View File

@ -36,6 +36,10 @@ ColorLayerComposite::RenderLayer(const nsIntPoint& aOffset,
mCompositor->DrawQuad(rect, clipRect, effects, opacity,
transform, gfx::Point(aOffset.x, aOffset.y));
mCompositor->DrawDiagnostics(gfx::Color(0.0, 1.0, 1.0, 1.0),
rect, clipRect,
transform, gfx::Point(aOffset.x, aOffset.y));
}
} /* layers */

View File

@ -174,6 +174,9 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
Float(tileRegionRect.width) / texRect.width,
Float(tileRegionRect.height) / texRect.height);
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform, aOffset);
GetCompositor()->DrawDiagnostics(gfx::Color(0.0,1.0,0.0,1.0),
rect, aClipRect, aTransform, aOffset);
}
}
}

View File

@ -103,6 +103,8 @@ ImageHostSingle::Composite(EffectChain& aEffectChain,
gfx::Rect rect(tileRect.x, tileRect.y, tileRect.width, tileRect.height);
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
aOpacity, aTransform, aOffset);
GetCompositor()->DrawDiagnostics(gfx::Color(0.5,0.0,0.0,1.0),
rect, aClipRect, aTransform, aOffset);
} while (it->NextTile());
it->EndTileIteration();
} else {
@ -127,6 +129,8 @@ ImageHostSingle::Composite(EffectChain& aEffectChain,
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
aOpacity, aTransform, aOffset);
GetCompositor()->DrawDiagnostics(gfx::Color(1.0,0.1,0.1,1.0),
rect, aClipRect, aTransform, aOffset);
}
mTextureHost->Unlock();

View File

@ -205,6 +205,8 @@ TiledContentHost::RenderTile(const TiledTexture& aTile,
textureRect.width / aTextureBounds.width,
textureRect.height / aTextureBounds.height);
mCompositor->DrawQuad(graphicsRect, aClipRect, aEffectChain, aOpacity, aTransform, aOffset);
mCompositor->DrawDiagnostics(gfx::Color(0.0,0.5,0.0,1.0),
graphicsRect, aClipRect, aTransform, aOffset);
}
aTile.mTextureHost->Unlock();

View File

@ -232,6 +232,7 @@ struct OpRemoveChild { PLayer container; PLayer childLayer; };
struct OpRepositionChild { PLayer container; PLayer childLayer; PLayer after; };
struct OpRaiseToTopChild { PLayer container; PLayer childLayer; };
struct OpSetColoredBorders { bool enabled; };
// Paint (buffer update)
struct OpPaintTiledLayerBuffer {
@ -291,6 +292,7 @@ union Edit {
OpCreateRefLayer;
OpSetLayerAttributes;
OpSetColoredBorders;
OpSetRoot;
OpInsertAfter;

View File

@ -238,7 +238,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
break;
}
// Attributes
// Attributes
case Edit::TOpSetLayerAttributes: {
MOZ_LAYERS_LOG(("[ParentSide] SetLayerAttributes"));
@ -329,6 +329,14 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
}
break;
}
case Edit::TOpSetColoredBorders: {
if (edit.get_OpSetColoredBorders().enabled()) {
mLayerManager->GetCompositor()->EnableColoredBorders();
} else {
mLayerManager->GetCompositor()->DisableColoredBorders();
}
break;
}
// Tree ops
case Edit::TOpSetRoot: {
MOZ_LAYERS_LOG(("[ParentSide] SetRoot"));

View File

@ -165,6 +165,7 @@ CompositableForwarder::IdentifyTextureHost(const TextureFactoryIdentifier& aIden
ShadowLayerForwarder::ShadowLayerForwarder()
: mShadowManager(NULL)
, mIsFirstPaint(false)
, mDrawColoredBorders(false)
{
mTxn = new Transaction();
}
@ -360,6 +361,11 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
NS_ABORT_IF_FALSE(!mTxn->Finished(), "forgot BeginTransaction?");
if (mDrawColoredBorders != gfxPlatform::DrawLayerBorders()) {
mDrawColoredBorders = gfxPlatform::DrawLayerBorders();
mTxn->AddEdit(OpSetColoredBorders(mDrawColoredBorders));
}
AutoTxnEnd _(mTxn);
if (mTxn->Empty() && !mTxn->RotationChanged()) {

View File

@ -432,6 +432,7 @@ private:
Transaction* mTxn;
bool mIsFirstPaint;
bool mDrawColoredBorders;
};
class CompositableClient;

View File

@ -96,6 +96,8 @@ static int gCMSIntent = -2;
static void ShutdownCMS();
static void MigratePrefs();
static bool sDrawLayerBorders = false;
#include "mozilla/gfx/2D.h"
using namespace mozilla::gfx;
@ -400,6 +402,10 @@ gfxPlatform::Init()
gPlatform->mOrientationSyncMillis = Preferences::GetUint("layers.orientation.sync.timeout", (uint32_t)0);
mozilla::Preferences::AddBoolVarCache(&sDrawLayerBorders,
"layers.draw-borders",
false);
CreateCMSOutputProfile();
}
@ -1103,6 +1109,13 @@ gfxPlatform::IsLangCJK(eFontPrefLang aLang)
}
}
bool
gfxPlatform::DrawLayerBorders()
{
return sDrawLayerBorders;
}
void
gfxPlatform::GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
{

View File

@ -530,6 +530,8 @@ public:
uint32_t GetOrientationSyncMillis() const;
static bool DrawLayerBorders();
protected:
gfxPlatform();
virtual ~gfxPlatform();

View File

@ -3962,6 +3962,8 @@ pref("layers.acceleration.force-enabled", false);
pref("layers.acceleration.draw-fps", false);
pref("layers.draw-borders", false);
pref("layers.offmainthreadcomposition.enabled", false);
// same effect as layers.offmainthreadcomposition.enabled, but specifically for
// use with tests.