gfx/layers/ipc/LayerTransactionParent.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=8 et :
     3  */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #ifndef MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H
     9 #define MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H
    11 #include <stddef.h>                     // for size_t
    12 #include <stdint.h>                     // for uint64_t, uint32_t
    13 #include "CompositableTransactionParent.h"
    14 #include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
    15 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
    16 #include "mozilla/layers/PLayerTransactionParent.h"
    17 #include "nsAutoPtr.h"                  // for nsRefPtr
    18 #include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
    20 class gfx3DMatrix;
    22 namespace mozilla {
    24 namespace ipc {
    25 class Shmem;
    26 }
    28 namespace layout {
    29 class RenderFrameParent;
    30 }
    32 namespace layers {
    34 class Layer;
    35 class LayerManagerComposite;
    36 class ShadowLayerParent;
    37 class CompositableParent;
    38 class ShadowLayersManager;
    40 class LayerTransactionParent : public PLayerTransactionParent,
    41                                public CompositableParentManager
    42 {
    43   typedef mozilla::layout::RenderFrameParent RenderFrameParent;
    44   typedef InfallibleTArray<Edit> EditArray;
    45   typedef InfallibleTArray<EditReply> EditReplyArray;
    47 public:
    48   LayerTransactionParent(LayerManagerComposite* aManager,
    49                          ShadowLayersManager* aLayersManager,
    50                          uint64_t aId);
    51   ~LayerTransactionParent();
    53   void Destroy();
    55   LayerManagerComposite* layer_manager() const { return mLayerManager; }
    57   uint64_t GetId() const { return mId; }
    58   Layer* GetRoot() const { return mRoot; }
    60   // ISurfaceAllocator
    61   virtual bool AllocShmem(size_t aSize,
    62                           ipc::SharedMemory::SharedMemoryType aType,
    63                           ipc::Shmem* aShmem) {
    64     return PLayerTransactionParent::AllocShmem(aSize, aType, aShmem);
    65   }
    67   virtual bool AllocUnsafeShmem(size_t aSize,
    68                                 ipc::SharedMemory::SharedMemoryType aType,
    69                                 ipc::Shmem* aShmem) {
    70     return PLayerTransactionParent::AllocUnsafeShmem(aSize, aType, aShmem);
    71   }
    73   virtual void DeallocShmem(ipc::Shmem& aShmem) MOZ_OVERRIDE
    74   {
    75     PLayerTransactionParent::DeallocShmem(aShmem);
    76   }
    78   virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE;
    80   virtual bool IsSameProcess() const MOZ_OVERRIDE;
    82 protected:
    83   virtual bool RecvUpdate(const EditArray& cset,
    84                           const TargetConfig& targetConfig,
    85                           const bool& isFirstPaint,
    86                           const bool& scheduleComposite,
    87                           EditReplyArray* reply) MOZ_OVERRIDE;
    89   virtual bool RecvUpdateNoSwap(const EditArray& cset,
    90                                 const TargetConfig& targetConfig,
    91                                 const bool& isFirstPaint,
    92                                 const bool& scheduleComposite) MOZ_OVERRIDE;
    94   virtual bool RecvClearCachedResources() MOZ_OVERRIDE;
    95   virtual bool RecvForceComposite() MOZ_OVERRIDE;
    96   virtual bool RecvSetTestSampleTime(const TimeStamp& aTime) MOZ_OVERRIDE;
    97   virtual bool RecvLeaveTestMode() MOZ_OVERRIDE;
    98   virtual bool RecvGetOpacity(PLayerParent* aParent,
    99                               float* aOpacity) MOZ_OVERRIDE;
   100   virtual bool RecvGetAnimationTransform(PLayerParent* aParent,
   101                                          MaybeTransform* aTransform)
   102                                          MOZ_OVERRIDE;
   103   virtual bool RecvSetAsyncScrollOffset(PLayerParent* aLayer,
   104                                         const int32_t& aX, const int32_t& aY) MOZ_OVERRIDE;
   106   virtual PGrallocBufferParent*
   107   AllocPGrallocBufferParent(const IntSize& aSize,
   108                             const uint32_t& aFormat, const uint32_t& aUsage,
   109                             MaybeMagicGrallocBufferHandle* aOutHandle) MOZ_OVERRIDE;
   110   virtual bool
   111   DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE;
   113   virtual PLayerParent* AllocPLayerParent() MOZ_OVERRIDE;
   114   virtual bool DeallocPLayerParent(PLayerParent* actor) MOZ_OVERRIDE;
   116   virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE;
   117   virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE;
   119   virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
   120                                               const TextureFlags& aFlags) MOZ_OVERRIDE;
   121   virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE;
   123   bool Attach(ShadowLayerParent* aLayerParent,
   124               CompositableHost* aCompositable,
   125               bool aIsAsyncVideo);
   127   void AddIPDLReference() {
   128     MOZ_ASSERT(mIPCOpen == false);
   129     mIPCOpen = true;
   130     AddRef();
   131   }
   132   void ReleaseIPDLReference() {
   133     MOZ_ASSERT(mIPCOpen == true);
   134     mIPCOpen = false;
   135     Release();
   136   }
   137   friend class CompositorParent;
   138   friend class CrossProcessCompositorParent;
   139   friend class layout::RenderFrameParent;
   141 private:
   142   nsRefPtr<LayerManagerComposite> mLayerManager;
   143   ShadowLayersManager* mShadowLayersManager;
   144   // Hold the root because it might be grafted under various
   145   // containers in the "real" layer tree
   146   nsRefPtr<Layer> mRoot;
   147   // When this is nonzero, it refers to a layer tree owned by the
   148   // compositor thread.  It is always true that
   149   //   mId != 0 => mRoot == null
   150   // because the "real tree" is owned by the compositor.
   151   uint64_t mId;
   152   // When the widget/frame/browser stuff in this process begins its
   153   // destruction process, we need to Disconnect() all the currently
   154   // live shadow layers, because some of them might be orphaned from
   155   // the layer tree.  This happens in Destroy() above.  After we
   156   // Destroy() ourself, there's a window in which that information
   157   // hasn't yet propagated back to the child side and it might still
   158   // send us layer transactions.  We want to ignore those transactions
   159   // because they refer to "zombie layers" on this side.  So, we track
   160   // that state with |mDestroyed|.  This is similar to, but separate
   161   // from, |mLayerManager->IsDestroyed()|; we might have had Destroy()
   162   // called on us but the mLayerManager might not be destroyed, or
   163   // vice versa.  In both cases though, we want to ignore shadow-layer
   164   // transactions posted by the child.
   165   bool mDestroyed;
   167   bool mIPCOpen;
   168 };
   170 } // namespace layers
   171 } // namespace mozilla
   173 #endif // MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H

mercurial