Bug 899667 - Make layer borders more readable. r=BenWa
This commit is contained in:
@@ -27,19 +27,49 @@ Compositor::AssertOnCompositorThread()
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::DrawDiagnostics(const gfx::Color& aColor,
|
||||
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
||||
const gfx::Rect& rect,
|
||||
const gfx::Rect& aClipRect,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const gfx::Point& aOffset)
|
||||
{
|
||||
if (!mDrawColoredBorders) {
|
||||
if (!(mDiagnosticTypes & DIAGNOSTIC_TILE_BORDERS) && (aFlags & DIAGNOSTIC_TILE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(mDiagnosticTypes & DIAGNOSTIC_LAYER_BORDERS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int lWidth = 2;
|
||||
float opacity = 0.7;
|
||||
|
||||
gfx::Color color;
|
||||
if (aFlags & DIAGNOSTIC_CONTENT) {
|
||||
color = gfx::Color(0.0, 1.0, 0.0, 1.0); // green
|
||||
if (aFlags & DIAGNOSTIC_COMPONENT_ALPHA) {
|
||||
color = gfx::Color(0.0, 1.0, 1.0, 1.0); // greenish blue
|
||||
}
|
||||
} else if (aFlags & DIAGNOSTIC_IMAGE) {
|
||||
color = gfx::Color(0.5, 0.0, 0.0, 1.0); // red
|
||||
} else if (aFlags & DIAGNOSTIC_COLOR) {
|
||||
color = gfx::Color(0.0, 0.0, 1.0, 1.0); // blue
|
||||
} else if (aFlags & DIAGNOSTIC_CONTAINER) {
|
||||
color = gfx::Color(0.8, 0.0, 0.8, 1.0); // purple
|
||||
}
|
||||
|
||||
// make tile borders a bit more transparent to keep layer borders readable.
|
||||
if (aFlags & DIAGNOSTIC_TILE || aFlags & DIAGNOSTIC_BIGIMAGE) {
|
||||
lWidth = 1;
|
||||
opacity = 0.5;
|
||||
color.r *= 0.7;
|
||||
color.g *= 0.7;
|
||||
color.b *= 0.7;
|
||||
}
|
||||
|
||||
EffectChain effects;
|
||||
effects.mPrimaryEffect = new EffectSolidColor(aColor);
|
||||
int lWidth = 1;
|
||||
float opacity = 0.8;
|
||||
|
||||
effects.mPrimaryEffect = new EffectSolidColor(color);
|
||||
// left
|
||||
this->DrawQuad(gfx::Rect(rect.x, rect.y,
|
||||
lWidth, rect.height),
|
||||
|
||||
@@ -172,7 +172,7 @@ class Compositor : public RefCounted<Compositor>
|
||||
public:
|
||||
Compositor()
|
||||
: mCompositorID(0)
|
||||
, mDrawColoredBorders(false)
|
||||
, mDiagnosticTypes(DIAGNOSTIC_NONE)
|
||||
{
|
||||
MOZ_COUNT_CTOR(Compositor);
|
||||
}
|
||||
@@ -335,16 +335,12 @@ public:
|
||||
*/
|
||||
virtual bool SupportsPartialTextureUpdate() = 0;
|
||||
|
||||
void EnableColoredBorders()
|
||||
void SetDiagnosticTypes(DiagnosticTypes aDiagnostics)
|
||||
{
|
||||
mDrawColoredBorders = true;
|
||||
}
|
||||
void DisableColoredBorders()
|
||||
{
|
||||
mDrawColoredBorders = false;
|
||||
mDiagnosticTypes = aDiagnostics;
|
||||
}
|
||||
|
||||
void DrawDiagnostics(const gfx::Color& color,
|
||||
void DrawDiagnostics(DiagnosticFlags aFlags,
|
||||
const gfx::Rect& visibleRect,
|
||||
const gfx::Rect& aClipRect,
|
||||
const gfx::Matrix4x4& transform,
|
||||
@@ -417,7 +413,7 @@ public:
|
||||
protected:
|
||||
uint32_t mCompositorID;
|
||||
static LayersBackend sBackend;
|
||||
bool mDrawColoredBorders;
|
||||
DiagnosticTypes mDiagnosticTypes;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
||||
@@ -93,6 +93,28 @@ TextureRequiresLocking(TextureFlags aFlags)
|
||||
TEXTURE_IMMUTABLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of debug diagnostic to enable.
|
||||
*/
|
||||
typedef uint32_t DiagnosticTypes;
|
||||
const DiagnosticTypes DIAGNOSTIC_NONE = 0;
|
||||
const DiagnosticTypes DIAGNOSTIC_TILE_BORDERS = 1 << 0;
|
||||
const DiagnosticTypes DIAGNOSTIC_LAYER_BORDERS = 1 << 1;
|
||||
const DiagnosticTypes DIAGNOSTIC_BIGIMAGE_BORDERS = 1 << 2;
|
||||
|
||||
/**
|
||||
* Information about the object that is being diagnosed.
|
||||
*/
|
||||
typedef uint32_t DiagnosticFlags;
|
||||
const DiagnosticFlags DIAGNOSTIC_IMAGE = 1 << 0;
|
||||
const DiagnosticFlags DIAGNOSTIC_CONTENT = 1 << 1;
|
||||
const DiagnosticFlags DIAGNOSTIC_CANVAS = 1 << 2;
|
||||
const DiagnosticFlags DIAGNOSTIC_COLOR = 1 << 3;
|
||||
const DiagnosticFlags DIAGNOSTIC_CONTAINER = 1 << 4;
|
||||
const DiagnosticFlags DIAGNOSTIC_TILE = 1 << 5;
|
||||
const DiagnosticFlags DIAGNOSTIC_BIGIMAGE = 1 << 6;
|
||||
const DiagnosticFlags DIAGNOSTIC_COMPONENT_ALPHA = 1 << 7;
|
||||
|
||||
/**
|
||||
* See gfx/layers/Effects.h
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,7 @@ 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),
|
||||
mCompositor->DrawDiagnostics(DIAGNOSTIC_COLOR,
|
||||
rect, clipRect,
|
||||
transform, gfx::Point(aOffset.x, aOffset.y));
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ ContainerRender(ContainerT* aContainer,
|
||||
LayerRect layerViewport = frame.mViewport * frame.LayersPixelsPerCSSPixel();
|
||||
gfx::Rect rect(layerViewport.x, layerViewport.y, layerViewport.width, layerViewport.height);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
aManager->GetCompositor()->DrawDiagnostics(gfx::Color(1.0, 0.0, 0.0, 1.0),
|
||||
aManager->GetCompositor()->DrawDiagnostics(DIAGNOSTIC_CONTAINER,
|
||||
rect, clipRect,
|
||||
transform, gfx::Point(aOffset.x, aOffset.y));
|
||||
}
|
||||
|
||||
@@ -175,13 +175,10 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
Float(tileRegionRect.width) / texRect.width,
|
||||
Float(tileRegionRect.height) / texRect.height);
|
||||
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform, aOffset);
|
||||
if (iterOnWhite) {
|
||||
GetCompositor()->DrawDiagnostics(gfx::Color(0.0,0.0,1.0,1.0),
|
||||
rect, aClipRect, aTransform, aOffset);
|
||||
} else {
|
||||
GetCompositor()->DrawDiagnostics(gfx::Color(0.0,1.0,0.0,1.0),
|
||||
rect, aClipRect, aTransform, aOffset);
|
||||
}
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT;
|
||||
diagnostics |= usingTiles ? DIAGNOSTIC_BIGIMAGE : 0;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect, aTransform, aOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@ ImageHost::Composite(EffectChain& aEffectChain,
|
||||
source,
|
||||
aFilter);
|
||||
aEffectChain.mPrimaryEffect = effect;
|
||||
IntSize textureSize = source->GetSize();
|
||||
gfx::Rect gfxPictureRect
|
||||
= mHasPictureRect ? gfx::Rect(0, 0, mPictureRect.width, mPictureRect.height)
|
||||
: gfx::Rect(0, 0, textureSize.width, textureSize.height);
|
||||
|
||||
gfx::Rect pictureRect(0, 0,
|
||||
mPictureRect.width,
|
||||
@@ -91,10 +95,14 @@ ImageHost::Composite(EffectChain& aEffectChain,
|
||||
}
|
||||
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aOffset);
|
||||
GetCompositor()->DrawDiagnostics(gfx::Color(0.5,0.0,0.0,1.0),
|
||||
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE|DIAGNOSTIC_BIGIMAGE,
|
||||
rect, aClipRect, aTransform, aOffset);
|
||||
} while (it->NextTile());
|
||||
it->EndTileIteration();
|
||||
// layer border
|
||||
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE,
|
||||
gfxPictureRect, aClipRect,
|
||||
aTransform, aOffset);
|
||||
} else {
|
||||
IntSize textureSize = source->GetSize();
|
||||
gfx::Rect rect;
|
||||
@@ -116,8 +124,9 @@ ImageHost::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);
|
||||
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE,
|
||||
rect, aClipRect,
|
||||
aTransform, aOffset);
|
||||
}
|
||||
mFrontBuffer->Unlock();
|
||||
}
|
||||
@@ -270,7 +279,7 @@ DeprecatedImageHostSingle::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),
|
||||
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE|DIAGNOSTIC_BIGIMAGE,
|
||||
rect, aClipRect, aTransform, aOffset);
|
||||
} while (it->NextTile());
|
||||
it->EndTileIteration();
|
||||
@@ -296,7 +305,7 @@ DeprecatedImageHostSingle::Composite(EffectChain& aEffectChain,
|
||||
|
||||
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aOffset);
|
||||
GetCompositor()->DrawDiagnostics(gfx::Color(1.0,0.1,0.1,1.0),
|
||||
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE,
|
||||
rect, aClipRect, aTransform, aOffset);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ 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),
|
||||
mCompositor->DrawDiagnostics(DIAGNOSTIC_CONTENT|DIAGNOSTIC_TILE,
|
||||
graphicsRect, aClipRect, aTransform, aOffset);
|
||||
}
|
||||
|
||||
@@ -288,6 +288,10 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
||||
tileX++;
|
||||
x += w;
|
||||
}
|
||||
gfx::Rect rect(aVisibleRect.x, aVisibleRect.y,
|
||||
aVisibleRect.width, aVisibleRect.height);
|
||||
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_CONTENT,
|
||||
rect, aClipRect, aTransform, aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -18,6 +18,7 @@ include "mozilla/dom/ScreenOrientation.h";
|
||||
include "nsCSSProperty.h";
|
||||
include "gfxipc/ShadowLayerUtils.h";
|
||||
include "ImageLayers.h";
|
||||
include "mozilla/layers/CompositorTypes.h";
|
||||
|
||||
using gfxPoint3D;
|
||||
using nscoord;
|
||||
@@ -32,6 +33,7 @@ using mozilla::layers::TextureInfo;
|
||||
using mozilla::LayerMargin;
|
||||
using mozilla::LayerPoint;
|
||||
using mozilla::layers::ImageLayer::ScaleMode;
|
||||
using mozilla::layers::DiagnosticTypes;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@@ -237,7 +239,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; };
|
||||
struct OpSetDiagnosticTypes { DiagnosticTypes diagnostics; };
|
||||
|
||||
// Paint (buffer update)
|
||||
struct OpPaintTiledLayerBuffer {
|
||||
@@ -360,7 +362,7 @@ union Edit {
|
||||
OpCreateRefLayer;
|
||||
|
||||
OpSetLayerAttributes;
|
||||
OpSetColoredBorders;
|
||||
OpSetDiagnosticTypes;
|
||||
|
||||
OpSetRoot;
|
||||
OpInsertAfter;
|
||||
|
||||
@@ -333,12 +333,9 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Edit::TOpSetColoredBorders: {
|
||||
if (edit.get_OpSetColoredBorders().enabled()) {
|
||||
mLayerManager->GetCompositor()->EnableColoredBorders();
|
||||
} else {
|
||||
mLayerManager->GetCompositor()->DisableColoredBorders();
|
||||
}
|
||||
case Edit::TOpSetDiagnosticTypes: {
|
||||
mLayerManager->GetCompositor()->SetDiagnosticTypes(
|
||||
edit.get_OpSetDiagnosticTypes().diagnostics());
|
||||
break;
|
||||
}
|
||||
// Tree ops
|
||||
|
||||
@@ -166,8 +166,8 @@ CompositableForwarder::IdentifyTextureHost(const TextureFactoryIdentifier& aIden
|
||||
|
||||
ShadowLayerForwarder::ShadowLayerForwarder()
|
||||
: mShadowManager(nullptr)
|
||||
, mDiagnosticTypes(DIAGNOSTIC_NONE)
|
||||
, mIsFirstPaint(false)
|
||||
, mDrawColoredBorders(false)
|
||||
, mWindowOverlayChanged(false)
|
||||
{
|
||||
mTxn = new Transaction();
|
||||
@@ -436,9 +436,10 @@ 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));
|
||||
DiagnosticTypes diagnostics = gfxPlatform::GetPlatform()->GetLayerDiagnosticTypes();
|
||||
if (mDiagnosticTypes != diagnostics) {
|
||||
mDiagnosticTypes = diagnostics;
|
||||
mTxn->AddEdit(OpSetDiagnosticTypes(diagnostics));
|
||||
}
|
||||
|
||||
AutoTxnEnd _(mTxn);
|
||||
|
||||
@@ -471,9 +471,8 @@ private:
|
||||
bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
|
||||
|
||||
Transaction* mTxn;
|
||||
|
||||
DiagnosticTypes mDiagnosticTypes;
|
||||
bool mIsFirstPaint;
|
||||
bool mDrawColoredBorders;
|
||||
bool mWindowOverlayChanged;
|
||||
};
|
||||
|
||||
|
||||
@@ -104,7 +104,6 @@ static int gCMSIntent = -2;
|
||||
static void ShutdownCMS();
|
||||
static void MigratePrefs();
|
||||
|
||||
static bool sDrawLayerBorders = false;
|
||||
static bool sDrawFrameCounter = false;
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
@@ -249,6 +248,9 @@ static const char *gPrefLangNames[] = {
|
||||
|
||||
gfxPlatform::gfxPlatform()
|
||||
: mAzureCanvasBackendCollector(this, &gfxPlatform::GetAzureBackendInfo)
|
||||
, mDrawLayerBorders(false)
|
||||
, mDrawTileBorders(false)
|
||||
, mDrawBigImageBorders(false)
|
||||
{
|
||||
mUseHarfBuzzScripts = UNINITIALIZED_VALUE;
|
||||
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
||||
@@ -265,6 +267,16 @@ gfxPlatform::gfxPlatform()
|
||||
mLayersUseDeprecated =
|
||||
Preferences::GetBool("layers.use-deprecated-textures", true);
|
||||
|
||||
Preferences::AddBoolVarCache(&mDrawLayerBorders,
|
||||
"layers.draw-borders",
|
||||
false);
|
||||
Preferences::AddBoolVarCache(&mDrawTileBorders,
|
||||
"layers.draw-tile-borders",
|
||||
false);
|
||||
Preferences::AddBoolVarCache(&mDrawBigImageBorders,
|
||||
"layers.draw-bigimage-borders",
|
||||
false);
|
||||
|
||||
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
|
||||
uint32_t contentMask = 0;
|
||||
InitBackendPrefs(canvasMask, contentMask);
|
||||
@@ -417,10 +429,6 @@ gfxPlatform::Init()
|
||||
|
||||
gPlatform->mOrientationSyncMillis = Preferences::GetUint("layers.orientation.sync.timeout", (uint32_t)0);
|
||||
|
||||
mozilla::Preferences::AddBoolVarCache(&sDrawLayerBorders,
|
||||
"layers.draw-borders",
|
||||
false);
|
||||
|
||||
mozilla::Preferences::AddBoolVarCache(&sDrawFrameCounter,
|
||||
"layers.frame-counter",
|
||||
false);
|
||||
@@ -1181,10 +1189,20 @@ gfxPlatform::IsLangCJK(eFontPrefLang aLang)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
gfxPlatform::DrawLayerBorders()
|
||||
mozilla::layers::DiagnosticTypes
|
||||
gfxPlatform::GetLayerDiagnosticTypes()
|
||||
{
|
||||
return sDrawLayerBorders;
|
||||
mozilla::layers::DiagnosticTypes type = DIAGNOSTIC_NONE;
|
||||
if (mDrawLayerBorders) {
|
||||
type |= mozilla::layers::DIAGNOSTIC_LAYER_BORDERS;
|
||||
}
|
||||
if (mDrawTileBorders) {
|
||||
type |= mozilla::layers::DIAGNOSTIC_TILE_BORDERS;
|
||||
}
|
||||
if (mDrawBigImageBorders) {
|
||||
type |= mozilla::layers::DIAGNOSTIC_BIGIMAGE_BORDERS;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "GfxInfoCollector.h"
|
||||
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
|
||||
#ifdef XP_OS2
|
||||
#undef OS2EMX_PLAIN_CHAR
|
||||
#endif
|
||||
@@ -560,7 +562,11 @@ public:
|
||||
|
||||
uint32_t GetOrientationSyncMillis() const;
|
||||
|
||||
static bool DrawLayerBorders();
|
||||
/**
|
||||
* Return the layer debugging options to use browser-wide.
|
||||
*/
|
||||
mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes();
|
||||
|
||||
static bool DrawFrameCounter();
|
||||
/**
|
||||
* Returns true if we should use raw memory to send data to the compositor
|
||||
@@ -675,6 +681,9 @@ private:
|
||||
uint32_t mOrientationSyncMillis;
|
||||
bool mLayersPreferMemoryOverShmem;
|
||||
bool mLayersUseDeprecated;
|
||||
bool mDrawLayerBorders;
|
||||
bool mDrawTileBorders;
|
||||
bool mDrawBigImageBorders;
|
||||
};
|
||||
|
||||
#endif /* GFX_PLATFORM_H */
|
||||
|
||||
@@ -4073,6 +4073,8 @@ pref("layers.acceleration.force-enabled", false);
|
||||
pref("layers.acceleration.draw-fps", false);
|
||||
|
||||
pref("layers.draw-borders", false);
|
||||
pref("layers.draw-tile-borders", false);
|
||||
pref("layers.draw-bigimage-borders", false);
|
||||
pref("layers.frame-counter", false);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
||||
Reference in New Issue
Block a user