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 02:20:52 -07: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-11 16:17:23 -07: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 07:35:29 -07: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 02:20:52 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-08-11 16:17:23 -07: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 02:20:52 -07:00
|
|
|
namespace layers {
|
|
|
|
|
2014-01-23 10:26:41 -08:00
|
|
|
/* static */ LayersBackend Compositor::sBackend = LayersBackend::LAYERS_NONE;
|
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 02:20:52 -07:00
|
|
|
/* static */ LayersBackend
|
|
|
|
Compositor::GetBackend()
|
2013-07-30 11:03:40 -07: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 02:20:52 -07:00
|
|
|
{
|
2013-06-26 16:30:52 -07: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 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
2013-10-24 07:35:29 -07: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 10:08:01 -07:00
|
|
|
void
|
2013-08-02 15:50:17 -07:00
|
|
|
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
2013-10-24 07:35:29 -07:00
|
|
|
const nsIntRegion& aVisibleRegion,
|
2013-03-21 10:08:01 -07:00
|
|
|
const gfx::Rect& aClipRect,
|
2013-11-07 01:53:08 -08:00
|
|
|
const gfx::Matrix4x4& aTransform)
|
2013-03-21 10:08:01 -07:00
|
|
|
{
|
2013-10-24 07:35:29 -07:00
|
|
|
if (!ShouldDrawDiagnostics(aFlags)) {
|
2013-03-21 10:08:01 -07:00
|
|
|
return;
|
|
|
|
}
|
2013-10-24 07:35:29 -07:00
|
|
|
|
|
|
|
if (aVisibleRegion.GetNumRects() > 1) {
|
|
|
|
nsIntRegionRectIterator screenIter(aVisibleRegion);
|
|
|
|
|
|
|
|
while (const nsIntRect* rect = screenIter.Next())
|
|
|
|
{
|
|
|
|
DrawDiagnostics(aFlags | DIAGNOSTIC_REGION_RECT,
|
2013-11-07 01:53:08 -08:00
|
|
|
ToRect(*rect), aClipRect, aTransform);
|
2013-10-24 07:35:29 -07:00
|
|
|
}
|
2013-10-10 10:36:24 -07:00
|
|
|
}
|
2013-10-24 07:35:29 -07:00
|
|
|
|
|
|
|
DrawDiagnostics(aFlags, ToRect(aVisibleRegion.GetBounds()),
|
2013-11-07 01:53:08 -08:00
|
|
|
aClipRect, aTransform);
|
2013-10-24 07:35:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
|
|
|
|
const gfx::Rect& aVisibleRect,
|
|
|
|
const gfx::Rect& aClipRect,
|
2013-11-07 01:53:08 -08:00
|
|
|
const gfx::Matrix4x4& aTransform)
|
2013-10-24 07:35:29 -07:00
|
|
|
{
|
|
|
|
if (!ShouldDrawDiagnostics(aFlags)) {
|
2013-08-02 15:50:17 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-24 07:35:29 -07:00
|
|
|
DrawDiagnosticsInternal(aFlags, aVisibleRect,
|
2013-11-07 01:53:08 -08:00
|
|
|
aClipRect, aTransform);
|
2013-10-24 07:35:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
|
|
|
|
const gfx::Rect& aVisibleRect,
|
|
|
|
const gfx::Rect& aClipRect,
|
2013-11-07 01:53:08 -08:00
|
|
|
const gfx::Matrix4x4& aTransform)
|
2013-10-24 07:35:29 -07:00
|
|
|
{
|
2013-10-10 10:36:24 -07:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
int lWidth = 4;
|
|
|
|
#elif defined(ANDROID)
|
|
|
|
int lWidth = 10;
|
|
|
|
#else
|
2013-08-02 15:50:17 -07:00
|
|
|
int lWidth = 2;
|
2013-10-10 10:36:24 -07:00
|
|
|
#endif
|
2014-01-09 06:26:19 -08:00
|
|
|
float opacity = 0.7f;
|
2013-08-02 15:50:17 -07:00
|
|
|
|
|
|
|
gfx::Color color;
|
|
|
|
if (aFlags & DIAGNOSTIC_CONTENT) {
|
2014-01-09 06:26:19 -08:00
|
|
|
color = gfx::Color(0.0f, 1.0f, 0.0f, 1.0f); // green
|
2013-08-02 15:50:17 -07:00
|
|
|
if (aFlags & DIAGNOSTIC_COMPONENT_ALPHA) {
|
2014-01-09 06:26:19 -08:00
|
|
|
color = gfx::Color(0.0f, 1.0f, 1.0f, 1.0f); // greenish blue
|
2013-08-02 15:50:17 -07:00
|
|
|
}
|
|
|
|
} else if (aFlags & DIAGNOSTIC_IMAGE) {
|
2014-01-09 06:26:19 -08:00
|
|
|
color = gfx::Color(1.0f, 0.0f, 0.0f, 1.0f); // red
|
2013-08-02 15:50:17 -07:00
|
|
|
} else if (aFlags & DIAGNOSTIC_COLOR) {
|
2014-01-09 06:26:19 -08:00
|
|
|
color = gfx::Color(0.0f, 0.0f, 1.0f, 1.0f); // blue
|
2013-08-02 15:50:17 -07:00
|
|
|
} else if (aFlags & DIAGNOSTIC_CONTAINER) {
|
2014-01-09 06:26:19 -08:00
|
|
|
color = gfx::Color(0.8f, 0.0f, 0.8f, 1.0f); // purple
|
2013-08-02 15:50:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// make tile borders a bit more transparent to keep layer borders readable.
|
2013-10-24 07:35:29 -07:00
|
|
|
if (aFlags & DIAGNOSTIC_TILE ||
|
|
|
|
aFlags & DIAGNOSTIC_BIGIMAGE ||
|
|
|
|
aFlags & DIAGNOSTIC_REGION_RECT) {
|
2013-08-02 15:50:17 -07:00
|
|
|
lWidth = 1;
|
2014-01-09 06:26:19 -08:00
|
|
|
opacity = 0.5f;
|
|
|
|
color.r *= 0.7f;
|
|
|
|
color.g *= 0.7f;
|
|
|
|
color.b *= 0.7f;
|
2013-08-02 15:50:17 -07:00
|
|
|
}
|
|
|
|
|
2013-03-21 10:08:01 -07:00
|
|
|
EffectChain effects;
|
2013-08-02 15:50:17 -07:00
|
|
|
|
|
|
|
effects.mPrimaryEffect = new EffectSolidColor(color);
|
2013-03-21 10:08:01 -07:00
|
|
|
// left
|
2013-10-24 07:35:29 -07:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x, aVisibleRect.y,
|
|
|
|
lWidth, aVisibleRect.height),
|
2013-03-21 10:08:01 -07:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 01:53:08 -08:00
|
|
|
aTransform);
|
2013-03-21 10:08:01 -07:00
|
|
|
// top
|
2013-10-24 07:35:29 -07:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x + lWidth, aVisibleRect.y,
|
|
|
|
aVisibleRect.width - 2 * lWidth, lWidth),
|
2013-03-21 10:08:01 -07:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 01:53:08 -08:00
|
|
|
aTransform);
|
2013-03-21 10:08:01 -07:00
|
|
|
// right
|
2013-10-24 07:35:29 -07:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x + aVisibleRect.width - lWidth, aVisibleRect.y,
|
|
|
|
lWidth, aVisibleRect.height),
|
2013-03-21 10:08:01 -07:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 01:53:08 -08:00
|
|
|
aTransform);
|
2013-03-21 10:08:01 -07:00
|
|
|
// bottom
|
2013-10-24 07:35:29 -07:00
|
|
|
this->DrawQuad(gfx::Rect(aVisibleRect.x + lWidth, aVisibleRect.y + aVisibleRect.height-lWidth,
|
|
|
|
aVisibleRect.width - 2 * lWidth, lWidth),
|
2013-03-21 10:08:01 -07:00
|
|
|
aClipRect, effects, opacity,
|
2013-11-07 01:53:08 -08:00
|
|
|
aTransform);
|
2013-03-21 10:08:01 -07: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 02:20:52 -07:00
|
|
|
} // namespace
|
|
|
|
} // namespace
|