зеркало из https://github.com/mozilla/gecko-dev.git
Bug 930033 - Draw layer borders for the bounding box of the visible region for ThebesLayers. r=nical
This commit is contained in:
Родитель
9bf2a6e71d
Коммит
b9c3d10afd
|
@ -8,6 +8,7 @@
|
|||
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
||||
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "gfx2DGlue.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
@ -32,23 +33,70 @@ Compositor::AssertOnCompositorThread()
|
|||
"Can only call this from the compositor thread!");
|
||||
}
|
||||
|
||||
bool
|
||||
Compositor::ShouldDrawDiagnostics(DiagnosticFlags aFlags)
|
||||
{
|
||||
if ((aFlags & DIAGNOSTIC_TILE) && !(mDiagnosticTypes & DIAGNOSTIC_TILE_BORDERS)) {
|
||||
return false;
|
||||
}
|
||||
if ((aFlags & DIAGNOSTIC_BIGIMAGE) &&
|
||||
!(mDiagnosticTypes & DIAGNOSTIC_BIGIMAGE_BORDERS)) {
|
||||
return false;
|
||||
}
|
||||
if (!mDiagnosticTypes) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
||||
const gfx::Rect& rect,
|
||||
const nsIntRegion& aVisibleRegion,
|
||||
const gfx::Rect& aClipRect,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const gfx::Point& aOffset)
|
||||
{
|
||||
if ((aFlags & DIAGNOSTIC_TILE) && !(mDiagnosticTypes & DIAGNOSTIC_TILE_BORDERS)) {
|
||||
return;
|
||||
}
|
||||
if ((aFlags & DIAGNOSTIC_BIGIMAGE) && !(mDiagnosticTypes & DIAGNOSTIC_BIGIMAGE_BORDERS)) {
|
||||
return;
|
||||
}
|
||||
if (!mDiagnosticTypes) {
|
||||
if (!ShouldDrawDiagnostics(aFlags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aVisibleRegion.GetNumRects() > 1) {
|
||||
nsIntRegionRectIterator screenIter(aVisibleRegion);
|
||||
|
||||
while (const nsIntRect* rect = screenIter.Next())
|
||||
{
|
||||
DrawDiagnostics(aFlags | DIAGNOSTIC_REGION_RECT,
|
||||
ToRect(*rect), aClipRect, aTransform, aOffset);
|
||||
}
|
||||
}
|
||||
|
||||
DrawDiagnostics(aFlags, ToRect(aVisibleRegion.GetBounds()),
|
||||
aClipRect, aTransform, aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
||||
const gfx::Rect& aVisibleRect,
|
||||
const gfx::Rect& aClipRect,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const gfx::Point& aOffset)
|
||||
{
|
||||
if (!ShouldDrawDiagnostics(aFlags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DrawDiagnosticsInternal(aFlags, aVisibleRect,
|
||||
aClipRect, aTransform,
|
||||
aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
|
||||
const gfx::Rect& aVisibleRect,
|
||||
const gfx::Rect& aClipRect,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const gfx::Point& aOffset)
|
||||
{
|
||||
#ifdef MOZ_B2G
|
||||
int lWidth = 4;
|
||||
#elif defined(ANDROID)
|
||||
|
@ -73,7 +121,9 @@ Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
|||
}
|
||||
|
||||
// make tile borders a bit more transparent to keep layer borders readable.
|
||||
if (aFlags & DIAGNOSTIC_TILE || aFlags & DIAGNOSTIC_BIGIMAGE) {
|
||||
if (aFlags & DIAGNOSTIC_TILE ||
|
||||
aFlags & DIAGNOSTIC_BIGIMAGE ||
|
||||
aFlags & DIAGNOSTIC_REGION_RECT) {
|
||||
lWidth = 1;
|
||||
opacity = 0.5;
|
||||
color.r *= 0.7;
|
||||
|
@ -85,23 +135,23 @@ Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
|||
|
||||
effects.mPrimaryEffect = new EffectSolidColor(color);
|
||||
// left
|
||||
this->DrawQuad(gfx::Rect(rect.x, rect.y,
|
||||
lWidth, rect.height),
|
||||
this->DrawQuad(gfx::Rect(aVisibleRect.x, aVisibleRect.y,
|
||||
lWidth, aVisibleRect.height),
|
||||
aClipRect, effects, opacity,
|
||||
aTransform, aOffset);
|
||||
// top
|
||||
this->DrawQuad(gfx::Rect(rect.x + lWidth, rect.y,
|
||||
rect.width - 2 * lWidth, lWidth),
|
||||
this->DrawQuad(gfx::Rect(aVisibleRect.x + lWidth, aVisibleRect.y,
|
||||
aVisibleRect.width - 2 * lWidth, lWidth),
|
||||
aClipRect, effects, opacity,
|
||||
aTransform, aOffset);
|
||||
// right
|
||||
this->DrawQuad(gfx::Rect(rect.x + rect.width - lWidth, rect.y,
|
||||
lWidth, rect.height),
|
||||
this->DrawQuad(gfx::Rect(aVisibleRect.x + aVisibleRect.width - lWidth, aVisibleRect.y,
|
||||
lWidth, aVisibleRect.height),
|
||||
aClipRect, effects, opacity,
|
||||
aTransform, aOffset);
|
||||
// bottom
|
||||
this->DrawQuad(gfx::Rect(rect.x + lWidth, rect.y + rect.height-lWidth,
|
||||
rect.width - 2 * lWidth, lWidth),
|
||||
this->DrawQuad(gfx::Rect(aVisibleRect.x + lWidth, aVisibleRect.y + aVisibleRect.height-lWidth,
|
||||
aVisibleRect.width - 2 * lWidth, lWidth),
|
||||
aClipRect, effects, opacity,
|
||||
aTransform, aOffset);
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@
|
|||
class nsIWidget;
|
||||
struct gfxMatrix;
|
||||
struct nsIntSize;
|
||||
class nsIntRegion;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
@ -351,6 +352,12 @@ public:
|
|||
const gfx::Matrix4x4& transform,
|
||||
const gfx::Point& aOffset);
|
||||
|
||||
void DrawDiagnostics(DiagnosticFlags aFlags,
|
||||
const nsIntRegion& visibleRegion,
|
||||
const gfx::Rect& aClipRect,
|
||||
const gfx::Matrix4x4& transform,
|
||||
const gfx::Point& aOffset);
|
||||
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual const char* Name() const = 0;
|
||||
|
@ -422,6 +429,14 @@ public:
|
|||
static LayersBackend GetBackend();
|
||||
|
||||
protected:
|
||||
void DrawDiagnosticsInternal(DiagnosticFlags aFlags,
|
||||
const gfx::Rect& aVisibleRect,
|
||||
const gfx::Rect& aClipRect,
|
||||
const gfx::Matrix4x4& transform,
|
||||
const gfx::Point& aOffset);
|
||||
|
||||
bool ShouldDrawDiagnostics(DiagnosticFlags);
|
||||
|
||||
uint32_t mCompositorID;
|
||||
static LayersBackend sBackend;
|
||||
DiagnosticTypes mDiagnosticTypes;
|
||||
|
|
|
@ -112,6 +112,7 @@ 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;
|
||||
const DiagnosticFlags DIAGNOSTIC_REGION_RECT = 1 << 8;
|
||||
|
||||
/**
|
||||
* See gfx/layers/Effects.h
|
||||
|
|
|
@ -206,10 +206,12 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
|
|||
Float(tileRegionRect.width) / texRect.width,
|
||||
Float(tileRegionRect.height) / texRect.height);
|
||||
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform, aOffset);
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT;
|
||||
diagnostics |= usingTiles ? DIAGNOSTIC_BIGIMAGE : 0;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect, aTransform, aOffset);
|
||||
if (usingTiles) {
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT | DIAGNOSTIC_BIGIMAGE;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
|
||||
aTransform, aOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +227,10 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
|
|||
if (iterOnWhite) {
|
||||
iterOnWhite->EndTileIteration();
|
||||
}
|
||||
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, *aVisibleRegion, aClipRect, aTransform, aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -33,6 +33,11 @@ inline Rect ToRect(const gfxRect &aRect)
|
|||
Float(aRect.width), Float(aRect.height));
|
||||
}
|
||||
|
||||
inline Rect ToRect(const nsIntRect &aRect)
|
||||
{
|
||||
return Rect(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
}
|
||||
|
||||
inline IntRect ToIntRect(const nsIntRect &aRect)
|
||||
{
|
||||
return IntRect(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
|
|
Загрузка…
Ссылка в новой задаче