|
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/. */ |
|
5 |
|
6 #ifndef gfx_layers_ipc_ImageBridgeParent_h_ |
|
7 #define gfx_layers_ipc_ImageBridgeParent_h_ |
|
8 |
|
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 |
|
20 |
|
21 class MessageLoop; |
|
22 |
|
23 namespace mozilla { |
|
24 namespace ipc { |
|
25 class Shmem; |
|
26 } |
|
27 |
|
28 namespace layers { |
|
29 |
|
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; |
|
41 |
|
42 ImageBridgeParent(MessageLoop* aLoop, Transport* aTransport); |
|
43 ~ImageBridgeParent(); |
|
44 |
|
45 virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE; |
|
46 |
|
47 virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; |
|
48 |
|
49 static PImageBridgeParent* |
|
50 Create(Transport* aTransport, ProcessId aOtherProcess); |
|
51 |
|
52 virtual PGrallocBufferParent* |
|
53 AllocPGrallocBufferParent(const IntSize&, const uint32_t&, const uint32_t&, |
|
54 MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE; |
|
55 |
|
56 virtual bool |
|
57 DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE; |
|
58 |
|
59 // PImageBridge |
|
60 virtual bool RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply) MOZ_OVERRIDE; |
|
61 virtual bool RecvUpdateNoSwap(const EditArray& aEdits) MOZ_OVERRIDE; |
|
62 |
|
63 virtual bool IsAsync() const MOZ_OVERRIDE { return true; } |
|
64 |
|
65 PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo, |
|
66 uint64_t*) MOZ_OVERRIDE; |
|
67 bool DeallocPCompositableParent(PCompositableParent* aActor) MOZ_OVERRIDE; |
|
68 |
|
69 virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData, |
|
70 const TextureFlags& aFlags) MOZ_OVERRIDE; |
|
71 virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE; |
|
72 |
|
73 // Shutdown step 1 |
|
74 virtual bool RecvWillStop() MOZ_OVERRIDE; |
|
75 // Shutdown step 2 |
|
76 virtual bool RecvStop() MOZ_OVERRIDE; |
|
77 |
|
78 MessageLoop * GetMessageLoop(); |
|
79 |
|
80 |
|
81 // ISurfaceAllocator |
|
82 |
|
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 } |
|
89 |
|
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 } |
|
96 |
|
97 void DeallocShmem(ipc::Shmem& aShmem) MOZ_OVERRIDE |
|
98 { |
|
99 PImageBridgeParent::DeallocShmem(aShmem); |
|
100 } |
|
101 |
|
102 virtual bool IsSameProcess() const MOZ_OVERRIDE; |
|
103 |
|
104 // Overriden from IToplevelProtocol |
|
105 IToplevelProtocol* |
|
106 CloneToplevel(const InfallibleTArray<ProtocolFdMapping>& aFds, |
|
107 base::ProcessHandle aPeerProcess, |
|
108 mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE; |
|
109 |
|
110 private: |
|
111 void DeferredDestroy(); |
|
112 |
|
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 }; |
|
119 |
|
120 } // layers |
|
121 } // mozilla |
|
122 |
|
123 #endif // gfx_layers_ipc_ImageBridgeParent_h_ |