2010-07-21 11:06:33 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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/. */
|
2010-03-03 13:37:04 -08:00
|
|
|
|
2013-11-26 16:29:46 -08:00
|
|
|
#include "RotatedBuffer.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include <sys/types.h> // for int32_t
|
|
|
|
#include <algorithm> // for max
|
|
|
|
#include "BasicImplData.h" // for BasicImplData
|
|
|
|
#include "BasicLayersImpl.h" // for ToData
|
2013-10-11 13:47:47 -07:00
|
|
|
#include "BufferUnrotate.h" // for BufferUnrotate
|
2013-08-22 00:11:51 -07:00
|
|
|
#include "GeckoProfiler.h" // for PROFILER_LABEL
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "Layers.h" // for ThebesLayer, Layer, etc
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2014-02-26 18:53:27 -08:00
|
|
|
#include "gfxPrefs.h" // for gfxPrefs
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "gfxUtils.h" // for gfxUtils
|
2013-12-08 18:52:54 -08:00
|
|
|
#include "mozilla/ArrayUtils.h" // for ArrayLength
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
|
|
#include "mozilla/gfx/BaseRect.h" // for BaseRect
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
|
|
#include "mozilla/gfx/Matrix.h" // for Matrix
|
|
|
|
#include "mozilla/gfx/Point.h" // for Point, IntPoint
|
|
|
|
#include "mozilla/gfx/Rect.h" // for Rect, IntRect
|
2014-01-10 11:06:17 -08:00
|
|
|
#include "mozilla/gfx/Types.h" // for ExtendMode::ExtendMode::CLAMP, etc
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer
|
2014-03-31 23:28:23 -07:00
|
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "nsSize.h" // for nsIntSize
|
2013-10-07 16:15:59 -07:00
|
|
|
#include "gfx2DGlue.h"
|
2010-03-03 13:37:04 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
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
|
|
|
|
|
|
|
using namespace gfx;
|
|
|
|
|
2010-03-03 13:37:04 -08:00
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
nsIntRect
|
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
|
|
|
RotatedBuffer::GetQuadrantRectangle(XSide aXSide, YSide aYSide) const
|
2010-03-03 13:37:04 -08:00
|
|
|
{
|
|
|
|
// quadrantTranslation is the amount we translate the top-left
|
|
|
|
// of the quadrant by to get coordinates relative to the layer
|
|
|
|
nsIntPoint quadrantTranslation = -mBufferRotation;
|
|
|
|
quadrantTranslation.x += aXSide == LEFT ? mBufferRect.width : 0;
|
|
|
|
quadrantTranslation.y += aYSide == TOP ? mBufferRect.height : 0;
|
|
|
|
return mBufferRect + quadrantTranslation;
|
|
|
|
}
|
|
|
|
|
2013-11-04 20:50:57 -08:00
|
|
|
Rect
|
|
|
|
RotatedBuffer::GetSourceRectangle(XSide aXSide, YSide aYSide) const
|
|
|
|
{
|
|
|
|
Rect result;
|
|
|
|
if (aXSide == LEFT) {
|
|
|
|
result.x = 0;
|
|
|
|
result.width = mBufferRotation.x;
|
|
|
|
} else {
|
|
|
|
result.x = mBufferRotation.x;
|
|
|
|
result.width = mBufferRect.width - mBufferRotation.x;
|
|
|
|
}
|
|
|
|
if (aYSide == TOP) {
|
|
|
|
result.y = 0;
|
|
|
|
result.height = mBufferRotation.y;
|
|
|
|
} else {
|
|
|
|
result.y = mBufferRotation.y;
|
|
|
|
result.height = mBufferRect.height - mBufferRotation.y;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* @param aXSide LEFT means we draw from the left side of the buffer (which
|
|
|
|
* is drawn on the right side of mBufferRect). RIGHT means we draw from
|
|
|
|
* the right side of the buffer (which is drawn on the left side of
|
|
|
|
* mBufferRect).
|
|
|
|
* @param aYSide TOP means we draw from the top side of the buffer (which
|
|
|
|
* is drawn on the bottom side of mBufferRect). BOTTOM means we draw from
|
|
|
|
* the bottom side of the buffer (which is drawn on the top side of
|
|
|
|
* mBufferRect).
|
|
|
|
*/
|
2010-03-03 13:37:04 -08:00
|
|
|
void
|
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
|
|
|
RotatedBuffer::DrawBufferQuadrant(gfx::DrawTarget* aTarget,
|
|
|
|
XSide aXSide, YSide aYSide,
|
2013-04-21 19:40:52 -07:00
|
|
|
ContextSource aSource,
|
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
|
|
|
float aOpacity,
|
2013-09-10 22:08:53 -07:00
|
|
|
gfx::CompositionOp aOperator,
|
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
|
|
|
gfx::SourceSurface* aMask,
|
|
|
|
const gfx::Matrix* aMaskTransform) const
|
|
|
|
{
|
|
|
|
// The rectangle that we're going to fill. Basically we're going to
|
|
|
|
// render the buffer at mBufferRect + quadrantTranslation to get the
|
|
|
|
// pixels in the right place, but we're only going to paint within
|
|
|
|
// mBufferRect
|
|
|
|
nsIntRect quadrantRect = GetQuadrantRectangle(aXSide, aYSide);
|
|
|
|
nsIntRect fillRect;
|
|
|
|
if (!fillRect.IntersectRect(mBufferRect, quadrantRect))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gfx::Point quadrantTranslation(quadrantRect.x, quadrantRect.y);
|
|
|
|
|
2013-11-04 20:50:56 -08:00
|
|
|
// direct2d is much slower when using OP_SOURCE so use OP_OVER and
|
|
|
|
// (maybe) a clear instead. Normally we need to draw in a single operation
|
|
|
|
// (to avoid flickering) but direct2d is ok since it defers rendering.
|
|
|
|
// We should try abstract this logic in a helper when we have other use
|
|
|
|
// cases.
|
2014-06-19 13:35:33 -07:00
|
|
|
if (aTarget->GetBackendType() == BackendType::DIRECT2D && aOperator == CompositionOp::OP_SOURCE) {
|
2014-01-10 11:06:17 -08:00
|
|
|
aOperator = CompositionOp::OP_OVER;
|
2014-01-10 11:06:16 -08:00
|
|
|
if (mDTBuffer->GetFormat() == SurfaceFormat::B8G8R8A8) {
|
2013-11-04 20:50:56 -08:00
|
|
|
aTarget->ClearRect(ToRect(fillRect));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-17 18:07:08 -08:00
|
|
|
RefPtr<gfx::SourceSurface> snapshot;
|
2013-04-21 19:40:52 -07:00
|
|
|
if (aSource == BUFFER_BLACK) {
|
|
|
|
snapshot = mDTBuffer->Snapshot();
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aSource == BUFFER_WHITE);
|
|
|
|
snapshot = mDTBufferOnWhite->Snapshot();
|
|
|
|
}
|
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
|
|
|
|
2014-01-10 11:06:17 -08:00
|
|
|
if (aOperator == CompositionOp::OP_SOURCE) {
|
2013-09-10 22:08:53 -07:00
|
|
|
// OP_SOURCE is unbounded in Azure, and we really don't want that behaviour here.
|
|
|
|
// We also can't do a ClearRect+FillRect since we need the drawing to happen
|
|
|
|
// as an atomic operation (to prevent flickering).
|
|
|
|
aTarget->PushClipRect(gfx::Rect(fillRect.x, fillRect.y,
|
|
|
|
fillRect.width, fillRect.height));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (aMask) {
|
2014-02-28 11:51:17 -08:00
|
|
|
Matrix oldTransform = aTarget->GetTransform();
|
|
|
|
|
2013-11-04 20:50:57 -08:00
|
|
|
// Transform from user -> buffer space.
|
|
|
|
Matrix transform;
|
|
|
|
transform.Translate(quadrantTranslation.x, quadrantTranslation.y);
|
|
|
|
|
2014-02-28 11:51:17 -08:00
|
|
|
Matrix inverseMask = *aMaskTransform;
|
|
|
|
inverseMask.Invert();
|
|
|
|
|
|
|
|
transform *= oldTransform;
|
|
|
|
transform *= inverseMask;
|
|
|
|
|
2013-11-04 20:50:57 -08:00
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
2014-01-10 11:06:17 -08:00
|
|
|
SurfacePattern source(snapshot, ExtendMode::CLAMP, transform, Filter::POINT);
|
2013-11-04 20:50:57 -08:00
|
|
|
#else
|
2014-01-10 11:06:17 -08:00
|
|
|
SurfacePattern source(snapshot, ExtendMode::CLAMP, transform);
|
2013-11-04 20:50:57 -08:00
|
|
|
#endif
|
|
|
|
|
2013-09-13 02:06:21 -07:00
|
|
|
aTarget->SetTransform(*aMaskTransform);
|
|
|
|
aTarget->MaskSurface(source, aMask, Point(0, 0), DrawOptions(aOpacity, aOperator));
|
|
|
|
aTarget->SetTransform(oldTransform);
|
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
|
|
|
} else {
|
2013-11-04 20:50:57 -08:00
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
2014-01-10 11:06:17 -08:00
|
|
|
DrawSurfaceOptions options(Filter::POINT);
|
2013-11-04 20:50:57 -08:00
|
|
|
#else
|
|
|
|
DrawSurfaceOptions options;
|
|
|
|
#endif
|
|
|
|
aTarget->DrawSurface(snapshot, ToRect(fillRect),
|
|
|
|
GetSourceRectangle(aXSide, aYSide),
|
|
|
|
options,
|
|
|
|
DrawOptions(aOpacity, aOperator));
|
2013-09-10 22:08:53 -07:00
|
|
|
}
|
|
|
|
|
2014-01-10 11:06:17 -08:00
|
|
|
if (aOperator == CompositionOp::OP_SOURCE) {
|
2013-09-10 22:08:53 -07:00
|
|
|
aTarget->PopClip();
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-21 19:40:52 -07:00
|
|
|
RotatedBuffer::DrawBufferWithRotation(gfx::DrawTarget *aTarget, ContextSource aSource,
|
|
|
|
float aOpacity,
|
2013-09-10 22:08:53 -07:00
|
|
|
gfx::CompositionOp aOperator,
|
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
|
|
|
gfx::SourceSurface* aMask,
|
|
|
|
const gfx::Matrix* aMaskTransform) const
|
|
|
|
{
|
2014-05-23 14:12:29 -07:00
|
|
|
PROFILER_LABEL("RotatedBuffer", "DrawBufferWithRotation",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
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
|
|
|
// See above, in Azure Repeat should always be a safe, even faster choice
|
|
|
|
// though! Particularly on D2D Repeat should be a lot faster, need to look
|
|
|
|
// into that. TODO[Bas]
|
2013-09-10 22:08:53 -07:00
|
|
|
DrawBufferQuadrant(aTarget, LEFT, TOP, aSource, aOpacity, aOperator, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, RIGHT, TOP, aSource, aOpacity, aOperator, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, LEFT, BOTTOM, aSource, aOpacity, aOperator, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, RIGHT, BOTTOM, aSource, aOpacity, aOperator,aMask, aMaskTransform);
|
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 */ bool
|
2014-01-07 13:09:34 -08:00
|
|
|
RotatedContentBuffer::IsClippingCheap(DrawTarget* aTarget, const nsIntRegion& aRegion)
|
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
|
|
|
{
|
2014-01-07 13:09:34 -08:00
|
|
|
// Assume clipping is cheap if the draw target just has an integer
|
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
|
|
|
// translation, and the visible region is simple.
|
2014-01-07 13:09:34 -08:00
|
|
|
return !aTarget->GetTransform().HasNonIntegerTranslation() &&
|
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
|
|
|
aRegion.GetNumRects() <= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::DrawTo(ThebesLayer* aLayer,
|
2014-01-07 13:09:34 -08:00
|
|
|
DrawTarget* aTarget,
|
2013-11-26 16:29:46 -08:00
|
|
|
float aOpacity,
|
2014-01-07 13:09:34 -08:00
|
|
|
CompositionOp aOp,
|
2014-04-09 02:15:19 -07:00
|
|
|
SourceSurface* aMask,
|
2014-01-27 12:25:20 -08:00
|
|
|
const Matrix* aMaskTransform)
|
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-11-21 14:07:55 -08:00
|
|
|
if (!EnsureBuffer()) {
|
|
|
|
return;
|
|
|
|
}
|
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-11-26 16:29:45 -08:00
|
|
|
bool clipped = false;
|
|
|
|
|
|
|
|
// If the entire buffer is valid, we can just draw the whole thing,
|
|
|
|
// no need to clip. But we'll still clip if clipping is cheap ---
|
|
|
|
// that might let us copy a smaller region of the buffer.
|
|
|
|
// Also clip to the visible region if we're told to.
|
|
|
|
if (!aLayer->GetValidRegion().Contains(BufferRect()) ||
|
|
|
|
(ToData(aLayer)->GetClipToVisibleRegion() &&
|
|
|
|
!aLayer->GetVisibleRegion().Contains(BufferRect())) ||
|
|
|
|
IsClippingCheap(aTarget, aLayer->GetEffectiveVisibleRegion())) {
|
|
|
|
// We don't want to draw invalid stuff, so we need to clip. Might as
|
|
|
|
// well clip to the smallest area possible --- the visible region.
|
|
|
|
// Bug 599189 if there is a non-integer-translation transform in aTarget,
|
|
|
|
// we might sample pixels outside GetEffectiveVisibleRegion(), which is wrong
|
|
|
|
// and may cause gray lines.
|
2014-01-07 13:09:34 -08:00
|
|
|
gfxUtils::ClipToRegionSnapped(aTarget, aLayer->GetEffectiveVisibleRegion());
|
2013-11-26 16:29:45 -08:00
|
|
|
clipped = true;
|
|
|
|
}
|
2013-08-22 23:13:55 -07:00
|
|
|
|
2014-04-09 02:15:19 -07:00
|
|
|
DrawBufferWithRotation(aTarget, BUFFER_BLACK, aOpacity, aOp, aMask, aMaskTransform);
|
2013-11-26 16:29:45 -08:00
|
|
|
if (clipped) {
|
2014-01-07 13:09:34 -08:00
|
|
|
aTarget->PopClip();
|
2013-11-26 16:29:45 -08:00
|
|
|
}
|
2013-04-21 19:40:52 -07:00
|
|
|
}
|
|
|
|
|
2014-01-07 13:09:34 -08:00
|
|
|
DrawTarget*
|
|
|
|
RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds,
|
2014-04-10 01:42:29 -07:00
|
|
|
ContextSource aSource,
|
|
|
|
DrawIterator* aIter)
|
2010-11-05 00:17:07 -07:00
|
|
|
{
|
2014-04-10 01:42:29 -07:00
|
|
|
nsIntRect bounds = aBounds;
|
|
|
|
if (aIter) {
|
|
|
|
// If an iterator was provided, then BeginPaint must have been run with
|
|
|
|
// PAINT_CAN_DRAW_ROTATED, and the draw region might cover multiple quadrants.
|
|
|
|
// Iterate over each of them, and return an appropriate buffer each time we find
|
|
|
|
// one that intersects the draw region. The iterator mCount value tracks which
|
|
|
|
// quadrants we have considered across multiple calls to this function.
|
|
|
|
aIter->mDrawRegion.SetEmpty();
|
|
|
|
while (aIter->mCount < 4) {
|
|
|
|
nsIntRect quadrant = GetQuadrantRectangle((aIter->mCount & 1) ? LEFT : RIGHT,
|
|
|
|
(aIter->mCount & 2) ? TOP : BOTTOM);
|
|
|
|
aIter->mDrawRegion.And(aBounds, quadrant);
|
|
|
|
aIter->mCount++;
|
|
|
|
if (!aIter->mDrawRegion.IsEmpty()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aIter->mDrawRegion.IsEmpty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
bounds = aIter->mDrawRegion.GetBounds();
|
|
|
|
}
|
|
|
|
|
2013-11-21 14:07:55 -08:00
|
|
|
if (!EnsureBuffer()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
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
|
|
|
|
2014-01-07 13:09:34 -08:00
|
|
|
MOZ_ASSERT(!mLoanedDrawTarget, "draw target has been borrowed and not returned");
|
2013-04-21 19:40:52 -07:00
|
|
|
if (aSource == BUFFER_BOTH && HaveBufferOnWhite()) {
|
2013-11-21 14:07:55 -08:00
|
|
|
if (!EnsureBufferOnWhite()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-11-26 16:29:45 -08:00
|
|
|
MOZ_ASSERT(mDTBuffer && mDTBufferOnWhite);
|
2014-01-07 13:09:34 -08:00
|
|
|
mLoanedDrawTarget = Factory::CreateDualDrawTarget(mDTBuffer, mDTBufferOnWhite);
|
2013-04-21 19:40:52 -07:00
|
|
|
} else if (aSource == BUFFER_WHITE) {
|
2013-11-21 14:07:55 -08:00
|
|
|
if (!EnsureBufferOnWhite()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-01-07 13:09:34 -08:00
|
|
|
mLoanedDrawTarget = mDTBufferOnWhite;
|
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
|
|
|
} else {
|
2013-04-21 19:40:52 -07:00
|
|
|
// BUFFER_BLACK, or BUFFER_BOTH with a single buffer.
|
2014-01-07 13:09:34 -08:00
|
|
|
mLoanedDrawTarget = mDTBuffer;
|
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
|
|
|
}
|
2010-11-05 00:17:07 -07:00
|
|
|
|
|
|
|
// Figure out which quadrant to draw in
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t xBoundary = mBufferRect.XMost() - mBufferRotation.x;
|
|
|
|
int32_t yBoundary = mBufferRect.YMost() - mBufferRotation.y;
|
2014-04-10 01:42:29 -07:00
|
|
|
XSide sideX = bounds.XMost() <= xBoundary ? RIGHT : LEFT;
|
|
|
|
YSide sideY = bounds.YMost() <= yBoundary ? BOTTOM : TOP;
|
2010-11-05 00:17:07 -07:00
|
|
|
nsIntRect quadrantRect = GetQuadrantRectangle(sideX, sideY);
|
2014-04-10 01:42:29 -07:00
|
|
|
NS_ASSERTION(quadrantRect.Contains(bounds), "Messed up quadrants");
|
2010-11-05 00:17:07 -07:00
|
|
|
|
2014-01-07 13:09:34 -08:00
|
|
|
mLoanedTransform = mLoanedDrawTarget->GetTransform();
|
|
|
|
mLoanedTransform.Translate(-quadrantRect.x, -quadrantRect.y);
|
|
|
|
mLoanedDrawTarget->SetTransform(mLoanedTransform);
|
|
|
|
mLoanedTransform.Translate(quadrantRect.x, quadrantRect.y);
|
|
|
|
|
|
|
|
return mLoanedDrawTarget;
|
|
|
|
}
|
2013-05-09 14:02:50 -07:00
|
|
|
|
2014-01-07 13:09:34 -08:00
|
|
|
void
|
|
|
|
BorrowDrawTarget::ReturnDrawTarget(gfx::DrawTarget*& aReturned)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aReturned == mLoanedDrawTarget);
|
|
|
|
mLoanedDrawTarget->SetTransform(mLoanedTransform);
|
|
|
|
mLoanedDrawTarget = nullptr;
|
|
|
|
aReturned = nullptr;
|
2010-11-05 00:17:07 -07:00
|
|
|
}
|
|
|
|
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxContentType
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::BufferContentType()
|
2012-09-12 03:41:34 -07:00
|
|
|
{
|
2013-12-05 10:39:22 -08:00
|
|
|
if (mBufferProvider || mDTBuffer) {
|
|
|
|
SurfaceFormat format;
|
|
|
|
|
|
|
|
if (mBufferProvider) {
|
2014-04-10 01:14:28 -07:00
|
|
|
format = mBufferProvider->GetFormat();
|
2013-12-05 10:39:22 -08:00
|
|
|
} else if (mDTBuffer) {
|
|
|
|
format = mDTBuffer->GetFormat();
|
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-12-05 10:39:22 -08:00
|
|
|
|
|
|
|
return ContentForFormat(format);
|
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
|
|
|
}
|
2014-01-23 10:26:40 -08:00
|
|
|
return gfxContentType::SENTINEL;
|
2012-09-12 03:41:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::BufferSizeOkFor(const nsIntSize& aSize)
|
2012-09-12 03:41:34 -07:00
|
|
|
{
|
2014-02-26 17:48:41 -08:00
|
|
|
return (aSize == mBufferRect.Size() ||
|
|
|
|
(SizedToVisibleBounds != mBufferSizePolicy &&
|
|
|
|
aSize < mBufferRect.Size()));
|
2012-09-12 03:41:34 -07:00
|
|
|
}
|
|
|
|
|
2013-11-21 14:07:55 -08:00
|
|
|
bool
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::EnsureBuffer()
|
2012-09-12 03:41:34 -07:00
|
|
|
{
|
2014-01-07 13:09:34 -08:00
|
|
|
NS_ASSERTION(!mLoanedDrawTarget, "Loaned draw target must be returned");
|
2013-12-05 10:39:22 -08:00
|
|
|
if (!mDTBuffer) {
|
2014-03-31 23:28:23 -07:00
|
|
|
if (mBufferProvider) {
|
2014-06-11 11:57:58 -07:00
|
|
|
mDTBuffer = mBufferProvider->BorrowDrawTarget();
|
2013-12-05 10:39:22 -08: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
|
|
|
}
|
2013-11-21 14:07:55 -08:00
|
|
|
|
2013-11-26 16:29:45 -08:00
|
|
|
NS_WARN_IF_FALSE(mDTBuffer, "no buffer");
|
|
|
|
return !!mDTBuffer;
|
2012-09-12 03:41:34 -07:00
|
|
|
}
|
|
|
|
|
2013-11-21 14:07:55 -08:00
|
|
|
bool
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::EnsureBufferOnWhite()
|
2013-04-21 19:40:52 -07:00
|
|
|
{
|
2014-01-07 13:09:34 -08:00
|
|
|
NS_ASSERTION(!mLoanedDrawTarget, "Loaned draw target must be returned");
|
2013-12-05 10:39:22 -08:00
|
|
|
if (!mDTBufferOnWhite) {
|
2014-03-31 23:28:23 -07:00
|
|
|
if (mBufferProviderOnWhite) {
|
2013-12-05 10:39:22 -08:00
|
|
|
mDTBufferOnWhite =
|
2014-06-11 11:57:58 -07:00
|
|
|
mBufferProviderOnWhite->BorrowDrawTarget();
|
2013-12-05 10:39:22 -08:00
|
|
|
}
|
2013-04-21 19:40:52 -07:00
|
|
|
}
|
2013-11-21 14:07:55 -08:00
|
|
|
|
2013-11-26 16:29:45 -08:00
|
|
|
NS_WARN_IF_FALSE(mDTBufferOnWhite, "no buffer");
|
|
|
|
return mDTBufferOnWhite;
|
2013-04-21 19:40:52 -07:00
|
|
|
}
|
|
|
|
|
2012-09-12 03:41:34 -07:00
|
|
|
bool
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::HaveBuffer() const
|
2012-09-12 03:41:34 -07:00
|
|
|
{
|
2014-03-31 23:28:23 -07:00
|
|
|
return mDTBuffer || mBufferProvider;
|
2012-09-12 03:41:34 -07:00
|
|
|
}
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
bool
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::HaveBufferOnWhite() const
|
2013-04-21 19:40:52 -07:00
|
|
|
{
|
2014-03-31 23:28:23 -07:00
|
|
|
return mDTBufferOnWhite || mBufferProviderOnWhite;
|
2013-04-21 19:40:52 -07:00
|
|
|
}
|
|
|
|
|
2010-03-03 13:37:04 -08:00
|
|
|
static void
|
2012-08-22 08:56:38 -07:00
|
|
|
WrapRotationAxis(int32_t* aRotationPoint, int32_t aSize)
|
2010-03-03 13:37:04 -08:00
|
|
|
{
|
|
|
|
if (*aRotationPoint < 0) {
|
|
|
|
*aRotationPoint += aSize;
|
|
|
|
} else if (*aRotationPoint >= aSize) {
|
|
|
|
*aRotationPoint -= aSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 12:49:03 -07:00
|
|
|
static nsIntRect
|
|
|
|
ComputeBufferRect(const nsIntRect& aRequestedRect)
|
|
|
|
{
|
|
|
|
nsIntRect rect(aRequestedRect);
|
|
|
|
// Set a minimum width to guarantee a minimum size of buffers we
|
|
|
|
// allocate (and work around problems on some platforms with smaller
|
|
|
|
// dimensions). 64 is the magic number needed to work around the
|
|
|
|
// rendering glitch, and guarantees image rows can be SIMD'd for
|
|
|
|
// even r5g6b5 surfaces pretty much everywhere.
|
2013-01-15 04:22:03 -08:00
|
|
|
rect.width = std::max(aRequestedRect.width, 64);
|
2013-09-23 06:04:35 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
// Set a minumum height to guarantee a minumum height of buffers we
|
|
|
|
// allocate. Some GL implementations fail to render gralloc textures
|
|
|
|
// with a height 9px-16px. It happens on Adreno 200. Adreno 320 does not
|
|
|
|
// have this problem. 32 is choosed as alignment of gralloc buffers.
|
|
|
|
// See Bug 873937.
|
|
|
|
// Increase the height only when the requested height is more than 0.
|
|
|
|
// See Bug 895976.
|
|
|
|
// XXX it might be better to disable it on the gpu that does not have
|
|
|
|
// the height problem.
|
|
|
|
if (rect.height > 0) {
|
|
|
|
rect.height = std::max(aRequestedRect.height, 32);
|
|
|
|
}
|
|
|
|
#endif
|
2012-09-20 12:49:03 -07:00
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2014-01-08 16:57:52 -08:00
|
|
|
void
|
|
|
|
RotatedContentBuffer::FlushBuffers()
|
|
|
|
{
|
|
|
|
if (mDTBuffer) {
|
|
|
|
mDTBuffer->Flush();
|
|
|
|
}
|
|
|
|
if (mDTBufferOnWhite) {
|
|
|
|
mDTBufferOnWhite->Flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-26 16:29:46 -08:00
|
|
|
RotatedContentBuffer::PaintState
|
2014-01-12 11:57:17 -08:00
|
|
|
RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
|
2013-11-26 16:29:46 -08:00
|
|
|
uint32_t aFlags)
|
2010-03-03 13:37:04 -08:00
|
|
|
{
|
|
|
|
PaintState result;
|
2011-06-22 05:11:28 -07:00
|
|
|
// We need to disable rotation if we're going to be resampled when
|
2011-03-31 14:33:46 -07:00
|
|
|
// drawing, because we might sample across the rotation boundary.
|
2013-08-04 00:46:17 -07:00
|
|
|
bool canHaveRotation = gfxPlatform::BufferRotationEnabled() &&
|
|
|
|
!(aFlags & (PAINT_WILL_RESAMPLE | PAINT_NO_ROTATION));
|
2011-03-01 12:30:16 -08:00
|
|
|
|
|
|
|
nsIntRegion validRegion = aLayer->GetValidRegion();
|
|
|
|
|
2014-01-12 11:57:17 -08:00
|
|
|
bool canUseOpaqueSurface = aLayer->CanUseOpaqueSurface();
|
2014-01-30 01:39:11 -08:00
|
|
|
ContentType layerContentType =
|
2014-01-23 10:26:40 -08:00
|
|
|
canUseOpaqueSurface ? gfxContentType::COLOR :
|
|
|
|
gfxContentType::COLOR_ALPHA;
|
2014-01-12 11:57:17 -08:00
|
|
|
|
2014-01-17 06:00:00 -08:00
|
|
|
SurfaceMode mode;
|
2011-03-01 12:30:16 -08:00
|
|
|
nsIntRegion neededRegion;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool canReuseBuffer;
|
2011-03-01 12:30:16 -08:00
|
|
|
nsIntRect destBufferRect;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
while (true) {
|
2013-04-21 19:40:52 -07:00
|
|
|
mode = aLayer->GetSurfaceMode();
|
2011-03-01 12:30:16 -08:00
|
|
|
neededRegion = aLayer->GetVisibleRegion();
|
2012-09-12 03:41:34 -07:00
|
|
|
canReuseBuffer = HaveBuffer() && BufferSizeOkFor(neededRegion.GetBounds().Size());
|
2014-01-30 01:39:11 -08:00
|
|
|
result.mContentType = layerContentType;
|
2011-03-01 12:30:16 -08:00
|
|
|
|
|
|
|
if (canReuseBuffer) {
|
|
|
|
if (mBufferRect.Contains(neededRegion.GetBounds())) {
|
|
|
|
// We don't need to adjust mBufferRect.
|
|
|
|
destBufferRect = mBufferRect;
|
2011-03-09 09:27:37 -08:00
|
|
|
} else if (neededRegion.GetBounds().Size() <= mBufferRect.Size()) {
|
2011-03-01 12:30:16 -08:00
|
|
|
// The buffer's big enough but doesn't contain everything that's
|
|
|
|
// going to be visible. We'll move it.
|
|
|
|
destBufferRect = nsIntRect(neededRegion.GetBounds().TopLeft(), mBufferRect.Size());
|
2011-03-09 09:27:37 -08:00
|
|
|
} else {
|
|
|
|
destBufferRect = neededRegion.GetBounds();
|
2011-03-01 12:30:16 -08:00
|
|
|
}
|
|
|
|
} else {
|
2012-09-20 12:49:03 -07:00
|
|
|
// We won't be reusing the buffer. Compute a new rect.
|
|
|
|
destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
|
2011-03-01 12:30:16 -08:00
|
|
|
}
|
|
|
|
|
2014-01-23 10:26:41 -08:00
|
|
|
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
2013-04-21 19:40:52 -07:00
|
|
|
#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
|
2014-01-23 10:26:41 -08:00
|
|
|
mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
|
2013-04-21 19:40:52 -07:00
|
|
|
#else
|
|
|
|
if (!aLayer->GetParent() ||
|
|
|
|
!aLayer->GetParent()->SupportsComponentAlphaChildren() ||
|
|
|
|
!aLayer->Manager()->IsCompositingCheap() ||
|
|
|
|
!aLayer->AsShadowableLayer() ||
|
|
|
|
!aLayer->AsShadowableLayer()->HasShadow() ||
|
2014-02-26 18:53:27 -08:00
|
|
|
!gfxPrefs::ComponentAlphaEnabled()) {
|
2014-01-23 10:26:41 -08:00
|
|
|
mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
|
2013-04-21 19:40:52 -07:00
|
|
|
} else {
|
2014-01-30 01:39:11 -08:00
|
|
|
result.mContentType = gfxContentType::COLOR;
|
2013-04-21 19:40:52 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-03-01 12:30:16 -08:00
|
|
|
if ((aFlags & PAINT_WILL_RESAMPLE) &&
|
2011-04-18 20:07:23 -07:00
|
|
|
(!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
|
2011-03-01 12:30:16 -08:00
|
|
|
neededRegion.GetNumRects() > 1)) {
|
|
|
|
// The area we add to neededRegion might not be painted opaquely
|
2014-01-23 10:26:41 -08:00
|
|
|
if (mode == SurfaceMode::SURFACE_OPAQUE) {
|
2014-01-30 01:39:11 -08:00
|
|
|
result.mContentType = gfxContentType::COLOR_ALPHA;
|
2014-01-23 10:26:41 -08:00
|
|
|
mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
|
2013-04-21 19:40:52 -07:00
|
|
|
}
|
2011-03-01 12:30:16 -08:00
|
|
|
|
|
|
|
// We need to validate the entire buffer, to make sure that only valid
|
|
|
|
// pixels are sampled
|
|
|
|
neededRegion = destBufferRect;
|
|
|
|
}
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
// If we have an existing buffer, but the content type has changed or we
|
|
|
|
// have transitioned into/out of component alpha, then we need to recreate it.
|
|
|
|
if (HaveBuffer() &&
|
2014-01-30 01:39:11 -08:00
|
|
|
(result.mContentType != BufferContentType() ||
|
2014-01-23 10:26:41 -08:00
|
|
|
(mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) != HaveBufferOnWhite())) {
|
2013-04-21 19:40:52 -07:00
|
|
|
|
2011-03-01 12:30:16 -08:00
|
|
|
// We're effectively clearing the valid region, so we need to draw
|
|
|
|
// the entire needed region now.
|
|
|
|
result.mRegionToInvalidate = aLayer->GetValidRegion();
|
|
|
|
validRegion.SetEmpty();
|
|
|
|
Clear();
|
|
|
|
// Restart decision process with the cleared buffer. We can only go
|
2013-11-26 16:29:46 -08:00
|
|
|
// around the loop one more iteration, since mDTBuffer is null now.
|
2011-03-01 12:30:16 -08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2010-03-03 13:37:04 -08:00
|
|
|
}
|
|
|
|
|
2011-03-09 09:27:37 -08:00
|
|
|
NS_ASSERTION(destBufferRect.Contains(neededRegion.GetBounds()),
|
|
|
|
"Destination rect doesn't contain what we need to paint");
|
|
|
|
|
2011-03-01 12:30:16 -08:00
|
|
|
result.mRegionToDraw.Sub(neededRegion, validRegion);
|
2014-01-12 11:57:17 -08:00
|
|
|
|
2014-04-09 02:15:18 -07:00
|
|
|
if (result.mRegionToDraw.IsEmpty())
|
|
|
|
return result;
|
|
|
|
|
2014-04-29 13:33:11 -07:00
|
|
|
if (HaveBuffer()) {
|
|
|
|
// Do not modify result.mRegionToDraw or result.mContentType after this call.
|
|
|
|
// Do not modify mBufferRect, mBufferRotation, or mDidSelfCopy,
|
|
|
|
// or call CreateBuffer before this call.
|
|
|
|
FinalizeFrame(result.mRegionToDraw);
|
|
|
|
}
|
2014-01-12 11:57:17 -08:00
|
|
|
|
2011-03-01 12:30:16 -08:00
|
|
|
nsIntRect drawBounds = result.mRegionToDraw.GetBounds();
|
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
|
|
|
RefPtr<DrawTarget> destDTBuffer;
|
2013-04-21 19:40:52 -07:00
|
|
|
RefPtr<DrawTarget> destDTBufferOnWhite;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t bufferFlags = canHaveRotation ? ALLOW_REPEAT : 0;
|
2014-01-23 10:26:41 -08:00
|
|
|
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
2013-04-21 19:40:52 -07:00
|
|
|
bufferFlags |= BUFFER_COMPONENT_ALPHA;
|
|
|
|
}
|
2011-03-01 12:30:16 -08:00
|
|
|
if (canReuseBuffer) {
|
2013-11-21 14:07:55 -08:00
|
|
|
if (!EnsureBuffer()) {
|
|
|
|
return result;
|
|
|
|
}
|
2010-03-03 13:37:04 -08:00
|
|
|
nsIntRect keepArea;
|
|
|
|
if (keepArea.IntersectRect(destBufferRect, mBufferRect)) {
|
2013-11-26 16:29:46 -08:00
|
|
|
// Set mBufferRotation so that the pixels currently in mDTBuffer
|
2010-03-03 13:37:04 -08:00
|
|
|
// will still be rendered in the right place when mBufferRect
|
|
|
|
// changes to destBufferRect.
|
|
|
|
nsIntPoint newRotation = mBufferRotation +
|
|
|
|
(destBufferRect.TopLeft() - mBufferRect.TopLeft());
|
|
|
|
WrapRotationAxis(&newRotation.x, mBufferRect.width);
|
|
|
|
WrapRotationAxis(&newRotation.y, mBufferRect.height);
|
|
|
|
NS_ASSERTION(nsIntRect(nsIntPoint(0,0), mBufferRect.Size()).Contains(newRotation),
|
|
|
|
"newRotation out of bounds");
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t xBoundary = destBufferRect.XMost() - newRotation.x;
|
|
|
|
int32_t yBoundary = destBufferRect.YMost() - newRotation.y;
|
2014-04-09 02:15:17 -07:00
|
|
|
bool drawWrapsBuffer = (drawBounds.x < xBoundary && xBoundary < drawBounds.XMost()) ||
|
|
|
|
(drawBounds.y < yBoundary && yBoundary < drawBounds.YMost());
|
|
|
|
if ((drawWrapsBuffer && !(aFlags & PAINT_CAN_DRAW_ROTATED)) ||
|
2011-03-01 12:30:16 -08:00
|
|
|
(newRotation != nsIntPoint(0,0) && !canHaveRotation)) {
|
2010-03-03 13:37:04 -08:00
|
|
|
// The stuff we need to redraw will wrap around an edge of the
|
2014-04-09 02:15:17 -07:00
|
|
|
// buffer (and the caller doesn't know how to support that), so
|
|
|
|
// move the pixels we can keep into a position that lets us
|
|
|
|
// redraw in just one quadrant.
|
2011-03-09 09:27:37 -08:00
|
|
|
if (mBufferRotation == nsIntPoint(0,0)) {
|
2012-10-03 19:13:14 -07:00
|
|
|
nsIntRect srcRect(nsIntPoint(0, 0), mBufferRect.Size());
|
2011-03-09 09:27:37 -08:00
|
|
|
nsIntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft();
|
2013-11-26 16:29:45 -08:00
|
|
|
MOZ_ASSERT(mDTBuffer);
|
|
|
|
mDTBuffer->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
|
|
|
|
IntPoint(dest.x, dest.y));
|
2014-01-23 10:26:41 -08:00
|
|
|
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
2013-11-26 16:29:45 -08:00
|
|
|
if (!EnsureBufferOnWhite()) {
|
|
|
|
return result;
|
2013-08-08 16:32:19 -07:00
|
|
|
}
|
2013-11-26 16:29:45 -08:00
|
|
|
MOZ_ASSERT(mDTBufferOnWhite);
|
|
|
|
mDTBufferOnWhite->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
|
|
|
|
IntPoint(dest.x, dest.y));
|
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
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
result.mDidSelfCopy = true;
|
2013-10-11 13:47:47 -07:00
|
|
|
mDidSelfCopy = true;
|
2011-03-09 09:27:37 -08:00
|
|
|
// Don't set destBuffer; we special-case self-copies, and
|
|
|
|
// just did the necessary work above.
|
|
|
|
mBufferRect = destBufferRect;
|
2010-03-03 13:37:04 -08:00
|
|
|
} else {
|
2013-10-11 13:47:47 -07:00
|
|
|
// With azure and a data surface perform an buffer unrotate
|
|
|
|
// (SelfCopy).
|
2013-11-26 16:29:45 -08:00
|
|
|
unsigned char* data;
|
|
|
|
IntSize size;
|
|
|
|
int32_t stride;
|
|
|
|
SurfaceFormat format;
|
|
|
|
|
|
|
|
if (mDTBuffer->LockBits(&data, &size, &stride, &format)) {
|
|
|
|
uint8_t bytesPerPixel = BytesPerPixel(format);
|
|
|
|
BufferUnrotate(data,
|
|
|
|
size.width * bytesPerPixel,
|
|
|
|
size.height, stride,
|
|
|
|
newRotation.x * bytesPerPixel, newRotation.y);
|
|
|
|
mDTBuffer->ReleaseBits(data);
|
2013-10-11 13:47:47 -07:00
|
|
|
|
2014-01-23 10:26:41 -08:00
|
|
|
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
2013-11-26 16:29:45 -08:00
|
|
|
if (!EnsureBufferOnWhite()) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mDTBufferOnWhite);
|
|
|
|
mDTBufferOnWhite->LockBits(&data, &size, &stride, &format);
|
2013-10-11 13:47:47 -07:00
|
|
|
uint8_t bytesPerPixel = BytesPerPixel(format);
|
|
|
|
BufferUnrotate(data,
|
|
|
|
size.width * bytesPerPixel,
|
|
|
|
size.height, stride,
|
|
|
|
newRotation.x * bytesPerPixel, newRotation.y);
|
2013-11-26 16:29:45 -08:00
|
|
|
mDTBufferOnWhite->ReleaseBits(data);
|
2013-10-11 13:47:47 -07:00
|
|
|
}
|
2013-11-26 16:29:45 -08:00
|
|
|
|
|
|
|
// Buffer unrotate moves all the pixels, note that
|
|
|
|
// we self copied for SyncBackToFrontBuffer
|
|
|
|
result.mDidSelfCopy = true;
|
|
|
|
mDidSelfCopy = true;
|
|
|
|
mBufferRect = destBufferRect;
|
|
|
|
mBufferRotation = nsIntPoint(0, 0);
|
2013-10-11 13:47:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!result.mDidSelfCopy) {
|
|
|
|
destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
|
2014-01-30 01:39:11 -08:00
|
|
|
CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
|
2013-10-11 13:47:47 -07:00
|
|
|
&destDTBuffer, &destDTBufferOnWhite);
|
2013-11-26 16:29:45 -08:00
|
|
|
if (!destDTBuffer) {
|
2013-10-11 13:47:47 -07:00
|
|
|
return result;
|
2013-11-26 16:29:45 -08:00
|
|
|
}
|
2013-10-11 13:47:47 -07:00
|
|
|
}
|
2010-03-03 13:37:04 -08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mBufferRect = destBufferRect;
|
|
|
|
mBufferRotation = newRotation;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// No pixels are going to be kept. The whole visible region
|
|
|
|
// will be redrawn, so we don't need to copy anything, so we don't
|
|
|
|
// set destBuffer.
|
|
|
|
mBufferRect = destBufferRect;
|
|
|
|
mBufferRotation = nsIntPoint(0,0);
|
|
|
|
}
|
|
|
|
} else {
|
2014-02-26 17:48:41 -08:00
|
|
|
// The buffer's not big enough, so allocate a new one
|
2014-01-30 01:39:11 -08:00
|
|
|
CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
|
2013-09-11 21:53:46 -07:00
|
|
|
&destDTBuffer, &destDTBufferOnWhite);
|
2013-11-26 16:29:45 -08:00
|
|
|
if (!destDTBuffer) {
|
2010-03-03 13:37:04 -08:00
|
|
|
return result;
|
2013-11-26 16:29:45 -08:00
|
|
|
}
|
2010-03-03 13:37:04 -08: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
|
|
|
|
2011-03-01 12:30:16 -08:00
|
|
|
NS_ASSERTION(!(aFlags & PAINT_WILL_RESAMPLE) || destBufferRect == neededRegion.GetBounds(),
|
|
|
|
"If we're resampling, we need to validate the entire buffer");
|
2010-03-03 13:37:04 -08:00
|
|
|
|
2010-07-15 14:08:09 -07:00
|
|
|
// If we have no buffered data already, then destBuffer will be a fresh buffer
|
|
|
|
// and we do not need to clear it below.
|
2012-10-17 22:44:26 -07:00
|
|
|
bool isClear = !HaveBuffer();
|
2010-07-15 14:08:09 -07:00
|
|
|
|
2013-11-26 16:29:45 -08:00
|
|
|
if (destDTBuffer) {
|
2014-01-23 10:26:41 -08:00
|
|
|
if (!isClear && (mode != SurfaceMode::SURFACE_COMPONENT_ALPHA || HaveBufferOnWhite())) {
|
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
|
|
|
// Copy the bits
|
|
|
|
nsIntPoint offset = -destBufferRect.TopLeft();
|
|
|
|
Matrix mat;
|
|
|
|
mat.Translate(offset.x, offset.y);
|
|
|
|
destDTBuffer->SetTransform(mat);
|
2013-11-21 14:07:55 -08:00
|
|
|
if (!EnsureBuffer()) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mDTBuffer, "Have we got a Thebes buffer for some reason?");
|
2014-01-10 11:06:17 -08:00
|
|
|
DrawBufferWithRotation(destDTBuffer, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
|
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
|
|
|
destDTBuffer->SetTransform(Matrix());
|
2013-08-08 16:30:19 -07:00
|
|
|
|
2014-01-23 10:26:41 -08:00
|
|
|
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
2013-08-08 16:30:19 -07:00
|
|
|
NS_ASSERTION(destDTBufferOnWhite, "Must have a white buffer!");
|
|
|
|
destDTBufferOnWhite->SetTransform(mat);
|
2013-11-21 14:07:55 -08:00
|
|
|
if (!EnsureBufferOnWhite()) {
|
|
|
|
return result;
|
|
|
|
}
|
2013-11-10 13:30:51 -08:00
|
|
|
MOZ_ASSERT(mDTBufferOnWhite, "Have we got a Thebes buffer for some reason?");
|
2014-01-10 11:06:17 -08:00
|
|
|
DrawBufferWithRotation(destDTBufferOnWhite, BUFFER_WHITE, 1.0, CompositionOp::OP_SOURCE);
|
2013-08-08 16:30:19 -07:00
|
|
|
destDTBufferOnWhite->SetTransform(Matrix());
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
mDTBuffer = destDTBuffer.forget();
|
2013-08-08 16:30:19 -07:00
|
|
|
mDTBufferOnWhite = destDTBufferOnWhite.forget();
|
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
|
|
|
mBufferRect = destBufferRect;
|
|
|
|
mBufferRotation = nsIntPoint(0,0);
|
2010-03-03 13:37:04 -08:00
|
|
|
}
|
2011-03-01 12:30:16 -08:00
|
|
|
NS_ASSERTION(canHaveRotation || mBufferRotation == nsIntPoint(0,0),
|
|
|
|
"Rotation disabled, but we have nonzero rotation?");
|
2010-03-03 13:37:04 -08:00
|
|
|
|
|
|
|
nsIntRegion invalidate;
|
|
|
|
invalidate.Sub(aLayer->GetValidRegion(), destBufferRect);
|
|
|
|
result.mRegionToInvalidate.Or(result.mRegionToInvalidate, invalidate);
|
2014-01-23 10:26:41 -08:00
|
|
|
result.mClip = DrawRegionClip::DRAW_SNAPPED;
|
2014-01-12 11:54:36 -08:00
|
|
|
result.mMode = mode;
|
2010-03-03 13:37:04 -08:00
|
|
|
|
2014-01-12 11:57:17 -08:00
|
|
|
return result;
|
|
|
|
}
|
2010-03-03 13:37:04 -08:00
|
|
|
|
2014-01-12 11:57:17 -08:00
|
|
|
DrawTarget*
|
2014-05-22 14:08:21 -07:00
|
|
|
RotatedContentBuffer::BorrowDrawTargetForPainting(PaintState& aPaintState,
|
2014-04-09 02:15:17 -07:00
|
|
|
DrawIterator* aIter /* = nullptr */)
|
2014-01-12 11:57:17 -08:00
|
|
|
{
|
2014-01-23 10:26:41 -08:00
|
|
|
if (aPaintState.mMode == SurfaceMode::SURFACE_NONE) {
|
2014-01-12 11:57:17 -08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-04-10 01:42:29 -07:00
|
|
|
DrawTarget* result = BorrowDrawTargetForQuadrantUpdate(aPaintState.mRegionToDraw.GetBounds(),
|
|
|
|
BUFFER_BOTH, aIter);
|
|
|
|
if (!result) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-05-22 14:08:21 -07:00
|
|
|
nsIntRegion* drawPtr = &aPaintState.mRegionToDraw;
|
2014-04-09 02:15:17 -07:00
|
|
|
if (aIter) {
|
2014-04-10 01:42:29 -07:00
|
|
|
// The iterators draw region currently only contains the bounds of the region,
|
|
|
|
// this makes it the precise region.
|
|
|
|
aIter->mDrawRegion.And(aIter->mDrawRegion, aPaintState.mRegionToDraw);
|
2014-04-09 02:15:17 -07:00
|
|
|
drawPtr = &aIter->mDrawRegion;
|
|
|
|
}
|
2014-06-19 13:35:33 -07:00
|
|
|
if (result->GetBackendType() == BackendType::DIRECT2D ||
|
|
|
|
result->GetBackendType() == BackendType::DIRECT2D1_1) {
|
2014-05-22 14:08:21 -07:00
|
|
|
drawPtr->SimplifyOutwardByArea(100 * 100);
|
|
|
|
}
|
2014-04-09 02:15:17 -07:00
|
|
|
|
2014-01-23 10:26:41 -08:00
|
|
|
if (aPaintState.mMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
2013-11-26 16:29:45 -08:00
|
|
|
MOZ_ASSERT(mDTBuffer && mDTBufferOnWhite);
|
2014-04-09 02:15:17 -07:00
|
|
|
nsIntRegionRectIterator iter(*drawPtr);
|
2013-11-26 16:29:45 -08:00
|
|
|
const nsIntRect *iterRect;
|
|
|
|
while ((iterRect = iter.Next())) {
|
|
|
|
mDTBuffer->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
|
|
|
|
ColorPattern(Color(0.0, 0.0, 0.0, 1.0)));
|
|
|
|
mDTBufferOnWhite->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
|
|
|
|
ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
|
2013-08-08 16:30:19 -07:00
|
|
|
}
|
2014-01-30 01:39:11 -08:00
|
|
|
} else if (aPaintState.mContentType == gfxContentType::COLOR_ALPHA && HaveBuffer()) {
|
2014-01-12 11:57:17 -08:00
|
|
|
// HaveBuffer() => we have an existing buffer that we must clear
|
2014-04-09 02:15:17 -07:00
|
|
|
nsIntRegionRectIterator iter(*drawPtr);
|
2013-11-26 16:29:45 -08:00
|
|
|
const nsIntRect *iterRect;
|
|
|
|
while ((iterRect = iter.Next())) {
|
2014-01-12 11:57:17 -08:00
|
|
|
result->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
|
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
|
|
|
}
|
2010-03-03 13:37:04 -08: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
|
|
|
|
2010-03-03 13:37:04 -08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|