1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/ipc/LayerTransactionParent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,173 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H 1.12 +#define MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H 1.13 + 1.14 +#include <stddef.h> // for size_t 1.15 +#include <stdint.h> // for uint64_t, uint32_t 1.16 +#include "CompositableTransactionParent.h" 1.17 +#include "mozilla/Attributes.h" // for MOZ_OVERRIDE 1.18 +#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc 1.19 +#include "mozilla/layers/PLayerTransactionParent.h" 1.20 +#include "nsAutoPtr.h" // for nsRefPtr 1.21 +#include "nsTArrayForwardDeclare.h" // for InfallibleTArray 1.22 + 1.23 +class gfx3DMatrix; 1.24 + 1.25 +namespace mozilla { 1.26 + 1.27 +namespace ipc { 1.28 +class Shmem; 1.29 +} 1.30 + 1.31 +namespace layout { 1.32 +class RenderFrameParent; 1.33 +} 1.34 + 1.35 +namespace layers { 1.36 + 1.37 +class Layer; 1.38 +class LayerManagerComposite; 1.39 +class ShadowLayerParent; 1.40 +class CompositableParent; 1.41 +class ShadowLayersManager; 1.42 + 1.43 +class LayerTransactionParent : public PLayerTransactionParent, 1.44 + public CompositableParentManager 1.45 +{ 1.46 + typedef mozilla::layout::RenderFrameParent RenderFrameParent; 1.47 + typedef InfallibleTArray<Edit> EditArray; 1.48 + typedef InfallibleTArray<EditReply> EditReplyArray; 1.49 + 1.50 +public: 1.51 + LayerTransactionParent(LayerManagerComposite* aManager, 1.52 + ShadowLayersManager* aLayersManager, 1.53 + uint64_t aId); 1.54 + ~LayerTransactionParent(); 1.55 + 1.56 + void Destroy(); 1.57 + 1.58 + LayerManagerComposite* layer_manager() const { return mLayerManager; } 1.59 + 1.60 + uint64_t GetId() const { return mId; } 1.61 + Layer* GetRoot() const { return mRoot; } 1.62 + 1.63 + // ISurfaceAllocator 1.64 + virtual bool AllocShmem(size_t aSize, 1.65 + ipc::SharedMemory::SharedMemoryType aType, 1.66 + ipc::Shmem* aShmem) { 1.67 + return PLayerTransactionParent::AllocShmem(aSize, aType, aShmem); 1.68 + } 1.69 + 1.70 + virtual bool AllocUnsafeShmem(size_t aSize, 1.71 + ipc::SharedMemory::SharedMemoryType aType, 1.72 + ipc::Shmem* aShmem) { 1.73 + return PLayerTransactionParent::AllocUnsafeShmem(aSize, aType, aShmem); 1.74 + } 1.75 + 1.76 + virtual void DeallocShmem(ipc::Shmem& aShmem) MOZ_OVERRIDE 1.77 + { 1.78 + PLayerTransactionParent::DeallocShmem(aShmem); 1.79 + } 1.80 + 1.81 + virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE; 1.82 + 1.83 + virtual bool IsSameProcess() const MOZ_OVERRIDE; 1.84 + 1.85 +protected: 1.86 + virtual bool RecvUpdate(const EditArray& cset, 1.87 + const TargetConfig& targetConfig, 1.88 + const bool& isFirstPaint, 1.89 + const bool& scheduleComposite, 1.90 + EditReplyArray* reply) MOZ_OVERRIDE; 1.91 + 1.92 + virtual bool RecvUpdateNoSwap(const EditArray& cset, 1.93 + const TargetConfig& targetConfig, 1.94 + const bool& isFirstPaint, 1.95 + const bool& scheduleComposite) MOZ_OVERRIDE; 1.96 + 1.97 + virtual bool RecvClearCachedResources() MOZ_OVERRIDE; 1.98 + virtual bool RecvForceComposite() MOZ_OVERRIDE; 1.99 + virtual bool RecvSetTestSampleTime(const TimeStamp& aTime) MOZ_OVERRIDE; 1.100 + virtual bool RecvLeaveTestMode() MOZ_OVERRIDE; 1.101 + virtual bool RecvGetOpacity(PLayerParent* aParent, 1.102 + float* aOpacity) MOZ_OVERRIDE; 1.103 + virtual bool RecvGetAnimationTransform(PLayerParent* aParent, 1.104 + MaybeTransform* aTransform) 1.105 + MOZ_OVERRIDE; 1.106 + virtual bool RecvSetAsyncScrollOffset(PLayerParent* aLayer, 1.107 + const int32_t& aX, const int32_t& aY) MOZ_OVERRIDE; 1.108 + 1.109 + virtual PGrallocBufferParent* 1.110 + AllocPGrallocBufferParent(const IntSize& aSize, 1.111 + const uint32_t& aFormat, const uint32_t& aUsage, 1.112 + MaybeMagicGrallocBufferHandle* aOutHandle) MOZ_OVERRIDE; 1.113 + virtual bool 1.114 + DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE; 1.115 + 1.116 + virtual PLayerParent* AllocPLayerParent() MOZ_OVERRIDE; 1.117 + virtual bool DeallocPLayerParent(PLayerParent* actor) MOZ_OVERRIDE; 1.118 + 1.119 + virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE; 1.120 + virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE; 1.121 + 1.122 + virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData, 1.123 + const TextureFlags& aFlags) MOZ_OVERRIDE; 1.124 + virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE; 1.125 + 1.126 + bool Attach(ShadowLayerParent* aLayerParent, 1.127 + CompositableHost* aCompositable, 1.128 + bool aIsAsyncVideo); 1.129 + 1.130 + void AddIPDLReference() { 1.131 + MOZ_ASSERT(mIPCOpen == false); 1.132 + mIPCOpen = true; 1.133 + AddRef(); 1.134 + } 1.135 + void ReleaseIPDLReference() { 1.136 + MOZ_ASSERT(mIPCOpen == true); 1.137 + mIPCOpen = false; 1.138 + Release(); 1.139 + } 1.140 + friend class CompositorParent; 1.141 + friend class CrossProcessCompositorParent; 1.142 + friend class layout::RenderFrameParent; 1.143 + 1.144 +private: 1.145 + nsRefPtr<LayerManagerComposite> mLayerManager; 1.146 + ShadowLayersManager* mShadowLayersManager; 1.147 + // Hold the root because it might be grafted under various 1.148 + // containers in the "real" layer tree 1.149 + nsRefPtr<Layer> mRoot; 1.150 + // When this is nonzero, it refers to a layer tree owned by the 1.151 + // compositor thread. It is always true that 1.152 + // mId != 0 => mRoot == null 1.153 + // because the "real tree" is owned by the compositor. 1.154 + uint64_t mId; 1.155 + // When the widget/frame/browser stuff in this process begins its 1.156 + // destruction process, we need to Disconnect() all the currently 1.157 + // live shadow layers, because some of them might be orphaned from 1.158 + // the layer tree. This happens in Destroy() above. After we 1.159 + // Destroy() ourself, there's a window in which that information 1.160 + // hasn't yet propagated back to the child side and it might still 1.161 + // send us layer transactions. We want to ignore those transactions 1.162 + // because they refer to "zombie layers" on this side. So, we track 1.163 + // that state with |mDestroyed|. This is similar to, but separate 1.164 + // from, |mLayerManager->IsDestroyed()|; we might have had Destroy() 1.165 + // called on us but the mLayerManager might not be destroyed, or 1.166 + // vice versa. In both cases though, we want to ignore shadow-layer 1.167 + // transactions posted by the child. 1.168 + bool mDestroyed; 1.169 + 1.170 + bool mIPCOpen; 1.171 +}; 1.172 + 1.173 +} // namespace layers 1.174 +} // namespace mozilla 1.175 + 1.176 +#endif // MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H