diff --git a/gfx/layers/LayersTypes.h b/gfx/layers/LayersTypes.h index 5d6129f0744..58c8b6d48f3 100644 --- a/gfx/layers/LayersTypes.h +++ b/gfx/layers/LayersTypes.h @@ -11,6 +11,7 @@ #include "nsRegion.h" #include "mozilla/TypedEnum.h" +#include "mozilla/TypedEnumBits.h" #ifdef MOZ_WIDGET_GONK #include @@ -75,42 +76,47 @@ 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. -enum LayerRenderStateFlags { - LAYER_RENDER_STATE_Y_FLIPPED = 1 << 0, - LAYER_RENDER_STATE_BUFFER_ROTATION = 1 << 1, +MOZ_BEGIN_ENUM_CLASS(LayerRenderStateFlags, int8_t) + LAYER_RENDER_STATE_DEFAULT = 0, + Y_FLIPPED = 1 << 0, + BUFFER_ROTATION = 1 << 1, // Notify Composer2D to swap the RB pixels of gralloc buffer - LAYER_RENDER_STATE_FORMAT_RB_SWAP = 1 << 2 -}; + FORMAT_RB_SWAP = 1 << 2 +MOZ_END_ENUM_CLASS(LayerRenderStateFlags) +MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LayerRenderStateFlags) // 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 - : mSurface(nullptr), mTexture(nullptr), mFlags(0), mHasOwnOffset(false) + : mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT) + , mHasOwnOffset(false) + , mSurface(nullptr) + , mTexture(nullptr) #endif {} #ifdef MOZ_WIDGET_GONK LayerRenderState(android::GraphicBuffer* aSurface, const nsIntSize& aSize, - uint32_t aFlags, + LayerRenderStateFlags aFlags, TextureHost* aTexture) - : mSurface(aSurface) + : mFlags(aFlags) + , mHasOwnOffset(false) + , mSurface(aSurface) , mSize(aSize) , mTexture(aTexture) - , mFlags(aFlags) - , mHasOwnOffset(false) {} bool YFlipped() const - { return mFlags & LAYER_RENDER_STATE_Y_FLIPPED; } + { return bool(mFlags & LayerRenderStateFlags::Y_FLIPPED); } bool BufferRotated() const - { return mFlags & LAYER_RENDER_STATE_BUFFER_ROTATION; } + { return bool(mFlags & LayerRenderStateFlags::BUFFER_ROTATION); } bool FormatRBSwapped() const - { return mFlags & LAYER_RENDER_STATE_FORMAT_RB_SWAP; } + { return bool(mFlags & LayerRenderStateFlags::FORMAT_RB_SWAP); } #endif void SetOffset(const nsIntPoint& aOffset) @@ -119,6 +125,12 @@ 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 mSurface; @@ -126,12 +138,6 @@ 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) diff --git a/gfx/layers/opengl/GrallocTextureHost.cpp b/gfx/layers/opengl/GrallocTextureHost.cpp index 89cee82eab8..8413416ceb7 100644 --- a/gfx/layers/opengl/GrallocTextureHost.cpp +++ b/gfx/layers/opengl/GrallocTextureHost.cpp @@ -370,7 +370,7 @@ LayerRenderState GrallocTextureHostOGL::GetRenderState() { if (IsValid()) { - uint32_t flags = 0; + LayerRenderStateFlags flags = LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT; if (mFlags & TextureFlags::NEEDS_Y_FLIP) { flags |= LAYER_RENDER_STATE_Y_FLIPPED; }