Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef gfx_layers_ipc_ImageBridgeParent_h_
7 #define gfx_layers_ipc_ImageBridgeParent_h_
9 #include <stddef.h> // for size_t
10 #include <stdint.h> // for uint32_t, uint64_t
11 #include "CompositableTransactionParent.h"
12 #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
13 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
14 #include "mozilla/ipc/ProtocolUtils.h"
15 #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
16 #include "mozilla/layers/PImageBridgeParent.h"
17 #include "nsAutoPtr.h" // for nsRefPtr
18 #include "nsISupportsImpl.h"
19 #include "nsTArrayForwardDeclare.h" // for InfallibleTArray
21 class MessageLoop;
23 namespace mozilla {
24 namespace ipc {
25 class Shmem;
26 }
28 namespace layers {
30 /**
31 * ImageBridgeParent is the manager Protocol of ImageContainerParent.
32 * It's purpose is mainly to setup the IPDL connection. Most of the
33 * interesting stuff is in ImageContainerParent.
34 */
35 class ImageBridgeParent : public PImageBridgeParent,
36 public CompositableParentManager
37 {
38 public:
39 typedef InfallibleTArray<CompositableOperation> EditArray;
40 typedef InfallibleTArray<EditReply> EditReplyArray;
42 ImageBridgeParent(MessageLoop* aLoop, Transport* aTransport);
43 ~ImageBridgeParent();
45 virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE;
47 virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
49 static PImageBridgeParent*
50 Create(Transport* aTransport, ProcessId aOtherProcess);
52 virtual PGrallocBufferParent*
53 AllocPGrallocBufferParent(const IntSize&, const uint32_t&, const uint32_t&,
54 MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE;
56 virtual bool
57 DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE;
59 // PImageBridge
60 virtual bool RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply) MOZ_OVERRIDE;
61 virtual bool RecvUpdateNoSwap(const EditArray& aEdits) MOZ_OVERRIDE;
63 virtual bool IsAsync() const MOZ_OVERRIDE { return true; }
65 PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo,
66 uint64_t*) MOZ_OVERRIDE;
67 bool DeallocPCompositableParent(PCompositableParent* aActor) MOZ_OVERRIDE;
69 virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
70 const TextureFlags& aFlags) MOZ_OVERRIDE;
71 virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE;
73 // Shutdown step 1
74 virtual bool RecvWillStop() MOZ_OVERRIDE;
75 // Shutdown step 2
76 virtual bool RecvStop() MOZ_OVERRIDE;
78 MessageLoop * GetMessageLoop();
81 // ISurfaceAllocator
83 bool AllocShmem(size_t aSize,
84 ipc::SharedMemory::SharedMemoryType aType,
85 ipc::Shmem* aShmem) MOZ_OVERRIDE
86 {
87 return AllocShmem(aSize, aType, aShmem);
88 }
90 bool AllocUnsafeShmem(size_t aSize,
91 ipc::SharedMemory::SharedMemoryType aType,
92 ipc::Shmem* aShmem) MOZ_OVERRIDE
93 {
94 return AllocUnsafeShmem(aSize, aType, aShmem);
95 }
97 void DeallocShmem(ipc::Shmem& aShmem) MOZ_OVERRIDE
98 {
99 PImageBridgeParent::DeallocShmem(aShmem);
100 }
102 virtual bool IsSameProcess() const MOZ_OVERRIDE;
104 // Overriden from IToplevelProtocol
105 IToplevelProtocol*
106 CloneToplevel(const InfallibleTArray<ProtocolFdMapping>& aFds,
107 base::ProcessHandle aPeerProcess,
108 mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE;
110 private:
111 void DeferredDestroy();
113 MessageLoop* mMessageLoop;
114 Transport* mTransport;
115 // This keeps us alive until ActorDestroy(), at which point we do a
116 // deferred destruction of ourselves.
117 nsRefPtr<ImageBridgeParent> mSelfRef;
118 };
120 } // layers
121 } // mozilla
123 #endif // gfx_layers_ipc_ImageBridgeParent_h_