gfx/layers/LayersTypes.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/LayersTypes.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,172 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef GFX_LAYERSTYPES_H
    1.10 +#define GFX_LAYERSTYPES_H
    1.11 +
    1.12 +#include <stdint.h>                     // for uint32_t
    1.13 +#include "nsPoint.h"                    // for nsIntPoint
    1.14 +#include "nsRegion.h"
    1.15 +
    1.16 +#include "mozilla/TypedEnum.h"
    1.17 +
    1.18 +#ifdef MOZ_WIDGET_GONK
    1.19 +#include <ui/GraphicBuffer.h>
    1.20 +#endif
    1.21 +#if defined(DEBUG) || defined(PR_LOGGING)
    1.22 +#  include <stdio.h>            // FILE
    1.23 +#  include "prlog.h"            // for PR_LOG
    1.24 +#  ifndef MOZ_LAYERS_HAVE_LOG
    1.25 +#    define MOZ_LAYERS_HAVE_LOG
    1.26 +#  endif
    1.27 +#  define MOZ_LAYERS_LOG(_args)                             \
    1.28 +  PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args)
    1.29 +#  define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args)         \
    1.30 +  do { if (layer->AsShadowableLayer()) { PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args); } } while (0)
    1.31 +#else
    1.32 +struct PRLogModuleInfo;
    1.33 +#  define MOZ_LAYERS_LOG(_args)
    1.34 +#  define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args)
    1.35 +#endif  // if defined(DEBUG) || defined(PR_LOGGING)
    1.36 +
    1.37 +namespace android {
    1.38 +class GraphicBuffer;
    1.39 +}
    1.40 +
    1.41 +namespace mozilla {
    1.42 +namespace layers {
    1.43 +
    1.44 +class TextureHost;
    1.45 +
    1.46 +typedef uint32_t TextureFlags;
    1.47 +
    1.48 +#undef NONE
    1.49 +#undef OPAQUE
    1.50 +
    1.51 +MOZ_BEGIN_ENUM_CLASS(LayersBackend, int8_t)
    1.52 +  LAYERS_NONE = 0,
    1.53 +  LAYERS_BASIC,
    1.54 +  LAYERS_OPENGL,
    1.55 +  LAYERS_D3D9,
    1.56 +  LAYERS_D3D10,
    1.57 +  LAYERS_D3D11,
    1.58 +  LAYERS_CLIENT,
    1.59 +  LAYERS_LAST
    1.60 +MOZ_END_ENUM_CLASS(LayersBackend)
    1.61 +
    1.62 +MOZ_BEGIN_ENUM_CLASS(BufferMode, int8_t)
    1.63 +  BUFFER_NONE,
    1.64 +  BUFFERED
    1.65 +MOZ_END_ENUM_CLASS(BufferMode)
    1.66 +
    1.67 +MOZ_BEGIN_ENUM_CLASS(DrawRegionClip, int8_t)
    1.68 +  DRAW,
    1.69 +  DRAW_SNAPPED,
    1.70 +  CLIP_NONE
    1.71 +MOZ_END_ENUM_CLASS(DrawRegionClip)
    1.72 +
    1.73 +MOZ_BEGIN_ENUM_CLASS(SurfaceMode, int8_t)
    1.74 +  SURFACE_NONE = 0,
    1.75 +  SURFACE_OPAQUE,
    1.76 +  SURFACE_SINGLE_CHANNEL_ALPHA,
    1.77 +  SURFACE_COMPONENT_ALPHA
    1.78 +MOZ_END_ENUM_CLASS(SurfaceMode)
    1.79 +
    1.80 +// LayerRenderState for Composer2D
    1.81 +// We currently only support Composer2D using gralloc. If we want to be backed
    1.82 +// by other surfaces we will need a more generic LayerRenderState.
    1.83 +enum LayerRenderStateFlags {
    1.84 +  LAYER_RENDER_STATE_Y_FLIPPED = 1 << 0,
    1.85 +  LAYER_RENDER_STATE_BUFFER_ROTATION = 1 << 1,
    1.86 +  // Notify Composer2D to swap the RB pixels of gralloc buffer
    1.87 +  LAYER_RENDER_STATE_FORMAT_RB_SWAP = 1 << 2
    1.88 +};
    1.89 +
    1.90 +// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
    1.91 +// android::sp unless we have to.
    1.92 +struct LayerRenderState {
    1.93 +  LayerRenderState()
    1.94 +#ifdef MOZ_WIDGET_GONK
    1.95 +    : mSurface(nullptr), mTexture(nullptr), mFlags(0), mHasOwnOffset(false)
    1.96 +#endif
    1.97 +  {}
    1.98 +
    1.99 +#ifdef MOZ_WIDGET_GONK
   1.100 +  LayerRenderState(android::GraphicBuffer* aSurface,
   1.101 +                   const nsIntSize& aSize,
   1.102 +                   uint32_t aFlags,
   1.103 +                   TextureHost* aTexture)
   1.104 +    : mSurface(aSurface)
   1.105 +    , mSize(aSize)
   1.106 +    , mTexture(aTexture)
   1.107 +    , mFlags(aFlags)
   1.108 +    , mHasOwnOffset(false)
   1.109 +  {}
   1.110 +
   1.111 +  bool YFlipped() const
   1.112 +  { return mFlags & LAYER_RENDER_STATE_Y_FLIPPED; }
   1.113 +
   1.114 +  bool BufferRotated() const
   1.115 +  { return mFlags & LAYER_RENDER_STATE_BUFFER_ROTATION; }
   1.116 +
   1.117 +  bool FormatRBSwapped() const
   1.118 +  { return mFlags & LAYER_RENDER_STATE_FORMAT_RB_SWAP; }
   1.119 +#endif
   1.120 +
   1.121 +  void SetOffset(const nsIntPoint& aOffset)
   1.122 +  {
   1.123 +    mOffset = aOffset;
   1.124 +    mHasOwnOffset = true;
   1.125 +  }
   1.126 +
   1.127 +#ifdef MOZ_WIDGET_GONK
   1.128 +  // surface to render
   1.129 +  android::sp<android::GraphicBuffer> mSurface;
   1.130 +  // size of mSurface 
   1.131 +  nsIntSize mSize;
   1.132 +  TextureHost* mTexture;
   1.133 +#endif
   1.134 +  // see LayerRenderStateFlags
   1.135 +  uint32_t mFlags;
   1.136 +  // the location of the layer's origin on mSurface
   1.137 +  nsIntPoint mOffset;
   1.138 +  // true if mOffset is applicable
   1.139 +  bool mHasOwnOffset;
   1.140 +};
   1.141 +
   1.142 +MOZ_BEGIN_ENUM_CLASS(ScaleMode, int8_t)
   1.143 +  SCALE_NONE,
   1.144 +  STRETCH,
   1.145 +  SENTINEL
   1.146 +// Unimplemented - PRESERVE_ASPECT_RATIO_CONTAIN
   1.147 +MOZ_END_ENUM_CLASS(ScaleMode)
   1.148 +
   1.149 +struct EventRegions {
   1.150 +  nsIntRegion mHitRegion;
   1.151 +  nsIntRegion mDispatchToContentHitRegion;
   1.152 +
   1.153 +  bool operator==(const EventRegions& aRegions) const
   1.154 +  {
   1.155 +    return mHitRegion == aRegions.mHitRegion &&
   1.156 +           mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion;
   1.157 +  }
   1.158 +  bool operator!=(const EventRegions& aRegions) const
   1.159 +  {
   1.160 +    return !(*this == aRegions);
   1.161 +  }
   1.162 +
   1.163 +  nsCString ToString() const
   1.164 +  {
   1.165 +    nsCString result = mHitRegion.ToString();
   1.166 +    result.AppendLiteral(";dispatchToContent=");
   1.167 +    result.Append(mDispatchToContentHitRegion.ToString());
   1.168 +    return result;
   1.169 +  }
   1.170 +};
   1.171 +
   1.172 +} // namespace
   1.173 +} // namespace
   1.174 +
   1.175 +#endif /* GFX_LAYERSTYPES_H */

mercurial