michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H michael@0: #define MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H michael@0: michael@0: #include // for size_t michael@0: #include // for uint64_t, uint32_t michael@0: #include "CompositableTransactionParent.h" michael@0: #include "mozilla/Attributes.h" // for MOZ_OVERRIDE michael@0: #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc michael@0: #include "mozilla/layers/PLayerTransactionParent.h" michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: #include "nsTArrayForwardDeclare.h" // for InfallibleTArray michael@0: michael@0: class gfx3DMatrix; michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace ipc { michael@0: class Shmem; michael@0: } michael@0: michael@0: namespace layout { michael@0: class RenderFrameParent; michael@0: } michael@0: michael@0: namespace layers { michael@0: michael@0: class Layer; michael@0: class LayerManagerComposite; michael@0: class ShadowLayerParent; michael@0: class CompositableParent; michael@0: class ShadowLayersManager; michael@0: michael@0: class LayerTransactionParent : public PLayerTransactionParent, michael@0: public CompositableParentManager michael@0: { michael@0: typedef mozilla::layout::RenderFrameParent RenderFrameParent; michael@0: typedef InfallibleTArray EditArray; michael@0: typedef InfallibleTArray EditReplyArray; michael@0: michael@0: public: michael@0: LayerTransactionParent(LayerManagerComposite* aManager, michael@0: ShadowLayersManager* aLayersManager, michael@0: uint64_t aId); michael@0: ~LayerTransactionParent(); michael@0: michael@0: void Destroy(); michael@0: michael@0: LayerManagerComposite* layer_manager() const { return mLayerManager; } michael@0: michael@0: uint64_t GetId() const { return mId; } michael@0: Layer* GetRoot() const { return mRoot; } michael@0: michael@0: // ISurfaceAllocator michael@0: virtual bool AllocShmem(size_t aSize, michael@0: ipc::SharedMemory::SharedMemoryType aType, michael@0: ipc::Shmem* aShmem) { michael@0: return PLayerTransactionParent::AllocShmem(aSize, aType, aShmem); michael@0: } michael@0: michael@0: virtual bool AllocUnsafeShmem(size_t aSize, michael@0: ipc::SharedMemory::SharedMemoryType aType, michael@0: ipc::Shmem* aShmem) { michael@0: return PLayerTransactionParent::AllocUnsafeShmem(aSize, aType, aShmem); michael@0: } michael@0: michael@0: virtual void DeallocShmem(ipc::Shmem& aShmem) MOZ_OVERRIDE michael@0: { michael@0: PLayerTransactionParent::DeallocShmem(aShmem); michael@0: } michael@0: michael@0: virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsSameProcess() const MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: virtual bool RecvUpdate(const EditArray& cset, michael@0: const TargetConfig& targetConfig, michael@0: const bool& isFirstPaint, michael@0: const bool& scheduleComposite, michael@0: EditReplyArray* reply) MOZ_OVERRIDE; michael@0: michael@0: virtual bool RecvUpdateNoSwap(const EditArray& cset, michael@0: const TargetConfig& targetConfig, michael@0: const bool& isFirstPaint, michael@0: const bool& scheduleComposite) MOZ_OVERRIDE; michael@0: michael@0: virtual bool RecvClearCachedResources() MOZ_OVERRIDE; michael@0: virtual bool RecvForceComposite() MOZ_OVERRIDE; michael@0: virtual bool RecvSetTestSampleTime(const TimeStamp& aTime) MOZ_OVERRIDE; michael@0: virtual bool RecvLeaveTestMode() MOZ_OVERRIDE; michael@0: virtual bool RecvGetOpacity(PLayerParent* aParent, michael@0: float* aOpacity) MOZ_OVERRIDE; michael@0: virtual bool RecvGetAnimationTransform(PLayerParent* aParent, michael@0: MaybeTransform* aTransform) michael@0: MOZ_OVERRIDE; michael@0: virtual bool RecvSetAsyncScrollOffset(PLayerParent* aLayer, michael@0: const int32_t& aX, const int32_t& aY) MOZ_OVERRIDE; michael@0: michael@0: virtual PGrallocBufferParent* michael@0: AllocPGrallocBufferParent(const IntSize& aSize, michael@0: const uint32_t& aFormat, const uint32_t& aUsage, michael@0: MaybeMagicGrallocBufferHandle* aOutHandle) MOZ_OVERRIDE; michael@0: virtual bool michael@0: DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE; michael@0: michael@0: virtual PLayerParent* AllocPLayerParent() MOZ_OVERRIDE; michael@0: virtual bool DeallocPLayerParent(PLayerParent* actor) MOZ_OVERRIDE; michael@0: michael@0: virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE; michael@0: virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE; michael@0: michael@0: virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData, michael@0: const TextureFlags& aFlags) MOZ_OVERRIDE; michael@0: virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE; michael@0: michael@0: bool Attach(ShadowLayerParent* aLayerParent, michael@0: CompositableHost* aCompositable, michael@0: bool aIsAsyncVideo); michael@0: michael@0: void AddIPDLReference() { michael@0: MOZ_ASSERT(mIPCOpen == false); michael@0: mIPCOpen = true; michael@0: AddRef(); michael@0: } michael@0: void ReleaseIPDLReference() { michael@0: MOZ_ASSERT(mIPCOpen == true); michael@0: mIPCOpen = false; michael@0: Release(); michael@0: } michael@0: friend class CompositorParent; michael@0: friend class CrossProcessCompositorParent; michael@0: friend class layout::RenderFrameParent; michael@0: michael@0: private: michael@0: nsRefPtr mLayerManager; michael@0: ShadowLayersManager* mShadowLayersManager; michael@0: // Hold the root because it might be grafted under various michael@0: // containers in the "real" layer tree michael@0: nsRefPtr mRoot; michael@0: // When this is nonzero, it refers to a layer tree owned by the michael@0: // compositor thread. It is always true that michael@0: // mId != 0 => mRoot == null michael@0: // because the "real tree" is owned by the compositor. michael@0: uint64_t mId; michael@0: // When the widget/frame/browser stuff in this process begins its michael@0: // destruction process, we need to Disconnect() all the currently michael@0: // live shadow layers, because some of them might be orphaned from michael@0: // the layer tree. This happens in Destroy() above. After we michael@0: // Destroy() ourself, there's a window in which that information michael@0: // hasn't yet propagated back to the child side and it might still michael@0: // send us layer transactions. We want to ignore those transactions michael@0: // because they refer to "zombie layers" on this side. So, we track michael@0: // that state with |mDestroyed|. This is similar to, but separate michael@0: // from, |mLayerManager->IsDestroyed()|; we might have had Destroy() michael@0: // called on us but the mLayerManager might not be destroyed, or michael@0: // vice versa. In both cases though, we want to ignore shadow-layer michael@0: // transactions posted by the child. michael@0: bool mDestroyed; michael@0: michael@0: bool mIPCOpen; michael@0: }; michael@0: michael@0: } // namespace layers michael@0: } // namespace mozilla michael@0: michael@0: #endif // MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H