michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_LAYERSTYPES_H michael@0: #define GFX_LAYERSTYPES_H michael@0: michael@0: #include // for uint32_t michael@0: #include "nsPoint.h" // for nsIntPoint michael@0: #include "nsRegion.h" michael@0: michael@0: #include "mozilla/TypedEnum.h" michael@0: michael@0: #ifdef MOZ_WIDGET_GONK michael@0: #include michael@0: #endif michael@0: #if defined(DEBUG) || defined(PR_LOGGING) michael@0: # include // FILE michael@0: # include "prlog.h" // for PR_LOG michael@0: # ifndef MOZ_LAYERS_HAVE_LOG michael@0: # define MOZ_LAYERS_HAVE_LOG michael@0: # endif michael@0: # define MOZ_LAYERS_LOG(_args) \ michael@0: PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args) michael@0: # define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args) \ michael@0: do { if (layer->AsShadowableLayer()) { PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args); } } while (0) michael@0: #else michael@0: struct PRLogModuleInfo; michael@0: # define MOZ_LAYERS_LOG(_args) michael@0: # define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args) michael@0: #endif // if defined(DEBUG) || defined(PR_LOGGING) michael@0: michael@0: namespace android { michael@0: class GraphicBuffer; michael@0: } michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class TextureHost; michael@0: michael@0: typedef uint32_t TextureFlags; michael@0: michael@0: #undef NONE michael@0: #undef OPAQUE michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(LayersBackend, int8_t) michael@0: LAYERS_NONE = 0, michael@0: LAYERS_BASIC, michael@0: LAYERS_OPENGL, michael@0: LAYERS_D3D9, michael@0: LAYERS_D3D10, michael@0: LAYERS_D3D11, michael@0: LAYERS_CLIENT, michael@0: LAYERS_LAST michael@0: MOZ_END_ENUM_CLASS(LayersBackend) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(BufferMode, int8_t) michael@0: BUFFER_NONE, michael@0: BUFFERED michael@0: MOZ_END_ENUM_CLASS(BufferMode) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(DrawRegionClip, int8_t) michael@0: DRAW, michael@0: DRAW_SNAPPED, michael@0: CLIP_NONE michael@0: MOZ_END_ENUM_CLASS(DrawRegionClip) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(SurfaceMode, int8_t) michael@0: SURFACE_NONE = 0, michael@0: SURFACE_OPAQUE, michael@0: SURFACE_SINGLE_CHANNEL_ALPHA, michael@0: SURFACE_COMPONENT_ALPHA michael@0: MOZ_END_ENUM_CLASS(SurfaceMode) michael@0: michael@0: // LayerRenderState for Composer2D michael@0: // We currently only support Composer2D using gralloc. If we want to be backed michael@0: // by other surfaces we will need a more generic LayerRenderState. michael@0: enum LayerRenderStateFlags { michael@0: LAYER_RENDER_STATE_Y_FLIPPED = 1 << 0, michael@0: LAYER_RENDER_STATE_BUFFER_ROTATION = 1 << 1, michael@0: // Notify Composer2D to swap the RB pixels of gralloc buffer michael@0: LAYER_RENDER_STATE_FORMAT_RB_SWAP = 1 << 2 michael@0: }; michael@0: michael@0: // The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include michael@0: // android::sp unless we have to. michael@0: struct LayerRenderState { michael@0: LayerRenderState() michael@0: #ifdef MOZ_WIDGET_GONK michael@0: : mSurface(nullptr), mTexture(nullptr), mFlags(0), mHasOwnOffset(false) michael@0: #endif michael@0: {} michael@0: michael@0: #ifdef MOZ_WIDGET_GONK michael@0: LayerRenderState(android::GraphicBuffer* aSurface, michael@0: const nsIntSize& aSize, michael@0: uint32_t aFlags, michael@0: TextureHost* aTexture) michael@0: : mSurface(aSurface) michael@0: , mSize(aSize) michael@0: , mTexture(aTexture) michael@0: , mFlags(aFlags) michael@0: , mHasOwnOffset(false) michael@0: {} michael@0: michael@0: bool YFlipped() const michael@0: { return mFlags & LAYER_RENDER_STATE_Y_FLIPPED; } michael@0: michael@0: bool BufferRotated() const michael@0: { return mFlags & LAYER_RENDER_STATE_BUFFER_ROTATION; } michael@0: michael@0: bool FormatRBSwapped() const michael@0: { return mFlags & LAYER_RENDER_STATE_FORMAT_RB_SWAP; } michael@0: #endif michael@0: michael@0: void SetOffset(const nsIntPoint& aOffset) michael@0: { michael@0: mOffset = aOffset; michael@0: mHasOwnOffset = true; michael@0: } michael@0: michael@0: #ifdef MOZ_WIDGET_GONK michael@0: // surface to render michael@0: android::sp mSurface; michael@0: // size of mSurface michael@0: nsIntSize mSize; michael@0: TextureHost* mTexture; michael@0: #endif michael@0: // see LayerRenderStateFlags michael@0: uint32_t mFlags; michael@0: // the location of the layer's origin on mSurface michael@0: nsIntPoint mOffset; michael@0: // true if mOffset is applicable michael@0: bool mHasOwnOffset; michael@0: }; michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(ScaleMode, int8_t) michael@0: SCALE_NONE, michael@0: STRETCH, michael@0: SENTINEL michael@0: // Unimplemented - PRESERVE_ASPECT_RATIO_CONTAIN michael@0: MOZ_END_ENUM_CLASS(ScaleMode) michael@0: michael@0: struct EventRegions { michael@0: nsIntRegion mHitRegion; michael@0: nsIntRegion mDispatchToContentHitRegion; michael@0: michael@0: bool operator==(const EventRegions& aRegions) const michael@0: { michael@0: return mHitRegion == aRegions.mHitRegion && michael@0: mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion; michael@0: } michael@0: bool operator!=(const EventRegions& aRegions) const michael@0: { michael@0: return !(*this == aRegions); michael@0: } michael@0: michael@0: nsCString ToString() const michael@0: { michael@0: nsCString result = mHitRegion.ToString(); michael@0: result.AppendLiteral(";dispatchToContent="); michael@0: result.Append(mDispatchToContentHitRegion.ToString()); michael@0: return result; michael@0: } michael@0: }; michael@0: michael@0: } // namespace michael@0: } // namespace michael@0: michael@0: #endif /* GFX_LAYERSTYPES_H */