LCOV - code coverage report
Current view: top level - gfx/layers/ipc - ImageBridgeParent.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 6 16.7 %
Date: 2017-07-14 16:53:18 Functions: 1 5 20.0 %
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 gfx_layers_ipc_ImageBridgeParent_h_
       7             : #define gfx_layers_ipc_ImageBridgeParent_h_
       8             : 
       9             : #include <stddef.h>                     // for size_t
      10             : #include <stdint.h>                     // for uint32_t, uint64_t
      11             : #include "CompositableTransactionParent.h"
      12             : #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
      13             : #include "mozilla/Attributes.h"         // for override
      14             : #include "mozilla/ipc/ProtocolUtils.h"
      15             : #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
      16             : #include "mozilla/layers/CompositorThread.h"
      17             : #include "mozilla/layers/PImageBridgeParent.h"
      18             : #include "nsISupportsImpl.h"
      19             : #include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
      20             : 
      21             : class MessageLoop;
      22             : 
      23             : namespace base {
      24             : class Thread;
      25             : } // namespace base
      26             : 
      27             : namespace mozilla {
      28             : namespace ipc {
      29             : class Shmem;
      30             : } // namespace ipc
      31             : 
      32             : namespace layers {
      33             : 
      34             : struct ImageCompositeNotificationInfo;
      35             : 
      36             : /**
      37             :  * ImageBridgeParent is the manager Protocol of async Compositables.
      38             :  */
      39             : class ImageBridgeParent final : public PImageBridgeParent,
      40             :                                 public CompositableParentManager,
      41             :                                 public ShmemAllocator
      42             : {
      43             : public:
      44             :   typedef InfallibleTArray<CompositableOperation> EditArray;
      45             :   typedef InfallibleTArray<OpDestroy> OpDestroyArray;
      46             : 
      47             : protected:
      48             :   ImageBridgeParent(MessageLoop* aLoop, ProcessId aChildProcessId);
      49             : 
      50             : public:
      51             :   ~ImageBridgeParent();
      52             : 
      53             :   /**
      54             :    * Creates the globals of ImageBridgeParent.
      55             :    */
      56             :   static void Setup();
      57             : 
      58             :   static ImageBridgeParent* CreateSameProcess();
      59             :   static bool CreateForGPUProcess(Endpoint<PImageBridgeParent>&& aEndpoint);
      60             :   static bool CreateForContent(Endpoint<PImageBridgeParent>&& aEndpoint);
      61             : 
      62           0 :   virtual ShmemAllocator* AsShmemAllocator() override { return this; }
      63             : 
      64             :   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
      65             : 
      66             :   // CompositableParentManager
      67             :   virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) override;
      68             : 
      69             :   virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override;
      70             : 
      71           0 :   virtual base::ProcessId GetChildProcessId() override
      72             :   {
      73           0 :     return OtherPid();
      74             :   }
      75             : 
      76             :   // PImageBridge
      77             :   virtual mozilla::ipc::IPCResult RecvImageBridgeThreadId(const PlatformThreadId& aThreadId) override;
      78             :   virtual mozilla::ipc::IPCResult RecvInitReadLocks(ReadLockArray&& aReadLocks) override;
      79             :   virtual mozilla::ipc::IPCResult RecvUpdate(EditArray&& aEdits, OpDestroyArray&& aToDestroy,
      80             :                                           const uint64_t& aFwdTransactionId) override;
      81             : 
      82             :   virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
      83             :                                               const LayersBackend& aLayersBackend,
      84             :                                               const TextureFlags& aFlags,
      85             :                                               const uint64_t& aSerial,
      86             :                                               const wr::MaybeExternalImageId& aExternalImageId) override;
      87             :   virtual bool DeallocPTextureParent(PTextureParent* actor) override;
      88             : 
      89             :   virtual mozilla::ipc::IPCResult RecvNewCompositable(const CompositableHandle& aHandle,
      90             :                                                       const TextureInfo& aInfo) override;
      91             :   virtual mozilla::ipc::IPCResult RecvReleaseCompositable(const CompositableHandle& aHandle) override;
      92             : 
      93             :   PMediaSystemResourceManagerParent* AllocPMediaSystemResourceManagerParent() override;
      94             :   bool DeallocPMediaSystemResourceManagerParent(PMediaSystemResourceManagerParent* aActor) override;
      95             : 
      96             :   // Shutdown step 1
      97             :   virtual mozilla::ipc::IPCResult RecvWillClose() override;
      98             : 
      99           1 :   MessageLoop* GetMessageLoop() const { return mMessageLoop; }
     100             : 
     101             :   // ShmemAllocator
     102             : 
     103             :   virtual bool AllocShmem(size_t aSize,
     104             :                           ipc::SharedMemory::SharedMemoryType aType,
     105             :                           ipc::Shmem* aShmem) override;
     106             : 
     107             :   virtual bool AllocUnsafeShmem(size_t aSize,
     108             :                                 ipc::SharedMemory::SharedMemoryType aType,
     109             :                                 ipc::Shmem* aShmem) override;
     110             : 
     111             :   virtual void DeallocShmem(ipc::Shmem& aShmem) override;
     112             : 
     113             :   virtual bool IsSameProcess() const override;
     114             : 
     115             :   static RefPtr<ImageBridgeParent> GetInstance(ProcessId aId);
     116             : 
     117             :   static bool NotifyImageComposites(nsTArray<ImageCompositeNotificationInfo>& aNotifications);
     118             : 
     119           0 :   virtual bool UsesImageBridge() const override { return true; }
     120             : 
     121           0 :   virtual bool IPCOpen() const override { return !mClosed; }
     122             : 
     123             : protected:
     124             :   void OnChannelConnected(int32_t pid) override;
     125             : 
     126             :   void Bind(Endpoint<PImageBridgeParent>&& aEndpoint);
     127             : 
     128             : private:
     129             :   void DeferredDestroy();
     130             :   MessageLoop* mMessageLoop;
     131             :   // This keeps us alive until ActorDestroy(), at which point we do a
     132             :   // deferred destruction of ourselves.
     133             :   RefPtr<ImageBridgeParent> mSelfRef;
     134             : 
     135             :   bool mSetChildThreadPriority;
     136             :   bool mClosed;
     137             : 
     138             :   /**
     139             :    * Map of all living ImageBridgeParent instances
     140             :    */
     141             :   static std::map<base::ProcessId, ImageBridgeParent*> sImageBridges;
     142             : 
     143             :   RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
     144             : };
     145             : 
     146             : } // namespace layers
     147             : } // namespace mozilla
     148             : 
     149             : #endif // gfx_layers_ipc_ImageBridgeParent_h_

Generated by: LCOV version 1.13