LCOV - code coverage report
Current view: top level - gfx/layers/ipc - CompositableForwarder.h (source / functions) Hit Total Coverage
Test: output.info Lines: 6 7 85.7 %
Date: 2017-07-14 16:53:18 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef MOZILLA_LAYERS_COMPOSITABLEFORWARDER
       8             : #define MOZILLA_LAYERS_COMPOSITABLEFORWARDER
       9             : 
      10             : #include <stdint.h>                     // for int32_t, uint64_t
      11             : #include "gfxTypes.h"
      12             : #include "mozilla/Attributes.h"         // for override
      13             : #include "mozilla/UniquePtr.h"
      14             : #include "mozilla/layers/CompositableClient.h"  // for CompositableClient
      15             : #include "mozilla/layers/CompositorTypes.h"
      16             : #include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
      17             : #include "mozilla/layers/LayersTypes.h"  // for LayersBackend
      18             : #include "mozilla/layers/TextureClient.h"  // for TextureClient
      19             : #include "mozilla/layers/TextureForwarder.h"  // for TextureForwarder
      20             : #include "nsRegion.h"                   // for nsIntRegion
      21             : #include "mozilla/gfx/Rect.h"
      22             : #include "nsHashKeys.h"
      23             : #include "nsTHashtable.h"
      24             : 
      25             : namespace mozilla {
      26             : namespace layers {
      27             : 
      28             : class CompositableClient;
      29             : class ImageContainer;
      30             : class SurfaceDescriptor;
      31             : class SurfaceDescriptorTiles;
      32             : class ThebesBufferData;
      33             : class PTextureChild;
      34             : 
      35             : /**
      36             :  * A transaction is a set of changes that happenned on the content side, that
      37             :  * should be sent to the compositor side.
      38             :  * CompositableForwarder is an interface to manage a transaction of
      39             :  * compositable objetcs.
      40             :  *
      41             :  * ShadowLayerForwarder is an example of a CompositableForwarder (that can
      42             :  * additionally forward modifications of the Layer tree).
      43             :  * ImageBridgeChild is another CompositableForwarder.
      44             :  *
      45             :  * CompositableForwarder implements KnowsCompositor for simplicity as all
      46             :  * implementations of CompositableForwarder currently also implement KnowsCompositor.
      47             :  * This dependency could be split if we add new use cases.
      48             :  */
      49           5 : class CompositableForwarder : public KnowsCompositor
      50             : {
      51             : public:
      52             :   /**
      53             :    * Setup the IPDL actor for aCompositable to be part of layers
      54             :    * transactions.
      55             :    */
      56             :   virtual void Connect(CompositableClient* aCompositable,
      57             :                        ImageContainer* aImageContainer = nullptr) = 0;
      58             : 
      59             :   /**
      60             :    * Tell the CompositableHost on the compositor side what TiledLayerBuffer to
      61             :    * use for the next composition.
      62             :    */
      63             :   virtual void UseTiledLayerBuffer(CompositableClient* aCompositable,
      64             :                                    const SurfaceDescriptorTiles& aTiledDescriptor) = 0;
      65             : 
      66             :   /**
      67             :    * Communicate to the compositor that aRegion in the texture identified by
      68             :    * aCompositable and aIdentifier has been updated to aThebesBuffer.
      69             :    */
      70             :   virtual void UpdateTextureRegion(CompositableClient* aCompositable,
      71             :                                    const ThebesBufferData& aThebesBufferData,
      72             :                                    const nsIntRegion& aUpdatedRegion) = 0;
      73             : 
      74             :   virtual void ReleaseCompositable(const CompositableHandle& aHandle) = 0;
      75             :   virtual bool DestroyInTransaction(PTextureChild* aTexture) = 0;
      76             : 
      77             :   /**
      78             :    * Tell the CompositableHost on the compositor side to remove the texture
      79             :    * from the CompositableHost.
      80             :    * This function does not delete the TextureHost corresponding to the
      81             :    * TextureClient passed in parameter.
      82             :    * When the TextureClient has TEXTURE_DEALLOCATE_CLIENT flag,
      83             :    * the transaction becomes synchronous.
      84             :    */
      85             :   virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
      86             :                                              TextureClient* aTexture) = 0;
      87             : 
      88             :   struct TimedTextureClient {
      89          33 :     TimedTextureClient()
      90          33 :         : mTextureClient(nullptr), mFrameID(0), mProducerID(0) {}
      91             : 
      92             :     TextureClient* mTextureClient;
      93             :     TimeStamp mTimeStamp;
      94             :     nsIntRect mPictureRect;
      95             :     int32_t mFrameID;
      96             :     int32_t mProducerID;
      97             :   };
      98             :   /**
      99             :    * Tell the CompositableHost on the compositor side what textures to use for
     100             :    * the next composition.
     101             :    */
     102             :   virtual void UseTextures(CompositableClient* aCompositable,
     103             :                            const nsTArray<TimedTextureClient>& aTextures) = 0;
     104             :   virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
     105             :                                          TextureClient* aClientOnBlack,
     106             :                                          TextureClient* aClientOnWhite) = 0;
     107             : 
     108             :   virtual void UpdateFwdTransactionId() = 0;
     109             :   virtual uint64_t GetFwdTransactionId() = 0;
     110             : 
     111             :   virtual bool InForwarderThread() = 0;
     112             : 
     113         129 :   void AssertInForwarderThread() {
     114         129 :     MOZ_ASSERT(InForwarderThread());
     115         129 :   }
     116             : 
     117             :   static uint32_t GetMaxFileDescriptorsPerMessage();
     118             : 
     119           0 :   virtual ShadowLayerForwarder* AsLayerForwarder() { return nullptr; }
     120             : 
     121             : protected:
     122             :   nsTArray<RefPtr<TextureClient> > mTexturesToRemove;
     123             :   nsTArray<RefPtr<CompositableClient>> mCompositableClientsToRemove;
     124             : };
     125             : 
     126             : } // namespace layers
     127             : } // namespace mozilla
     128             : 
     129             : #endif

Generated by: LCOV version 1.13