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
|
|
|
|
|
|
|
#include "ThebesLayerBuffer.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-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 "gfxColor.h" // for gfxRGBA
|
|
|
|
#include "gfxContext.h" // for gfxContext, etc
|
|
|
|
#include "gfxMatrix.h" // for gfxMatrix
|
|
|
|
#include "gfxPattern.h" // for gfxPattern
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
|
|
|
#include "gfxPoint.h" // for gfxPoint
|
|
|
|
#include "gfxRect.h" // for gfxRect
|
|
|
|
#include "gfxTeeSurface.h" // for gfxTeeSurface
|
|
|
|
#include "gfxUtils.h" // for gfxUtils
|
|
|
|
#include "mozilla/Util.h" // for ArrayLength
|
|
|
|
#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
|
|
|
|
#include "mozilla/gfx/Types.h" // for ExtendMode::EXTEND_CLAMP, etc
|
|
|
|
#include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer
|
|
|
|
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient
|
|
|
|
#include "nsSize.h" // for nsIntSize
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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).
|
|
|
|
*/
|
|
|
|
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(gfxContext* 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,
|
|
|
|
gfxASurface* aMask,
|
|
|
|
const gfxMatrix* aMaskTransform) const
|
2010-03-03 13:37:04 -08:00
|
|
|
{
|
|
|
|
// 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;
|
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 (!fillRect.IntersectRect(mBufferRect, quadrantRect)) {
|
2010-03-03 13:37:04 -08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> source;
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
if (aSource == BUFFER_BLACK) {
|
|
|
|
if (mBuffer) {
|
|
|
|
source = mBuffer;
|
|
|
|
} else if (mDTBuffer) {
|
|
|
|
source = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDTBuffer);
|
|
|
|
} else {
|
|
|
|
NS_RUNTIMEABORT("Can't draw a RotatedBuffer without any buffer!");
|
|
|
|
}
|
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
|
|
|
MOZ_ASSERT(aSource == BUFFER_WHITE);
|
|
|
|
if (mBufferOnWhite) {
|
|
|
|
source = mBufferOnWhite;
|
|
|
|
} else if (mDTBufferOnWhite) {
|
|
|
|
source = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDTBufferOnWhite);
|
|
|
|
} else {
|
|
|
|
NS_RUNTIMEABORT("Can't draw a RotatedBuffer without any buffer!");
|
|
|
|
}
|
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
|
|
|
|
|
|
|
aTarget->NewPath();
|
2010-09-03 13:10:46 -07:00
|
|
|
aTarget->Rectangle(gfxRect(fillRect.x, fillRect.y,
|
|
|
|
fillRect.width, fillRect.height),
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2010-09-03 13:10:46 -07:00
|
|
|
|
|
|
|
gfxPoint quadrantTranslation(quadrantRect.x, quadrantRect.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
|
|
|
nsRefPtr<gfxPattern> pattern = new gfxPattern(source);
|
2010-09-03 13:10:46 -07:00
|
|
|
|
2010-09-09 12:33:04 -07:00
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
|
|
|
gfxPattern::GraphicsFilter filter = gfxPattern::FILTER_NEAREST;
|
|
|
|
pattern->SetFilter(filter);
|
|
|
|
#endif
|
|
|
|
|
2010-09-23 16:06:27 -07:00
|
|
|
gfxContextMatrixAutoSaveRestore saveMatrix(aTarget);
|
|
|
|
|
2010-09-03 13:10:46 -07:00
|
|
|
// Transform from user -> buffer space.
|
|
|
|
gfxMatrix transform;
|
|
|
|
transform.Translate(-quadrantTranslation);
|
|
|
|
|
|
|
|
pattern->SetMatrix(transform);
|
|
|
|
aTarget->SetPattern(pattern);
|
|
|
|
|
2012-02-07 14:27:21 -08:00
|
|
|
if (aMask) {
|
|
|
|
if (aOpacity == 1.0) {
|
|
|
|
aTarget->SetMatrix(*aMaskTransform);
|
|
|
|
aTarget->Mask(aMask);
|
|
|
|
} else {
|
|
|
|
aTarget->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
|
|
|
|
aTarget->Paint(aOpacity);
|
|
|
|
aTarget->PopGroupToSource();
|
|
|
|
aTarget->SetMatrix(*aMaskTransform);
|
|
|
|
aTarget->Mask(aMask);
|
|
|
|
}
|
2010-07-15 14:08:04 -07:00
|
|
|
} else {
|
2012-02-07 14:27:21 -08:00
|
|
|
if (aOpacity == 1.0) {
|
|
|
|
aTarget->Fill();
|
|
|
|
} else {
|
|
|
|
aTarget->Save();
|
|
|
|
aTarget->Clip();
|
|
|
|
aTarget->Paint(aOpacity);
|
|
|
|
aTarget->Restore();
|
|
|
|
}
|
2010-07-15 14:08:04 -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
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> surf = aTarget->CurrentSurface();
|
|
|
|
surf->Flush();
|
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
|
|
|
/**
|
|
|
|
* @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,
|
|
|
|
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-04-21 19:40:52 -07:00
|
|
|
RefPtr<SourceSurface> snapshot;
|
|
|
|
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
|
|
|
|
|
|
|
// Transform from user -> buffer space.
|
|
|
|
Matrix transform;
|
|
|
|
transform.Translate(quadrantTranslation.x, quadrantTranslation.y);
|
|
|
|
|
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
|
|
|
SurfacePattern source(snapshot, EXTEND_CLAMP, transform, FILTER_POINT);
|
|
|
|
#else
|
|
|
|
SurfacePattern source(snapshot, EXTEND_CLAMP, transform);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (aMask) {
|
|
|
|
SurfacePattern mask(aMask, EXTEND_CLAMP, *aMaskTransform);
|
|
|
|
|
2013-09-11 10:31:53 -07:00
|
|
|
aTarget->Mask(source, mask, DrawOptions(aOpacity));
|
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 {
|
|
|
|
aTarget->FillRect(gfx::Rect(fillRect.x, fillRect.y,
|
|
|
|
fillRect.width, fillRect.height),
|
2013-09-11 10:31:53 -07:00
|
|
|
source, DrawOptions(aOpacity));
|
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
|
|
|
}
|
|
|
|
|
|
|
|
aTarget->Flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-21 19:40:52 -07:00
|
|
|
RotatedBuffer::DrawBufferWithRotation(gfxContext* aTarget, ContextSource aSource,
|
|
|
|
float aOpacity,
|
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
|
|
|
gfxASurface* aMask,
|
|
|
|
const gfxMatrix* aMaskTransform) const
|
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
|
|
|
PROFILER_LABEL("RotatedBuffer", "DrawBufferWithRotation");
|
2010-03-03 13:37:04 -08:00
|
|
|
// Draw four quadrants. We could use REPEAT_, but it's probably better
|
|
|
|
// not to, to be performance-safe.
|
2013-04-21 19:40:52 -07:00
|
|
|
DrawBufferQuadrant(aTarget, LEFT, TOP, aSource, aOpacity, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, RIGHT, TOP, aSource, aOpacity, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, LEFT, BOTTOM, aSource, aOpacity, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, RIGHT, BOTTOM, aSource, aOpacity, aMask, aMaskTransform);
|
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
|
|
|
void
|
2013-04-21 19:40:52 -07:00
|
|
|
RotatedBuffer::DrawBufferWithRotation(gfx::DrawTarget *aTarget, ContextSource aSource,
|
|
|
|
float aOpacity,
|
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
|
|
|
|
{
|
|
|
|
PROFILER_LABEL("RotatedBuffer", "DrawBufferWithRotation");
|
|
|
|
// 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-11 10:31:53 -07:00
|
|
|
DrawBufferQuadrant(aTarget, LEFT, TOP, aSource, aOpacity, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, RIGHT, TOP, aSource, aOpacity, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, LEFT, BOTTOM, aSource, aOpacity, aMask, aMaskTransform);
|
|
|
|
DrawBufferQuadrant(aTarget, RIGHT, BOTTOM, aSource, aOpacity, 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
|
|
|
|
ThebesLayerBuffer::IsClippingCheap(gfxContext* aTarget, const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
// Assume clipping is cheap if the context just has an integer
|
|
|
|
// translation, and the visible region is simple.
|
|
|
|
return !aTarget->CurrentMatrix().HasNonIntegerTranslation() &&
|
|
|
|
aRegion.GetNumRects() <= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThebesLayerBuffer::DrawTo(ThebesLayer* aLayer,
|
|
|
|
gfxContext* aTarget,
|
|
|
|
float aOpacity,
|
|
|
|
gfxASurface* aMask,
|
|
|
|
const gfxMatrix* aMaskTransform)
|
|
|
|
{
|
|
|
|
EnsureBuffer();
|
|
|
|
|
|
|
|
if (aTarget->IsCairo()) {
|
|
|
|
aTarget->Save();
|
|
|
|
// 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.
|
|
|
|
gfxUtils::ClipToRegionSnapped(aTarget, aLayer->GetEffectiveVisibleRegion());
|
|
|
|
}
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
DrawBufferWithRotation(aTarget, BUFFER_BLACK, aOpacity, 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
|
|
|
aTarget->Restore();
|
|
|
|
} else {
|
|
|
|
RefPtr<DrawTarget> dt = aTarget->GetDrawTarget();
|
2013-08-22 23:13:55 -07:00
|
|
|
bool clipped = false;
|
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 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.
|
|
|
|
gfxUtils::ClipToRegionSnapped(dt, aLayer->GetEffectiveVisibleRegion());
|
2013-08-22 23:13:55 -07:00
|
|
|
clipped = true;
|
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-08-22 23:13:55 -07:00
|
|
|
RefPtr<SourceSurface> mask;
|
|
|
|
if (aMask) {
|
|
|
|
mask = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
Matrix maskTransform;
|
|
|
|
if (aMaskTransform) {
|
|
|
|
maskTransform = ToMatrix(*aMaskTransform);
|
|
|
|
}
|
|
|
|
|
2013-09-11 10:31:53 -07:00
|
|
|
DrawBufferWithRotation(dt, BUFFER_BLACK, aOpacity, mask, &maskTransform);
|
2013-08-22 23:13:55 -07:00
|
|
|
if (clipped) {
|
|
|
|
dt->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
|
|
|
}
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
static void
|
|
|
|
FillSurface(gfxASurface* aSurface, const nsIntRegion& aRegion,
|
|
|
|
const nsIntPoint& aOffset, const gfxRGBA& aColor)
|
|
|
|
{
|
|
|
|
nsRefPtr<gfxContext> ctx = new gfxContext(aSurface);
|
|
|
|
ctx->Translate(-gfxPoint(aOffset.x, aOffset.y));
|
|
|
|
gfxUtils::ClipToRegion(ctx, aRegion);
|
|
|
|
ctx->SetColor(aColor);
|
|
|
|
ctx->Paint();
|
|
|
|
}
|
|
|
|
|
2010-11-05 00:17:07 -07:00
|
|
|
already_AddRefed<gfxContext>
|
2013-05-09 14:02:50 -07:00
|
|
|
ThebesLayerBuffer::GetContextForQuadrantUpdate(const nsIntRect& aBounds, ContextSource aSource, nsIntPoint *aTopLeft)
|
2010-11-05 00:17:07 -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
|
|
|
EnsureBuffer();
|
|
|
|
|
|
|
|
nsRefPtr<gfxContext> ctx;
|
2013-04-21 19:40:52 -07:00
|
|
|
if (aSource == BUFFER_BOTH && HaveBufferOnWhite()) {
|
|
|
|
EnsureBufferOnWhite();
|
2013-08-08 16:30:19 -07:00
|
|
|
if (mBuffer) {
|
|
|
|
MOZ_ASSERT(mBufferOnWhite);
|
|
|
|
gfxASurface* surfaces[2] = { mBuffer, mBufferOnWhite };
|
|
|
|
nsRefPtr<gfxTeeSurface> surf = new gfxTeeSurface(surfaces, ArrayLength(surfaces));
|
|
|
|
|
|
|
|
// XXX If the device offset is set on the individual surfaces instead of on
|
|
|
|
// the tee surface, we render in the wrong place. Why?
|
|
|
|
gfxPoint deviceOffset = mBuffer->GetDeviceOffset();
|
|
|
|
surfaces[0]->SetDeviceOffset(gfxPoint(0, 0));
|
|
|
|
surfaces[1]->SetDeviceOffset(gfxPoint(0, 0));
|
|
|
|
surf->SetDeviceOffset(deviceOffset);
|
|
|
|
|
|
|
|
surf->SetAllowUseAsSource(false);
|
|
|
|
ctx = new gfxContext(surf);
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(mDTBuffer && mDTBufferOnWhite);
|
|
|
|
RefPtr<DrawTarget> dualDT = Factory::CreateDualDrawTarget(mDTBuffer, mDTBufferOnWhite);
|
|
|
|
ctx = new gfxContext(dualDT);
|
|
|
|
}
|
2013-04-21 19:40:52 -07:00
|
|
|
} else if (aSource == BUFFER_WHITE) {
|
|
|
|
EnsureBufferOnWhite();
|
|
|
|
if (mBufferOnWhite) {
|
|
|
|
ctx = new gfxContext(mBufferOnWhite);
|
|
|
|
} else {
|
|
|
|
ctx = new gfxContext(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.
|
|
|
|
if (mBuffer) {
|
|
|
|
ctx = new gfxContext(mBuffer);
|
|
|
|
} else {
|
|
|
|
ctx = new gfxContext(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;
|
2010-11-05 00:17:07 -07:00
|
|
|
XSide sideX = aBounds.XMost() <= xBoundary ? RIGHT : LEFT;
|
|
|
|
YSide sideY = aBounds.YMost() <= yBoundary ? BOTTOM : TOP;
|
|
|
|
nsIntRect quadrantRect = GetQuadrantRectangle(sideX, sideY);
|
|
|
|
NS_ASSERTION(quadrantRect.Contains(aBounds), "Messed up quadrants");
|
|
|
|
ctx->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
|
|
|
|
|
2013-05-09 14:02:50 -07:00
|
|
|
if (aTopLeft) {
|
|
|
|
*aTopLeft = nsIntPoint(quadrantRect.x, quadrantRect.y);
|
|
|
|
}
|
|
|
|
|
2010-11-05 00:17:07 -07:00
|
|
|
return ctx.forget();
|
|
|
|
}
|
|
|
|
|
2012-09-12 03:41:34 -07:00
|
|
|
gfxASurface::gfxContentType
|
|
|
|
ThebesLayerBuffer::BufferContentType()
|
|
|
|
{
|
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 (mBuffer) {
|
|
|
|
return mBuffer->GetContentType();
|
|
|
|
}
|
|
|
|
if (mBufferProvider) {
|
2013-04-21 19:40:52 -07:00
|
|
|
return mBufferProvider->GetContentType();
|
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 (mDTBuffer) {
|
|
|
|
switch (mDTBuffer->GetFormat()) {
|
|
|
|
case FORMAT_A8:
|
|
|
|
return gfxASurface::CONTENT_ALPHA;
|
|
|
|
case FORMAT_B8G8R8A8:
|
|
|
|
case FORMAT_R8G8B8A8:
|
|
|
|
return gfxASurface::CONTENT_COLOR_ALPHA;
|
|
|
|
default:
|
|
|
|
return gfxASurface::CONTENT_COLOR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gfxASurface::CONTENT_SENTINEL;
|
2012-09-12 03:41:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThebesLayerBuffer::BufferSizeOkFor(const nsIntSize& aSize)
|
|
|
|
{
|
|
|
|
return (aSize == mBufferRect.Size() ||
|
|
|
|
(SizedToVisibleBounds != mBufferSizePolicy &&
|
|
|
|
aSize < mBufferRect.Size()));
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:32:19 -07:00
|
|
|
bool
|
|
|
|
ThebesLayerBuffer::IsAzureBuffer()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(mDTBuffer && mBuffer), "Trying to use Azure and Thebes in the same buffer?");
|
|
|
|
if (mDTBuffer) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (mBuffer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return SupportsAzureContent();
|
|
|
|
}
|
|
|
|
|
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
|
2012-09-12 03:41:34 -07:00
|
|
|
ThebesLayerBuffer::EnsureBuffer()
|
|
|
|
{
|
2013-04-21 19:40:52 -07:00
|
|
|
if ((!mBuffer && !mDTBuffer) && mBufferProvider) {
|
2013-08-08 16:32:19 -07:00
|
|
|
if (IsAzureBuffer()) {
|
2013-04-21 19:40:52 -07:00
|
|
|
mDTBuffer = mBufferProvider->LockDrawTarget();
|
2013-08-08 16:32:19 -07:00
|
|
|
mBuffer = 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
|
|
|
} else {
|
2013-04-21 19:40:52 -07:00
|
|
|
mBuffer = mBufferProvider->LockSurface();
|
2013-08-08 16:32:19 -07:00
|
|
|
mDTBuffer = 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
|
|
|
}
|
|
|
|
}
|
2012-09-12 03:41:34 -07:00
|
|
|
}
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
void
|
|
|
|
ThebesLayerBuffer::EnsureBufferOnWhite()
|
|
|
|
{
|
|
|
|
if ((!mBufferOnWhite && !mDTBufferOnWhite) && mBufferProviderOnWhite) {
|
2013-08-08 16:32:19 -07:00
|
|
|
if (IsAzureBuffer()) {
|
2013-04-21 19:40:52 -07:00
|
|
|
mDTBufferOnWhite = mBufferProviderOnWhite->LockDrawTarget();
|
2013-08-08 16:32:19 -07:00
|
|
|
mBufferOnWhite = nullptr;
|
2013-04-21 19:40:52 -07:00
|
|
|
} else {
|
|
|
|
mBufferOnWhite = mBufferProviderOnWhite->LockSurface();
|
2013-08-08 16:32:19 -07:00
|
|
|
mDTBufferOnWhite = nullptr;
|
2013-04-21 19:40:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-12 03:41:34 -07:00
|
|
|
bool
|
2013-04-21 19:40:52 -07:00
|
|
|
ThebesLayerBuffer::HaveBuffer() const
|
2012-09-12 03:41:34 -07:00
|
|
|
{
|
2013-04-21 19:40:52 -07:00
|
|
|
return mDTBuffer || mBuffer || mBufferProvider;
|
2012-09-12 03:41:34 -07:00
|
|
|
}
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
bool
|
|
|
|
ThebesLayerBuffer::HaveBufferOnWhite() const
|
|
|
|
{
|
|
|
|
return mDTBufferOnWhite || mBufferOnWhite || mBufferProviderOnWhite;
|
|
|
|
}
|
|
|
|
|
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);
|
2012-09-20 12:49:03 -07:00
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2010-03-03 13:37:04 -08:00
|
|
|
ThebesLayerBuffer::PaintState
|
2010-09-03 13:10:46 -07:00
|
|
|
ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
|
2012-08-22 08:56:38 -07: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();
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
Layer::SurfaceMode mode;
|
2011-03-01 12:30:16 -08:00
|
|
|
ContentType contentType;
|
|
|
|
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
|
|
|
contentType = aContentType;
|
|
|
|
neededRegion = aLayer->GetVisibleRegion();
|
2012-09-12 03:41:34 -07:00
|
|
|
canReuseBuffer = HaveBuffer() && BufferSizeOkFor(neededRegion.GetBounds().Size());
|
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
|
|
|
}
|
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
|
|
|
|
#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
|
|
|
|
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
|
|
|
|
#else
|
|
|
|
if (!aLayer->GetParent() ||
|
|
|
|
!aLayer->GetParent()->SupportsComponentAlphaChildren() ||
|
|
|
|
!aLayer->Manager()->IsCompositingCheap() ||
|
|
|
|
!aLayer->AsShadowableLayer() ||
|
|
|
|
!aLayer->AsShadowableLayer()->HasShadow() ||
|
2013-08-08 16:30:19 -07:00
|
|
|
!gfxPlatform::ComponentAlphaEnabled()) {
|
2013-04-21 19:40:52 -07:00
|
|
|
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
|
|
|
|
} else {
|
|
|
|
contentType = gfxASurface::CONTENT_COLOR;
|
|
|
|
}
|
|
|
|
#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
|
2013-04-21 19:40:52 -07:00
|
|
|
if (mode == Layer::SURFACE_OPAQUE) {
|
|
|
|
contentType = gfxASurface::CONTENT_COLOR_ALPHA;
|
|
|
|
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
|
|
|
|
}
|
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() &&
|
|
|
|
(contentType != BufferContentType() ||
|
|
|
|
mode == Layer::SURFACE_COMPONENT_ALPHA) != (HaveBufferOnWhite())) {
|
|
|
|
|
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
|
|
|
|
// around the loop one more iteration, since mBuffer is null now.
|
|
|
|
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);
|
2010-03-03 13:37:04 -08:00
|
|
|
if (result.mRegionToDraw.IsEmpty())
|
|
|
|
return result;
|
|
|
|
|
2011-03-01 12:30:16 -08:00
|
|
|
nsIntRect drawBounds = result.mRegionToDraw.GetBounds();
|
2010-03-03 13:37:04 -08:00
|
|
|
nsRefPtr<gfxASurface> destBuffer;
|
2013-04-21 19:40:52 -07:00
|
|
|
nsRefPtr<gfxASurface> destBufferOnWhite;
|
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;
|
2013-04-21 19:40:52 -07:00
|
|
|
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
|
|
|
|
bufferFlags |= BUFFER_COMPONENT_ALPHA;
|
|
|
|
}
|
2011-03-01 12:30:16 -08:00
|
|
|
if (canReuseBuffer) {
|
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
|
|
|
EnsureBuffer();
|
2010-03-03 13:37:04 -08:00
|
|
|
nsIntRect keepArea;
|
|
|
|
if (keepArea.IntersectRect(destBufferRect, mBufferRect)) {
|
|
|
|
// Set mBufferRotation so that the pixels currently in mBuffer
|
|
|
|
// 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;
|
2010-03-03 13:37:04 -08:00
|
|
|
if ((drawBounds.x < xBoundary && xBoundary < drawBounds.XMost()) ||
|
2011-03-01 12:30:16 -08:00
|
|
|
(drawBounds.y < yBoundary && yBoundary < drawBounds.YMost()) ||
|
|
|
|
(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
|
2011-03-09 09:27:37 -08:00
|
|
|
// buffer, so move the pixels we can keep into a position that
|
|
|
|
// lets us redraw in just one quadrant.
|
|
|
|
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-08-08 16:32:19 -07:00
|
|
|
if (IsAzureBuffer()) {
|
|
|
|
MOZ_ASSERT(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
|
|
|
RefPtr<SourceSurface> source = mDTBuffer->Snapshot();
|
|
|
|
mDTBuffer->CopySurface(source,
|
|
|
|
IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
|
|
|
|
IntPoint(dest.x, dest.y));
|
2013-08-08 16:30:19 -07:00
|
|
|
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
|
|
|
|
EnsureBufferOnWhite();
|
|
|
|
MOZ_ASSERT(mDTBufferOnWhite);
|
|
|
|
RefPtr<SourceSurface> sourceOnWhite = mDTBufferOnWhite->Snapshot();
|
|
|
|
mDTBufferOnWhite->CopySurface(sourceOnWhite,
|
|
|
|
IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
|
|
|
|
IntPoint(dest.x, dest.y));
|
|
|
|
}
|
2013-08-08 16:32:19 -07:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(mBuffer);
|
|
|
|
mBuffer->MovePixels(srcRect, dest);
|
|
|
|
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
|
|
|
|
EnsureBufferOnWhite();
|
|
|
|
MOZ_ASSERT(mBufferOnWhite);
|
|
|
|
mBufferOnWhite->MovePixels(srcRect, dest);
|
|
|
|
}
|
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;
|
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 {
|
|
|
|
// We can't do a real self-copy because the buffer is rotated.
|
|
|
|
// So allocate a new buffer for the destination.
|
2012-09-20 12:49:03 -07:00
|
|
|
destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
|
2013-08-08 16:32:19 -07:00
|
|
|
if (IsAzureBuffer()) {
|
2013-07-23 23:46:27 -07:00
|
|
|
MOZ_ASSERT(!mBuffer);
|
2013-08-08 16:30:19 -07:00
|
|
|
destDTBuffer = CreateDTBuffer(contentType, destBufferRect, bufferFlags, &destDTBufferOnWhite);
|
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-07-23 23:46:27 -07:00
|
|
|
MOZ_ASSERT(!mDTBuffer);
|
2013-04-21 19:40:52 -07:00
|
|
|
destBuffer = CreateBuffer(contentType, destBufferRect, bufferFlags, getter_AddRefs(destBufferOnWhite));
|
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 (!destBuffer && !destDTBuffer)
|
2010-03-03 13:37:04 -08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
} 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 {
|
|
|
|
// The buffer's not big enough, so allocate a new one
|
2013-08-08 16:32:19 -07:00
|
|
|
if (IsAzureBuffer()) {
|
2013-07-23 23:46:27 -07:00
|
|
|
MOZ_ASSERT(!mBuffer);
|
2013-08-08 16:30:19 -07:00
|
|
|
destDTBuffer = CreateDTBuffer(contentType, destBufferRect, bufferFlags, &destDTBufferOnWhite);
|
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-07-23 23:46:27 -07:00
|
|
|
MOZ_ASSERT(!mDTBuffer);
|
2013-04-21 19:40:52 -07:00
|
|
|
destBuffer = CreateBuffer(contentType, destBufferRect, bufferFlags, getter_AddRefs(destBufferOnWhite));
|
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 (!destBuffer && !destDTBuffer)
|
2010-03-03 13:37:04 -08:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2012-10-03 19:13:14 -07:00
|
|
|
if (destBuffer) {
|
2013-04-21 19:40:52 -07:00
|
|
|
if (!isClear && (mode != Layer::SURFACE_COMPONENT_ALPHA || HaveBufferOnWhite())) {
|
2010-03-03 13:37:04 -08:00
|
|
|
// Copy the bits
|
2012-10-03 19:13:14 -07:00
|
|
|
nsRefPtr<gfxContext> tmpCtx = new gfxContext(destBuffer);
|
2010-03-03 13:37:04 -08:00
|
|
|
nsIntPoint offset = -destBufferRect.TopLeft();
|
|
|
|
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
tmpCtx->Translate(gfxPoint(offset.x, offset.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
|
|
|
EnsureBuffer();
|
2013-04-21 19:40:52 -07:00
|
|
|
DrawBufferWithRotation(tmpCtx, BUFFER_BLACK);
|
|
|
|
|
|
|
|
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
|
|
|
|
EnsureBufferOnWhite();
|
|
|
|
NS_ASSERTION(destBufferOnWhite, "Must have a white buffer!");
|
|
|
|
nsRefPtr<gfxContext> tmpCtx = new gfxContext(destBufferOnWhite);
|
|
|
|
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
tmpCtx->Translate(gfxPoint(offset.x, offset.y));
|
|
|
|
DrawBufferWithRotation(tmpCtx, BUFFER_WHITE);
|
|
|
|
}
|
2010-03-03 13:37:04 -08:00
|
|
|
}
|
|
|
|
|
2012-10-03 19:13:14 -07:00
|
|
|
mBuffer = destBuffer.forget();
|
2013-08-08 16:32:19 -07:00
|
|
|
mDTBuffer = nullptr;
|
2010-03-03 13:37:04 -08:00
|
|
|
mBufferRect = destBufferRect;
|
2013-04-21 19:40:52 -07:00
|
|
|
mBufferOnWhite = destBufferOnWhite.forget();
|
2013-08-08 16:32:19 -07:00
|
|
|
mDTBufferOnWhite = nullptr;
|
2010-03-03 13:37:04 -08:00
|
|
|
mBufferRotation = nsIntPoint(0,0);
|
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 if (destDTBuffer) {
|
2013-04-21 19:40:52 -07:00
|
|
|
if (!isClear && (mode != Layer::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);
|
|
|
|
EnsureBuffer();
|
2013-07-23 23:46:27 -07:00
|
|
|
MOZ_ASSERT(mDTBuffer, "Have we got a Thebes buffer for some reason?");
|
2013-09-11 10:31:53 -07:00
|
|
|
DrawBufferWithRotation(destDTBuffer, BUFFER_BLACK);
|
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
|
|
|
|
|
|
|
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
|
|
|
|
NS_ASSERTION(destDTBufferOnWhite, "Must have a white buffer!");
|
|
|
|
destDTBufferOnWhite->SetTransform(mat);
|
|
|
|
EnsureBufferOnWhite();
|
|
|
|
MOZ_ASSERT(destDTBufferOnWhite, "Have we got a Thebes buffer for some reason?");
|
2013-09-11 10:31:53 -07:00
|
|
|
DrawBufferWithRotation(destDTBufferOnWhite, BUFFER_WHITE);
|
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:32:19 -07:00
|
|
|
mBuffer = nullptr;
|
2013-08-08 16:30:19 -07:00
|
|
|
mDTBufferOnWhite = destDTBufferOnWhite.forget();
|
2013-08-08 16:32:19 -07:00
|
|
|
mBufferOnWhite = 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
|
|
|
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);
|
|
|
|
|
2013-05-09 14:02:50 -07:00
|
|
|
nsIntPoint topLeft;
|
|
|
|
result.mContext = GetContextForQuadrantUpdate(drawBounds, BUFFER_BOTH, &topLeft);
|
2010-03-03 13:37:04 -08:00
|
|
|
|
2013-04-21 19:40:52 -07:00
|
|
|
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
|
2013-08-08 16:32:19 -07:00
|
|
|
if (IsAzureBuffer()) {
|
2013-08-08 16:30:19 -07:00
|
|
|
MOZ_ASSERT(mDTBuffer && mDTBufferOnWhite);
|
|
|
|
nsIntRegionRectIterator iter(result.mRegionToDraw);
|
|
|
|
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:32:19 -07:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(mBuffer && mBufferOnWhite);
|
|
|
|
FillSurface(mBuffer, result.mRegionToDraw, topLeft, gfxRGBA(0.0, 0.0, 0.0, 1.0));
|
|
|
|
FillSurface(mBufferOnWhite, result.mRegionToDraw, topLeft, gfxRGBA(1.0, 1.0, 1.0, 1.0));
|
2013-08-08 16:30:19 -07:00
|
|
|
}
|
2013-05-09 14:02:50 -07:00
|
|
|
gfxUtils::ClipToRegionSnapped(result.mContext, result.mRegionToDraw);
|
2013-04-21 19:40:52 -07:00
|
|
|
} else if (contentType == gfxASurface::CONTENT_COLOR_ALPHA && !isClear) {
|
2013-08-08 16:32:19 -07:00
|
|
|
if (IsAzureBuffer()) {
|
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
|
|
|
nsIntRegionRectIterator iter(result.mRegionToDraw);
|
|
|
|
const nsIntRect *iterRect;
|
|
|
|
while ((iterRect = iter.Next())) {
|
|
|
|
result.mContext->GetDrawTarget()->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
|
|
|
|
}
|
|
|
|
// Clear will do something expensive with a complex clip pushed, so clip
|
|
|
|
// here.
|
|
|
|
gfxUtils::ClipToRegionSnapped(result.mContext, result.mRegionToDraw);
|
2013-08-08 16:32:19 -07:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(result.mContext->IsCairo());
|
|
|
|
gfxUtils::ClipToRegionSnapped(result.mContext, result.mRegionToDraw);
|
|
|
|
result.mContext->SetOperator(gfxContext::OPERATOR_CLEAR);
|
|
|
|
result.mContext->Paint();
|
|
|
|
result.mContext->SetOperator(gfxContext::OPERATOR_OVER);
|
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 {
|
|
|
|
gfxUtils::ClipToRegionSnapped(result.mContext, result.mRegionToDraw);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|