Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2014-04-27 15:09:36 -04:00
commit cfd536708f
81 changed files with 541 additions and 1413 deletions

View File

@ -5,8 +5,6 @@
{
// bug 826335, globo.com
"globo.com": "\\(Mobile#(Android; Mobile",
// bug 826344, abril.com.br
"abril.com.br": "\\(Mobile#(Android; Mobile",
// bug 826347, msn.com
"msn.com": "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19",
// bug 826348, linkedin.com
@ -43,20 +41,10 @@
"avianca.com": "\\(Mobile#(Android; Mobile",
// bug 827678, marca.com
"marca.com": "\\(Mobile#(Android; Mobile",
// bug 828354, gazeta.pl
"gazeta.pl": "\\(Mobile#(Android; Mobile",
// bug 828360, sport.pl
"sport.pl": "\\(Mobile#(Android; Mobile",
// bug 828371, ingbank.pl
"ingbank.pl": "\\(Mobile#(Android; Mobile",
// bug 828378, wyborcza.pl
"wyborcza.pl": "\\(Mobile#(Android; Mobile",
// bug 828380, deser.pl
"deser.pl": "\\(Mobile#(Android; Mobile",
// bug 828386, ebay.es
"ebay.es": "\\(Mobile#(Android; Mobile",
// bug 828392, infojobs.net
"infojobs.net": "\\(Mobile#(Android; Mobile",
// bug 828399, antena3.com
"antena3.com": "\\(Mobile#(Android; Mobile",
// bug 828416, loteriasyapuestas.es
@ -79,8 +67,6 @@
"games.com": "\\(Mobile#(Android; Mobile",
// bug 843160, ehow.com
"ehow.com": "\\(Mobile#(Android; Mobile",
// bug 866577, 3g.qq.com
"3g.qq.com": "\\(Mobile#(Android; Mobile",
// bug 878228, blikk.hu
"blikk.hu": "\\(Mobile#(Android; Mobile",
// bug 878232, hazipatika.com
@ -97,8 +83,6 @@
"portfolio.hu": "\\(Mobile#(Android; Mobile",
// bug 878253, vatera.hu
"vatera.hu": "\\(Mobile#(Android; Mobile",
// bug 878255, 24sata.hr
"24sata.hr": "\\(Mobile#(Android; Mobile",
// bug 878260, cdm.me
"cdm.me": "\\(Mobile#(Android; Mobile",
// bug 878262, download.com
@ -111,8 +95,6 @@
"livescore.com": "\\(Mobile#(Android; Mobile",
// bug 878277, naslovi.net
"naslovi.net": "\\(Mobile#(Android; Mobile",
// bug 878630, ask.com
"ask.com": "\\(Mobile#(Android; Mobile",
// bug 878632, banorte.com
"banorte.com": "\\(Mobile#(Android; Mobile",
// bug 878649, univision.com

View File

@ -246,6 +246,7 @@ support-files =
[browser_dbg_variables-view-data.js]
[browser_dbg_variables-view-edit-cancel.js]
[browser_dbg_variables-view-edit-click.js]
skip-if = (os == 'mac' || os == 'win') && (debug == false) # Bug 986166
[browser_dbg_variables-view-edit-getset-01.js]
[browser_dbg_variables-view-edit-getset-02.js]
[browser_dbg_variables-view-edit-value.js]

View File

@ -85,13 +85,20 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
// We syncd the enum of channel type between nsIAudioChannelAgent.idl and
// AudioChannelBinding.h the same.
MOZ_ASSERT(int(AUDIO_AGENT_CHANNEL_NORMAL) == int(AudioChannel::Normal) &&
int(AUDIO_AGENT_CHANNEL_CONTENT) == int(AudioChannel::Content) &&
int(AUDIO_AGENT_CHANNEL_NOTIFICATION) == int(AudioChannel::Notification) &&
int(AUDIO_AGENT_CHANNEL_ALARM) == int(AudioChannel::Alarm) &&
int(AUDIO_AGENT_CHANNEL_TELEPHONY) == int(AudioChannel::Telephony) &&
int(AUDIO_AGENT_CHANNEL_RINGER) == int(AudioChannel::Ringer) &&
int(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) == int(AudioChannel::Publicnotification),
MOZ_ASSERT(static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_NORMAL) ==
AudioChannel::Normal &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_CONTENT) ==
AudioChannel::Content &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_NOTIFICATION) ==
AudioChannel::Notification &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_ALARM) ==
AudioChannel::Alarm &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_TELEPHONY) ==
AudioChannel::Telephony &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_RINGER) ==
AudioChannel::Ringer &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) ==
AudioChannel::Publicnotification,
"Enum of channel on nsIAudioChannelAgent.idl should be the same with AudioChannelBinding.h");
if (mAudioChannelType != AUDIO_AGENT_CHANNEL_ERROR ||

View File

@ -75,7 +75,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
allocator,
gfx::ImageFormatToSurfaceFormat(format),
gfx::BackendType::NONE, // we don't need to use it with a DrawTarget
layers::TextureFlags::DEFAULT);
TEXTURE_FLAGS_DEFAULT);
if (!grallocTC->AllocateForGLRendering(size)) {
return nullptr;

View File

@ -323,35 +323,6 @@ struct ParamTraits<mozilla::gfx::ColorSpace>
mozilla::gfx::ColorSpace::Max>
{};
template <>
struct ParamTraits<mozilla::layers::TextureFlags>
: public BitFlagsTypedEnumSerializer<
mozilla::layers::TextureFlags,
mozilla::layers::TextureFlags::ALL_BITS>
{};
template <>
struct ParamTraits<mozilla::layers::TextureIdentifier>
: public ContiguousTypedEnumSerializer<
mozilla::layers::TextureIdentifier,
mozilla::layers::TextureIdentifier::Front,
mozilla::layers::TextureIdentifier::HighBound>
{};
template <>
struct ParamTraits<mozilla::layers::DeprecatedTextureHostFlags>
: public BitFlagsTypedEnumSerializer<
mozilla::layers::DeprecatedTextureHostFlags,
mozilla::layers::DeprecatedTextureHostFlags::ALL_BITS>
{};
template <>
struct ParamTraits<mozilla::layers::DiagnosticTypes>
: public BitFlagsTypedEnumSerializer<
mozilla::layers::DiagnosticTypes,
mozilla::layers::DiagnosticTypes::ALL_BITS>
{};
/*
template <>
struct ParamTraits<mozilla::PixelFormat>
@ -838,10 +809,10 @@ struct ParamTraits<mozilla::layers::TextureInfo>
template <>
struct ParamTraits<mozilla::layers::CompositableType>
: public ContiguousTypedEnumSerializer<
: public ContiguousEnumSerializer<
mozilla::layers::CompositableType,
mozilla::layers::CompositableType::BUFFER_UNKNOWN,
mozilla::layers::CompositableType::BUFFER_COUNT>
mozilla::layers::BUFFER_UNKNOWN,
mozilla::layers::BUFFER_COUNT>
{};
template <>

View File

@ -51,14 +51,14 @@ Compositor::AssertOnCompositorThread()
bool
Compositor::ShouldDrawDiagnostics(DiagnosticFlags aFlags)
{
if ((aFlags & DiagnosticFlags::TILE) && !(mDiagnosticTypes & DiagnosticTypes::TILE_BORDERS)) {
if ((aFlags & DIAGNOSTIC_TILE) && !(mDiagnosticTypes & DIAGNOSTIC_TILE_BORDERS)) {
return false;
}
if ((aFlags & DiagnosticFlags::BIGIMAGE) &&
!(mDiagnosticTypes & DiagnosticTypes::BIGIMAGE_BORDERS)) {
if ((aFlags & DIAGNOSTIC_BIGIMAGE) &&
!(mDiagnosticTypes & DIAGNOSTIC_BIGIMAGE_BORDERS)) {
return false;
}
if (mDiagnosticTypes == DiagnosticTypes::NO_DIAGNOSTIC) {
if (!mDiagnosticTypes) {
return false;
}
return true;
@ -80,7 +80,7 @@ Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
while (const nsIntRect* rect = screenIter.Next())
{
DrawDiagnostics(aFlags | DiagnosticFlags::REGION_RECT,
DrawDiagnostics(aFlags | DIAGNOSTIC_REGION_RECT,
ToRect(*rect), aClipRect, aTransform, aFlashCounter);
}
}
@ -153,23 +153,23 @@ Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
float opacity = 0.7f;
gfx::Color color;
if (aFlags & DiagnosticFlags::CONTENT) {
if (aFlags & DIAGNOSTIC_CONTENT) {
color = gfx::Color(0.0f, 1.0f, 0.0f, 1.0f); // green
if (aFlags & DiagnosticFlags::COMPONENT_ALPHA) {
if (aFlags & DIAGNOSTIC_COMPONENT_ALPHA) {
color = gfx::Color(0.0f, 1.0f, 1.0f, 1.0f); // greenish blue
}
} else if (aFlags & DiagnosticFlags::IMAGE) {
} else if (aFlags & DIAGNOSTIC_IMAGE) {
color = gfx::Color(1.0f, 0.0f, 0.0f, 1.0f); // red
} else if (aFlags & DiagnosticFlags::COLOR) {
} else if (aFlags & DIAGNOSTIC_COLOR) {
color = gfx::Color(0.0f, 0.0f, 1.0f, 1.0f); // blue
} else if (aFlags & DiagnosticFlags::CONTAINER) {
} else if (aFlags & DIAGNOSTIC_CONTAINER) {
color = gfx::Color(0.8f, 0.0f, 0.8f, 1.0f); // purple
}
// make tile borders a bit more transparent to keep layer borders readable.
if (aFlags & DiagnosticFlags::TILE ||
aFlags & DiagnosticFlags::BIGIMAGE ||
aFlags & DiagnosticFlags::REGION_RECT) {
if (aFlags & DIAGNOSTIC_TILE ||
aFlags & DIAGNOSTIC_BIGIMAGE ||
aFlags & DIAGNOSTIC_REGION_RECT) {
lWidth = 1;
opacity = 0.5f;
color.r *= 0.7f;
@ -177,7 +177,7 @@ Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
color.b *= 0.7f;
}
if (mDiagnosticTypes & DiagnosticTypes::FLASH_BORDERS) {
if (mDiagnosticTypes & DIAGNOSTIC_FLASH_BORDERS) {
float flash = (float)aFlashCounter / (float)DIAGNOSTIC_FLASH_COUNTER_MAX;
color.r *= flash;
color.g *= flash;

View File

@ -199,13 +199,13 @@ public:
Compositor(PCompositorParent* aParent = nullptr)
: mCompositorID(0)
, mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC)
, mDiagnosticTypes(DIAGNOSTIC_NONE)
, mParent(aParent)
, mScreenRotation(ROTATION_0)
{
}
virtual TemporaryRef<DataTextureSource> CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
virtual TemporaryRef<DataTextureSource> CreateDataTextureSource(TextureFlags aFlags = 0) = 0;
virtual bool Initialize() = 0;
virtual void Destroy() = 0;

View File

@ -11,9 +11,6 @@
#include "LayersTypes.h" // for LayersBackend, etc
#include "nsXULAppAPI.h" // for GeckoProcessType, etc
#include "mozilla/TypedEnum.h"
#include "mozilla/TypedEnumBits.h"
namespace mozilla {
namespace layers {
@ -28,69 +25,65 @@ const SurfaceDescriptorType SURFACEDESCRIPTOR_UNKNOWN = 0;
*
* XXX - switch to all caps constant names which seems to be the standard in gecko
*/
MOZ_BEGIN_ENUM_CLASS(TextureFlags, uint32_t)
NO_FLAGS = 0,
// Use nearest-neighbour texture filtering (as opposed to linear filtering).
USE_NEAREST_FILTER = 1 << 0,
// The texture should be flipped around the y-axis when composited.
NEEDS_Y_FLIP = 1 << 1,
// Force the texture to be represented using a single tile (note that this means
// tiled textures, not tiled layers).
DISALLOW_BIGIMAGE = 1 << 2,
// Allow using 'repeat' mode for wrapping.
ALLOW_REPEAT = 1 << 3,
// The texture represents a tile which is newly created.
NEW_TILE = 1 << 4,
// The texture is part of a component-alpha pair
COMPONENT_ALPHA = 1 << 5,
// The buffer will be treated as if the RB bytes are swapped.
// This is useful for rendering using Cairo/Thebes, because there is no
// BGRX Android pixel format, and so we have to do byte swapping.
//
// For example, if the GraphicBuffer has an Android pixel format of
// PIXEL_FORMAT_RGBA_8888 and isRBSwapped is true, when it is sampled
// (for example, with GL), a BGRA shader should be used.
RB_SWAPPED = 1 << 6,
typedef uint32_t TextureFlags;
// Use nearest-neighbour texture filtering (as opposed to linear filtering).
const TextureFlags TEXTURE_USE_NEAREST_FILTER = 1 << 0;
// The texture should be flipped around the y-axis when composited.
const TextureFlags TEXTURE_NEEDS_Y_FLIP = 1 << 1;
// Force the texture to be represented using a single tile (note that this means
// tiled textures, not tiled layers).
const TextureFlags TEXTURE_DISALLOW_BIGIMAGE = 1 << 2;
// Allow using 'repeat' mode for wrapping.
const TextureFlags TEXTURE_ALLOW_REPEAT = 1 << 3;
// The texture represents a tile which is newly created.
const TextureFlags TEXTURE_NEW_TILE = 1 << 4;
// The texture is part of a component-alpha pair
const TextureFlags TEXTURE_COMPONENT_ALPHA = 1 << 5;
// The buffer will be treated as if the RB bytes are swapped.
// This is useful for rendering using Cairo/Thebes, because there is no
// BGRX Android pixel format, and so we have to do byte swapping.
//
// For example, if the GraphicBuffer has an Android pixel format of
// PIXEL_FORMAT_RGBA_8888 and isRBSwapped is true, when it is sampled
// (for example, with GL), a BGRA shader should be used.
const TextureFlags TEXTURE_RB_SWAPPED = 1 << 6;
FRONT = 1 << 7,
// A texture host on white for component alpha
ON_WHITE = 1 << 8,
// A texture host on black for component alpha
ON_BLACK = 1 << 9,
// A texture host that supports tiling
TILE = 1 << 10,
// A texture should be recycled when no longer in used
RECYCLE = 1 << 11,
// Texture contents should be initialized
// from the previous texture.
COPY_PREVIOUS = 1 << 12,
// Who is responsible for deallocating the shared data.
// if DEALLOCATE_CLIENT is set, the shared data is deallocated on the
// client side and requires some extra synchronizaion to ensure race-free
// deallocation.
// The default behaviour is to deallocate on the host side.
DEALLOCATE_CLIENT = 1 << 13,
// After being shared ith the compositor side, an immutable texture is never
// modified, it can only be read. It is safe to not Lock/Unlock immutable
// textures.
IMMUTABLE = 1 << 14,
// The contents of the texture must be uploaded or copied immediately
// during the transaction, because the producer may want to write
// to it again.
IMMEDIATE_UPLOAD = 1 << 15,
// The texture is going to be used as part of a double
// buffered pair, and so we can guarantee that the producer/consumer
// won't be racing to access its contents.
DOUBLE_BUFFERED = 1 << 16,
// We've previously tried a texture and it didn't work for some reason. If there
// is a fallback available, try that.
ALLOC_FALLBACK = 1 << 17,
// OR union of all valid bits
ALL_BITS = (1 << 18) - 1,
// the default flags
DEFAULT = FRONT
MOZ_END_ENUM_CLASS(TextureFlags)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(TextureFlags)
const TextureFlags TEXTURE_FRONT = 1 << 12;
// A texture host on white for component alpha
const TextureFlags TEXTURE_ON_WHITE = 1 << 13;
// A texture host on black for component alpha
const TextureFlags TEXTURE_ON_BLACK = 1 << 14;
// A texture host that supports tiling
const TextureFlags TEXTURE_TILE = 1 << 15;
// A texture should be recycled when no longer in used
const TextureFlags TEXTURE_RECYCLE = 1 << 16;
// Texture contents should be initialized
// from the previous texture.
const TextureFlags TEXTURE_COPY_PREVIOUS = 1 << 24;
// Who is responsible for deallocating the shared data.
// if TEXTURE_DEALLOCATE_CLIENT is set, the shared data is deallocated on the
// client side and requires some extra synchronizaion to ensure race-free
// deallocation.
// The default behaviour is to deallocate on the host side.
const TextureFlags TEXTURE_DEALLOCATE_CLIENT = 1 << 25;
// After being shared ith the compositor side, an immutable texture is never
// modified, it can only be read. It is safe to not Lock/Unlock immutable
// textures.
const TextureFlags TEXTURE_IMMUTABLE = 1 << 27;
// The contents of the texture must be uploaded or copied immediately
// during the transaction, because the producer may want to write
// to it again.
const TextureFlags TEXTURE_IMMEDIATE_UPLOAD = 1 << 28;
// The texture is going to be used as part of a double
// buffered pair, and so we can guarantee that the producer/consumer
// won't be racing to access its contents.
const TextureFlags TEXTURE_DOUBLE_BUFFERED = 1 << 29;
// We've previously tried a texture and it didn't work for some reason. If there
// is a fallback available, try that.
const TextureFlags TEXTURE_ALLOC_FALLBACK = 1 << 31;
// the default flags
const TextureFlags TEXTURE_FLAGS_DEFAULT = TEXTURE_FRONT;
static inline bool
TextureRequiresLocking(TextureFlags aFlags)
@ -98,61 +91,57 @@ TextureRequiresLocking(TextureFlags aFlags)
// If we're not double buffered, or uploading
// within a transaction, then we need to support
// locking correctly.
return !(aFlags & (TextureFlags::IMMEDIATE_UPLOAD |
TextureFlags::DOUBLE_BUFFERED |
TextureFlags::IMMUTABLE));
return !(aFlags & (TEXTURE_IMMEDIATE_UPLOAD |
TEXTURE_DOUBLE_BUFFERED |
TEXTURE_IMMUTABLE));
}
/**
* The type of debug diagnostic to enable.
*/
MOZ_BEGIN_ENUM_CLASS(DiagnosticTypes, uint8_t)
NO_DIAGNOSTIC = 0,
TILE_BORDERS = 1 << 0,
LAYER_BORDERS = 1 << 1,
BIGIMAGE_BORDERS = 1 << 2,
FLASH_BORDERS = 1 << 3,
ALL_BITS = (1 << 4) - 1
MOZ_END_ENUM_CLASS(DiagnosticTypes)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DiagnosticTypes)
typedef uint32_t DiagnosticTypes;
const DiagnosticTypes DIAGNOSTIC_NONE = 0;
const DiagnosticTypes DIAGNOSTIC_TILE_BORDERS = 1 << 0;
const DiagnosticTypes DIAGNOSTIC_LAYER_BORDERS = 1 << 1;
const DiagnosticTypes DIAGNOSTIC_BIGIMAGE_BORDERS = 1 << 2;
const DiagnosticTypes DIAGNOSTIC_FLASH_BORDERS = 1 << 3;
#define DIAGNOSTIC_FLASH_COUNTER_MAX 100
/**
* Information about the object that is being diagnosed.
*/
MOZ_BEGIN_ENUM_CLASS(DiagnosticFlags, uint16_t)
NO_DIAGNOSTIC = 0,
IMAGE = 1 << 0,
CONTENT = 1 << 1,
CANVAS = 1 << 2,
COLOR = 1 << 3,
CONTAINER = 1 << 4,
TILE = 1 << 5,
BIGIMAGE = 1 << 6,
COMPONENT_ALPHA = 1 << 7,
REGION_RECT = 1 << 8
MOZ_END_ENUM_CLASS(DiagnosticFlags)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DiagnosticFlags)
typedef uint32_t DiagnosticFlags;
const DiagnosticFlags DIAGNOSTIC_IMAGE = 1 << 0;
const DiagnosticFlags DIAGNOSTIC_CONTENT = 1 << 1;
const DiagnosticFlags DIAGNOSTIC_CANVAS = 1 << 2;
const DiagnosticFlags DIAGNOSTIC_COLOR = 1 << 3;
const DiagnosticFlags DIAGNOSTIC_CONTAINER = 1 << 4;
const DiagnosticFlags DIAGNOSTIC_TILE = 1 << 5;
const DiagnosticFlags DIAGNOSTIC_BIGIMAGE = 1 << 6;
const DiagnosticFlags DIAGNOSTIC_COMPONENT_ALPHA = 1 << 7;
const DiagnosticFlags DIAGNOSTIC_REGION_RECT = 1 << 8;
/**
* See gfx/layers/Effects.h
*/
MOZ_BEGIN_ENUM_CLASS(EffectTypes, uint8_t)
MASK,
MAX_SECONDARY, // sentinel for the count of secondary effect types
RGB,
YCBCR,
COMPONENT_ALPHA,
SOLID_COLOR,
RENDER_TARGET,
MAX //sentinel for the count of all effect types
MOZ_END_ENUM_CLASS(EffectTypes)
enum EffectTypes
{
EFFECT_MASK,
EFFECT_MAX_SECONDARY, // sentinel for the count of secondary effect types
EFFECT_RGB,
EFFECT_YCBCR,
EFFECT_COMPONENT_ALPHA,
EFFECT_SOLID_COLOR,
EFFECT_RENDER_TARGET,
EFFECT_MAX //sentinel for the count of all effect types
};
/**
* How the Compositable should manage textures.
*/
MOZ_BEGIN_ENUM_CLASS(CompositableType, uint8_t)
enum CompositableType
{
BUFFER_UNKNOWN,
// the deprecated compositable types
BUFFER_IMAGE_SINGLE, // image/canvas with a single texture, single buffered
@ -164,23 +153,23 @@ MOZ_BEGIN_ENUM_CLASS(CompositableType, uint8_t)
BUFFER_TILED, // tiled thebes layer
BUFFER_SIMPLE_TILED,
// the new compositable types
IMAGE, // image with single buffering
CONTENT_SINGLE, // thebes layer interface, single buffering
CONTENT_DOUBLE, // thebes layer interface, double buffering
COMPOSITABLE_IMAGE, // image with single buffering
COMPOSITABLE_CONTENT_SINGLE, // thebes layer interface, single buffering
COMPOSITABLE_CONTENT_DOUBLE, // thebes layer interface, double buffering
BUFFER_COUNT
MOZ_END_ENUM_CLASS(CompositableType)
};
/**
* How the texture host is used for composition,
*/
MOZ_BEGIN_ENUM_CLASS(DeprecatedTextureHostFlags, uint8_t)
DEFAULT = 0, // The default texture host for the given SurfaceDescriptor
TILED = 1 << 0, // A texture host that supports tiling
COPY_PREVIOUS = 1 << 1, // Texture contents should be initialized
enum DeprecatedTextureHostFlags
{
TEXTURE_HOST_DEFAULT = 0, // The default texture host for the given
// SurfaceDescriptor
TEXTURE_HOST_TILED = 1 << 0, // A texture host that supports tiling
TEXTURE_HOST_COPY_PREVIOUS = 1 << 1 // Texture contents should be initialized
// from the previous texture.
ALL_BITS = (1 << 2) - 1
MOZ_END_ENUM_CLASS(DeprecatedTextureHostFlags)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DeprecatedTextureHostFlags)
};
/**
* Sent from the compositor to the content-side LayerManager, includes properties
@ -214,13 +203,11 @@ struct TextureFactoryIdentifier
* XXX - This is now redundant with TextureFlags. it ill be removed along with
* deprecated texture classes.
*/
MOZ_BEGIN_ENUM_CLASS(TextureIdentifier, uint8_t)
Front = 1,
Back = 2,
OnWhiteFront = 3,
OnWhiteBack = 4,
HighBound
MOZ_END_ENUM_CLASS(TextureIdentifier)
typedef uint32_t TextureIdentifier;
const TextureIdentifier TextureFront = 1;
const TextureIdentifier TextureBack = 2;
const TextureIdentifier TextureOnWhiteFront = 3;
const TextureIdentifier TextureOnWhiteBack = 4;
/**
* Information required by the compositor from the content-side for creating or
@ -232,19 +219,19 @@ MOZ_END_ENUM_CLASS(TextureIdentifier)
struct TextureInfo
{
CompositableType mCompositableType;
DeprecatedTextureHostFlags mDeprecatedTextureHostFlags;
TextureFlags mTextureFlags;
uint32_t mDeprecatedTextureHostFlags;
uint32_t mTextureFlags;
TextureInfo()
: mCompositableType(CompositableType::BUFFER_UNKNOWN)
, mDeprecatedTextureHostFlags(DeprecatedTextureHostFlags::DEFAULT)
, mTextureFlags(TextureFlags::NO_FLAGS)
: mCompositableType(BUFFER_UNKNOWN)
, mDeprecatedTextureHostFlags(0)
, mTextureFlags(0)
{}
TextureInfo(CompositableType aType)
: mCompositableType(aType)
, mDeprecatedTextureHostFlags(DeprecatedTextureHostFlags::DEFAULT)
, mTextureFlags(TextureFlags::NO_FLAGS)
, mDeprecatedTextureHostFlags(0)
, mTextureFlags(0)
{}
bool operator==(const TextureInfo& aOther) const
@ -260,24 +247,21 @@ struct TextureInfo
*
* See ShadowLayerForwarder::OpenDescriptor for example.
*/
MOZ_BEGIN_ENUM_CLASS(OpenMode, uint8_t)
OPEN_NONE = 0,
OPEN_READ = 0x1,
OPEN_WRITE = 0x2,
OPEN_READ_WRITE = OPEN_READ|OPEN_WRITE,
OPEN_READ_ONLY = OPEN_READ,
OPEN_WRITE_ONLY = OPEN_WRITE
MOZ_END_ENUM_CLASS(OpenMode)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(OpenMode)
typedef uint32_t OpenMode;
const OpenMode OPEN_READ = 0x1;
const OpenMode OPEN_WRITE = 0x2;
const OpenMode OPEN_READ_WRITE = OPEN_READ|OPEN_WRITE;
const OpenMode OPEN_READ_ONLY = OPEN_READ;
const OpenMode OPEN_WRITE_ONLY = OPEN_WRITE;
// The kinds of mask texture a shader can support
// We rely on the items in this enum being sequential
MOZ_BEGIN_ENUM_CLASS(MaskType, uint8_t)
enum MaskType {
MaskNone = 0, // no mask layer
Mask2d, // mask layer for layers with 2D transforms
Mask3d, // mask layer for layers with 3D transforms
NumMaskTypes
MOZ_END_ENUM_CLASS(MaskType)
};
} // namespace layers
} // namespace mozilla

