Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/layers/Compositor.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "base/message_loop.h" // for MessageLoop
|
|
|
|
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
|
|
|
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
|
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
2013-10-24 18:35:29 +04:00
|
|
|
#include "gfx2DGlue.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-08-12 03:17:23 +04:00
|
|
|
namespace gfx {
|
|
|
|
class Matrix4x4;
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
/* static */ LayersBackend Compositor::sBackend = LAYERS_NONE;
|
|
|
|
/* static */ LayersBackend
|
|
|
|
Compositor::GetBackend()
|
2013-07-30 22:03:40 +04:00
|
|
|
{
|
|
|
|
AssertOnCompositorThread();
|
|
|
|
return sBackend;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
Compositor::AssertOnCompositorThread()
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-06-27 03:30:52 +04:00
|
|
|
MOZ_ASSERT(CompositorParent::CompositorLoop() ==
|
|
|
|
MessageLoop::current(),
|
|
|
|
"Can only call this from the compositor thread!");
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2013-10-24 18:35:29 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-21 21:08:01 +04:00
|
|
|
void
|
2013-08-03 02:50:17 +04:00
|
|
|
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
2013-10-24 18:35:29 +04:00
|
|
|
const nsIntRegion& aVisibleRegion,
|
2013-03-21 21:08:01 +04:00
|
|
|
const gfx::Rect& aClipRect,
|
2013-11-07 13:53:08 +04:00
|
|
|
const gfx::Matrix4x4& aTransform)
|
2013-03-21 21:08:01 +04:00
|
|
|
{
|
2013-10-24 18:35:29 +04:00
|
|
|
if (!ShouldDrawDiagnostics(aFlags)) {
|
2013-03-21 21:08:01 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-10-24 18:35:29 +04:00
|
|
|
|
|
|
|
if (aVisibleRegion.GetNumRects() > 1) {
|
|
|
|
nsIntRegionRectIterator screenIter(aVisibleRegion);
|
|
|
|
|
|
|
|
while (const nsIntRect* rect = screenIter.Next())
|
|
|
|
{
|
|
|
|
DrawDiagnostics(aFlags | DIAGNOSTIC_REGION_RECT,
|
2013-11-07 13:53:08 +04:00
|
|
|
ToRect(*rect), aClipRect, aTransform);
|
2013-10-24 18:35:29 +04:00
|
|
|
}
|
2013-10-10 21:36:24 +04:00
|
|
|
}
|
2013-10-24 18:35:29 +04:00
|
|
|
|
|
|
|
DrawDiagnostics(aFlags, ToRect(aVisibleRegion.GetBounds()),
|
2013-11-07 13:53:08 +04:00
|
|
|
aClipRect, aTransform);
|
2013-10-24 18:35:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
|
|
|
const gfx::Rect& aVisibleRect,
|
|
|
|
const gfx::Rect& aClipRect,
|
2013-11-07 13:53:08 +04:00
|
|
|
const gfx::Matrix4x4& aTransform)
|
2013-10-24 18:35:29 +04:00
|
|
|
{
|
|
|
|
if (!ShouldDrawDiagnostics(aFlags)) {
|
2013-08-03 02:50:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-24 18:35:29 +04:00
|
|
|
DrawDiagnosticsInternal(aFlags, aVisibleRect,
|
2013-11-07 13:53:08 +04:00
|
|
|
aClipRect, aTransform);
|
2013-10-24 18:35:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
|
|
|
|
const gfx::Rect& aVisibleRect,
|
|
|
|
const gfx::Rect& aClipRect,
|
2013-11-07 13:53:08 +04:00
|
|
|
const gfx::Matrix4x4& aTransform)
|
2013-10-24 18:35:29 +04:00
|
|
|
{
|
2013-10-10 21:36:24 +04:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
int lWidth = 4;
|
|
|
|
#elif defined(ANDROID)
|
|
|
|
int lWidth = 10;
|
|
|
|
#else
|
2013-08-03 02:50:17 +04:00
|
|
|
int lWidth = 2;
|
2013-10-10 21:36:24 +04:00
|
|
|
#endif
|
2013-08-03 02:50:17 +04:00
|
|
|
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) {
|
2013-10-10 21:36:24 +04:00
|
|
|
color = gfx::Color(1.0, 0.0, 0.0, 1.0); // red
|
2013-08-03 02:50:17 +04:00
|
|
|
} 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.
|
2013-10-24 18:35:29 +04:00
|
|
|
if (aFlags & DIAGNOSTIC_TILE ||
|
|
|
|
aFlags & DIAGNOSTIC_BIGIMAGE ||
|
|
|
|
aFlags & DIAGNOSTIC_REGION_RECT) {
|
2013-08-03 02:50:17 +04:00
|
|
|
lWidth = 1;
|
|
|
|
opacity = 0.5;
|
|
|
|
color.r *= 0.7;
|
|
|
|
color.g *= 0.7;
|
|
|
|
color.b *= 0.7;
|
|
|
|
}
|
|
|
|
|
2013-03-21 21:08:01 +04:00
|
|
|
EffectChain effects;
|
2013-08-03 02:50:17 +04:00
|
|
|
|
|
|
|
effects.mPrimaryEffect = new EffectSolidColor(color);
|
2013-03-21 21:08:01 +04:00
|
|
|
// left
|
2013-10-24 18:35:29 +04:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x, aVisibleRect.y,
|
|
|
|
lWidth, aVisibleRect.height),
|
2013-03-21 21:08:01 +04:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 13:53:08 +04:00
|
|
|
aTransform);
|
2013-03-21 21:08:01 +04:00
|
|
|
// top
|
2013-10-24 18:35:29 +04:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x + lWidth, aVisibleRect.y,
|
|
|
|
aVisibleRect.width - 2 * lWidth, lWidth),
|
2013-03-21 21:08:01 +04:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 13:53:08 +04:00
|
|
|
aTransform);
|
2013-03-21 21:08:01 +04:00
|
|
|
// right
|
2013-10-24 18:35:29 +04:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x + aVisibleRect.width - lWidth, aVisibleRect.y,
|
|
|
|
lWidth, aVisibleRect.height),
|
2013-03-21 21:08:01 +04:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 13:53:08 +04:00
|
|
|
aTransform);
|
2013-03-21 21:08:01 +04:00
|
|
|
// bottom
|
2013-10-24 18:35:29 +04:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x + lWidth, aVisibleRect.y + aVisibleRect.height-lWidth,
|
|
|
|
aVisibleRect.width - 2 * lWidth, lWidth),
|
2013-03-21 21:08:01 +04:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 13:53:08 +04:00
|
|
|
aTransform);
|
2013-03-21 21:08:01 +04:00
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
} // namespace
|
|
|
|
} // namespace
|