LCOV - code coverage report
Current view: top level - gfx/layers/ipc - LayerTransactionParent.h (source / functions) Hit Total Coverage
Test: output.info Lines: 2 19 10.5 %
Date: 2018-08-07 16:35:00 Functions: 0 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_LAYERTRANSACTIONPARENT_H
       8             : #define MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H
       9             : 
      10             : #include <stddef.h>                     // for size_t
      11             : #include <stdint.h>                     // for uint64_t, uint32_t
      12             : #include "CompositableTransactionParent.h"
      13             : #include "mozilla/Attributes.h"         // for override
      14             : #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
      15             : #include "mozilla/layers/PLayerTransactionParent.h"
      16             : #include "nsRefPtrHashtable.h"
      17             : #include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
      18             : 
      19             : namespace mozilla {
      20             : 
      21             : namespace ipc {
      22             : class Shmem;
      23             : } // namespace ipc
      24             : 
      25             : namespace layout {
      26             : class RenderFrameParent;
      27             : } // namespace layout
      28             : 
      29             : namespace layers {
      30             : 
      31             : class Layer;
      32             : class HostLayerManager;
      33             : class ShadowLayerParent;
      34             : class CompositableParent;
      35             : class CompositorAnimationStorage;
      36             : class CompositorBridgeParentBase;
      37             : 
      38             : class LayerTransactionParent final : public PLayerTransactionParent,
      39             :                                      public CompositableParentManager,
      40             :                                      public ShmemAllocator
      41             : {
      42             :   typedef mozilla::layout::RenderFrameParent RenderFrameParent;
      43             :   typedef InfallibleTArray<Edit> EditArray;
      44             :   typedef InfallibleTArray<OpDestroy> OpDestroyArray;
      45             :   typedef InfallibleTArray<PluginWindowData> PluginsArray;
      46             : 
      47             : public:
      48             :   LayerTransactionParent(HostLayerManager* aManager,
      49             :                          CompositorBridgeParentBase* aBridge,
      50             :                          CompositorAnimationStorage* aAnimStorage,
      51             :                          LayersId aId);
      52             : 
      53             : protected:
      54             :   ~LayerTransactionParent();
      55             : 
      56             : public:
      57             :   void Destroy();
      58             : 
      59             :   void SetLayerManager(HostLayerManager* aLayerManager, CompositorAnimationStorage* aAnimStorage);
      60             : 
      61             :   LayersId GetId() const { return mId; }
      62           0 :   Layer* GetRoot() const { return mRoot; }
      63             : 
      64             :   uint64_t GetChildEpoch() const { return mChildEpoch; }
      65             :   bool ShouldParentObserveEpoch();
      66             : 
      67           0 :   ShmemAllocator* AsShmemAllocator() override { return this; }
      68             : 
      69             :   bool AllocShmem(size_t aSize,
      70             :                   ipc::SharedMemory::SharedMemoryType aType,
      71             :                   ipc::Shmem* aShmem) override;
      72             : 
      73             :   bool AllocUnsafeShmem(size_t aSize,
      74             :                         ipc::SharedMemory::SharedMemoryType aType,
      75             :                         ipc::Shmem* aShmem) override;
      76             : 
      77             :   void DeallocShmem(ipc::Shmem& aShmem) override;
      78             : 
      79             :   bool IsSameProcess() const override;
      80             : 
      81             :   const TransactionId& GetPendingTransactionId() { return mPendingTransaction; }
      82             :   void SetPendingTransactionId(TransactionId aId, const TimeStamp& aTxnStartTime, const TimeStamp& aFwdTime)
      83             :   {
      84           0 :     mPendingTransaction = aId;
      85           0 :     mTxnStartTime = aTxnStartTime;
      86           0 :     mFwdTime = aFwdTime;
      87             :   }
      88             :   TransactionId FlushTransactionId(TimeStamp& aCompositeEnd);
      89             : 
      90             :   // CompositableParentManager
      91             :   void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) override;
      92             : 
      93             :   void SendPendingAsyncMessages() override;
      94             : 
      95             :   void SetAboutToSendAsyncMessages() override;
      96             : 
      97             :   void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override;
      98             : 
      99           0 :   base::ProcessId GetChildProcessId() override
     100             :   {
     101           0 :     return OtherPid();
     102             :   }
     103             : 
     104             : protected:
     105             :   mozilla::ipc::IPCResult RecvShutdown() override;
     106             :   mozilla::ipc::IPCResult RecvShutdownSync() override;
     107             : 
     108             :   mozilla::ipc::IPCResult RecvPaintTime(const TransactionId& aTransactionId,
     109             :                                         const TimeDuration& aPaintTime) override;
     110             : 
     111             :   mozilla::ipc::IPCResult RecvUpdate(const TransactionInfo& aInfo) override;
     112             : 
     113             :   mozilla::ipc::IPCResult RecvSetLayerObserverEpoch(const uint64_t& aLayerObserverEpoch) override;
     114             :   mozilla::ipc::IPCResult RecvNewCompositable(const CompositableHandle& aHandle,
     115             :                                               const TextureInfo& aInfo) override;
     116             :   mozilla::ipc::IPCResult RecvReleaseLayer(const LayerHandle& aHandle) override;
     117             :   mozilla::ipc::IPCResult RecvReleaseCompositable(const CompositableHandle& aHandle) override;
     118             : 
     119             :   mozilla::ipc::IPCResult RecvClearCachedResources() override;
     120             :   mozilla::ipc::IPCResult RecvScheduleComposite() override;
     121             :   mozilla::ipc::IPCResult RecvSetTestSampleTime(const TimeStamp& aTime) override;
     122             :   mozilla::ipc::IPCResult RecvLeaveTestMode() override;
     123             :   mozilla::ipc::IPCResult RecvGetAnimationOpacity(const uint64_t& aCompositorAnimationsId,
     124             :                                                   float* aOpacity,
     125             :                                                   bool* aHasAnimationOpacity) override;
     126             :   mozilla::ipc::IPCResult RecvGetAnimationTransform(const uint64_t& aCompositorAnimationsId,
     127             :                                                     MaybeTransform* aTransform) override;
     128             :   mozilla::ipc::IPCResult RecvGetTransform(const LayerHandle& aHandle,
     129             :                                            MaybeTransform* aTransform) override;
     130             :   mozilla::ipc::IPCResult RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aId,
     131             :                                                    const float& aX, const float& aY) override;
     132             :   mozilla::ipc::IPCResult RecvSetAsyncZoom(const FrameMetrics::ViewID& aId,
     133             :                                            const float& aValue) override;
     134             :   mozilla::ipc::IPCResult RecvFlushApzRepaints() override;
     135             :   mozilla::ipc::IPCResult RecvGetAPZTestData(APZTestData* aOutData) override;
     136             :   mozilla::ipc::IPCResult RecvRequestProperty(const nsString& aProperty, float* aValue) override;
     137             :   mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC(const uint64_t& aBlockId,
     138             :                                                      nsTArray<ScrollableLayerGuid>&& aTargets) override;
     139             :   mozilla::ipc::IPCResult RecvRecordPaintTimes(const PaintTiming& aTiming) override;
     140             :   mozilla::ipc::IPCResult RecvGetTextureFactoryIdentifier(TextureFactoryIdentifier* aIdentifier) override;
     141             : 
     142             :   bool SetLayerAttributes(const OpSetLayerAttributes& aOp);
     143             : 
     144             :   void ActorDestroy(ActorDestroyReason why) override;
     145             : 
     146             :   template <typename T>
     147           7 :   bool BindLayer(const RefPtr<Layer>& aLayer, const T& aCreateOp) {
     148           7 :     return BindLayerToHandle(aLayer, aCreateOp.layer());
     149             :   }
     150             : 
     151             :   bool BindLayerToHandle(RefPtr<Layer> aLayer, const LayerHandle& aHandle);
     152             : 
     153             :   Layer* AsLayer(const LayerHandle& aLayer);
     154             : 
     155             :   bool Attach(Layer* aLayer, CompositableHost* aCompositable, bool aIsAsyncVideo);
     156             : 
     157           0 :   void AddIPDLReference() {
     158           0 :     MOZ_ASSERT(mIPCOpen == false);
     159           0 :     mIPCOpen = true;
     160           0 :     AddRef();
     161           0 :   }
     162           0 :   void ReleaseIPDLReference() {
     163           0 :     MOZ_ASSERT(mIPCOpen == true);
     164           0 :     mIPCOpen = false;
     165           0 :     Release();
     166           0 :   }
     167             :   friend class CompositorBridgeParent;
     168             :   friend class CrossProcessCompositorBridgeParent;
     169             :   friend class layout::RenderFrameParent;
     170             : 
     171             : private:
     172             :   // This is a function so we can log or breakpoint on why hit
     173             :   // testing tree changes are made.
     174             :   void UpdateHitTestingTree(Layer* aLayer, const char* aWhy) {
     175             :     mUpdateHitTestingTree = true;
     176             :   }
     177             : 
     178             : private:
     179             :   RefPtr<HostLayerManager> mLayerManager;
     180             :   CompositorBridgeParentBase* mCompositorBridge;
     181             :   RefPtr<CompositorAnimationStorage> mAnimStorage;
     182             : 
     183             :   // Hold the root because it might be grafted under various
     184             :   // containers in the "real" layer tree
     185             :   RefPtr<Layer> mRoot;
     186             : 
     187             :   // Mapping from LayerHandles to Layers.
     188             :   nsRefPtrHashtable<nsUint64HashKey, Layer> mLayerMap;
     189             : 
     190             :   LayersId mId;
     191             : 
     192             :   // These fields keep track of the latest epoch values in the child and the
     193             :   // parent. mChildEpoch is the latest epoch value received from the child.
     194             :   // mParentEpoch is the latest epoch value that we have told TabParent about
     195             :   // (via ObserveLayerUpdate).
     196             :   uint64_t mChildEpoch;
     197             :   uint64_t mParentEpoch;
     198             : 
     199             :   TransactionId mPendingTransaction;
     200             :   TimeStamp mTxnStartTime;
     201             :   TimeStamp mFwdTime;
     202             : 
     203             :   // When the widget/frame/browser stuff in this process begins its
     204             :   // destruction process, we need to Disconnect() all the currently
     205             :   // live shadow layers, because some of them might be orphaned from
     206             :   // the layer tree.  This happens in Destroy() above.  After we
     207             :   // Destroy() ourself, there's a window in which that information
     208             :   // hasn't yet propagated back to the child side and it might still
     209             :   // send us layer transactions.  We want to ignore those transactions
     210             :   // because they refer to "zombie layers" on this side.  So, we track
     211             :   // that state with |mDestroyed|.  This is similar to, but separate
     212             :   // from, |mLayerManager->IsDestroyed()|; we might have had Destroy()
     213             :   // called on us but the mLayerManager might not be destroyed, or
     214             :   // vice versa.  In both cases though, we want to ignore shadow-layer
     215             :   // transactions posted by the child.
     216             : 
     217             :   bool mDestroyed;
     218             :   bool mIPCOpen;
     219             : 
     220             :   // This is set during RecvUpdate to track whether we'll need to update
     221             :   // APZ's hit test regions.
     222             :   bool mUpdateHitTestingTree;
     223             : };
     224             : 
     225             : } // namespace layers
     226             : } // namespace mozilla
     227             : 
     228             : #endif // MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H

Generated by: LCOV version 1.13-14-ga5dd952