LCOV - code coverage report
Current view: top level - gfx/layers - CompositorTypes.h (source / functions) Hit Total Coverage
Test: output.info Lines: 17 28 60.7 %
Date: 2017-07-14 16:53:18 Functions: 9 17 52.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             : * This Source Code Form is subject to the terms of the Mozilla Public
       3             : * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef MOZILLA_LAYERS_COMPOSITORTYPES_H
       7             : #define MOZILLA_LAYERS_COMPOSITORTYPES_H
       8             : 
       9             : #include <stdint.h>                     // for uint32_t
      10             : #include <sys/types.h>                  // for int32_t
      11             : #include "LayersTypes.h"                // for LayersBackend, etc
      12             : #include "nsXULAppAPI.h"                // for GeckoProcessType, etc
      13             : #include "mozilla/gfx/Types.h"
      14             : #include "mozilla/EnumSet.h"
      15             : 
      16             : #include "mozilla/TypedEnumBits.h"
      17             : 
      18             : namespace mozilla {
      19             : namespace layers {
      20             : 
      21             : /**
      22             :  * Flags used by texture clients and texture hosts. These are passed from client
      23             :  * side to host side when textures and compositables are created. Usually set
      24             :  * by the compositableCient, they may be modified by either the compositable or
      25             :  * texture clients.
      26             :  */
      27             : enum class TextureFlags : uint32_t {
      28             :   NO_FLAGS           = 0,
      29             :   // Use nearest-neighbour texture filtering (as opposed to linear filtering).
      30             :   USE_NEAREST_FILTER = 1 << 0,
      31             :   // The compositor assumes everything is origin-top-left by default.
      32             :   ORIGIN_BOTTOM_LEFT = 1 << 1,
      33             :   // Force the texture to be represented using a single tile (note that this means
      34             :   // tiled textures, not tiled layers).
      35             :   DISALLOW_BIGIMAGE  = 1 << 2,
      36             :   // The buffer will be treated as if the RB bytes are swapped.
      37             :   // This is useful for rendering using Cairo/Thebes, because there is no
      38             :   // BGRX Android pixel format, and so we have to do byte swapping.
      39             :   //
      40             :   // For example, if the GraphicBuffer has an Android pixel format of
      41             :   // PIXEL_FORMAT_RGBA_8888 and isRBSwapped is true, when it is sampled
      42             :   // (for example, with GL), a BGRA shader should be used.
      43             :   RB_SWAPPED         = 1 << 3,
      44             :   // Data in this texture has not been alpha-premultiplied.
      45             :   // XXX - Apparently only used with ImageClient/Host
      46             :   NON_PREMULTIPLIED  = 1 << 4,
      47             :   // The TextureClient should be recycled with recycle callback when no longer
      48             :   // in used. When the texture is used in host side, ref count of TextureClient
      49             :   // is transparently added by ShadowLayerForwarder or ImageBridgeChild.
      50             :   RECYCLE            = 1 << 5,
      51             :   // If DEALLOCATE_CLIENT is set, the shared data is deallocated on the
      52             :   // client side and requires some extra synchronizaion to ensure race-free
      53             :   // deallocation.
      54             :   // The default behaviour is to deallocate on the host side.
      55             :   DEALLOCATE_CLIENT  = 1 << 6,
      56             :   DEALLOCATE_SYNC    = 1 << 6, // XXX - make it a separate flag.
      57             :   DEALLOCATE_MAIN_THREAD = 1 << 8,
      58             :   // After being shared ith the compositor side, an immutable texture is never
      59             :   // modified, it can only be read. It is safe to not Lock/Unlock immutable
      60             :   // textures.
      61             :   IMMUTABLE          = 1 << 9,
      62             :   // The contents of the texture must be uploaded or copied immediately
      63             :   // during the transaction, because the producer may want to write
      64             :   // to it again.
      65             :   IMMEDIATE_UPLOAD   = 1 << 10,
      66             :   // The texture is part of a component-alpha pair
      67             :   COMPONENT_ALPHA    = 1 << 11,
      68             :   // The texture is being allocated for a compositor that no longer exists.
      69             :   // This flag is only used in the parent process.
      70             :   INVALID_COMPOSITOR = 1 << 12,
      71             :   // The texture was created by converting from YCBCR to RGB
      72             :   RGB_FROM_YCBCR     = 1 << 13,
      73             :   // The texture is used for snapshot.
      74             :   SNAPSHOT           = 1 << 14,
      75             : 
      76             :   // OR union of all valid bits
      77             :   ALL_BITS           = (1 << 15) - 1,
      78             :   // the default flags
      79             :   DEFAULT = NO_FLAGS
      80             : };
      81         292 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(TextureFlags)
      82             : 
      83             : static inline bool
      84           0 : TextureRequiresLocking(TextureFlags aFlags)
      85             : {
      86             :   // If we're not double buffered, or uploading
      87             :   // within a transaction, then we need to support
      88             :   // locking correctly.
      89           0 :   return !(aFlags & (TextureFlags::IMMEDIATE_UPLOAD |
      90          28 :                      TextureFlags::IMMUTABLE));
      91             : }
      92             : 
      93             : /**
      94             :  * The type of debug diagnostic to enable.
      95             :  */
      96             : enum class DiagnosticTypes : uint8_t {
      97             :   NO_DIAGNOSTIC    = 0,
      98             :   TILE_BORDERS     = 1 << 0,
      99             :   LAYER_BORDERS    = 1 << 1,
     100             :   BIGIMAGE_BORDERS = 1 << 2,
     101             :   FLASH_BORDERS    = 1 << 3,
     102             :   ALL_BITS         = (1 << 4) - 1
     103             : };
     104          29 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DiagnosticTypes)
     105             : 
     106             : #define DIAGNOSTIC_FLASH_COUNTER_MAX 100
     107             : 
     108             : /**
     109             :  * Information about the object that is being diagnosed.
     110             :  */
     111             : enum class DiagnosticFlags : uint16_t {
     112             :   NO_DIAGNOSTIC   = 0,
     113             :   IMAGE           = 1 << 0,
     114             :   CONTENT         = 1 << 1,
     115             :   CANVAS          = 1 << 2,
     116             :   COLOR           = 1 << 3,
     117             :   CONTAINER       = 1 << 4,
     118             :   TILE            = 1 << 5,
     119             :   BIGIMAGE        = 1 << 6,
     120             :   COMPONENT_ALPHA = 1 << 7,
     121             :   REGION_RECT     = 1 << 8,
     122             :   NV12            = 1 << 9,
     123             :   YCBCR           = 1 << 10
     124             : };
     125         172 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DiagnosticFlags)
     126             : 
     127             : /**
     128             :  * See gfx/layers/Effects.h
     129             :  */
     130             : enum class EffectTypes : uint8_t {
     131             :   MASK,
     132             :   BLEND_MODE,
     133             :   COLOR_MATRIX,
     134             :   MAX_SECONDARY, // sentinel for the count of secondary effect types
     135             :   RGB,
     136             :   YCBCR,
     137             :   NV12,
     138             :   COMPONENT_ALPHA,
     139             :   SOLID_COLOR,
     140             :   RENDER_TARGET,
     141             :   MAX  //sentinel for the count of all effect types
     142             : };
     143             : 
     144             : /**
     145             :  * How the Compositable should manage textures.
     146             :  */
     147             : enum class CompositableType : uint8_t {
     148             :   UNKNOWN,
     149             :   CONTENT_TILED,   // tiled painted layer
     150             :   IMAGE,           // image with single buffering
     151             :   IMAGE_BRIDGE,    // ImageBridge protocol
     152             :   CONTENT_SINGLE,  // painted layer interface, single buffering
     153             :   CONTENT_DOUBLE,  // painted layer interface, double buffering
     154             :   COUNT
     155             : };
     156             : 
     157             : #ifdef XP_WIN
     158             : typedef void* SyncHandle;
     159             : #else
     160             : typedef uintptr_t SyncHandle;
     161             : #endif // XP_WIN
     162             : 
     163             : /**
     164             :  * Sent from the compositor to the content-side LayerManager, includes properties
     165             :  * of the compositor and should (in the future) include information about what
     166             :  * kinds of buffer and texture clients to create.
     167             :  */
     168             : struct TextureFactoryIdentifier
     169             : {
     170             :   LayersBackend mParentBackend;
     171             :   GeckoProcessType mParentProcessType;
     172             :   int32_t mMaxTextureSize;
     173             :   bool mCompositorUseANGLE;
     174             :   bool mSupportsTextureBlitting;
     175             :   bool mSupportsPartialUploads;
     176             :   bool mSupportsComponentAlpha;
     177             :   bool mSupportsBackdropCopyForComponentAlpha;
     178             :   bool mUsingAdvancedLayers;
     179             :   SyncHandle mSyncHandle;
     180             : 
     181          14 :   explicit TextureFactoryIdentifier(LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE,
     182             :                                     GeckoProcessType aParentProcessType = GeckoProcessType_Default,
     183             :                                     int32_t aMaxTextureSize = 4096,
     184             :                                     bool aCompositorUseANGLE = false,
     185             :                                     bool aSupportsTextureBlitting = false,
     186             :                                     bool aSupportsPartialUploads = false,
     187             :                                     bool aSupportsComponentAlpha = true,
     188             :                                     SyncHandle aSyncHandle = 0)
     189          14 :     : mParentBackend(aLayersBackend)
     190             :     , mParentProcessType(aParentProcessType)
     191             :     , mMaxTextureSize(aMaxTextureSize)
     192             :     , mCompositorUseANGLE(aCompositorUseANGLE)
     193             :     , mSupportsTextureBlitting(aSupportsTextureBlitting)
     194             :     , mSupportsPartialUploads(aSupportsPartialUploads)
     195             :     , mSupportsComponentAlpha(aSupportsComponentAlpha)
     196             :     , mSupportsBackdropCopyForComponentAlpha(true)
     197             :     , mUsingAdvancedLayers(false)
     198          14 :     , mSyncHandle(aSyncHandle)
     199          14 :   {}
     200             : 
     201           0 :   bool operator==(const TextureFactoryIdentifier& aOther) const {
     202             :     return
     203           0 :       mParentBackend == aOther.mParentBackend &&
     204           0 :       mParentProcessType == aOther.mParentProcessType &&
     205           0 :       mMaxTextureSize == aOther.mMaxTextureSize &&
     206           0 :       mCompositorUseANGLE == aOther.mCompositorUseANGLE &&
     207           0 :       mSupportsTextureBlitting == aOther.mSupportsTextureBlitting &&
     208           0 :       mSupportsPartialUploads == aOther.mSupportsPartialUploads &&
     209           0 :       mSupportsComponentAlpha == aOther.mSupportsComponentAlpha &&
     210           0 :       mSyncHandle == aOther.mSyncHandle;
     211             :   }
     212             : };
     213             : 
     214             : /**
     215             :  * Information required by the compositor from the content-side for creating or
     216             :  * using compositables and textures.
     217             :  * XXX - TextureInfo is a bad name: this information is useful for the compositable,
     218             :  * not the Texture. And ith new Textures, only the compositable type is really
     219             :  * useful. This may (should) be removed in the near future.
     220             :  */
     221             : struct TextureInfo
     222             : {
     223             :   CompositableType mCompositableType;
     224             :   TextureFlags mTextureFlags;
     225             : 
     226          22 :   TextureInfo()
     227          22 :     : mCompositableType(CompositableType::UNKNOWN)
     228          22 :     , mTextureFlags(TextureFlags::NO_FLAGS)
     229          22 :   {}
     230             : 
     231          22 :   explicit TextureInfo(CompositableType aType,
     232             :                        TextureFlags aTextureFlags = TextureFlags::DEFAULT)
     233          22 :     : mCompositableType(aType)
     234          22 :     , mTextureFlags(aTextureFlags)
     235          22 :   {}
     236             : 
     237             :   bool operator==(const TextureInfo& aOther) const
     238             :   {
     239             :     return mCompositableType == aOther.mCompositableType &&
     240             :            mTextureFlags == aOther.mTextureFlags;
     241             :   }
     242             : };
     243             : 
     244             : /**
     245             :  * How a SurfaceDescriptor will be opened.
     246             :  *
     247             :  * See ShadowLayerForwarder::OpenDescriptor for example.
     248             :  */
     249             : enum class OpenMode : uint8_t {
     250             :   OPEN_NONE        = 0,
     251             :   OPEN_READ        = 0x1,
     252             :   OPEN_WRITE       = 0x2,
     253             :   OPEN_READ_WRITE  = OPEN_READ|OPEN_WRITE,
     254             :   OPEN_READ_ONLY   = OPEN_READ,
     255             :   OPEN_WRITE_ONLY  = OPEN_WRITE
     256             : };
     257         141 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(OpenMode)
     258             : 
     259             : // The kinds of mask texture a shader can support
     260             : // We rely on the items in this enum being sequential
     261             : enum class MaskType : uint8_t {
     262             :   MaskNone = 0,   // no mask layer
     263             :   Mask,           // mask layer
     264             :   NumMaskTypes
     265             : };
     266             : 
     267             : } // namespace layers
     268             : } // namespace mozilla
     269             : 
     270             : #endif

Generated by: LCOV version 1.13