michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 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 gfx_layers_ipc_ImageBridgeParent_h_ michael@0: #define gfx_layers_ipc_ImageBridgeParent_h_ michael@0: michael@0: #include // for size_t michael@0: #include // for uint32_t, uint64_t michael@0: #include "CompositableTransactionParent.h" michael@0: #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 michael@0: #include "mozilla/Attributes.h" // for MOZ_OVERRIDE michael@0: #include "mozilla/ipc/ProtocolUtils.h" michael@0: #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc michael@0: #include "mozilla/layers/PImageBridgeParent.h" michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: #include "nsISupportsImpl.h" michael@0: #include "nsTArrayForwardDeclare.h" // for InfallibleTArray michael@0: michael@0: class MessageLoop; michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: class Shmem; michael@0: } michael@0: michael@0: namespace layers { michael@0: michael@0: /** michael@0: * ImageBridgeParent is the manager Protocol of ImageContainerParent. michael@0: * It's purpose is mainly to setup the IPDL connection. Most of the michael@0: * interesting stuff is in ImageContainerParent. michael@0: */ michael@0: class ImageBridgeParent : public PImageBridgeParent, michael@0: public CompositableParentManager michael@0: { michael@0: public: michael@0: typedef InfallibleTArray EditArray; michael@0: typedef InfallibleTArray EditReplyArray; michael@0: michael@0: ImageBridgeParent(MessageLoop* aLoop, Transport* aTransport); michael@0: ~ImageBridgeParent(); michael@0: michael@0: virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE; michael@0: michael@0: virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: static PImageBridgeParent* michael@0: Create(Transport* aTransport, ProcessId aOtherProcess); michael@0: michael@0: virtual PGrallocBufferParent* michael@0: AllocPGrallocBufferParent(const IntSize&, const uint32_t&, const uint32_t&, michael@0: MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE; michael@0: michael@0: // PImageBridge michael@0: virtual bool RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply) MOZ_OVERRIDE; michael@0: virtual bool RecvUpdateNoSwap(const EditArray& aEdits) MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsAsync() const MOZ_OVERRIDE { return true; } michael@0: michael@0: PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo, michael@0: uint64_t*) MOZ_OVERRIDE; michael@0: bool DeallocPCompositableParent(PCompositableParent* aActor) 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: // Shutdown step 1 michael@0: virtual bool RecvWillStop() MOZ_OVERRIDE; michael@0: // Shutdown step 2 michael@0: virtual bool RecvStop() MOZ_OVERRIDE; michael@0: michael@0: MessageLoop * GetMessageLoop(); michael@0: michael@0: michael@0: // ISurfaceAllocator michael@0: michael@0: bool AllocShmem(size_t aSize, michael@0: ipc::SharedMemory::SharedMemoryType aType, michael@0: ipc::Shmem* aShmem) MOZ_OVERRIDE michael@0: { michael@0: return AllocShmem(aSize, aType, aShmem); michael@0: } michael@0: michael@0: bool AllocUnsafeShmem(size_t aSize, michael@0: ipc::SharedMemory::SharedMemoryType aType, michael@0: ipc::Shmem* aShmem) MOZ_OVERRIDE michael@0: { michael@0: return AllocUnsafeShmem(aSize, aType, aShmem); michael@0: } michael@0: michael@0: void DeallocShmem(ipc::Shmem& aShmem) MOZ_OVERRIDE michael@0: { michael@0: PImageBridgeParent::DeallocShmem(aShmem); michael@0: } michael@0: michael@0: virtual bool IsSameProcess() const MOZ_OVERRIDE; michael@0: michael@0: // Overriden from IToplevelProtocol michael@0: IToplevelProtocol* michael@0: CloneToplevel(const InfallibleTArray& aFds, michael@0: base::ProcessHandle aPeerProcess, michael@0: mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: void DeferredDestroy(); michael@0: michael@0: MessageLoop* mMessageLoop; michael@0: Transport* mTransport; michael@0: // This keeps us alive until ActorDestroy(), at which point we do a michael@0: // deferred destruction of ourselves. michael@0: nsRefPtr mSelfRef; michael@0: }; michael@0: michael@0: } // layers michael@0: } // mozilla michael@0: michael@0: #endif // gfx_layers_ipc_ImageBridgeParent_h_