View File

@ -131,7 +131,7 @@ D3D9SurfaceImage::GetTextureClient(CompositableClient* aClient)
EnsureSynchronized();
if (!mTextureClient) {
RefPtr<SharedTextureClientD3D9> textureClient =
new SharedTextureClientD3D9(gfx::SurfaceFormat::B8G8R8X8, TextureFlags::DEFAULT);
new SharedTextureClientD3D9(gfx::SurfaceFormat::B8G8R8X8, TEXTURE_FLAGS_DEFAULT);
textureClient->InitWith(mTexture, mShareHandle, mDesc);
mTextureClient = textureClient;
}

View File

@ -17,7 +17,6 @@
#include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget, etc
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nscore.h" // for nsACString
#include "mozilla/EnumeratedArray.h"
namespace mozilla {
namespace layers {
@ -81,7 +80,7 @@ struct EffectMask : public Effect
EffectMask(TextureSource *aMaskTexture,
gfx::IntSize aSize,
const gfx::Matrix4x4 &aMaskTransform)
: Effect(EffectTypes::MASK)
: Effect(EFFECT_MASK)
, mMaskTexture(aMaskTexture)
, mIs3D(false)
, mSize(aSize)
@ -100,7 +99,7 @@ struct EffectMask : public Effect
struct EffectRenderTarget : public TexturedEffect
{
EffectRenderTarget(CompositingRenderTarget *aRenderTarget)
: TexturedEffect(EffectTypes::RENDER_TARGET, aRenderTarget, true, gfx::Filter::LINEAR)
: TexturedEffect(EFFECT_RENDER_TARGET, aRenderTarget, true, gfx::Filter::LINEAR)
, mRenderTarget(aRenderTarget)
{}
@ -116,7 +115,7 @@ struct EffectRGB : public TexturedEffect
bool aPremultiplied,
gfx::Filter aFilter,
bool aFlipped = false)
: TexturedEffect(EffectTypes::RGB, aTexture, aPremultiplied, aFilter)
: TexturedEffect(EFFECT_RGB, aTexture, aPremultiplied, aFilter)
{}
virtual const char* Name() { return "EffectRGB"; }
@ -125,7 +124,7 @@ struct EffectRGB : public TexturedEffect
struct EffectYCbCr : public TexturedEffect
{
EffectYCbCr(TextureSource *aSource, gfx::Filter aFilter)
: TexturedEffect(EffectTypes::YCBCR, aSource, false, aFilter)
: TexturedEffect(EFFECT_YCBCR, aSource, false, aFilter)
{}
virtual const char* Name() { return "EffectYCbCr"; }
@ -136,7 +135,7 @@ struct EffectComponentAlpha : public TexturedEffect
EffectComponentAlpha(TextureSource *aOnBlack,
TextureSource *aOnWhite,
gfx::Filter aFilter)
: TexturedEffect(EffectTypes::COMPONENT_ALPHA, nullptr, false, aFilter)
: TexturedEffect(EFFECT_COMPONENT_ALPHA, nullptr, false, aFilter)
, mOnBlack(aOnBlack)
, mOnWhite(aOnWhite)
{}
@ -150,7 +149,7 @@ struct EffectComponentAlpha : public TexturedEffect
struct EffectSolidColor : public Effect
{
EffectSolidColor(const gfx::Color &aColor)
: Effect(EffectTypes::SOLID_COLOR)
: Effect(EFFECT_SOLID_COLOR)
, mColor(aColor)
{}
@ -165,8 +164,7 @@ struct EffectChain
explicit EffectChain(void* aLayerRef) : mLayerRef(aLayerRef) {}
RefPtr<Effect> mPrimaryEffect;
EnumeratedArray<EffectTypes, EffectTypes::MAX_SECONDARY, RefPtr<Effect>>
mSecondaryEffects;
RefPtr<Effect> mSecondaryEffects[EFFECT_MAX_SECONDARY];
void* mLayerRef; //!< For LayerScope logging
};

View File

@ -131,7 +131,7 @@ ImageContainer::ImageContainer(int flag)
if (flag == ENABLE_ASYNC && ImageBridgeChild::IsCreated()) {
// the refcount of this ImageClient is 1. we don't use a RefPtr here because the refcount
// of this class must be done on the ImageBridge thread.
mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(CompositableType::BUFFER_IMAGE_SINGLE).drop();
mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(BUFFER_IMAGE_SINGLE).drop();
MOZ_ASSERT(mImageClient);
}
}
@ -624,12 +624,12 @@ CairoImage::GetTextureClient(CompositableClient *aClient)
// gfx::BackendType::NONE means default to content backend
textureClient = aClient->CreateTextureClientForDrawing(surface->GetFormat(),
TextureFlags::DEFAULT,
TEXTURE_FLAGS_DEFAULT,
gfx::BackendType::NONE,
surface->GetSize());
MOZ_ASSERT(textureClient->CanExposeDrawTarget());
if (!textureClient->AllocateForSurface(surface->GetSize()) ||
!textureClient->Lock(OpenMode::OPEN_WRITE_ONLY)) {
!textureClient->Lock(OPEN_WRITE_ONLY)) {
return nullptr;
}

View File

@ -778,20 +778,20 @@ LayerScope::SendEffectChain(GLContext* aGLContext,
const Effect* primaryEffect = aEffectChain.mPrimaryEffect;
switch (primaryEffect->mType) {
case EffectTypes::RGB:
case EFFECT_RGB:
{
const TexturedEffect* texturedEffect =
static_cast<const TexturedEffect*>(primaryEffect);
SendTexturedEffect(aGLContext, aEffectChain.mLayerRef, texturedEffect);
}
break;
case EffectTypes::YCBCR:
case EFFECT_YCBCR:
{
const EffectYCbCr* yCbCrEffect =
static_cast<const EffectYCbCr*>(primaryEffect);
SendYCbCrEffect(aGLContext, aEffectChain.mLayerRef, yCbCrEffect);
}
case EffectTypes::SOLID_COLOR:
case EFFECT_SOLID_COLOR:
{
const EffectSolidColor* solidColorEffect =
static_cast<const EffectSolidColor*>(primaryEffect);
@ -802,13 +802,13 @@ LayerScope::SendEffectChain(GLContext* aGLContext,
SendColor(aEffectChain.mLayerRef, color, aWidth, aHeight);
}
break;
case EffectTypes::COMPONENT_ALPHA:
case EffectTypes::RENDER_TARGET:
case EFFECT_COMPONENT_ALPHA:
case EFFECT_RENDER_TARGET:
default:
break;
}
//const Effect* secondaryEffect = aEffectChain.mSecondaryEffects[EffectTypes::MASK];
//const Effect* secondaryEffect = aEffectChain.mSecondaryEffects[EFFECT_MASK];
// TODO:
}

View File

@ -180,13 +180,13 @@ AppendToString(nsACString& s, TextureFlags flags,
const char* pfx, const char* sfx)
{
s += pfx;
if (flags == TextureFlags::NO_FLAGS) {
if (!flags) {
s += "NoFlags";
} else {
#define AppendFlag(test) \
{ \
if (!!(flags & test)) { \
if (flags & test) { \
if (previous) { \
s += "|"; \
} \
@ -195,11 +195,11 @@ AppendToString(nsACString& s, TextureFlags flags,
} \
}
bool previous = false;
AppendFlag(TextureFlags::USE_NEAREST_FILTER);
AppendFlag(TextureFlags::NEEDS_Y_FLIP);
AppendFlag(TextureFlags::DISALLOW_BIGIMAGE);
AppendFlag(TextureFlags::ALLOW_REPEAT);
AppendFlag(TextureFlags::NEW_TILE);
AppendFlag(TEXTURE_USE_NEAREST_FILTER);
AppendFlag(TEXTURE_NEEDS_Y_FLIP);
AppendFlag(TEXTURE_DISALLOW_BIGIMAGE);
AppendFlag(TEXTURE_ALLOW_REPEAT);
AppendFlag(TEXTURE_NEW_TILE);
#undef AppendFlag
}

View File

@ -11,7 +11,6 @@
#include "nsRegion.h"
#include "mozilla/TypedEnum.h"
#include "mozilla/TypedEnumBits.h"
#ifdef MOZ_WIDGET_GONK
#include <ui/GraphicBuffer.h>
@ -41,6 +40,8 @@ namespace layers {
class TextureHost;
typedef uint32_t TextureFlags;
#undef NONE
#undef OPAQUE
@ -76,47 +77,42 @@ MOZ_END_ENUM_CLASS(SurfaceMode)
// 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.
MOZ_BEGIN_ENUM_CLASS(LayerRenderStateFlags, int8_t)
LAYER_RENDER_STATE_DEFAULT = 0,
Y_FLIPPED = 1 << 0,
BUFFER_ROTATION = 1 << 1,
enum LayerRenderStateFlags {
LAYER_RENDER_STATE_Y_FLIPPED = 1 << 0,
LAYER_RENDER_STATE_BUFFER_ROTATION = 1 << 1,
// Notify Composer2D to swap the RB pixels of gralloc buffer
FORMAT_RB_SWAP = 1 << 2
MOZ_END_ENUM_CLASS(LayerRenderStateFlags)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LayerRenderStateFlags)
LAYER_RENDER_STATE_FORMAT_RB_SWAP = 1 << 2
};
// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
// android::sp unless we have to.
struct LayerRenderState {
LayerRenderState()
#ifdef MOZ_WIDGET_GONK
: mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT)
, mHasOwnOffset(false)
, mSurface(nullptr)
, mTexture(nullptr)
: mSurface(nullptr), mTexture(nullptr), mFlags(0), mHasOwnOffset(false)
#endif
{}
#ifdef MOZ_WIDGET_GONK
LayerRenderState(android::GraphicBuffer* aSurface,
const nsIntSize& aSize,
LayerRenderStateFlags aFlags,
uint32_t aFlags,
TextureHost* aTexture)
: mFlags(aFlags)
, mHasOwnOffset(false)
, mSurface(aSurface)
: mSurface(aSurface)
, mSize(aSize)
, mTexture(aTexture)
, mFlags(aFlags)
, mHasOwnOffset(false)
{}
bool YFlipped() const
{ return bool(mFlags & LayerRenderStateFlags::Y_FLIPPED); }
{ return mFlags & LAYER_RENDER_STATE_Y_FLIPPED; }
bool BufferRotated() const
{ return bool(mFlags & LayerRenderStateFlags::BUFFER_ROTATION); }
{ return mFlags & LAYER_RENDER_STATE_BUFFER_ROTATION; }
bool FormatRBSwapped() const
{ return bool(mFlags & LayerRenderStateFlags::FORMAT_RB_SWAP); }
{ return mFlags & LAYER_RENDER_STATE_FORMAT_RB_SWAP; }
#endif
void SetOffset(const nsIntPoint& aOffset)
@ -125,12 +121,6 @@ struct LayerRenderState {
mHasOwnOffset = true;
}
// see LayerRenderStateFlags
LayerRenderStateFlags mFlags;
// true if mOffset is applicable
bool mHasOwnOffset;
// the location of the layer's origin on mSurface
nsIntPoint mOffset;
#ifdef MOZ_WIDGET_GONK
// surface to render
android::sp<android::GraphicBuffer> mSurface;
@ -138,6 +128,12 @@ struct LayerRenderState {
nsIntSize mSize;
TextureHost* mTexture;
#endif
// see LayerRenderStateFlags
uint32_t mFlags;
// the location of the layer's origin on mSurface
nsIntPoint mOffset;
// true if mOffset is applicable
bool mHasOwnOffset;
};
MOZ_BEGIN_ENUM_CLASS(ScaleMode, int8_t)

View File

@ -14,7 +14,7 @@ MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
{
if (!mTextureClient) {
RefPtr<MacIOSurfaceTextureClientOGL> buffer =
new MacIOSurfaceTextureClientOGL(TextureFlags::DEFAULT);
new MacIOSurfaceTextureClientOGL(TEXTURE_FLAGS_DEFAULT);
buffer->InitWith(mSurface);
mTextureClient = buffer;
}

View File

@ -126,7 +126,7 @@ BasicCompositor::CreateDataTextureSource(TextureFlags aFlags)
bool
BasicCompositor::SupportsEffect(EffectTypes aEffect)
{
return static_cast<EffectTypes>(aEffect) != EffectTypes::YCBCR;
return static_cast<EffectTypes>(aEffect) != EFFECT_YCBCR;
}
static void
@ -291,8 +291,8 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
RefPtr<SourceSurface> sourceMask;
Matrix maskTransform;
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
EffectMask *effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
if (aEffectChain.mSecondaryEffects[EFFECT_MASK]) {
EffectMask *effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EFFECT_MASK].get());
sourceMask = effectMask->mMaskTexture->AsSourceBasic()->GetSurface();
MOZ_ASSERT(effectMask->mMaskTransform.Is2D(), "How did we end up with a 3D transform here?!");
MOZ_ASSERT(!effectMask->mIs3D);
@ -301,7 +301,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
}
switch (aEffectChain.mPrimaryEffect->mType) {
case EffectTypes::SOLID_COLOR: {
case EFFECT_SOLID_COLOR: {
EffectSolidColor* effectSolidColor =
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
@ -309,7 +309,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
DrawOptions(aOpacity), sourceMask, &maskTransform);
break;
}
case EffectTypes::RGB: {
case EFFECT_RGB: {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
TextureSourceBasic* source = texturedEffect->mTexture->AsSourceBasic();
@ -321,11 +321,11 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
aOpacity, sourceMask, &maskTransform);
break;
}
case EffectTypes::YCBCR: {
case EFFECT_YCBCR: {
NS_RUNTIMEABORT("Can't (easily) support component alpha with BasicCompositor!");
break;
}
case EffectTypes::RENDER_TARGET: {
case EFFECT_RENDER_TARGET: {
EffectRenderTarget* effectRenderTarget =
static_cast<EffectRenderTarget*>(aEffectChain.mPrimaryEffect.get());
RefPtr<BasicCompositingRenderTarget> surface
@ -339,7 +339,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
aOpacity, sourceMask, &maskTransform);
break;
}
case EffectTypes::COMPONENT_ALPHA: {
case EFFECT_COMPONENT_ALPHA: {
NS_RUNTIMEABORT("Can't (easily) support component alpha with BasicCompositor!");
break;
}

View File

@ -65,7 +65,7 @@ public:
const gfx::IntPoint &aSourcePoint) MOZ_OVERRIDE;
virtual TemporaryRef<DataTextureSource>
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) MOZ_OVERRIDE;
CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE;
virtual bool SupportsEffect(EffectTypes aEffect) MOZ_OVERRIDE;

View File

@ -71,7 +71,7 @@ TextureClientX11::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
TextureClientData*
TextureClientX11::DropTextureData()
{
MOZ_ASSERT(!(mFlags & TextureFlags::DEALLOCATE_CLIENT));
MOZ_ASSERT(!(mFlags & TEXTURE_DEALLOCATE_CLIENT));
return nullptr;
}

View File

@ -19,7 +19,7 @@ namespace layers {
class TextureClientX11 : public TextureClient
{
public:
TextureClientX11(gfx::SurfaceFormat format, TextureFlags aFlags = TextureFlags::DEFAULT);
TextureClientX11(gfx::SurfaceFormat format, TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
~TextureClientX11();

View File

@ -43,7 +43,7 @@ CanvasClient::CreateCanvasClient(CanvasClientType aType,
#endif
if (aType == CanvasClientGLContext &&
aForwarder->GetCompositorBackendType() == LayersBackend::LAYERS_OPENGL) {
aFlags |= TextureFlags::DEALLOCATE_CLIENT;
aFlags |= TEXTURE_DEALLOCATE_CLIENT;
return new CanvasClientSurfaceStream(aForwarder, aFlags);
}
return new CanvasClient2D(aForwarder, aFlags);
@ -66,9 +66,9 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
: gfxContentType::COLOR_ALPHA;
gfxImageFormat format
= gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
TextureFlags flags = TextureFlags::DEFAULT;
if (mTextureFlags & TextureFlags::NEEDS_Y_FLIP) {
flags |= TextureFlags::NEEDS_Y_FLIP;
uint32_t flags = TEXTURE_FLAGS_DEFAULT;
if (mTextureFlags & TEXTURE_NEEDS_Y_FLIP) {
flags |= TEXTURE_NEEDS_Y_FLIP;
}
mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format),
flags,
@ -79,7 +79,7 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
bufferCreated = true;
}
if (!mBuffer->Lock(OpenMode::OPEN_WRITE_ONLY)) {
if (!mBuffer->Lock(OPEN_WRITE_ONLY)) {
mBuffer = nullptr;
return;
}

View File

@ -79,7 +79,7 @@ public:
TextureInfo GetTextureInfo() const
{
return TextureInfo(CompositableType::IMAGE);
return TextureInfo(COMPOSITABLE_IMAGE);
}
virtual void Clear() MOZ_OVERRIDE
@ -113,7 +113,7 @@ public:
TextureInfo GetTextureInfo() const
{
return TextureInfo(CompositableType::IMAGE);
return TextureInfo(COMPOSITABLE_IMAGE);
}
virtual void Clear() MOZ_OVERRIDE

View File

@ -133,18 +133,18 @@ ClientCanvasLayer::RenderLayer()
}
if (!mCanvasClient) {
TextureFlags flags = TextureFlags::IMMEDIATE_UPLOAD;
TextureFlags flags = TEXTURE_IMMEDIATE_UPLOAD;
if (mNeedsYFlip) {
flags |= TextureFlags::NEEDS_Y_FLIP;
flags |= TEXTURE_NEEDS_Y_FLIP;
}
if (!mGLContext) {
// We don't support locking for buffer surfaces currently
flags |= TextureFlags::IMMEDIATE_UPLOAD;
flags |= TEXTURE_IMMEDIATE_UPLOAD;
} else {
// GLContext's SurfaceStream handles ownership itself,
// and doesn't require layers to do any deallocation.
flags |= TextureFlags::DEALLOCATE_CLIENT;
flags |= TEXTURE_DEALLOCATE_CLIENT;
}
mCanvasClient = CanvasClient::CreateCanvasClient(GetCanvasClientType(),
ClientManager()->AsShadowForwarder(), flags);

View File

@ -29,7 +29,7 @@ public:
ClientImageLayer(ClientLayerManager* aLayerManager)
: ImageLayer(aLayerManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
, mImageClientTypeContainer(CompositableType::BUFFER_UNKNOWN)
, mImageClientTypeContainer(BUFFER_UNKNOWN)
{
MOZ_COUNT_CTOR(ClientImageLayer);
}
@ -42,7 +42,7 @@ public:
virtual void SetContainer(ImageContainer* aContainer) MOZ_OVERRIDE
{
ImageLayer::SetContainer(aContainer);
mImageClientTypeContainer = CompositableType::BUFFER_UNKNOWN;
mImageClientTypeContainer = BUFFER_UNKNOWN;
}
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
@ -94,12 +94,12 @@ protected:
CompositableType GetImageClientType()
{
if (mImageClientTypeContainer != CompositableType::BUFFER_UNKNOWN) {
if (mImageClientTypeContainer != BUFFER_UNKNOWN) {
return mImageClientTypeContainer;
}
if (mContainer->IsAsync()) {
mImageClientTypeContainer = CompositableType::BUFFER_BRIDGE;
mImageClientTypeContainer = BUFFER_BRIDGE;
return mImageClientTypeContainer;
}
@ -107,13 +107,13 @@ protected:
AutoLockImage autoLock(mContainer, &surface);
#ifdef MOZ_WIDGET_GONK
// gralloc buffer needs CompositableType::BUFFER_IMAGE_BUFFERED to prevent
// gralloc buffer needs BUFFER_IMAGE_BUFFERED to prevent
// the buffer's usage conflict.
mImageClientTypeContainer = autoLock.GetImage() ?
CompositableType::BUFFER_IMAGE_BUFFERED : CompositableType::BUFFER_UNKNOWN;
BUFFER_IMAGE_BUFFERED : BUFFER_UNKNOWN;
#else
mImageClientTypeContainer = autoLock.GetImage() ?
CompositableType::BUFFER_IMAGE_SINGLE : CompositableType::BUFFER_UNKNOWN;
BUFFER_IMAGE_SINGLE : BUFFER_UNKNOWN;
#endif
return mImageClientTypeContainer;
}
@ -140,17 +140,17 @@ ClientImageLayer::RenderLayer()
if (!mImageClient ||
!mImageClient->UpdateImage(mContainer, GetContentFlags())) {
CompositableType type = GetImageClientType();
if (type == CompositableType::BUFFER_UNKNOWN) {
if (type == BUFFER_UNKNOWN) {
return;
}
TextureFlags flags = TextureFlags::FRONT;
TextureFlags flags = TEXTURE_FRONT;
if (mDisallowBigImage) {
flags |= TextureFlags::DISALLOW_BIGIMAGE;
flags |= TEXTURE_DISALLOW_BIGIMAGE;
}
mImageClient = ImageClient::CreateImageClient(type,
ClientManager()->AsShadowForwarder(),
flags);
if (type == CompositableType::BUFFER_BRIDGE) {
if (type == BUFFER_BRIDGE) {
static_cast<ImageClientBridge*>(mImageClient.get())->SetLayer(this);
}

View File

@ -75,7 +75,7 @@ protected:
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositableClient)
CompositableClient(CompositableForwarder* aForwarder, TextureFlags aFlags = TextureFlags::NO_FLAGS);
CompositableClient(CompositableForwarder* aForwarder, TextureFlags aFlags = 0);
virtual TextureInfo GetTextureInfo() const = 0;
@ -83,7 +83,7 @@ public:
TemporaryRef<BufferTextureClient>
CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT,
gfx::BackendType aMoz2dBackend = gfx::BackendType::NONE);
TemporaryRef<TextureClient>

View File

@ -40,19 +40,20 @@ namespace layers {
static TextureFlags TextureFlagsForRotatedContentBufferFlags(uint32_t aBufferFlags)
{
TextureFlags result = TextureFlags::NO_FLAGS;
TextureFlags result = 0;
if (aBufferFlags & RotatedContentBuffer::BUFFER_COMPONENT_ALPHA) {
result |= TextureFlags::COMPONENT_ALPHA;
result |= TEXTURE_COMPONENT_ALPHA;
}
if (aBufferFlags & RotatedContentBuffer::ALLOW_REPEAT) {
result |= TextureFlags::ALLOW_REPEAT;
result |= TEXTURE_ALLOW_REPEAT;
}
return result;
}
/* static */ TemporaryRef<ContentClient>
ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
{
@ -196,7 +197,7 @@ ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr<TextureClient>&
if (!aClient->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
mTextureInfo.mTextureFlags | TextureFlags::ALLOC_FALLBACK | aFlags,
mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags,
gfx::BackendType::NONE,
mSize);
if (!aClient) {
@ -235,19 +236,19 @@ ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat,
mSize = gfx::IntSize(aRect.width, aRect.height);
mTextureInfo.mTextureFlags = TextureFlagsForRotatedContentBufferFlags(aFlags);
if (!CreateAndAllocateTextureClient(mTextureClient, TextureFlags::ON_BLACK) ||
if (!CreateAndAllocateTextureClient(mTextureClient, TEXTURE_ON_BLACK) ||
!AddTextureClient(mTextureClient)) {
AbortTextureClientCreation();
return;
}
if (aFlags & BUFFER_COMPONENT_ALPHA) {
if (!CreateAndAllocateTextureClient(mTextureClientOnWhite, TextureFlags::ON_WHITE) ||
if (!CreateAndAllocateTextureClient(mTextureClientOnWhite, TEXTURE_ON_WHITE) ||
!AddTextureClient(mTextureClientOnWhite)) {
AbortTextureClientCreation();
return;
}
mTextureInfo.mTextureFlags |= TextureFlags::COMPONENT_ALPHA;
mTextureInfo.mTextureFlags |= TEXTURE_COMPONENT_ALPHA;
}
CreateFrontBuffer(aRect);
@ -267,12 +268,12 @@ ContentClientRemoteBuffer::CreateBuffer(ContentType aType,
// We just created the textures and we are about to get their draw targets
// so we have to lock them here.
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
DebugOnly<bool> locked = mTextureClient->Lock(OPEN_READ_WRITE);
MOZ_ASSERT(locked, "Could not lock the TextureClient");
*aBlackDT = mTextureClient->GetAsDrawTarget();
if (aFlags & BUFFER_COMPONENT_ALPHA) {
locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE);
MOZ_ASSERT(locked, "Could not lock the second TextureClient for component alpha");
*aWhiteDT = mTextureClientOnWhite->GetAsDrawTarget();
@ -338,13 +339,13 @@ ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
void
ContentClientDoubleBuffered::CreateFrontBuffer(const nsIntRect& aBufferRect)
{
if (!CreateAndAllocateTextureClient(mFrontClient, TextureFlags::ON_BLACK) ||
if (!CreateAndAllocateTextureClient(mFrontClient, TEXTURE_ON_BLACK) ||
!AddTextureClient(mFrontClient)) {
AbortTextureClientCreation();
return;
}
if (mTextureInfo.mTextureFlags & TextureFlags::COMPONENT_ALPHA) {
if (!CreateAndAllocateTextureClient(mFrontClientOnWhite, TextureFlags::ON_WHITE) ||
if (mTextureInfo.mTextureFlags & TEXTURE_COMPONENT_ALPHA) {
if (!CreateAndAllocateTextureClient(mFrontClientOnWhite, TEXTURE_ON_WHITE) ||
!AddTextureClient(mFrontClientOnWhite)) {
AbortTextureClientCreation();
return;
@ -426,11 +427,11 @@ void
ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
{
if (mTextureClient) {
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
DebugOnly<bool> locked = mTextureClient->Lock(OPEN_READ_WRITE);
MOZ_ASSERT(locked);
}
if (mTextureClientOnWhite) {
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE);
MOZ_ASSERT(locked);
}
@ -464,11 +465,11 @@ ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
// We need to ensure that we lock these two buffers in the same
// order as the compositor to prevent deadlocks.
if (!mFrontClient->Lock(OpenMode::OPEN_READ_ONLY)) {
if (!mFrontClient->Lock(OPEN_READ_ONLY)) {
return;
}
if (mFrontClientOnWhite &&
!mFrontClientOnWhite->Lock(OpenMode::OPEN_READ_ONLY)) {
!mFrontClientOnWhite->Lock(OPEN_READ_ONLY)) {
mFrontClient->Unlock();
return;
}
@ -539,11 +540,11 @@ void
ContentClientSingleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
{
if (mTextureClient) {
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
DebugOnly<bool> locked = mTextureClient->Lock(OPEN_READ_WRITE);
MOZ_ASSERT(locked);
}
if (mTextureClientOnWhite) {
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE);
MOZ_ASSERT(locked);
}
}
@ -571,23 +572,11 @@ FillSurface(DrawTarget* aDT, const nsIntRegion& aRegion,
}
}
void
ContentClientIncremental::NotifyBufferCreated(ContentType aType, TextureFlags aFlags)
{
mTextureInfo.mTextureFlags = aFlags;
mContentType = aType;
mForwarder->CreatedIncrementalBuffer(this,
mTextureInfo,
mBufferRect);
}
RotatedContentBuffer::PaintState
ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
uint32_t aFlags)
{
mTextureInfo.mDeprecatedTextureHostFlags = DeprecatedTextureHostFlags::DEFAULT;
mTextureInfo.mDeprecatedTextureHostFlags = 0;
PaintState result;
// We need to disable rotation if we're going to be resampled when
// drawing, because we might sample across the rotation boundary.
@ -612,7 +601,7 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
canReuseBuffer = neededRegion.GetBounds().Size() <= mBufferRect.Size() &&
mHasBuffer &&
(!(aFlags & RotatedContentBuffer::PAINT_WILL_RESAMPLE) ||
!(mTextureInfo.mTextureFlags & TextureFlags::ALLOW_REPEAT));
!(mTextureInfo.mTextureFlags & TEXTURE_ALLOW_REPEAT));
if (canReuseBuffer) {
if (mBufferRect.Contains(neededRegion.GetBounds())) {
@ -696,12 +685,9 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
nsIntRect drawBounds = result.mRegionToDraw.GetBounds();
bool createdBuffer = false;
TextureFlags bufferFlags = TextureFlags::NO_FLAGS;
if (canHaveRotation) {
bufferFlags |= TextureFlags::ALLOW_REPEAT;
}
uint32_t bufferFlags = canHaveRotation ? TEXTURE_ALLOW_REPEAT : 0;
if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
bufferFlags |= TextureFlags::COMPONENT_ALPHA;
bufferFlags |= TEXTURE_COMPONENT_ALPHA;
}
if (canReuseBuffer) {
nsIntRect keepArea;
@ -754,7 +740,7 @@ ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer,
if (createdBuffer) {
if (mHasBuffer &&
(mode != SurfaceMode::SURFACE_COMPONENT_ALPHA || mHasBufferOnWhite)) {
mTextureInfo.mDeprecatedTextureHostFlags = DeprecatedTextureHostFlags::COPY_PREVIOUS;
mTextureInfo.mDeprecatedTextureHostFlags = TEXTURE_HOST_COPY_PREVIOUS;
}
mHasBuffer = true;
@ -851,7 +837,7 @@ ContentClientIncremental::Updated(const nsIntRegion& aRegionToDraw,
{
if (IsSurfaceDescriptorValid(mUpdateDescriptor)) {
mForwarder->UpdateTextureIncremental(this,
TextureIdentifier::Front,
TextureFront,
mUpdateDescriptor,
aRegionToDraw,
mBufferRect,
@ -860,7 +846,7 @@ ContentClientIncremental::Updated(const nsIntRegion& aRegionToDraw,
}
if (IsSurfaceDescriptorValid(mUpdateDescriptorOnWhite)) {
mForwarder->UpdateTextureIncremental(this,
TextureIdentifier::OnWhiteFront,
TextureOnWhiteFront,
mUpdateDescriptorOnWhite,
aRegionToDraw,
mBufferRect,

View File

@ -274,7 +274,7 @@ protected:
virtual void DestroyFrontBuffer() {}
bool CreateAndAllocateTextureClient(RefPtr<TextureClient>& aClient,
TextureFlags aFlags = TextureFlags::NO_FLAGS);
TextureFlags aFlags = 0);
virtual void AbortTextureClientCreation()
{
@ -314,7 +314,7 @@ public:
ContentClientDoubleBuffered(CompositableForwarder* aFwd)
: ContentClientRemoteBuffer(aFwd)
{
mTextureInfo.mCompositableType = CompositableType::CONTENT_DOUBLE;
mTextureInfo.mCompositableType = COMPOSITABLE_CONTENT_DOUBLE;
}
virtual ~ContentClientDoubleBuffered() {}
@ -368,7 +368,7 @@ public:
ContentClientSingleBuffered(CompositableForwarder* aFwd)
: ContentClientRemoteBuffer(aFwd)
{
mTextureInfo.mCompositableType = CompositableType::CONTENT_SINGLE;
mTextureInfo.mCompositableType = COMPOSITABLE_CONTENT_SINGLE;
}
virtual ~ContentClientSingleBuffered() {}
@ -394,7 +394,7 @@ public:
, mHasBuffer(false)
, mHasBufferOnWhite(false)
{
mTextureInfo.mCompositableType = CompositableType::BUFFER_CONTENT_INC;
mTextureInfo.mCompositableType = BUFFER_CONTENT_INC;
}
typedef RotatedContentBuffer::PaintState PaintState;
@ -443,7 +443,16 @@ private:
BUFFER_WHITE
};
void NotifyBufferCreated(ContentType aType, TextureFlags aFlags);
void NotifyBufferCreated(ContentType aType, uint32_t aFlags)
{
mTextureInfo.mTextureFlags = aFlags & ~TEXTURE_DEALLOCATE_CLIENT;
mContentType = aType;
mForwarder->CreatedIncrementalBuffer(this,
mTextureInfo,
mBufferRect);
}
TemporaryRef<gfx::DrawTarget> GetUpdateSurface(BufferType aType,
const nsIntRegion& aUpdateRegion);

View File

@ -48,17 +48,17 @@ ImageClient::CreateImageClient(CompositableType aCompositableHostType,
{
RefPtr<ImageClient> result = nullptr;
switch (aCompositableHostType) {
case CompositableType::IMAGE:
case CompositableType::BUFFER_IMAGE_SINGLE:
result = new ImageClientSingle(aForwarder, aFlags, CompositableType::IMAGE);
case COMPOSITABLE_IMAGE:
case BUFFER_IMAGE_SINGLE:
result = new ImageClientSingle(aForwarder, aFlags, COMPOSITABLE_IMAGE);
break;
case CompositableType::BUFFER_IMAGE_BUFFERED:
result = new ImageClientBuffered(aForwarder, aFlags, CompositableType::IMAGE);
case BUFFER_IMAGE_BUFFERED:
result = new ImageClientBuffered(aForwarder, aFlags, COMPOSITABLE_IMAGE);
break;
case CompositableType::BUFFER_BRIDGE:
case BUFFER_BRIDGE:
result = new ImageClientBridge(aForwarder, aFlags);
break;
case CompositableType::BUFFER_UNKNOWN:
case BUFFER_UNKNOWN:
result = nullptr;
break;
default:
@ -86,7 +86,7 @@ ImageClientBuffered::ImageClientBuffered(CompositableForwarder* aFwd,
TextureInfo ImageClientSingle::GetTextureInfo() const
{
return TextureInfo(CompositableType::IMAGE);
return TextureInfo(COMPOSITABLE_IMAGE);
}
void
@ -164,7 +164,7 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer,
bool bufferCreated = false;
if (!mFrontBuffer) {
mFrontBuffer = CreateBufferTextureClient(gfx::SurfaceFormat::YUV, TextureFlags::DEFAULT);
mFrontBuffer = CreateBufferTextureClient(gfx::SurfaceFormat::YUV, TEXTURE_FLAGS_DEFAULT);
gfx::IntSize ySize(data->mYSize.width, data->mYSize.height);
gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
if (!mFrontBuffer->AsTextureClientYCbCr()->AllocateForYCbCr(ySize, cbCrSize, data->mStereoMode)) {
@ -174,7 +174,7 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer,
bufferCreated = true;
}
if (!mFrontBuffer->Lock(OpenMode::OPEN_WRITE_ONLY)) {
if (!mFrontBuffer->Lock(OPEN_WRITE_ONLY)) {
mFrontBuffer = nullptr;
return false;
}
@ -242,7 +242,7 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer,
bufferCreated = true;
}
if (!mFrontBuffer->Lock(OpenMode::OPEN_WRITE_ONLY)) {
if (!mFrontBuffer->Lock(OPEN_WRITE_ONLY)) {
mFrontBuffer = nullptr;
return false;
}
@ -335,7 +335,7 @@ ImageClient::UpdatePictureRect(nsIntRect aRect)
ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd,
TextureFlags aFlags)
: ImageClient(aFwd, aFlags, CompositableType::BUFFER_BRIDGE)
: ImageClient(aFwd, aFlags, BUFFER_BRIDGE)
, mAsyncContainerID(0)
, mLayer(nullptr)
{

View File

@ -72,10 +72,10 @@ SimpleTextureClientPool::GetTextureClient(bool aAutoRecycle)
// No unused clients in the pool, create one
if (gfxPrefs::ForceShmemTiles()) {
textureClient = TextureClient::CreateBufferTextureClient(mSurfaceAllocator,
mFormat, TextureFlags::IMMEDIATE_UPLOAD | TextureFlags::RECYCLE, gfx::BackendType::NONE);
mFormat, TEXTURE_IMMEDIATE_UPLOAD | TEXTURE_RECYCLE, gfx::BackendType::NONE);
} else {
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator,
mFormat, TextureFlags::DEFAULT | TextureFlags::RECYCLE, gfx::BackendType::NONE, mSize);
mFormat, TEXTURE_FLAGS_DEFAULT | TEXTURE_RECYCLE, gfx::BackendType::NONE, mSize);
}
if (!textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT)) {
NS_WARNING("TextureClient::AllocateForSurface failed!");

View File

@ -90,7 +90,7 @@ SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile,
return SimpleTiledLayerTile();
}
if (!textureClient->Lock(OpenMode::OPEN_READ_WRITE)) {
if (!textureClient->Lock(OPEN_READ_WRITE)) {
NS_WARNING("TextureClient lock failed");
return SimpleTiledLayerTile();
}

View File

@ -144,7 +144,7 @@ public:
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return TextureInfo(CompositableType::BUFFER_SIMPLE_TILED);
return TextureInfo(BUFFER_SIMPLE_TILED);
}
void UseTiledLayerBuffer();

View File

@ -289,7 +289,7 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
gfxWindowsPlatform::GetPlatform()->GetD2DDevice() &&
aSizeHint.width <= maxTextureSize &&
aSizeHint.height <= maxTextureSize &&
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK)) {
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK)) {
result = new TextureClientD3D11(aFormat, aTextureFlags);
}
if (parentBackend == LayersBackend::LAYERS_D3D9 &&
@ -297,7 +297,7 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
aAllocator->IsSameProcess() &&
aSizeHint.width <= maxTextureSize &&
aSizeHint.height <= maxTextureSize &&
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK)) {
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK)) {
if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
result = new DIBTextureClientD3D9(aFormat, aTextureFlags);
} else {
@ -314,7 +314,7 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
if (parentBackend == LayersBackend::LAYERS_BASIC &&
aMoz2DBackend == gfx::BackendType::CAIRO &&
type == gfxSurfaceType::Xlib &&
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK))
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK))
{
result = new TextureClientX11(aFormat, aTextureFlags);
}
@ -323,7 +323,7 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
// Bug 977963: Disabled for black layers
if (parentBackend == LayersBackend::LAYERS_OPENGL &&
type == gfxSurfaceType::Xlib &&
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK) &&
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK) &&
aFormat != SurfaceFormat::A8 &&
gl::sGLXLibrary.UseTextureFromPixmap())
{
@ -461,7 +461,7 @@ TextureClient::~TextureClient()
void TextureClient::ForceRemove()
{
if (mValid && mActor) {
if (GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
if (GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
mActor->SetTextureData(DropTextureData());
if (mActor->IPCOpen()) {
mActor->SendRemoveTextureSync();
@ -649,7 +649,7 @@ BufferTextureClient::BufferTextureClient(ISurfaceAllocator* aAllocator,
, mAllocator(aAllocator)
, mFormat(aFormat)
, mBackend(aMoz2DBackend)
, mOpenMode(OpenMode::OPEN_NONE)
, mOpenMode(0)
, mUsingFallbackDrawTarget(false)
, mLocked(false)
{}
@ -716,7 +716,7 @@ BufferTextureClient::GetAsDrawTarget()
}
mUsingFallbackDrawTarget = true;
if (mOpenMode & OpenMode::OPEN_READ) {
if (mOpenMode & OPEN_READ) {
RefPtr<DataSourceSurface> surface = serializer.GetAsSurface();
IntRect rect(0, 0, surface->GetSize().width, surface->GetSize().height);
mDrawTarget->CopySurface(surface, rect, IntPoint(0,0));
@ -750,7 +750,7 @@ BufferTextureClient::Unlock()
MOZ_ASSERT(mDrawTarget->refCount() == 1);
mDrawTarget->Flush();
if (mUsingFallbackDrawTarget && (mOpenMode & OpenMode::OPEN_WRITE)) {
if (mUsingFallbackDrawTarget && (mOpenMode & OPEN_WRITE)) {
// When we are using a fallback DrawTarget, it means we could not create
// a DrawTarget wrapping the TextureClient's shared memory. In this scenario
// we need to put the content of the fallback draw target back into our shared

View File

@ -130,7 +130,7 @@ class TextureClient
: public AtomicRefCountedWithFinalize<TextureClient>
{
public:
TextureClient(TextureFlags aFlags = TextureFlags::DEFAULT);
TextureClient(TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
virtual ~TextureClient();
static TemporaryRef<BufferTextureClient>
@ -175,7 +175,7 @@ public:
*
* This is typically used as follows:
*
* if (!texture->Lock(OpenMode::OPEN_READ_WRITE)) {
* if (!texture->Lock(OPEN_READ_WRITE)) {
* return false;
* }
* {
@ -262,7 +262,7 @@ public:
TextureFlags GetFlags() const { return mFlags; }
/**
* valid only for TextureFlags::RECYCLE TextureClient.
* valid only for TEXTURE_RECYCLE TextureClient.
* When called this texture client will grab a strong reference and release
* it once the compositor notifies that it is done with the texture.
* NOTE: In this stage the texture client can no longer be used by the
@ -275,9 +275,9 @@ public:
* modified, it can only be read. It is safe to not Lock/Unlock immutable
* textures.
*/
bool IsImmutable() const { return !!(mFlags & TextureFlags::IMMUTABLE); }
bool IsImmutable() const { return mFlags & TEXTURE_IMMUTABLE; }
void MarkImmutable() { AddFlags(TextureFlags::IMMUTABLE); }
void MarkImmutable() { AddFlags(TEXTURE_IMMUTABLE); }
bool IsSharedWithCompositor() const { return mShared; }
@ -307,7 +307,7 @@ public:
/**
* Triggers the destruction of the shared data and the corresponding TextureHost.
*
* If the texture flags contain TextureFlags::DEALLOCATE_CLIENT, the destruction
* If the texture flags contain TEXTURE_DEALLOCATE_CLIENT, the destruction
* will be synchronously coordinated with the compositor side, otherwise it
* will be done asynchronously.
*/

View File

@ -57,10 +57,10 @@ TextureClientPool::GetTextureClient()
if (gfxPrefs::ForceShmemTiles()) {
// gfx::BackendType::NONE means use the content backend
textureClient = TextureClient::CreateBufferTextureClient(mSurfaceAllocator,
mFormat, TextureFlags::IMMEDIATE_UPLOAD, gfx::BackendType::NONE);
mFormat, TEXTURE_IMMEDIATE_UPLOAD, gfx::BackendType::NONE);
} else {
textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator,
mFormat, TextureFlags::IMMEDIATE_UPLOAD, gfx::BackendType::NONE, mSize);
mFormat, TEXTURE_IMMEDIATE_UPLOAD, gfx::BackendType::NONE, mSize);
}
textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT);

View File

@ -443,13 +443,13 @@ TileClient::ValidateBackBufferFromFront(const nsIntRegion& aDirtyRegion,
return;
}
if (!mFrontBuffer->Lock(OpenMode::OPEN_READ)) {
if (!mFrontBuffer->Lock(OPEN_READ)) {
NS_WARNING("Failed to lock the tile's front buffer");
return;
}
TextureClientAutoUnlock autoFront(mFrontBuffer);
if (!mBackBuffer->Lock(OpenMode::OPEN_WRITE)) {
if (!mBackBuffer->Lock(OPEN_WRITE)) {
NS_WARNING("Failed to lock the tile's back buffer");
return;
}
@ -749,7 +749,7 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
mManager->GetTexturePool(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(GetContentType())),
&createdTextureClient, !usingSinglePaintBuffer);
if (!backBuffer->Lock(OpenMode::OPEN_READ_WRITE)) {
if (!backBuffer->Lock(OPEN_READ_WRITE)) {
NS_WARNING("Failed to lock tile TextureClient for updating.");
aTile.DiscardFrontBuffer();
return aTile;

View File

@ -483,7 +483,7 @@ public:
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return TextureInfo(CompositableType::BUFFER_TILED);
return TextureInfo(BUFFER_TILED);
}
virtual void ClearCachedResources() MOZ_OVERRIDE;

View File

@ -44,9 +44,9 @@ bool
CanvasLayerComposite::SetCompositableHost(CompositableHost* aHost)
{
switch (aHost->GetType()) {
case CompositableType::BUFFER_IMAGE_SINGLE:
case CompositableType::BUFFER_IMAGE_BUFFERED:
case CompositableType::IMAGE:
case BUFFER_IMAGE_SINGLE:
case BUFFER_IMAGE_BUFFERED:
case COMPOSITABLE_IMAGE:
mImageHost = aHost;
return true;
default:

View File

@ -11,7 +11,7 @@
#include "mozilla/gfx/Rect.h" // for Rect
#include "mozilla/gfx/Types.h" // for Color
#include "mozilla/layers/Compositor.h" // for Compositor
#include "mozilla/layers/CompositorTypes.h" // for DiagnosticFlags::COLOR
#include "mozilla/layers/CompositorTypes.h" // for DIAGNOSTIC_COLOR
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsPoint.h" // for nsIntPoint
@ -43,7 +43,7 @@ ColorLayerComposite::RenderLayer(const nsIntRect& aClipRect)
const gfx::Matrix4x4& transform = GetEffectiveTransform();
mCompositor->DrawQuad(rect, clipRect, effects, opacity, transform);
mCompositor->DrawDiagnostics(DiagnosticFlags::COLOR,
mCompositor->DrawDiagnostics(DIAGNOSTIC_COLOR,
rect, clipRect,
transform);
}

View File

@ -158,7 +158,7 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
source->GetSize(),
aTransform);
effect->mIs3D = aIs3D;
aEffects.mSecondaryEffects[EffectTypes::MASK] = effect;
aEffects.mSecondaryEffects[EFFECT_MASK] = effect;
return true;
}
@ -179,23 +179,23 @@ CompositableHost::Create(const TextureInfo& aTextureInfo)
{
RefPtr<CompositableHost> result;
switch (aTextureInfo.mCompositableType) {
case CompositableType::BUFFER_BRIDGE:
case BUFFER_BRIDGE:
NS_ERROR("Cannot create an image bridge compositable this way");
break;
case CompositableType::BUFFER_CONTENT_INC:
case BUFFER_CONTENT_INC:
result = new ContentHostIncremental(aTextureInfo);
break;
case CompositableType::BUFFER_TILED:
case CompositableType::BUFFER_SIMPLE_TILED:
case BUFFER_TILED:
case BUFFER_SIMPLE_TILED:
result = new TiledContentHost(aTextureInfo);
break;
case CompositableType::IMAGE:
case COMPOSITABLE_IMAGE:
result = new ImageHost(aTextureInfo);
break;
case CompositableType::CONTENT_SINGLE:
case COMPOSITABLE_CONTENT_SINGLE:
result = new ContentHostSingleBuffered(aTextureInfo);
break;
case CompositableType::CONTENT_DOUBLE:
case COMPOSITABLE_CONTENT_DOUBLE:
result = new ContentHostDoubleBuffered(aTextureInfo);
break;
default:
@ -203,7 +203,7 @@ CompositableHost::Create(const TextureInfo& aTextureInfo)
}
// We know that Tiled buffers don't use the compositable backend-specific
// data, so don't bother creating it.
if (result && aTextureInfo.mCompositableType != CompositableType::BUFFER_TILED) {
if (result && aTextureInfo.mCompositableType != BUFFER_TILED) {
RefPtr<CompositableBackendSpecificData> data = CreateCompositableBackendSpecificDataOGL();
result->SetCompositableBackendSpecificData(data);
}

View File

@ -18,7 +18,7 @@
#include "mozilla/gfx/Point.h" // for Point, IntPoint
#include "mozilla/gfx/Rect.h" // for IntRect, Rect
#include "mozilla/layers/Compositor.h" // for Compositor, etc
#include "mozilla/layers/CompositorTypes.h" // for DiagnosticFlags::CONTAINER
#include "mozilla/layers/CompositorTypes.h" // for DIAGNOSTIC_CONTAINER
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
#include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget
#include "mozilla/mozalloc.h" // for operator delete, etc
@ -413,7 +413,7 @@ ContainerRender(ContainerT* aContainer,
LayerRect layerBounds = ParentLayerRect(frame.mCompositionBounds) * ParentLayerToLayerScale(1.0);
gfx::Rect rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height);
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
aManager->GetCompositor()->DrawDiagnostics(DiagnosticFlags::CONTAINER,
aManager->GetCompositor()->DrawDiagnostics(DIAGNOSTIC_CONTAINER,
rect, clipRect,
aContainer->GetEffectiveTransform());
}

View File

@ -198,10 +198,8 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
Float(tileRegionRect.height) / texRect.height);
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform);
if (usingTiles) {
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT | DiagnosticFlags::BIGIMAGE;
if (iterOnWhite) {
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
}
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT | DIAGNOSTIC_BIGIMAGE;
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
aTransform, mFlashCounter);
}
@ -221,10 +219,8 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
iterOnWhite->EndTileIteration();
}
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT;
if (iterOnWhite) {
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
}
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT;
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
GetCompositor()->DrawDiagnostics(diagnostics, *aVisibleRegion, aClipRect,
aTransform, mFlashCounter);
}
@ -492,7 +488,7 @@ ContentHostIncremental::TextureCreationRequest::Execute(ContentHostIncremental*
temp->AsSourceOGL()->AsTextureImageTextureSource();
RefPtr<TextureImageTextureSourceOGL> newSourceOnWhite;
if (mTextureInfo.mTextureFlags & TextureFlags::COMPONENT_ALPHA) {
if (mTextureInfo.mTextureFlags & TEXTURE_COMPONENT_ALPHA) {
temp =
compositor->CreateDataTextureSource(mTextureInfo.mTextureFlags);
MOZ_ASSERT(temp->AsSourceOGL() &&
@ -500,7 +496,7 @@ ContentHostIncremental::TextureCreationRequest::Execute(ContentHostIncremental*
newSourceOnWhite = temp->AsSourceOGL()->AsTextureImageTextureSource();
}
if (mTextureInfo.mDeprecatedTextureHostFlags & DeprecatedTextureHostFlags::COPY_PREVIOUS) {
if (mTextureInfo.mDeprecatedTextureHostFlags & TEXTURE_HOST_COPY_PREVIOUS) {
nsIntRect bufferRect = aHost->mBufferRect;
nsIntPoint bufferRotation = aHost->mBufferRotation;
nsIntRect overlap;
@ -650,7 +646,7 @@ ContentHostIncremental::TextureUpdateRequest::Execute(ContentHostIncremental* aH
RefPtr<DataSourceSurface> surf = GetSurfaceForDescriptor(mDescriptor);
if (mTextureId == TextureIdentifier::Front) {
if (mTextureId == TextureFront) {
aHost->mSource->Update(surf, &mUpdated, &offset);
} else {
aHost->mSourceOnWhite->Update(surf, &mUpdated, &offset);
@ -689,7 +685,7 @@ ContentHostTexture::GetRenderState()
LayerRenderState result = mTextureHost->GetRenderState();
if (mBufferRotation != nsIntPoint()) {
result.mFlags |= LayerRenderStateFlags::BUFFER_ROTATION;
result.mFlags |= LAYER_RENDER_STATE_BUFFER_ROTATION;
}
result.SetOffset(GetOriginOffset());
return result;

View File

@ -209,7 +209,7 @@ public:
virtual ~ContentHostDoubleBuffered() {}
virtual CompositableType GetType() { return CompositableType::CONTENT_DOUBLE; }
virtual CompositableType GetType() { return COMPOSITABLE_CONTENT_DOUBLE; }
virtual bool UpdateThebes(const ThebesBufferData& aData,
const nsIntRegion& aUpdated,
@ -232,7 +232,7 @@ public:
{}
virtual ~ContentHostSingleBuffered() {}
virtual CompositableType GetType() { return CompositableType::CONTENT_SINGLE; }
virtual CompositableType GetType() { return COMPOSITABLE_CONTENT_SINGLE; }
virtual bool UpdateThebes(const ThebesBufferData& aData,
const nsIntRegion& aUpdated,
@ -256,7 +256,7 @@ public:
ContentHostIncremental(const TextureInfo& aTextureInfo);
~ContentHostIncremental();
virtual CompositableType GetType() { return CompositableType::BUFFER_CONTENT_INC; }
virtual CompositableType GetType() { return BUFFER_CONTENT_INC; }
virtual LayerRenderState GetRenderState() MOZ_OVERRIDE { return LayerRenderState(); }

View File

@ -126,12 +126,12 @@ ImageHost::Composite(EffectChain& aEffectChain,
}
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
aOpacity, aTransform);
GetCompositor()->DrawDiagnostics(DiagnosticFlags::IMAGE | DiagnosticFlags::BIGIMAGE,
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE|DIAGNOSTIC_BIGIMAGE,
rect, aClipRect, aTransform, mFlashCounter);
} while (it->NextTile());
it->EndTileIteration();
// layer border
GetCompositor()->DrawDiagnostics(DiagnosticFlags::IMAGE,
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE,
gfxPictureRect, aClipRect,
aTransform, mFlashCounter);
} else {
@ -148,14 +148,14 @@ ImageHost::Composite(EffectChain& aEffectChain,
rect = gfx::Rect(0, 0, textureSize.width, textureSize.height);
}
if (mFrontBuffer->GetFlags() & TextureFlags::NEEDS_Y_FLIP) {
if (mFrontBuffer->GetFlags() & TEXTURE_NEEDS_Y_FLIP) {
effect->mTextureCoords.y = effect->mTextureCoords.YMost();
effect->mTextureCoords.height = -effect->mTextureCoords.height;
}
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
aOpacity, aTransform);
GetCompositor()->DrawDiagnostics(DiagnosticFlags::IMAGE,
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_IMAGE,
rect, aClipRect,
aTransform, mFlashCounter);
}

View File

@ -51,9 +51,9 @@ bool
ImageLayerComposite::SetCompositableHost(CompositableHost* aHost)
{
switch (aHost->GetType()) {
case CompositableType::BUFFER_IMAGE_SINGLE:
case CompositableType::BUFFER_IMAGE_BUFFERED:
case CompositableType::IMAGE:
case BUFFER_IMAGE_SINGLE:
case BUFFER_IMAGE_BUFFERED:
case COMPOSITABLE_IMAGE:
mImageHost = aHost;
return true;
default:

View File

@ -233,7 +233,7 @@ TextureHost::~TextureHost()
void TextureHost::Finalize()
{
if (!(GetFlags() & TextureFlags::DEALLOCATE_CLIENT)) {
if (!(GetFlags() & TEXTURE_DEALLOCATE_CLIENT)) {
DeallocateSharedData();
DeallocateDeviceData();
}
@ -292,7 +292,7 @@ BufferTextureHost::Updated(const nsIntRegion* aRegion)
} else {
mPartialUpdate = false;
}
if (GetFlags() & TextureFlags::IMMEDIATE_UPLOAD) {
if (GetFlags() & TEXTURE_IMMEDIATE_UPLOAD) {
DebugOnly<bool> result = MaybeUpload(mPartialUpdate ? &mMaybeUpdatedRegion : nullptr);
NS_WARN_IF_FALSE(result, "Failed to upload a texture");
}
@ -355,7 +355,7 @@ BufferTextureHost::GetFormat() const
// instead (see BufferTextureHost::Upload)
if (mFormat == gfx::SurfaceFormat::YUV &&
mCompositor &&
!mCompositor->SupportsEffect(EffectTypes::YCBCR)) {
!mCompositor->SupportsEffect(EFFECT_YCBCR)) {
return gfx::SurfaceFormat::R8G8B8X8;
}
return mFormat;
@ -397,7 +397,7 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
YCbCrImageDataDeserializer yuvDeserializer(GetBuffer(), GetBufferSize());
MOZ_ASSERT(yuvDeserializer.IsValid());
if (!mCompositor->SupportsEffect(EffectTypes::YCBCR)) {
if (!mCompositor->SupportsEffect(EFFECT_YCBCR)) {
RefPtr<gfx::DataSourceSurface> surf = yuvDeserializer.ToDataSourceSurface();
if (!mFirstSource) {
mFirstSource = mCompositor->CreateDataTextureSource(mFlags);
@ -411,9 +411,9 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
RefPtr<DataTextureSource> srcV;
if (!mFirstSource) {
// We don't support BigImages for YCbCr compositing.
srcY = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
srcU = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
srcV = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
srcY = mCompositor->CreateDataTextureSource(mFlags|TEXTURE_DISALLOW_BIGIMAGE);
srcU = mCompositor->CreateDataTextureSource(mFlags|TEXTURE_DISALLOW_BIGIMAGE);
srcV = mCompositor->CreateDataTextureSource(mFlags|TEXTURE_DISALLOW_BIGIMAGE);
mFirstSource = srcY;
srcY->SetNextSibling(srcU);
srcU->SetNextSibling(srcV);
@ -569,7 +569,7 @@ MemoryTextureHost::MemoryTextureHost(uint8_t* aBuffer,
MemoryTextureHost::~MemoryTextureHost()
{
DeallocateDeviceData();
NS_ASSERTION(!mBuffer || (mFlags & TextureFlags::DEALLOCATE_CLIENT),
NS_ASSERTION(!mBuffer || (mFlags & TEXTURE_DEALLOCATE_CLIENT),
"Leaking our buffer");
MOZ_COUNT_DTOR(MemoryTextureHost);
}
@ -644,7 +644,7 @@ TextureParent::CompositorRecycle()
// Don't forget to prepare for the next reycle
// if TextureClient request it.
if (mTextureHost->GetFlags() & TextureFlags::RECYCLE) {
if (mTextureHost->GetFlags() & TEXTURE_RECYCLE) {
mWaitForClientRecycle = mTextureHost;
}
}
@ -671,7 +671,7 @@ TextureParent::Init(const SurfaceDescriptor& aSharedData,
aFlags);
if (mTextureHost) {
mTextureHost->mActor = this;
if (aFlags & TextureFlags::RECYCLE) {
if (aFlags & TEXTURE_RECYCLE) {
mWaitForClientRecycle = mTextureHost;
RECYCLE_LOG("Setup recycling for tile %p\n", this);
}
@ -711,11 +711,11 @@ TextureParent::ActorDestroy(ActorDestroyReason why)
NS_RUNTIMEABORT("FailedConstructor isn't possible in PTexture");
}
if (mTextureHost->GetFlags() & TextureFlags::RECYCLE) {
if (mTextureHost->GetFlags() & TEXTURE_RECYCLE) {
RECYCLE_LOG("clear recycling for tile %p\n", this);
mTextureHost->ClearRecycleCallback();
}
if (mTextureHost->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
if (mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
mTextureHost->ForgetSharedData();
}

View File

@ -54,10 +54,10 @@ bool
ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost)
{
switch (aHost->GetType()) {
case CompositableType::BUFFER_CONTENT_INC:
case CompositableType::BUFFER_TILED:
case CompositableType::CONTENT_SINGLE:
case CompositableType::CONTENT_DOUBLE:
case BUFFER_CONTENT_INC:
case BUFFER_TILED:
case COMPOSITABLE_CONTENT_SINGLE:
case COMPOSITABLE_CONTENT_DOUBLE:
mBuffer = static_cast<ContentHost*>(aHost);
return true;
default:

View File

@ -124,7 +124,7 @@ TiledLayerBufferComposite::Upload()
if(!IsValid()) {
return;
}
// The TextureClients were created with the TextureFlags::IMMEDIATE_UPLOAD flag,
// The TextureClients were created with the TEXTURE_IMMEDIATE_UPLOAD flag,
// so calling Update on all the texture hosts will perform the texture upload.
Update(mValidRegion, mPaintedRegion);
ClearPaintedRegion();
@ -145,7 +145,7 @@ TiledLayerBufferComposite::ValidateTile(TileHost aTile,
long start = PR_IntervalNow();
#endif
MOZ_ASSERT(aTile.mTextureHost->GetFlags() & TextureFlags::IMMEDIATE_UPLOAD);
MOZ_ASSERT(aTile.mTextureHost->GetFlags() & TEXTURE_IMMEDIATE_UPLOAD);
// We possibly upload the entire texture contents here. This is a purposeful
// decision, as sub-image upload can often be slow and/or unreliable, but
// we may want to reevaluate this in the future.
@ -380,7 +380,7 @@ TiledContentHost::RenderTile(const TileHost& aTile,
textureRect.height / aTextureBounds.height);
mCompositor->DrawQuad(graphicsRect, aClipRect, aEffectChain, aOpacity, aTransform);
}
mCompositor->DrawDiagnostics(DiagnosticFlags::CONTENT | DiagnosticFlags::TILE,
mCompositor->DrawDiagnostics(DIAGNOSTIC_CONTENT|DIAGNOSTIC_TILE,
aScreenRegion, aClipRect, aTransform, mFlashCounter);
}
@ -471,7 +471,7 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
}
gfx::Rect rect(visibleRect.x, visibleRect.y,
visibleRect.width, visibleRect.height);
GetCompositor()->DrawDiagnostics(DiagnosticFlags::CONTENT,
GetCompositor()->DrawDiagnostics(DIAGNOSTIC_CONTENT,
rect, aClipRect, aTransform, mFlashCounter);
}

View File

@ -219,7 +219,7 @@ public:
const nsIntRegion* aVisibleRegion = nullptr,
TiledLayerProperties* aLayerProperties = nullptr);
virtual CompositableType GetType() { return CompositableType::BUFFER_TILED; }
virtual CompositableType GetType() { return BUFFER_TILED; }
virtual TiledLayerComposer* AsTiledLayerComposer() MOZ_OVERRIDE { return this; }

View File

@ -25,7 +25,7 @@ X11TextureHost::X11TextureHost(TextureFlags aFlags,
mSurface = surface.get();
// The host always frees the pixmap.
MOZ_ASSERT(!(aFlags & TextureFlags::DEALLOCATE_CLIENT));
MOZ_ASSERT(!(aFlags & TEXTURE_DEALLOCATE_CLIENT));
mSurface->TakePixmap();
}

View File

@ -478,21 +478,21 @@ void
CompositorD3D11::SetPSForEffect(Effect* aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat)
{
switch (aEffect->mType) {
case EffectTypes::SOLID_COLOR:
case EFFECT_SOLID_COLOR:
mContext->PSSetShader(mAttachments->mSolidColorShader[aMaskType], nullptr, 0);
return;
case EffectTypes::RENDER_TARGET:
case EFFECT_RENDER_TARGET:
mContext->PSSetShader(mAttachments->mRGBAShader[aMaskType], nullptr, 0);
return;
case EffectTypes::RGB:
case EFFECT_RGB:
mContext->PSSetShader((aFormat == SurfaceFormat::B8G8R8A8 || aFormat == SurfaceFormat::R8G8B8A8)
? mAttachments->mRGBAShader[aMaskType]
: mAttachments->mRGBShader[aMaskType], nullptr, 0);
return;
case EffectTypes::YCBCR:
case EFFECT_YCBCR:
mContext->PSSetShader(mAttachments->mYCbCrShader[aMaskType], nullptr, 0);
return;
case EffectTypes::COMPONENT_ALPHA:
case EFFECT_COMPONENT_ALPHA:
mContext->PSSetShader(mAttachments->mComponentAlphaShader[aMaskType], nullptr, 0);
return;
default:
@ -521,9 +521,9 @@ CompositorD3D11::ClearRect(const gfx::Rect& aRect)
scissor.bottom = aRect.YMost();
mContext->RSSetScissorRects(1, &scissor);
mContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
mContext->VSSetShader(mAttachments->mVSQuadShader[MaskType::MaskNone], nullptr, 0);
mContext->VSSetShader(mAttachments->mVSQuadShader[MaskNone], nullptr, 0);
mContext->PSSetShader(mAttachments->mSolidColorShader[MaskType::MaskNone], nullptr, 0);
mContext->PSSetShader(mAttachments->mSolidColorShader[MaskNone], nullptr, 0);
mPSConstants.layerColor[0] = 0;
mPSConstants.layerColor[1] = 0;
mPSConstants.layerColor[2] = 0;
@ -554,18 +554,18 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
bool restoreBlendMode = false;
MaskType maskType = MaskType::MaskNone;
MaskType maskType = MaskNone;
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
if (aEffectChain.mSecondaryEffects[EFFECT_MASK]) {
if (aTransform.Is2D()) {
maskType = MaskType::Mask2d;
maskType = Mask2d;
} else {
MOZ_ASSERT(aEffectChain.mPrimaryEffect->mType == EffectTypes::RGB);
maskType = MaskType::Mask3d;
MOZ_ASSERT(aEffectChain.mPrimaryEffect->mType == EFFECT_RGB);
maskType = Mask3d;
}
EffectMask* maskEffect =
static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EFFECT_MASK].get());
TextureSourceD3D11* source = maskEffect->mMaskTexture->AsSourceD3D11();
if (!source) {
@ -598,7 +598,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
switch (aEffectChain.mPrimaryEffect->mType) {
case EffectTypes::SOLID_COLOR: {
case EFFECT_SOLID_COLOR: {
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, SurfaceFormat::UNKNOWN);
Color color =
@ -609,8 +609,8 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
mPSConstants.layerColor[3] = color.a * aOpacity;
}
break;
case EffectTypes::RGB:
case EffectTypes::RENDER_TARGET:
case EFFECT_RGB:
case EFFECT_RENDER_TARGET:
{
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
@ -640,7 +640,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
SetSamplerForFilter(texturedEffect->mFilter);
}
break;
case EffectTypes::YCBCR: {
case EFFECT_YCBCR: {
EffectYCbCr* ycbcrEffect =
static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
@ -680,7 +680,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
mContext->PSSetShaderResources(0, 3, srViews);
}
break;
case EffectTypes::COMPONENT_ALPHA:
case EFFECT_COMPONENT_ALPHA:
{
MOZ_ASSERT(gfxPrefs::ComponentAlphaEnabled());
MOZ_ASSERT(mAttachments->mComponentBlendState);
@ -900,7 +900,7 @@ CompositorD3D11::CreateShaders()
hr = mDevice->CreateVertexShader(LayerQuadVS,
sizeof(LayerQuadVS),
nullptr,
byRef(mAttachments->mVSQuadShader[MaskType::MaskNone]));
byRef(mAttachments->mVSQuadShader[MaskNone]));
if (FAILED(hr)) {
return false;
}
@ -908,7 +908,7 @@ CompositorD3D11::CreateShaders()
hr = mDevice->CreateVertexShader(LayerQuadMaskVS,
sizeof(LayerQuadMaskVS),
nullptr,
byRef(mAttachments->mVSQuadShader[MaskType::Mask2d]));
byRef(mAttachments->mVSQuadShader[Mask2d]));
if (FAILED(hr)) {
return false;
}
@ -916,16 +916,16 @@ CompositorD3D11::CreateShaders()
hr = mDevice->CreateVertexShader(LayerQuadMask3DVS,
sizeof(LayerQuadMask3DVS),
nullptr,
byRef(mAttachments->mVSQuadShader[MaskType::Mask3d]));
byRef(mAttachments->mVSQuadShader[Mask3d]));
if (FAILED(hr)) {
return false;
}
#define LOAD_PIXEL_SHADER(x) hr = mDevice->CreatePixelShader(x, sizeof(x), nullptr, byRef(mAttachments->m##x[MaskType::MaskNone])); \
#define LOAD_PIXEL_SHADER(x) hr = mDevice->CreatePixelShader(x, sizeof(x), nullptr, byRef(mAttachments->m##x[MaskNone])); \
if (FAILED(hr)) { \
return false; \
} \
hr = mDevice->CreatePixelShader(x##Mask, sizeof(x##Mask), nullptr, byRef(mAttachments->m##x[MaskType::Mask2d])); \
hr = mDevice->CreatePixelShader(x##Mask, sizeof(x##Mask), nullptr, byRef(mAttachments->m##x[Mask2d])); \
if (FAILED(hr)) { \
return false; \
}
@ -943,7 +943,7 @@ CompositorD3D11::CreateShaders()
hr = mDevice->CreatePixelShader(RGBAShaderMask3D,
sizeof(RGBAShaderMask3D),
nullptr,
byRef(mAttachments->mRGBAShader[MaskType::Mask3d]));
byRef(mAttachments->mRGBAShader[Mask3d]));
if (FAILED(hr)) {
return false;
}

View File

@ -50,7 +50,7 @@ public:
GetTextureFactoryIdentifier() MOZ_OVERRIDE;
virtual TemporaryRef<DataTextureSource>
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) MOZ_OVERRIDE;
CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE;
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) MOZ_OVERRIDE;
virtual int32_t GetMaxTextureSize() const MOZ_FINAL;

View File

@ -77,7 +77,7 @@ DataTextureSourceD3D11::DataTextureSourceD3D11(SurfaceFormat aFormat,
ID3D11Texture2D* aTexture)
: mCompositor(aCompositor)
, mFormat(aFormat)
, mFlags(TextureFlags::NO_FLAGS)
, mFlags(0)
, mCurrentTile(0)
, mIsTiled(false)
, mIterating(false)
@ -361,7 +361,7 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
int32_t maxSize = mCompositor->GetMaxTextureSize();
if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
(mFlags & TextureFlags::DISALLOW_BIGIMAGE)) {
(mFlags & TEXTURE_DISALLOW_BIGIMAGE)) {
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = aSurface->GetData();
initData.SysMemPitch = aSurface->Stride();

View File

@ -195,15 +195,15 @@ static DeviceManagerD3D9::ShaderMode
ShaderModeForEffectType(EffectTypes aEffectType, gfx::SurfaceFormat aFormat)
{
switch (aEffectType) {
case EffectTypes::SOLID_COLOR:
case EFFECT_SOLID_COLOR:
return DeviceManagerD3D9::SOLIDCOLORLAYER;
case EffectTypes::RENDER_TARGET:
case EFFECT_RENDER_TARGET:
return DeviceManagerD3D9::RGBALAYER;
case EffectTypes::RGB:
case EFFECT_RGB:
if (aFormat == SurfaceFormat::B8G8R8A8 || aFormat == SurfaceFormat::R8G8B8A8)
return DeviceManagerD3D9::RGBALAYER;
return DeviceManagerD3D9::RGBLAYER;
case EffectTypes::YCBCR:
case EFFECT_YCBCR:
return DeviceManagerD3D9::YCBCRLAYER;
}
@ -253,7 +253,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
1);
bool target = false;
if (aEffectChain.mPrimaryEffect->mType != EffectTypes::SOLID_COLOR) {
if (aEffectChain.mPrimaryEffect->mType != EFFECT_SOLID_COLOR) {
float opacity[4];
/*
* We always upload a 4 component float, but the shader will use only the
@ -265,13 +265,13 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
bool isPremultiplied = true;
MaskType maskType = MaskType::MaskNone;
MaskType maskType = MaskNone;
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
if (aEffectChain.mSecondaryEffects[EFFECT_MASK]) {
if (aTransform.Is2D()) {
maskType = MaskType::Mask2d;
maskType = Mask2d;
} else {
maskType = MaskType::Mask3d;
maskType = Mask3d;
}
}
@ -284,7 +284,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
uint32_t maskTexture = 0;
switch (aEffectChain.mPrimaryEffect->mType) {
case EffectTypes::SOLID_COLOR:
case EFFECT_SOLID_COLOR:
{
// output color is premultiplied, so we need to adjust all channels.
Color layerColor =
@ -301,8 +301,8 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER, maskType);
}
break;
case EffectTypes::RENDER_TARGET:
case EffectTypes::RGB:
case EFFECT_RENDER_TARGET:
case EFFECT_RGB:
{
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
@ -329,7 +329,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
isPremultiplied = texturedEffect->mPremultiplied;
}
break;
case EffectTypes::YCBCR:
case EFFECT_YCBCR:
{
EffectYCbCr* ycbcrEffect =
static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
@ -415,7 +415,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
maskTexture = mDeviceManager->SetShaderMode(DeviceManagerD3D9::YCBCRLAYER, maskType);
}
break;
case EffectTypes::COMPONENT_ALPHA:
case EFFECT_COMPONENT_ALPHA:
{
MOZ_ASSERT(gfxPrefs::ComponentAlphaEnabled());
EffectComponentAlpha* effectComponentAlpha =
@ -476,7 +476,7 @@ void
CompositorD3D9::SetMask(const EffectChain &aEffectChain, uint32_t aMaskTexture)
{
EffectMask *maskEffect =
static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EFFECT_MASK].get());
if (!maskEffect) {
return;
}

View File

@ -123,7 +123,7 @@ public:
}
virtual TemporaryRef<DataTextureSource>
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) MOZ_OVERRIDE;
CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE;
private:
// ensure mSize is up to date with respect to mWidget
void EnsureSize();

View File

@ -569,7 +569,7 @@ LoadMaskTexture(Layer* aMask, IDirect3DDevice9* aDevice,
uint32_t
DeviceManagerD3D9::SetShaderMode(ShaderMode aMode, MaskType aMaskType)
{
if (aMaskType == MaskType::MaskNone) {
if (aMaskType == MaskNone) {
switch (aMode) {
case RGBLAYER:
mDevice->SetVertexShader(mLayerVS);
@ -607,7 +607,7 @@ DeviceManagerD3D9::SetShaderMode(ShaderMode aMode, MaskType aMaskType)
maskTexRegister = 1;
break;
case RGBALAYER:
if (aMaskType == MaskType::Mask2d) {
if (aMaskType == Mask2d) {
mDevice->SetVertexShader(mLayerVSMask);
mDevice->SetPixelShader(mRGBAPSMask);
} else {
@ -643,9 +643,9 @@ DeviceManagerD3D9::SetShaderMode(ShaderMode aMode, MaskType aMaskType)
void
DeviceManagerD3D9::SetShaderMode(ShaderMode aMode, Layer* aMask, bool aIs2D)
{
MaskType maskType = MaskType::MaskNone;
MaskType maskType = MaskNone;
if (aMask) {
maskType = aIs2D ? MaskType::Mask2d : MaskType::Mask3d;
maskType = aIs2D ? Mask2d : Mask3d;
}
uint32_t maskTexRegister = SetShaderMode(aMode, maskType);
if (aMask) {
@ -654,7 +654,7 @@ DeviceManagerD3D9::SetShaderMode(ShaderMode aMode, Layer* aMask, bool aIs2D)
if (!LoadMaskTexture(aMask, mDevice, maskTexRegister)) {
// if we can't load the mask, fall back to unmasked rendering
NS_WARNING("Could not load texture for mask layer.");
SetShaderMode(aMode, MaskType::MaskNone);
SetShaderMode(aMode, MaskNone);
}
}
}

View File

@ -412,7 +412,7 @@ DataTextureSourceD3D9::Update(gfx::DataSourceSurface* aSurface,
int32_t maxSize = mCompositor->GetMaxTextureSize();
DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
(mFlags & TextureFlags::DISALLOW_BIGIMAGE)) {
(mFlags & TEXTURE_DISALLOW_BIGIMAGE)) {
mTexture = DataToTexture(deviceManager,
aSurface->GetData(), aSurface->Stride(),
IntSize(mSize), format, bpp);
@ -487,7 +487,7 @@ DataTextureSourceD3D9::Update(gfxWindowsSurface* aSurface)
int32_t maxSize = mCompositor->GetMaxTextureSize();
DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
(mFlags & TextureFlags::DISALLOW_BIGIMAGE)) {
(mFlags & TEXTURE_DISALLOW_BIGIMAGE)) {
mTexture = SurfaceToTexture(deviceManager, aSurface, mSize, format);
if (!mTexture) {

View File

@ -106,14 +106,14 @@ class DataTextureSourceD3D9 : public DataTextureSource
public:
DataTextureSourceD3D9(gfx::SurfaceFormat aFormat,
CompositorD3D9* aCompositor,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT,
StereoMode aStereoMode = StereoMode::MONO);
DataTextureSourceD3D9(gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
CompositorD3D9* aCompositor,
IDirect3DTexture9* aTexture,
TextureFlags aFlags = TextureFlags::DEFAULT);
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
virtual ~DataTextureSourceD3D9();

View File

@ -679,7 +679,7 @@ CompositorParent::CompositeToTarget(DrawTarget* aTarget)
// 0 -> Full-tilt composite
if (gfxPrefs::LayersCompositionFrameRate() == 0
|| mLayerManager->GetCompositor()->GetDiagnosticTypes() & DiagnosticTypes::FLASH_BORDERS) {
|| mLayerManager->GetCompositor()->GetDiagnosticTypes() & DIAGNOSTIC_FLASH_BORDERS) {
// Special full-tilt composite mode for performance testing
ScheduleComposition();
}

View File

@ -648,7 +648,7 @@ TemporaryRef<ImageClient>
ImageBridgeChild::CreateImageClientNow(CompositableType aType)
{
RefPtr<ImageClient> client
= ImageClient::CreateImageClient(aType, this, TextureFlags::NO_FLAGS);
= ImageClient::CreateImageClient(aType, this, 0);
MOZ_ASSERT(client, "failed to create ImageClient");
if (client) {
client->Connect();
@ -918,7 +918,7 @@ void
ImageBridgeChild::RemoveTextureFromCompositable(CompositableClient* aCompositable,
TextureClient* aTexture)
{
if (aTexture->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
if (aTexture->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
} else {

View File

@ -41,7 +41,6 @@ using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h";
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h";
using mozilla::layers::TextureIdentifier from "mozilla/layers/CompositorTypes.h";
namespace mozilla {
namespace layers {
@ -312,7 +311,7 @@ struct OpPaintTextureRegion {
struct OpPaintTextureIncremental {
PCompositable compositable;
TextureIdentifier textureId;
uint32_t textureId;
SurfaceDescriptor image;
nsIntRegion updatedRegion;
nsIntRect bufferRect;
@ -410,7 +409,7 @@ struct OpContentBufferSwap {
struct OpTextureSwap {
PCompositable compositable;
TextureIdentifier textureId;
uint32_t textureId;
SurfaceDescriptor image;
};

View File

@ -13,7 +13,6 @@ include ProtocolTypes;
include "mozilla/GfxMessageUtils.h";
using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h";
using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h";
namespace mozilla {
namespace layers {
@ -52,7 +51,7 @@ parent:
sync Stop();
sync PCompositable(TextureInfo aInfo) returns (uint64_t id);
async PTexture(SurfaceDescriptor aSharedData, TextureFlags aTextureFlags);
async PTexture(SurfaceDescriptor aSharedData, uint32_t aTextureFlags);
};

View File

@ -18,7 +18,6 @@ include "mozilla/GfxMessageUtils.h";
using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h";
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h";
/**
* The layers protocol is spoken between thread contexts that manage
@ -75,7 +74,7 @@ parent:
returns (MaybeMagicGrallocBufferHandle handle);
async PLayer();
async PCompositable(TextureInfo aTextureInfo);
async PTexture(SurfaceDescriptor aSharedData, TextureFlags aTextureFlags);
async PTexture(SurfaceDescriptor aSharedData, uint32_t aTextureFlags);
// The isFirstPaint flag can be used to indicate that this is the first update
// for a particular document.

View File

@ -166,7 +166,7 @@ CompositableForwarder::IdentifyTextureHost(const TextureFactoryIdentifier& aIden
}
ShadowLayerForwarder::ShadowLayerForwarder()
: mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC)
: mDiagnosticTypes(DIAGNOSTIC_NONE)
, mIsFirstPaint(false)
, mWindowOverlayChanged(false)
{
@ -367,7 +367,7 @@ ShadowLayerForwarder::UpdatedTexture(CompositableClient* aCompositable,
MOZ_ASSERT(aTexture->GetIPDLActor());
MaybeRegion region = aRegion ? MaybeRegion(*aRegion)
: MaybeRegion(null_t());
if (aTexture->GetFlags() & TextureFlags::IMMEDIATE_UPLOAD) {
if (aTexture->GetFlags() & TEXTURE_IMMEDIATE_UPLOAD) {
mTxn->AddPaint(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor(),
region));
@ -417,7 +417,7 @@ ShadowLayerForwarder::RemoveTextureFromCompositable(CompositableClient* aComposi
MOZ_ASSERT(aTexture->GetIPDLActor());
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
if (aTexture->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
if (aTexture->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
mTxn->MarkSyncTransaction();
}
// Hold texture until transaction complete.

View File

@ -91,7 +91,7 @@ SharedPlanarYCbCrImage::SetData(const PlanarYCbCrData& aData)
}
MOZ_ASSERT(mTextureClient->AsTextureClientYCbCr());
if (!mTextureClient->Lock(OpenMode::OPEN_WRITE_ONLY)) {
if (!mTextureClient->Lock(OPEN_WRITE_ONLY)) {
MOZ_ASSERT(false, "Failed to lock the texture.");
return;
}

View File

@ -803,13 +803,13 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect, MaskType aMask) const
ShaderConfigOGL config;
switch(aEffect->mType) {
case EffectTypes::SOLID_COLOR:
case EFFECT_SOLID_COLOR:
config.SetRenderColor(true);
break;
case EffectTypes::YCBCR:
case EFFECT_YCBCR:
config.SetYCbCr(true);
break;
case EffectTypes::COMPONENT_ALPHA:
case EFFECT_COMPONENT_ALPHA:
{
config.SetComponentAlpha(true);
EffectComponentAlpha* effectComponentAlpha =
@ -819,12 +819,12 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect, MaskType aMask) const
format == gfx::SurfaceFormat::B8G8R8X8);
break;
}
case EffectTypes::RENDER_TARGET:
case EFFECT_RENDER_TARGET:
config.SetTextureTarget(mFBOTextureTarget);
break;
default:
{
MOZ_ASSERT(aEffect->mType == EffectTypes::RGB);
MOZ_ASSERT(aEffect->mType == EFFECT_RGB);
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffect);
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
@ -839,8 +839,8 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect, MaskType aMask) const
break;
}
}
config.SetMask2D(aMask == MaskType::Mask2d);
config.SetMask3D(aMask == MaskType::Mask3d);
config.SetMask2D(aMask == Mask2d);
config.SetMask3D(aMask == Mask3d);
return config;
}
@ -909,8 +909,8 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
EffectMask* effectMask;
TextureSourceOGL* sourceMask = nullptr;
gfx::Matrix4x4 maskQuadTransform;
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
if (aEffectChain.mSecondaryEffects[EFFECT_MASK]) {
effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EFFECT_MASK].get());
sourceMask = effectMask->mMaskTexture->AsSourceOGL();
// NS_ASSERTION(textureMask->IsAlpha(),
@ -932,10 +932,10 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
maskQuadTransform._42 = float(-bounds.y)/bounds.height;
maskType = effectMask->mIs3D
? MaskType::Mask3d
: MaskType::Mask2d;
? Mask3d
: Mask2d;
} else {
maskType = MaskType::MaskNone;
maskType = MaskNone;
}
mPixelsFilled += aRect.width * aRect.height;
@ -943,7 +943,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
// Determine the color if this is a color shader and fold the opacity into
// the color since color shaders don't have an opacity uniform.
Color color;
if (aEffectChain.mPrimaryEffect->mType == EffectTypes::SOLID_COLOR) {
if (aEffectChain.mPrimaryEffect->mType == EFFECT_SOLID_COLOR) {
EffectSolidColor* effectSolidColor =
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
color = effectSolidColor->mColor;
@ -978,10 +978,10 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
}
switch (aEffectChain.mPrimaryEffect->mType) {
case EffectTypes::SOLID_COLOR: {
case EFFECT_SOLID_COLOR: {
program->SetRenderColor(color);
if (maskType != MaskType::MaskNone) {
if (maskType != MaskNone) {
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE0, maskQuadTransform);
}
@ -989,7 +989,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
}
break;
case EffectTypes::RGB: {
case EFFECT_RGB: {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
TextureSource *source = texturedEffect->mTexture;
@ -1019,7 +1019,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
program->SetTextureUnit(0);
if (maskType != MaskType::MaskNone) {
if (maskType != MaskNone) {
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE1, maskQuadTransform);
}
@ -1032,7 +1032,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
}
}
break;
case EffectTypes::YCBCR: {
case EFFECT_YCBCR: {
EffectYCbCr* effectYCbCr =
static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
TextureSource* sourceYCbCr = effectYCbCr->mTexture;
@ -1052,7 +1052,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
program->SetYCbCrTextureUnits(Y, Cb, Cr);
if (maskType != MaskType::MaskNone) {
if (maskType != MaskNone) {
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE3, maskQuadTransform);
}
BindAndDrawQuadWithTextureRect(program,
@ -1061,7 +1061,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
sourceYCbCr->GetSubSource(Y));
}
break;
case EffectTypes::RENDER_TARGET: {
case EFFECT_RENDER_TARGET: {
EffectRenderTarget* effectRenderTarget =
static_cast<EffectRenderTarget*>(aEffectChain.mPrimaryEffect.get());
RefPtr<CompositingRenderTargetOGL> surface
@ -1077,7 +1077,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
program->SetTextureTransform(Matrix4x4::From2D(transform));
program->SetTextureUnit(0);
if (maskType != MaskType::MaskNone) {
if (maskType != MaskNone) {
sourceMask->BindTexture(LOCAL_GL_TEXTURE1, gfx::Filter::LINEAR);
program->SetMaskTextureUnit(1);
program->SetMaskLayerTransform(maskQuadTransform);
@ -1094,7 +1094,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
BindAndDrawQuad(program);
}
break;
case EffectTypes::COMPONENT_ALPHA: {
case EFFECT_COMPONENT_ALPHA: {
MOZ_ASSERT(gfxPrefs::ComponentAlphaEnabled());
EffectComponentAlpha* effectComponentAlpha =
static_cast<EffectComponentAlpha*>(aEffectChain.mPrimaryEffect.get());
@ -1114,7 +1114,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
program->SetWhiteTextureUnit(1);
program->SetTextureTransform(gfx::Matrix4x4());
if (maskType != MaskType::MaskNone) {
if (maskType != MaskNone) {
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE2, maskQuadTransform);
}
// Pass 1.

View File

@ -20,7 +20,7 @@
#include "mozilla/gfx/Rect.h" // for Rect, IntRect
#include "mozilla/gfx/Types.h" // for Float, SurfaceFormat, etc
#include "mozilla/layers/Compositor.h" // for SurfaceInitMode, Compositor, etc
#include "mozilla/layers/CompositorTypes.h" // for MaskType::MaskType::NumMaskTypes, etc
#include "mozilla/layers/CompositorTypes.h" // for MaskType::NumMaskTypes, etc
#include "mozilla/layers/LayersTypes.h"
#include "nsAutoPtr.h" // for nsRefPtr, nsAutoPtr
#include "nsCOMPtr.h" // for already_AddRefed
@ -168,7 +168,7 @@ public:
virtual ~CompositorOGL();
virtual TemporaryRef<DataTextureSource>
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) MOZ_OVERRIDE;
CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE;
virtual bool Initialize() MOZ_OVERRIDE;
@ -358,7 +358,7 @@ private:
gfx::Rect *aClipRectOut = nullptr,
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
ShaderConfigOGL GetShaderConfigFor(Effect *aEffect, MaskType aMask = MaskType::MaskNone) const;
ShaderConfigOGL GetShaderConfigFor(Effect *aEffect, MaskType aMask = MaskNone) const;
ShaderProgramOGL* GetShaderProgramFor(const ShaderConfigOGL &aConfig);
/**

View File

@ -145,10 +145,10 @@ GrallocTextureClientOGL::Lock(OpenMode aMode)
WaitReleaseFence();
uint32_t usage = 0;
if (aMode & OpenMode::OPEN_READ) {
if (aMode & OPEN_READ) {
usage |= GRALLOC_USAGE_SW_READ_OFTEN;
}
if (aMode & OpenMode::OPEN_WRITE) {
if (aMode & OPEN_WRITE) {
usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;
}
int32_t rv = mGraphicBuffer->lock(usage, reinterpret_cast<void**>(&mMappedBuffer));
@ -234,14 +234,14 @@ GrallocTextureClientOGL::AllocateForSurface(gfx::IntSize aSize,
break;
case gfx::SurfaceFormat::B8G8R8A8:
format = android::PIXEL_FORMAT_RGBA_8888;
mFlags |= TextureFlags::RB_SWAPPED;
mFlags |= TEXTURE_RB_SWAPPED;
break;
case gfx::SurfaceFormat::R8G8B8X8:
format = android::PIXEL_FORMAT_RGBX_8888;
break;
case gfx::SurfaceFormat::B8G8R8X8:
format = android::PIXEL_FORMAT_RGBX_8888;
mFlags |= TextureFlags::RB_SWAPPED;
mFlags |= TEXTURE_RB_SWAPPED;
break;
case gfx::SurfaceFormat::R5G6B5:
format = android::PIXEL_FORMAT_RGB_565;

View File

@ -40,11 +40,11 @@ public:
GrallocTextureClientOGL(GrallocBufferActor* aActor,
gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend,
TextureFlags aFlags = TextureFlags::DEFAULT);
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
GrallocTextureClientOGL(ISurfaceAllocator* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2dBackend,
TextureFlags aFlags = TextureFlags::DEFAULT);
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
~GrallocTextureClientOGL();

View File

@ -19,9 +19,8 @@ using namespace android;
static gfx::SurfaceFormat
SurfaceFormatForAndroidPixelFormat(android::PixelFormat aFormat,
TextureFlags aFlags)
bool swapRB = false)
{
bool swapRB = bool(aFlags & TextureFlags::RB_SWAPPED);
switch (aFormat) {
case android::PIXEL_FORMAT_BGRA_8888:
return swapRB ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8A8;
@ -291,7 +290,7 @@ GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
if (graphicBuffer) {
format =
SurfaceFormatForAndroidPixelFormat(graphicBuffer->getPixelFormat(),
aFlags);
aFlags & TEXTURE_RB_SWAPPED);
}
mTextureSource = new GrallocTextureSourceOGL(nullptr,
graphicBuffer,
@ -370,12 +369,12 @@ LayerRenderState
GrallocTextureHostOGL::GetRenderState()
{
if (IsValid()) {
LayerRenderStateFlags flags = LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT;
if (mFlags & TextureFlags::NEEDS_Y_FLIP) {
flags |= LayerRenderStateFlags::Y_FLIPPED;
uint32_t flags = 0;
if (mFlags & TEXTURE_NEEDS_Y_FLIP) {
flags |= LAYER_RENDER_STATE_Y_FLIPPED;
}
if (mFlags & TextureFlags::RB_SWAPPED) {
flags |= LayerRenderStateFlags::FORMAT_RB_SWAP;
if (mFlags & TEXTURE_RB_SWAPPED) {
flags |= LAYER_RENDER_STATE_FORMAT_RB_SWAP;
}
return LayerRenderState(mTextureSource->mGraphicBuffer.get(),
gfx::ThebesIntSize(mSize),

View File

@ -23,7 +23,7 @@ SharedTextureClientOGL::SharedTextureClientOGL(TextureFlags aFlags)
, mInverted(false)
{
// SharedTextureClient is always owned externally.
mFlags |= TextureFlags::DEALLOCATE_CLIENT;
mFlags |= TEXTURE_DEALLOCATE_CLIENT;
}
SharedTextureClientOGL::~SharedTextureClientOGL()
@ -56,7 +56,7 @@ SharedTextureClientOGL::InitWith(gl::SharedTextureHandle aHandle,
mShareType = aShareType;
mInverted = aInverted;
if (mInverted) {
AddFlags(TextureFlags::NEEDS_Y_FLIP);
AddFlags(TEXTURE_NEEDS_Y_FLIP);
}
}

View File

@ -106,20 +106,20 @@ FlagsToGLFlags(TextureFlags aFlags)
{
uint32_t result = TextureImage::NoFlags;
if (aFlags & TextureFlags::USE_NEAREST_FILTER)
if (aFlags & TEXTURE_USE_NEAREST_FILTER)
result |= TextureImage::UseNearestFilter;
if (aFlags & TextureFlags::NEEDS_Y_FLIP)
if (aFlags & TEXTURE_NEEDS_Y_FLIP)
result |= TextureImage::NeedsYFlip;
if (aFlags & TextureFlags::DISALLOW_BIGIMAGE)
if (aFlags & TEXTURE_DISALLOW_BIGIMAGE)
result |= TextureImage::DisallowBigImage;
return static_cast<gl::TextureImage::Flags>(result);
}
static GLenum
WrapMode(gl::GLContext *aGl, TextureFlags aFlags)
GLenum
WrapMode(gl::GLContext *aGl, bool aAllowRepeat)
{
if ((aFlags & TextureFlags::ALLOW_REPEAT) &&
if (aAllowRepeat &&
(aGl->IsExtensionSupported(GLContext::ARB_texture_non_power_of_two) ||
aGl->IsExtensionSupported(GLContext::OES_texture_npot))) {
return LOCAL_GL_REPEAT;
@ -229,10 +229,10 @@ TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface,
if (!mTexImage ||
(mTexImage->GetSize() != size && !aSrcOffset) ||
mTexImage->GetContentType() != gfx::ContentForFormat(aSurface->GetFormat())) {
if (mFlags & TextureFlags::DISALLOW_BIGIMAGE) {
if (mFlags & TEXTURE_DISALLOW_BIGIMAGE) {
mTexImage = CreateBasicTextureImage(mGL, size,
gfx::ContentForFormat(aSurface->GetFormat()),
WrapMode(mGL, mFlags),
WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
FlagsToGLFlags(mFlags),
SurfaceFormatToImageFormat(aSurface->GetFormat()));
} else {
@ -243,7 +243,7 @@ TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface,
mTexImage = CreateTextureImage(mGL,
size,
gfx::ContentForFormat(aSurface->GetFormat()),
WrapMode(mGL, mFlags),
WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
FlagsToGLFlags(mFlags),
SurfaceFormatToImageFormat(aSurface->GetFormat()));
}
@ -268,7 +268,7 @@ TextureImageTextureSourceOGL::EnsureBuffer(const nsIntSize& aSize,
mTexImage = CreateTextureImage(mGL,
aSize.ToIntSize(),
aContentType,
WrapMode(mGL, mFlags),
WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
FlagsToGLFlags(mFlags));
}
mTexImage->Resize(aSize.ToIntSize());

View File

@ -196,7 +196,7 @@ class TextureImageTextureSourceOGL : public DataTextureSource
{
public:
TextureImageTextureSourceOGL(gl::GLContext* aGL,
TextureFlags aFlags = TextureFlags::DEFAULT)
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT)
: mGL(aGL)
, mFlags(aFlags)
, mIterating(false)

View File

@ -151,7 +151,7 @@ void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface)
texture->AllocateForSurface(ToIntSize(surface->GetSize()));
ASSERT_TRUE(texture->IsAllocated());
ASSERT_TRUE(texture->Lock(OpenMode::OPEN_READ_WRITE));
ASSERT_TRUE(texture->Lock(OPEN_READ_WRITE));
// client painting
RefPtr<DrawTarget> dt = texture->GetAsDrawTarget();
RefPtr<SourceSurface> source =
@ -202,7 +202,7 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
ycbcrData.mStereoMode);
ASSERT_TRUE(client->IsAllocated());
ASSERT_TRUE(client->Lock(OpenMode::OPEN_READ_WRITE));
ASSERT_TRUE(client->Lock(OPEN_READ_WRITE));
// client painting
texture->UpdateYCbCr(ycbcrData);
client->Unlock();
@ -270,7 +270,7 @@ TEST(Layers, TextureSerialization) {
= new MemoryTextureClient(nullptr,
mozilla::gfx::ImageFormatToSurfaceFormat(surface->Format()),
gfx::BackendType::CAIRO,
TextureFlags::DEALLOCATE_CLIENT);
TEXTURE_DEALLOCATE_CLIENT);
TestTextureClientSurface(client, surface);
@ -307,7 +307,7 @@ TEST(Layers, TextureYCbCrSerialization) {
= new MemoryTextureClient(nullptr,
mozilla::gfx::SurfaceFormat::YUV,
gfx::BackendType::CAIRO,
TextureFlags::DEALLOCATE_CLIENT);
TEXTURE_DEALLOCATE_CLIENT);
TestTextureClientYCbCr(client, clientData);

View File

@ -1396,18 +1396,18 @@ gfxPlatform::IsLangCJK(eFontPrefLang aLang)
mozilla::layers::DiagnosticTypes
gfxPlatform::GetLayerDiagnosticTypes()
{
mozilla::layers::DiagnosticTypes type = DiagnosticTypes::NO_DIAGNOSTIC;
mozilla::layers::DiagnosticTypes type = DIAGNOSTIC_NONE;
if (gfxPrefs::DrawLayerBorders()) {
type |= mozilla::layers::DiagnosticTypes::LAYER_BORDERS;
type |= mozilla::layers::DIAGNOSTIC_LAYER_BORDERS;
}
if (gfxPrefs::DrawTileBorders()) {
type |= mozilla::layers::DiagnosticTypes::TILE_BORDERS;
type |= mozilla::layers::DIAGNOSTIC_TILE_BORDERS;
}
if (gfxPrefs::DrawBigImageBorders()) {
type |= mozilla::layers::DiagnosticTypes::BIGIMAGE_BORDERS;
type |= mozilla::layers::DIAGNOSTIC_BIGIMAGE_BORDERS;
}
if (gfxPrefs::FlashLayerBorders()) {
type |= mozilla::layers::DiagnosticTypes::FLASH_BORDERS;
type |= mozilla::layers::DIAGNOSTIC_FLASH_BORDERS;
}
return type;
}

View File

@ -9,11 +9,40 @@
#ifndef mozilla_TypedEnum_h
#define mozilla_TypedEnum_h
#include "mozilla/TypedEnumInternal.h"
#include "mozilla/Attributes.h"
#include "mozilla/MacroArgs.h"
#if defined(__cplusplus)
#if defined(__clang__)
/*
* Per Clang documentation, "Note that marketing version numbers should not
* be used to check for language features, as different vendors use different
* numbering schemes. Instead, use the feature checking macros."
*/
# ifndef __has_extension
# define __has_extension __has_feature /* compatibility, for older versions of clang */
# endif
# if __has_extension(cxx_strong_enums)
# define MOZ_HAVE_CXX11_ENUM_TYPE
# define MOZ_HAVE_CXX11_STRONG_ENUMS
# endif
#elif defined(__GNUC__)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if MOZ_GCC_VERSION_AT_LEAST(4, 6, 3)
# define MOZ_HAVE_CXX11_ENUM_TYPE
# define MOZ_HAVE_CXX11_STRONG_ENUMS
# endif
# endif
#elif defined(_MSC_VER)
# if _MSC_VER >= 1400
# define MOZ_HAVE_CXX11_ENUM_TYPE
# endif
# if _MSC_VER >= 1700
# define MOZ_HAVE_CXX11_STRONG_ENUMS
# endif
#endif
/**
* MOZ_ENUM_TYPE specifies the underlying numeric type for an enum. It's
* specified by placing MOZ_ENUM_TYPE(type) immediately after the enum name in
@ -161,13 +190,9 @@
# define MOZ_END_NESTED_ENUM_CLASS(Name) \
}; \
Name() {} \
MOZ_CONSTEXPR Name(Enum aEnum) : mEnum(aEnum) {} \
template<typename Other> \
explicit MOZ_CONSTEXPR Name(Other num) : mEnum((Enum)num) {} \
MOZ_CONSTEXPR operator Enum() const { return mEnum; } \
explicit MOZ_CONSTEXPR Name(const mozilla::CastableTypedEnumResult<Name>& aOther) \
: mEnum(aOther.get()) \
{} \
Name(Enum aEnum) : mEnum(aEnum) {} \
explicit Name(int num) : mEnum((Enum)num) {} \
operator Enum() const { return mEnum; } \
private: \
Enum mEnum; \
};
@ -205,6 +230,7 @@
inline bool operator&&(const Name::Enum&, const bool&) MOZ_DELETE; \
inline bool operator||(const bool&, const Name::Enum&) MOZ_DELETE; \
inline bool operator||(const Name::Enum&, const bool&) MOZ_DELETE; \
inline int operator~(const Name::Enum&) MOZ_DELETE; \
inline int operator&(const int&, const Name::Enum&) MOZ_DELETE; \
inline int operator&(const Name::Enum&, const int&) MOZ_DELETE; \
inline int operator|(const int&, const Name::Enum&) MOZ_DELETE; \

View File

@ -1,182 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
/* MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS allows using a typed enum as bit flags. */
#ifndef mozilla_TypedEnumBits_h
#define mozilla_TypedEnumBits_h
#include "mozilla/IntegerTypeTraits.h"
#include "mozilla/TypedEnumInternal.h"
namespace mozilla {
#define MOZ_CASTABLETYPEDENUMRESULT_BINOP(Op, OtherType, ReturnType) \
template<typename E> \
MOZ_CONSTEXPR ReturnType \
operator Op(const OtherType& e, const CastableTypedEnumResult<E>& r) \
{ \
return ReturnType(e Op OtherType(r)); \
} \
template<typename E> \
MOZ_CONSTEXPR ReturnType \
operator Op(const CastableTypedEnumResult<E>& r, const OtherType& e) \
{ \
return ReturnType(OtherType(r) Op e); \
} \
template<typename E> \
MOZ_CONSTEXPR ReturnType \
operator Op(const CastableTypedEnumResult<E>& r1, \
const CastableTypedEnumResult<E>& r2) \
{ \
return ReturnType(OtherType(r1) Op OtherType(r2)); \
}
MOZ_CASTABLETYPEDENUMRESULT_BINOP(|, E, CastableTypedEnumResult<E>)
MOZ_CASTABLETYPEDENUMRESULT_BINOP(&, E, CastableTypedEnumResult<E>)
MOZ_CASTABLETYPEDENUMRESULT_BINOP(^, E, CastableTypedEnumResult<E>)
MOZ_CASTABLETYPEDENUMRESULT_BINOP(==, E, bool)
MOZ_CASTABLETYPEDENUMRESULT_BINOP(!=, E, bool)
MOZ_CASTABLETYPEDENUMRESULT_BINOP(||, bool, bool)
MOZ_CASTABLETYPEDENUMRESULT_BINOP(&&, bool, bool)
template <typename E>
MOZ_CONSTEXPR CastableTypedEnumResult<E>
operator ~(const CastableTypedEnumResult<E>& r)
{
return CastableTypedEnumResult<E>(~(E(r)));
}
#define MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(Op) \
template<typename E> \
E& \
operator Op(E& r1, \
const CastableTypedEnumResult<E>& r2) \
{ \
return r1 Op E(r2); \
}
MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(&=)
MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(|=)
MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(^=)
#undef MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP
#undef MOZ_CASTABLETYPEDENUMRESULT_BINOP
#ifndef MOZ_HAVE_CXX11_STRONG_ENUMS
#define MOZ_CASTABLETYPEDENUMRESULT_BINOP_EXTRA_NON_CXX11(Op, ReturnType) \
template<typename E> \
MOZ_CONSTEXPR ReturnType \
operator Op(typename E::Enum e, const CastableTypedEnumResult<E>& r) \
{ \
return ReturnType(e Op E(r)); \
} \
template<typename E> \
MOZ_CONSTEXPR ReturnType \
operator Op(const CastableTypedEnumResult<E>& r, typename E::Enum e) \
{ \
return ReturnType(E(r) Op e); \
}
MOZ_CASTABLETYPEDENUMRESULT_BINOP_EXTRA_NON_CXX11(|, CastableTypedEnumResult<E>)
MOZ_CASTABLETYPEDENUMRESULT_BINOP_EXTRA_NON_CXX11(&, CastableTypedEnumResult<E>)
MOZ_CASTABLETYPEDENUMRESULT_BINOP_EXTRA_NON_CXX11(^, CastableTypedEnumResult<E>)
MOZ_CASTABLETYPEDENUMRESULT_BINOP_EXTRA_NON_CXX11(==, bool)
MOZ_CASTABLETYPEDENUMRESULT_BINOP_EXTRA_NON_CXX11(!=, bool)
#undef MOZ_CASTABLETYPEDENUMRESULT_BINOP_EXTRA_NON_CXX11
#endif // not MOZ_HAVE_CXX11_STRONG_ENUMS
namespace detail {
template<typename E>
struct UnsignedIntegerTypeForEnum
: UnsignedStdintTypeForSize<sizeof(E)>
{};
}
} // namespace mozilla
#define MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, Op) \
inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
operator Op(Name a, Name b) \
{ \
typedef mozilla::CastableTypedEnumResult<Name> Result; \
typedef mozilla::detail::UnsignedIntegerTypeForEnum<Name>::Type U; \
return Result(Name(U(a) Op U(b))); \
} \
\
inline Name& \
operator Op##=(Name& a, Name b) \
{ \
return a = a Op b; \
}
#define MOZ_MAKE_ENUM_CLASS_OPS_IMPL(Name) \
MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, |) \
MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, &) \
MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, ^) \
inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
operator~(Name a) \
{ \
typedef mozilla::CastableTypedEnumResult<Name> Result; \
typedef mozilla::detail::UnsignedIntegerTypeForEnum<Name>::Type U; \
return Result(Name(~(U(a)))); \
}
#ifndef MOZ_HAVE_CXX11_STRONG_ENUMS
# define MOZ_MAKE_ENUM_CLASS_BITWISE_BINOP_EXTRA_NON_CXX11(Name, Op) \
inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
operator Op(Name a, Name::Enum b) \
{ \
return a Op Name(b); \
} \
\
inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
operator Op(Name::Enum a, Name b) \
{ \
return Name(a) Op b; \
} \
\
inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
operator Op(Name::Enum a, Name::Enum b) \
{ \
return Name(a) Op Name(b); \
} \
\
inline Name& \
operator Op##=(Name& a, Name::Enum b) \
{ \
return a = a Op Name(b); \
}
# define MOZ_MAKE_ENUM_CLASS_OPS_EXTRA_NON_CXX11(Name) \
MOZ_MAKE_ENUM_CLASS_BITWISE_BINOP_EXTRA_NON_CXX11(Name, |) \
MOZ_MAKE_ENUM_CLASS_BITWISE_BINOP_EXTRA_NON_CXX11(Name, &) \
MOZ_MAKE_ENUM_CLASS_BITWISE_BINOP_EXTRA_NON_CXX11(Name, ^) \
inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
operator~(Name::Enum a) \
{ \
return ~(Name(a)); \
}
#endif
/**
* MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS generates standard bitwise operators
* for the given enum type. Use this to enable using an enum type as bit-field.
*/
#ifdef MOZ_HAVE_CXX11_STRONG_ENUMS
# define MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Name) \
MOZ_MAKE_ENUM_CLASS_OPS_IMPL(Name)
#else
# define MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Name) \
MOZ_MAKE_ENUM_CLASS_OPS_IMPL(Name) \
MOZ_MAKE_ENUM_CLASS_OPS_EXTRA_NON_CXX11(Name)
#endif
#endif // mozilla_TypedEnumBits_h

View File

@ -1,112 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
/* Internal stuff needed by TypedEnum.h and TypedEnumBits.h. */
// NOTE: When we can assume C++11 enum class support and TypedEnum.h goes away,
// we should then consider folding TypedEnumInternal.h into TypedEnumBits.h.
#ifndef mozilla_TypedEnumInternal_h
#define mozilla_TypedEnumInternal_h
#include "mozilla/Attributes.h"
#if defined(__cplusplus)
#if defined(__clang__)
/*
* Per Clang documentation, "Note that marketing version numbers should not
* be used to check for language features, as different vendors use different
* numbering schemes. Instead, use the feature checking macros."
*/
# ifndef __has_extension
# define __has_extension __has_feature /* compatibility, for older versions of clang */
# endif
# if __has_extension(cxx_strong_enums)
# define MOZ_HAVE_CXX11_ENUM_TYPE
# define MOZ_HAVE_CXX11_STRONG_ENUMS
# endif
#elif defined(__GNUC__)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if MOZ_GCC_VERSION_AT_LEAST(4, 6, 3)
# define MOZ_HAVE_CXX11_ENUM_TYPE
# define MOZ_HAVE_CXX11_STRONG_ENUMS
# endif
# endif
#elif defined(_MSC_VER)
# if _MSC_VER >= 1400
# define MOZ_HAVE_CXX11_ENUM_TYPE
# endif
# if _MSC_VER >= 1700
# define MOZ_HAVE_CXX11_STRONG_ENUMS
# endif
#endif
namespace mozilla {
/*
* The problem that CastableTypedEnumResult aims to solve is that
* typed enums are not convertible to bool, and there is no way to make them
* be, yet user code wants to be able to write
*
* if (myFlags & Flags::SOME_PARTICULAR_FLAG) (1)
*
* There are different approaches to solving this. Most of them require
* adapting user code. For example, we could implement operator! and have
* the user write
*
* if (!!(myFlags & Flags::SOME_PARTICULAR_FLAG)) (2)
*
* Or we could supply a IsNonZero() or Any() function returning whether
* an enum value is nonzero, and have the user write
*
* if (Any(Flags & Flags::SOME_PARTICULAR_FLAG)) (3)
*
* But instead, we choose to preserve the original user syntax (1) as it
* is inherently more readable, and to ease porting existing code to typed
* enums. We achieve this by having operator& and other binary bitwise
* operators have as return type a class, CastableTypedEnumResult,
* that wraps a typed enum but adds bool convertibility.
*/
template<typename E>
class CastableTypedEnumResult
{
private:
const E mValue;
public:
explicit MOZ_CONSTEXPR CastableTypedEnumResult(E value)
: mValue(value)
{}
MOZ_CONSTEXPR operator E() const { return mValue; }
template<typename DestinationType>
MOZ_EXPLICIT_CONVERSION MOZ_CONSTEXPR
operator DestinationType() const {
return DestinationType(mValue);
}
MOZ_CONSTEXPR bool operator !() const { return !bool(mValue); }
#ifndef MOZ_HAVE_CXX11_STRONG_ENUMS
// This get() method is used to implement a constructor in the
// non-c++11 fallback path for MOZ_BEGIN_ENUM_CLASS, taking a
// CastableTypedEnumResult. If we try to implement it using the
// above conversion operator E(), then at least clang 3.3
// (when forced to take the non-c++11 fallback path) compiles
// this constructor to an infinite recursion. So we introduce this
// get() method, that does exactly the same as the conversion operator,
// to work around this.
MOZ_CONSTEXPR E get() const { return mValue; }
#endif
};
} // namespace mozilla
#endif // __cplusplus
#endif // mozilla_TypedEnumInternal_h

View File

@ -61,8 +61,6 @@ EXPORTS.mozilla = [
'TemplateLib.h',
'ThreadLocal.h',
'TypedEnum.h',
'TypedEnumBits.h',
'TypedEnumInternal.h',
'Types.h',
'TypeTraits.h',
'Vector.h',

View File

@ -4,565 +4,37 @@
#include "mozilla/Assertions.h"
#include "mozilla/TypedEnum.h"
#include "mozilla/TypedEnumBits.h"
#include <stdint.h>
// A rough feature check for is_literal_type. Not very carefully checked.
// Feel free to amend as needed.
// We leave ANDROID out because it's using stlport which doesn't have std::is_literal_type.
#if __cplusplus >= 201103L && !defined(ANDROID)
# if defined(__clang__)
/*
* Per Clang documentation, "Note that marketing version numbers should not
* be used to check for language features, as different vendors use different
* numbering schemes. Instead, use the feature checking macros."
*/
# ifndef __has_extension
# define __has_extension __has_feature /* compatibility, for older versions of clang */
# endif
# if __has_extension(is_literal) && __has_include(<type_traits>)
# define MOZ_HAVE_IS_LITERAL
# endif
# elif defined(__GNUC__)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0)
# define MOZ_HAVE_IS_LITERAL
# endif
# endif
# elif defined(_MSC_VER)
# if _MSC_VER >= 1700
# define MOZ_HAVE_IS_LITERAL
# endif
# endif
#endif
#ifdef MOZ_HAVE_IS_LITERAL
#include <type_traits>
template<typename T>
void
RequireLiteralType()
{
static_assert(std::is_literal_type<T>::value, "Expected a literal type");
}
#else // not MOZ_HAVE_IS_LITERAL
template<typename T>
void
RequireLiteralType()
{
}
#endif
template<typename T>
void
RequireLiteralType(const T&)
{
RequireLiteralType<T>();
}
MOZ_BEGIN_ENUM_CLASS(AutoEnum)
A,
B = -3,
C
B
MOZ_END_ENUM_CLASS(AutoEnum)
MOZ_BEGIN_ENUM_CLASS(CharEnum, char)
A,
B = 3,
C
B
MOZ_END_ENUM_CLASS(CharEnum)
MOZ_BEGIN_ENUM_CLASS(AutoEnumBitField)
A = 0x10,
B = 0x20,
C
MOZ_END_ENUM_CLASS(AutoEnumBitField)
MOZ_BEGIN_ENUM_CLASS(CharEnumBitField, char)
A = 0x10,
B,
C = 0x40
MOZ_END_ENUM_CLASS(CharEnumBitField)
struct Nested
{
MOZ_BEGIN_NESTED_ENUM_CLASS(AutoEnum)
A,
B,
C = -1
C
MOZ_END_NESTED_ENUM_CLASS(AutoEnum)
MOZ_BEGIN_NESTED_ENUM_CLASS(CharEnum, char)
A = 4,
B,
C = 1
D = 4,
E
MOZ_END_NESTED_ENUM_CLASS(CharEnum)
MOZ_BEGIN_NESTED_ENUM_CLASS(AutoEnumBitField)
A,
B = 0x20,
C
MOZ_END_NESTED_ENUM_CLASS(AutoEnumBitField)
MOZ_BEGIN_NESTED_ENUM_CLASS(CharEnumBitField, char)
A = 1,
B = 1,
C = 1
MOZ_END_NESTED_ENUM_CLASS(CharEnumBitField)
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AutoEnumBitField)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CharEnumBitField)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Nested::AutoEnumBitField)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Nested::CharEnumBitField)
#define MAKE_STANDARD_BITFIELD_FOR_TYPE(IntType) \
MOZ_BEGIN_ENUM_CLASS(BitFieldFor_##IntType, IntType) \
A = 1, \
B = 2, \
C = 4, \
MOZ_END_ENUM_CLASS(BitFieldFor_##IntType) \
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(BitFieldFor_##IntType)
MAKE_STANDARD_BITFIELD_FOR_TYPE(int8_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(uint8_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(int16_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(uint16_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(int32_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(uint32_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(int64_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(uint64_t)
MAKE_STANDARD_BITFIELD_FOR_TYPE(char)
typedef signed char signed_char;
MAKE_STANDARD_BITFIELD_FOR_TYPE(signed_char)
typedef unsigned char unsigned_char;
MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_char)
MAKE_STANDARD_BITFIELD_FOR_TYPE(short)
typedef unsigned short unsigned_short;
MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_short)
MAKE_STANDARD_BITFIELD_FOR_TYPE(int)
typedef unsigned int unsigned_int;
MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_int)
MAKE_STANDARD_BITFIELD_FOR_TYPE(long)
typedef unsigned long unsigned_long;
MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_long)
typedef long long long_long;
MAKE_STANDARD_BITFIELD_FOR_TYPE(long_long)
typedef unsigned long long unsigned_long_long;
MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_long_long)
#undef MAKE_STANDARD_BITFIELD_FOR_TYPE
template<typename T>
void
TestNonConvertibilityForOneType()
{
using mozilla::IsConvertible;
#ifdef MOZ_HAVE_CXX11_STRONG_ENUMS
static_assert(!IsConvertible<T, bool>::value, "should not be convertible");
static_assert(!IsConvertible<T, int>::value, "should not be convertible");
static_assert(!IsConvertible<T, uint64_t>::value, "should not be convertible");
#endif
static_assert(!IsConvertible<bool, T>::value, "should not be convertible");
static_assert(!IsConvertible<int, T>::value, "should not be convertible");
static_assert(!IsConvertible<uint64_t, T>::value, "should not be convertible");
}
template<typename TypedEnum>
void
TestTypedEnumBasics()
{
const TypedEnum a = TypedEnum::A;
int unused = int(a);
(void) unused;
RequireLiteralType(TypedEnum::A);
RequireLiteralType(a);
TestNonConvertibilityForOneType<TypedEnum>();
}
// Op wraps a bitwise binary operator, passed as a char template parameter,
// and applies it to its arguments (t1, t2). For example,
//
// Op<'|'>(t1, t2)
//
// is the same as
//
// t1 | t2.
//
template<char o, typename T1, typename T2>
auto Op(const T1& t1, const T2& t2)
-> decltype(t1 | t2) // See the static_assert's below --- the return type
// depends solely on the operands type, not on the
// choice of operation.
{
using mozilla::IsSame;
static_assert(IsSame<decltype(t1 | t2), decltype(t1 & t2)>::value,
"binary ops should have the same result type");
static_assert(IsSame<decltype(t1 | t2), decltype(t1 ^ t2)>::value,
"binary ops should have the same result type");
static_assert(o == '|' ||
o == '&' ||
o == '^', "unexpected operator character");
return o == '|' ? t1 | t2
: o == '&' ? t1 & t2
: t1 ^ t2;
}
// OpAssign wraps a bitwise binary operator, passed as a char template
// parameter, and applies the corresponding compound-assignment operator to its
// arguments (t1, t2). For example,
//
// OpAssign<'|'>(t1, t2)
//
// is the same as
//
// t1 |= t2.
//
template<char o, typename T1, typename T2>
T1& OpAssign(T1& t1, const T2& t2)
{
static_assert(o == '|' ||
o == '&' ||
o == '^', "unexpected operator character");
switch (o) {
case '|': return t1 |= t2;
case '&': return t1 &= t2;
case '^': return t1 ^= t2;
default: MOZ_CRASH();
}
}
// Tests a single binary bitwise operator, using a single set of three operands.
// The operations tested are:
//
// result = t1 Op t2;
// result Op= t3;
//
// Where Op is the operator specified by the char template parameter 'o' and can
// be any of '|', '&', '^'.
//
// Note that the operands t1, t2, t3 are intentionally passed with free types
// (separate template parameters for each) because their type may actually be
// different from TypedEnum:
// 1) Their type could be CastableTypedEnumResult<TypedEnum> if they are
// the result of a bitwise operation themselves;
// 2) In the non-c++11 legacy path, the type of enum values is also
// different from TypedEnum.
//
template<typename TypedEnum, char o, typename T1, typename T2, typename T3>
void TestBinOp(const T1& t1, const T2& t2, const T3& t3)
{
typedef typename mozilla::detail::UnsignedIntegerTypeForEnum<TypedEnum>::Type
UnsignedIntegerType;
// Part 1:
// Test the bitwise binary operator i.e.
// result = t1 Op t2;
auto result = Op<o>(t1, t2);
typedef decltype(result) ResultType;
RequireLiteralType<ResultType>();
TestNonConvertibilityForOneType<ResultType>();
UnsignedIntegerType unsignedIntegerResult
= Op<o>(UnsignedIntegerType(t1), UnsignedIntegerType(t2));
MOZ_RELEASE_ASSERT(unsignedIntegerResult == UnsignedIntegerType(result));
MOZ_RELEASE_ASSERT(unsignedIntegerResult == UnsignedIntegerType(TypedEnum(result)));
MOZ_RELEASE_ASSERT((!unsignedIntegerResult) == (!result));
MOZ_RELEASE_ASSERT((!!unsignedIntegerResult) == (!!result));
MOZ_RELEASE_ASSERT(bool(unsignedIntegerResult) == bool(result));
// Part 2:
// Test the compound-assignment operator, i.e.
// result Op= t3;
TypedEnum newResult = result;
OpAssign<o>(newResult, t3);
UnsignedIntegerType unsignedIntegerNewResult = unsignedIntegerResult;
OpAssign<o>(unsignedIntegerNewResult, UnsignedIntegerType(t3));
MOZ_RELEASE_ASSERT(unsignedIntegerNewResult == UnsignedIntegerType(newResult));
// Part 3:
// Test additional boolean operators that we unfortunately had to add to
// CastableTypedEnumResult at some point to please some compiler,
// even though bool convertibility should have been enough.
MOZ_RELEASE_ASSERT(result == TypedEnum(result));
MOZ_RELEASE_ASSERT(!(result != TypedEnum(result)));
MOZ_RELEASE_ASSERT((result && true) == bool(result));
MOZ_RELEASE_ASSERT((result && false) == false);
MOZ_RELEASE_ASSERT((true && result) == bool(result));
MOZ_RELEASE_ASSERT((false && result && false) == false);
MOZ_RELEASE_ASSERT((result || false) == bool(result));
MOZ_RELEASE_ASSERT((result || true) == true);
MOZ_RELEASE_ASSERT((false || result) == bool(result));
MOZ_RELEASE_ASSERT((true || result) == true);
}
// Similar to TestBinOp but testing the unary ~ operator.
template<typename TypedEnum, typename T>
void TestTilde(const T& t)
{
typedef typename mozilla::detail::UnsignedIntegerTypeForEnum<TypedEnum>::Type
UnsignedIntegerType;
auto result = ~t;
typedef decltype(result) ResultType;
RequireLiteralType<ResultType>();
TestNonConvertibilityForOneType<ResultType>();
UnsignedIntegerType unsignedIntegerResult = ~(UnsignedIntegerType(t));
MOZ_RELEASE_ASSERT(unsignedIntegerResult == UnsignedIntegerType(result));
MOZ_RELEASE_ASSERT(unsignedIntegerResult == UnsignedIntegerType(TypedEnum(result)));
MOZ_RELEASE_ASSERT((!unsignedIntegerResult) == (!result));
MOZ_RELEASE_ASSERT((!!unsignedIntegerResult) == (!!result));
MOZ_RELEASE_ASSERT(bool(unsignedIntegerResult) == bool(result));
}
// Helper dispatching a given triple of operands to all operator-specific
// testing functions.
template<typename TypedEnum, typename T1, typename T2, typename T3>
void TestAllOpsForGivenOperands(const T1& t1, const T2& t2, const T3& t3)
{
TestBinOp<TypedEnum, '|'>(t1, t2, t3);
TestBinOp<TypedEnum, '&'>(t1, t2, t3);
TestBinOp<TypedEnum, '^'>(t1, t2, t3);
TestTilde<TypedEnum>(t1);
}
// Helper building various triples of operands using a given operator,
// and testing all operators with them.
template<typename TypedEnum, char o>
void TestAllOpsForOperandsBuiltUsingGivenOp()
{
// The type of enum values like TypedEnum::A may be different from
// TypedEnum. That is the case in the legacy non-C++11 path. We want to
// ensure good test coverage even when these two types are distinct.
// To that effect, we have both 'auto' typed variables, preserving the
// original type of enum values, and 'plain' typed variables, that
// are plain TypedEnum's.
const TypedEnum a_plain = TypedEnum::A;
const TypedEnum b_plain = TypedEnum::B;
const TypedEnum c_plain = TypedEnum::C;
auto a_auto = TypedEnum::A;
auto b_auto = TypedEnum::B;
auto c_auto = TypedEnum::C;
auto ab_plain = Op<o>(a_plain, b_plain);
auto bc_plain = Op<o>(b_plain, c_plain);
auto ab_auto = Op<o>(a_auto, b_auto);
auto bc_auto = Op<o>(b_auto, c_auto);
// On each row below, we pass a triple of operands. Keep in mind that this
// is going to be received as (t1, t2, t3) and the actual tests performed
// will be of the form
//
// result = t1 Op t2;
// result Op= t3;
//
// For this reason, we carefully ensure that the values of (t1, t2)
// systematically cover all types of such pairs; to limit complexity,
// we are not so careful with t3, and we just try to pass t3's
// that may lead to nontrivial bitwise operations.
TestAllOpsForGivenOperands<TypedEnum>(a_plain, b_plain, c_plain);
TestAllOpsForGivenOperands<TypedEnum>(a_plain, bc_plain, b_auto);
TestAllOpsForGivenOperands<TypedEnum>(ab_plain, c_plain, a_plain);
TestAllOpsForGivenOperands<TypedEnum>(ab_plain, bc_plain, a_auto);
TestAllOpsForGivenOperands<TypedEnum>(a_plain, b_auto, c_plain);
TestAllOpsForGivenOperands<TypedEnum>(a_plain, bc_auto, b_auto);
TestAllOpsForGivenOperands<TypedEnum>(ab_plain, c_auto, a_plain);
TestAllOpsForGivenOperands<TypedEnum>(ab_plain, bc_auto, a_auto);
TestAllOpsForGivenOperands<TypedEnum>(a_auto, b_plain, c_plain);
TestAllOpsForGivenOperands<TypedEnum>(a_auto, bc_plain, b_auto);
TestAllOpsForGivenOperands<TypedEnum>(ab_auto, c_plain, a_plain);
TestAllOpsForGivenOperands<TypedEnum>(ab_auto, bc_plain, a_auto);
TestAllOpsForGivenOperands<TypedEnum>(a_auto, b_auto, c_plain);
TestAllOpsForGivenOperands<TypedEnum>(a_auto, bc_auto, b_auto);
TestAllOpsForGivenOperands<TypedEnum>(ab_auto, c_auto, a_plain);
TestAllOpsForGivenOperands<TypedEnum>(ab_auto, bc_auto, a_auto);
}
// Tests all bitwise operations on a given TypedEnum bitfield.
template<typename TypedEnum>
void
TestTypedEnumBitField()
{
TestTypedEnumBasics<TypedEnum>();
TestAllOpsForOperandsBuiltUsingGivenOp<TypedEnum, '|'>();
TestAllOpsForOperandsBuiltUsingGivenOp<TypedEnum, '&'>();
TestAllOpsForOperandsBuiltUsingGivenOp<TypedEnum, '^'>();
}
// Checks that enum bitwise expressions have the same non-convertibility properties as
// c++11 enum classes do, i.e. not implicitly convertible to anything
// (though *explicitly* convertible).
void TestNoConversionsBetweenUnrelatedTypes()
{
using mozilla::IsConvertible;
// Two typed enum classes having the same underlying integer type, to ensure that
// we would catch bugs accidentally allowing conversions in that case.
typedef CharEnumBitField T1;
typedef Nested::CharEnumBitField T2;
static_assert(!IsConvertible<T1, T2>::value,
"should not be convertible");
static_assert(!IsConvertible<T1, decltype(T2::A)>::value,
"should not be convertible");
static_assert(!IsConvertible<T1, decltype(T2::A | T2::B)>::value,
"should not be convertible");
static_assert(!IsConvertible<decltype(T1::A), T2>::value,
"should not be convertible");
static_assert(!IsConvertible<decltype(T1::A), decltype(T2::A)>::value,
"should not be convertible");
static_assert(!IsConvertible<decltype(T1::A), decltype(T2::A | T2::B)>::value,
"should not be convertible");
// The following are #ifdef MOZ_HAVE_EXPLICIT_CONVERSION because
// without support for explicit conversion operators, we can't easily have these
// bad conversions completely removed. They still do fail to compile in practice,
// but not in a way that we can static_assert on.
#ifdef MOZ_HAVE_EXPLICIT_CONVERSION
static_assert(!IsConvertible<decltype(T1::A | T1::B), T2>::value,
"should not be convertible");
static_assert(!IsConvertible<decltype(T1::A | T1::B), decltype(T2::A)>::value,
"should not be convertible");
static_assert(!IsConvertible<decltype(T1::A | T1::B), decltype(T2::A | T2::B)>::value,
"should not be convertible");
#endif
}
MOZ_BEGIN_ENUM_CLASS(Int8EnumWithHighBits, int8_t)
A = 0x20,
B = 0x40
MOZ_END_ENUM_CLASS(Int8EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int8EnumWithHighBits)
MOZ_BEGIN_ENUM_CLASS(Uint8EnumWithHighBits, uint8_t)
A = 0x40,
B = 0x80
MOZ_END_ENUM_CLASS(Uint8EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint8EnumWithHighBits)
MOZ_BEGIN_ENUM_CLASS(Int16EnumWithHighBits, int16_t)
A = 0x2000,
B = 0x4000
MOZ_END_ENUM_CLASS(Int16EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int16EnumWithHighBits)
MOZ_BEGIN_ENUM_CLASS(Uint16EnumWithHighBits, uint16_t)
A = 0x4000,
B = 0x8000
MOZ_END_ENUM_CLASS(Uint16EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint16EnumWithHighBits)
MOZ_BEGIN_ENUM_CLASS(Int32EnumWithHighBits, int32_t)
A = 0x20000000,
B = 0x40000000
MOZ_END_ENUM_CLASS(Int32EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int32EnumWithHighBits)
MOZ_BEGIN_ENUM_CLASS(Uint32EnumWithHighBits, uint32_t)
A = 0x40000000u,
B = 0x80000000u
MOZ_END_ENUM_CLASS(Uint32EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint32EnumWithHighBits)
MOZ_BEGIN_ENUM_CLASS(Int64EnumWithHighBits, int64_t)
A = 0x2000000000000000ll,
B = 0x4000000000000000ll
MOZ_END_ENUM_CLASS(Int64EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int64EnumWithHighBits)
MOZ_BEGIN_ENUM_CLASS(Uint64EnumWithHighBits, uint64_t)
A = 0x4000000000000000ull,
B = 0x8000000000000000ull
MOZ_END_ENUM_CLASS(Uint64EnumWithHighBits)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint64EnumWithHighBits)
// Checks that we don't accidentally truncate high bits by coercing to the wrong
// integer type internally when implementing bitwise ops.
template<typename EnumType, typename IntType>
void TestIsNotTruncated()
{
EnumType a = EnumType::A;
EnumType b = EnumType::B;
MOZ_RELEASE_ASSERT(IntType(a));
MOZ_RELEASE_ASSERT(IntType(b));
MOZ_RELEASE_ASSERT(a | EnumType::B);
MOZ_RELEASE_ASSERT(a | b);
MOZ_RELEASE_ASSERT(EnumType::A | EnumType::B);
EnumType c = EnumType::A | EnumType::B;
MOZ_RELEASE_ASSERT(IntType(c));
MOZ_RELEASE_ASSERT(c & c);
MOZ_RELEASE_ASSERT(c | c);
MOZ_RELEASE_ASSERT(c == (EnumType::A | EnumType::B));
MOZ_RELEASE_ASSERT(a != (EnumType::A | EnumType::B));
MOZ_RELEASE_ASSERT(b != (EnumType::A | EnumType::B));
MOZ_RELEASE_ASSERT(c & EnumType::A);
MOZ_RELEASE_ASSERT(c & EnumType::B);
EnumType d = EnumType::A;
d |= EnumType::B;
MOZ_RELEASE_ASSERT(d == c);
}
// Simply check that this compiles.
const AutoEnum autoEnum = AutoEnum::A;
const CharEnum charEnum = CharEnum::B;
const Nested::AutoEnum nestedAutoEnum = Nested::AutoEnum::C;
const Nested::CharEnum nestedCharEnum = Nested::CharEnum::D;
int
main()
{
TestTypedEnumBasics<AutoEnum>();
TestTypedEnumBasics<CharEnum>();
TestTypedEnumBasics<Nested::AutoEnum>();
TestTypedEnumBasics<Nested::CharEnum>();
TestTypedEnumBitField<AutoEnumBitField>();
TestTypedEnumBitField<CharEnumBitField>();
TestTypedEnumBitField<Nested::AutoEnumBitField>();
TestTypedEnumBitField<Nested::CharEnumBitField>();
TestTypedEnumBitField<BitFieldFor_uint8_t>();
TestTypedEnumBitField<BitFieldFor_int8_t>();
TestTypedEnumBitField<BitFieldFor_uint16_t>();
TestTypedEnumBitField<BitFieldFor_int16_t>();
TestTypedEnumBitField<BitFieldFor_uint32_t>();
TestTypedEnumBitField<BitFieldFor_int32_t>();
TestTypedEnumBitField<BitFieldFor_uint64_t>();
TestTypedEnumBitField<BitFieldFor_int64_t>();
TestTypedEnumBitField<BitFieldFor_char>();
TestTypedEnumBitField<BitFieldFor_signed_char>();
TestTypedEnumBitField<BitFieldFor_unsigned_char>();
TestTypedEnumBitField<BitFieldFor_short>();
TestTypedEnumBitField<BitFieldFor_unsigned_short>();
TestTypedEnumBitField<BitFieldFor_int>();
TestTypedEnumBitField<BitFieldFor_unsigned_int>();
TestTypedEnumBitField<BitFieldFor_long>();
TestTypedEnumBitField<BitFieldFor_unsigned_long>();
TestTypedEnumBitField<BitFieldFor_long_long>();
TestTypedEnumBitField<BitFieldFor_unsigned_long_long>();
TestNoConversionsBetweenUnrelatedTypes();
TestIsNotTruncated<Int8EnumWithHighBits, int8_t>();
TestIsNotTruncated<Int16EnumWithHighBits, int16_t>();
TestIsNotTruncated<Int32EnumWithHighBits, int32_t>();
TestIsNotTruncated<Int64EnumWithHighBits, int64_t>();
TestIsNotTruncated<Uint8EnumWithHighBits, uint8_t>();
TestIsNotTruncated<Uint16EnumWithHighBits, uint16_t>();
TestIsNotTruncated<Uint32EnumWithHighBits, uint32_t>();
TestIsNotTruncated<Uint64EnumWithHighBits, uint64_t>();
return 0;
}

View File

@ -439,7 +439,7 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence,
new GrallocTextureClientOGL(ImageBridgeChild::GetSingleton(),
gfx::SurfaceFormat::UNKNOWN,
gfx::BackendType::NONE,
TextureFlags::DEALLOCATE_CLIENT);
TEXTURE_DEALLOCATE_CLIENT);
usage |= GraphicBuffer::USAGE_HW_TEXTURE;
bool result = textureClient->AllocateGralloc(IntSize(w, h), format, usage);
sp<GraphicBuffer> graphicBuffer = textureClient->GetGraphicBuffer();

View File

@ -467,7 +467,7 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence, bool a
new GrallocTextureClientOGL(ImageBridgeChild::GetSingleton(),
gfx::SurfaceFormat::UNKNOWN,
gfx::BackendType::NONE,
TextureFlags::DEALLOCATE_CLIENT);
TEXTURE_DEALLOCATE_CLIENT);
usage |= GraphicBuffer::USAGE_HW_TEXTURE;
bool result = textureClient->AllocateGralloc(IntSize(w, h), format, usage);
sp<GraphicBuffer> graphicBuffer = textureClient->GetGraphicBuffer();

View File

@ -341,7 +341,7 @@ status_t GonkNativeWindow::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
new GrallocTextureClientOGL(ImageBridgeChild::GetSingleton(),
gfx::SurfaceFormat::UNKNOWN,
gfx::BackendType::NONE,
TextureFlags::DEALLOCATE_CLIENT);
TEXTURE_DEALLOCATE_CLIENT);
usage |= GraphicBuffer::USAGE_HW_TEXTURE;
bool result = textureClient->AllocateGralloc(IntSize(w, h), format, usage);
sp<GraphicBuffer> graphicBuffer = textureClient->GetGraphicBuffer();