Bug 958984. Move SurfaceMode enum out of Layer class so we could forward declare it instead of including header. r=nical

This commit is contained in:
Nick Lebedev 2014-01-17 15:00:00 +01:00
parent 257c8ee5fc
commit 940cdd21fd
6 changed files with 34 additions and 35 deletions

View File

@ -1104,12 +1104,6 @@ public:
// quality.
bool CanUseOpaqueSurface();
enum SurfaceMode {
SURFACE_NONE = 0,
SURFACE_OPAQUE,
SURFACE_SINGLE_CHANNEL_ALPHA,
SURFACE_COMPONENT_ALPHA
};
SurfaceMode GetSurfaceMode()
{
if (CanUseOpaqueSurface())

View File

@ -61,6 +61,13 @@ enum DrawRegionClip {
CLIP_NONE,
};
enum SurfaceMode {
SURFACE_NONE = 0,
SURFACE_OPAQUE,
SURFACE_SINGLE_CHANNEL_ALPHA,
SURFACE_COMPONENT_ALPHA
};
// LayerRenderState for Composer2D
// We currently only support Composer2D using gralloc. If we want to be backed
// by other surfaces we will need a more generic LayerRenderState.

View File

@ -417,7 +417,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
canUseOpaqueSurface ? GFX_CONTENT_COLOR :
GFX_CONTENT_COLOR_ALPHA;
Layer::SurfaceMode mode;
SurfaceMode mode;
nsIntRegion neededRegion;
bool canReuseBuffer;
nsIntRect destBufferRect;
@ -443,9 +443,9 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
}
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
mode = SURFACE_SINGLE_CHANNEL_ALPHA;
#else
if (!aLayer->GetParent() ||
!aLayer->GetParent()->SupportsComponentAlphaChildren() ||
@ -453,7 +453,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
!aLayer->AsShadowableLayer() ||
!aLayer->AsShadowableLayer()->HasShadow() ||
!gfxPlatform::ComponentAlphaEnabled()) {
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
mode = SURFACE_SINGLE_CHANNEL_ALPHA;
} else {
contentType = GFX_CONTENT_COLOR;
}
@ -464,9 +464,9 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
(!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
neededRegion.GetNumRects() > 1)) {
// The area we add to neededRegion might not be painted opaquely
if (mode == Layer::SURFACE_OPAQUE) {
if (mode == SURFACE_OPAQUE) {
contentType = GFX_CONTENT_COLOR_ALPHA;
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
mode = SURFACE_SINGLE_CHANNEL_ALPHA;
}
// We need to validate the entire buffer, to make sure that only valid
@ -478,7 +478,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
// have transitioned into/out of component alpha, then we need to recreate it.
if (HaveBuffer() &&
(contentType != BufferContentType() ||
(mode == Layer::SURFACE_COMPONENT_ALPHA) != HaveBufferOnWhite())) {
(mode == SURFACE_COMPONENT_ALPHA) != HaveBufferOnWhite())) {
// We're effectively clearing the valid region, so we need to draw
// the entire needed region now.
@ -510,7 +510,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
RefPtr<DrawTarget> destDTBuffer;
RefPtr<DrawTarget> destDTBufferOnWhite;
uint32_t bufferFlags = canHaveRotation ? ALLOW_REPEAT : 0;
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
bufferFlags |= BUFFER_COMPONENT_ALPHA;
}
if (canReuseBuffer) {
@ -542,7 +542,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
MOZ_ASSERT(mDTBuffer);
mDTBuffer->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
IntPoint(dest.x, dest.y));
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
if (!EnsureBufferOnWhite()) {
return result;
}
@ -571,7 +571,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
newRotation.x * bytesPerPixel, newRotation.y);
mDTBuffer->ReleaseBits(data);
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
if (!EnsureBufferOnWhite()) {
return result;
}
@ -630,7 +630,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
bool isClear = !HaveBuffer();
if (destDTBuffer) {
if (!isClear && (mode != Layer::SURFACE_COMPONENT_ALPHA || HaveBufferOnWhite())) {
if (!isClear && (mode != SURFACE_COMPONENT_ALPHA || HaveBufferOnWhite())) {
// Copy the bits
nsIntPoint offset = -destBufferRect.TopLeft();
Matrix mat;
@ -643,7 +643,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer,
DrawBufferWithRotation(destDTBuffer, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
destDTBuffer->SetTransform(Matrix());
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
NS_ASSERTION(destDTBufferOnWhite, "Must have a white buffer!");
destDTBufferOnWhite->SetTransform(mat);
if (!EnsureBufferOnWhite()) {
@ -688,7 +688,7 @@ RotatedContentBuffer::BorrowDrawTargetForPainting(ThebesLayer* aLayer,
canUseOpaqueSurface ? GFX_CONTENT_COLOR :
GFX_CONTENT_COLOR_ALPHA;
if (aPaintState.mMode == Layer::SURFACE_COMPONENT_ALPHA) {
if (aPaintState.mMode == SURFACE_COMPONENT_ALPHA) {
MOZ_ASSERT(mDTBuffer && mDTBufferOnWhite);
nsIntRegionRectIterator iter(aPaintState.mRegionToDraw);
const nsIntRect *iterRect;

View File

@ -19,7 +19,6 @@
#include "nsRect.h" // for nsIntRect
#include "nsRegion.h" // for nsIntRegion
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
#include "Layers.h" // for Layer::SurfaceMode
#include "LayersTypes.h"
struct gfxMatrix;
@ -34,6 +33,7 @@ namespace layers {
class DeprecatedTextureClient;
class TextureClient;
class ThebesLayer;
/**
* This is a cairo/Thebes surface, but with a literal twist. Scrolling
@ -214,13 +214,13 @@ public:
*/
struct PaintState {
PaintState()
: mMode(Layer::SURFACE_NONE)
: mMode(SURFACE_NONE)
, mDidSelfCopy(false)
{}
nsIntRegion mRegionToDraw;
nsIntRegion mRegionToInvalidate;
Layer::SurfaceMode mMode;
SurfaceMode mMode;
DrawRegionClip mClip;
bool mDidSelfCopy;
};

View File

@ -7,7 +7,6 @@
#include "ClientCanvasLayer.h" // for ClientCanvasLayer
#include "GLContext.h" // for GLContext
#include "GLScreenBuffer.h" // for GLScreenBuffer
#include "Layers.h" // for Layer, etc
#include "SurfaceStream.h" // for SurfaceStream
#include "SurfaceTypes.h" // for SurfaceStreamHandle
#include "gfx2DGlue.h" // for ImageFormatToSurfaceFormat
@ -239,7 +238,7 @@ DeprecatedCanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLaye
{
if (!mDeprecatedTextureClient) {
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_STREAM_GL,
aLayer->GetSurfaceMode() == Layer::SURFACE_OPAQUE
aLayer->GetSurfaceMode() == SURFACE_OPAQUE
? GFX_CONTENT_COLOR
: GFX_CONTENT_COLOR_ALPHA);
MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");

View File

@ -5,7 +5,6 @@
#include "mozilla/layers/ContentClient.h"
#include "BasicLayers.h" // for BasicLayerManager
#include "Layers.h" // for ThebesLayer, Layer, etc
#include "gfxColor.h" // for gfxRGBA
#include "gfxContext.h" // for gfxContext, etc
#include "gfxPlatform.h" // for gfxPlatform
@ -1026,7 +1025,7 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
canUseOpaqueSurface ? GFX_CONTENT_COLOR :
GFX_CONTENT_COLOR_ALPHA;
Layer::SurfaceMode mode;
SurfaceMode mode;
nsIntRegion neededRegion;
bool canReuseBuffer;
nsIntRect destBufferRect;
@ -1053,11 +1052,11 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
destBufferRect = neededRegion.GetBounds();
}
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
if (!gfxPlatform::ComponentAlphaEnabled() ||
!aLayer->GetParent() ||
!aLayer->GetParent()->SupportsComponentAlphaChildren()) {
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
mode = SURFACE_SINGLE_CHANNEL_ALPHA;
} else {
contentType = GFX_CONTENT_COLOR;
}
@ -1067,9 +1066,9 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
(!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
neededRegion.GetNumRects() > 1)) {
// The area we add to neededRegion might not be painted opaquely
if (mode == Layer::SURFACE_OPAQUE) {
if (mode == SURFACE_OPAQUE) {
contentType = GFX_CONTENT_COLOR_ALPHA;
mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
mode = SURFACE_SINGLE_CHANNEL_ALPHA;
}
// For component alpha layers, we leave contentType as GFX_CONTENT_COLOR.
@ -1080,7 +1079,7 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
if (mHasBuffer &&
(mContentType != contentType ||
(mode == Layer::SURFACE_COMPONENT_ALPHA) != mHasBufferOnWhite)) {
(mode == SURFACE_COMPONENT_ALPHA) != mHasBufferOnWhite)) {
// We're effectively clearing the valid region, so we need to draw
// the entire needed region now.
result.mRegionToInvalidate = aLayer->GetValidRegion();
@ -1123,7 +1122,7 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
bool createdBuffer = false;
uint32_t bufferFlags = canHaveRotation ? TEXTURE_ALLOW_REPEAT : 0;
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
bufferFlags |= TEXTURE_COMPONENT_ALPHA;
}
if (canReuseBuffer) {
@ -1176,12 +1175,12 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
if (createdBuffer) {
if (mHasBuffer &&
(mode != Layer::SURFACE_COMPONENT_ALPHA || mHasBufferOnWhite)) {
(mode != SURFACE_COMPONENT_ALPHA || mHasBufferOnWhite)) {
mTextureInfo.mDeprecatedTextureHostFlags = TEXTURE_HOST_COPY_PREVIOUS;
}
mHasBuffer = true;
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
if (mode == SURFACE_COMPONENT_ALPHA) {
mHasBufferOnWhite = true;
}
mBufferRect = destBufferRect;
@ -1224,7 +1223,7 @@ ContentClientIncremental::BorrowDrawTargetForPainting(ThebesLayer* aLayer,
// BeginUpdate is allowed to modify the given region,
// if it wants more to be repainted than we request.
if (aPaintState.mMode == Layer::SURFACE_COMPONENT_ALPHA) {
if (aPaintState.mMode == SURFACE_COMPONENT_ALPHA) {
nsIntRegion drawRegionCopy = aPaintState.mRegionToDraw;
nsRefPtr<gfxASurface> onBlack = GetUpdateSurface(BUFFER_BLACK, drawRegionCopy);
nsRefPtr<gfxASurface> onWhite = GetUpdateSurface(BUFFER_WHITE, aPaintState.mRegionToDraw);