gfx/layers/ipc/LayerTransactionParent.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:5caa50660cab
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=8 et :
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 #ifndef MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H
9 #define MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H
10
11 #include <stddef.h> // for size_t
12 #include <stdint.h> // for uint64_t, uint32_t
13 #include "CompositableTransactionParent.h"
14 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
15 #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
16 #include "mozilla/layers/PLayerTransactionParent.h"
17 #include "nsAutoPtr.h" // for nsRefPtr
18 #include "nsTArrayForwardDeclare.h" // for InfallibleTArray
19
20 class gfx3DMatrix;
21
22 namespace mozilla {
23
24 namespace ipc {
25 class Shmem;
26 }
27
28 namespace layout {
29 class RenderFrameParent;
30 }
31
32 namespace layers {
33
34 class Layer;
35 class LayerManagerComposite;
36 class ShadowLayerParent;
37 class CompositableParent;
38 class ShadowLayersManager;
39
40 class LayerTransactionParent : public PLayerTransactionParent,
41 public CompositableParentManager
42 {
43 typedef mozilla::layout::RenderFrameParent RenderFrameParent;
44 typedef InfallibleTArray<Edit> EditArray;
45 typedef InfallibleTArray<EditReply> EditReplyArray;
46
47 public:
48 LayerTransactionParent(LayerManagerComposite* aManager,
49 ShadowLayersManager* aLayersManager,
50 uint64_t aId);
51 ~LayerTransactionParent();
52
53 void Destroy();
54
55 LayerManagerComposite* layer_manager() const { return mLayerManager; }
56
57 uint64_t GetId() const { return mId; }
58 Layer* GetRoot() const { return mRoot; }
59
60 // ISurfaceAllocator
61 virtual bool AllocShmem(size_t aSize,
62 ipc::SharedMemory::SharedMemoryType aType,
63 ipc::Shmem* aShmem) {
64 return PLayerTransactionParent::AllocShmem(aSize, aType, aShmem);
65 }
66
67 virtual bool AllocUnsafeShmem(size_t aSize,
68 ipc::SharedMemory::SharedMemoryType aType,
69 ipc::Shmem* aShmem) {
70 return PLayerTransactionParent::AllocUnsafeShmem(aSize, aType, aShmem);
71 }
72
73 virtual void DeallocShmem(ipc::Shmem& aShmem) MOZ_OVERRIDE
74 {
75 PLayerTransactionParent::DeallocShmem(aShmem);
76 }
77
78 virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE;
79
80 virtual bool IsSameProcess() const MOZ_OVERRIDE;
81
82 protected:
83 virtual bool RecvUpdate(const EditArray& cset,
84 const TargetConfig& targetConfig,
85 const bool& isFirstPaint,
86 const bool& scheduleComposite,
87 EditReplyArray* reply) MOZ_OVERRIDE;
88
89 virtual bool RecvUpdateNoSwap(const EditArray& cset,
90 const TargetConfig& targetConfig,
91 const bool& isFirstPaint,
92 const bool& scheduleComposite) MOZ_OVERRIDE;
93
94 virtual bool RecvClearCachedResources() MOZ_OVERRIDE;
95 virtual bool RecvForceComposite() MOZ_OVERRIDE;
96 virtual bool RecvSetTestSampleTime(const TimeStamp& aTime) MOZ_OVERRIDE;
97 virtual bool RecvLeaveTestMode() MOZ_OVERRIDE;
98 virtual bool RecvGetOpacity(PLayerParent* aParent,
99 float* aOpacity) MOZ_OVERRIDE;
100 virtual bool RecvGetAnimationTransform(PLayerParent* aParent,
101 MaybeTransform* aTransform)
102 MOZ_OVERRIDE;
103 virtual bool RecvSetAsyncScrollOffset(PLayerParent* aLayer,
104 const int32_t& aX, const int32_t& aY) MOZ_OVERRIDE;
105
106 virtual PGrallocBufferParent*
107 AllocPGrallocBufferParent(const IntSize& aSize,
108 const uint32_t& aFormat, const uint32_t& aUsage,
109 MaybeMagicGrallocBufferHandle* aOutHandle) MOZ_OVERRIDE;
110 virtual bool
111 DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE;
112
113 virtual PLayerParent* AllocPLayerParent() MOZ_OVERRIDE;
114 virtual bool DeallocPLayerParent(PLayerParent* actor) MOZ_OVERRIDE;
115
116 virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE;
117 virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE;
118
119 virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
120 const TextureFlags& aFlags) MOZ_OVERRIDE;
121 virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE;
122
123 bool Attach(ShadowLayerParent* aLayerParent,
124 CompositableHost* aCompositable,
125 bool aIsAsyncVideo);
126
127 void AddIPDLReference() {
128 MOZ_ASSERT(mIPCOpen == false);
129 mIPCOpen = true;
130 AddRef();
131 }
132 void ReleaseIPDLReference() {
133 MOZ_ASSERT(mIPCOpen == true);
134 mIPCOpen = false;
135 Release();
136 }
137 friend class CompositorParent;
138 friend class CrossProcessCompositorParent;
139 friend class layout::RenderFrameParent;
140
141 private:
142 nsRefPtr<LayerManagerComposite> mLayerManager;
143 ShadowLayersManager* mShadowLayersManager;
144 // Hold the root because it might be grafted under various
145 // containers in the "real" layer tree
146 nsRefPtr<Layer> mRoot;
147 // When this is nonzero, it refers to a layer tree owned by the
148 // compositor thread. It is always true that
149 // mId != 0 => mRoot == null
150 // because the "real tree" is owned by the compositor.
151 uint64_t mId;
152 // When the widget/frame/browser stuff in this process begins its
153 // destruction process, we need to Disconnect() all the currently
154 // live shadow layers, because some of them might be orphaned from
155 // the layer tree. This happens in Destroy() above. After we
156 // Destroy() ourself, there's a window in which that information
157 // hasn't yet propagated back to the child side and it might still
158 // send us layer transactions. We want to ignore those transactions
159 // because they refer to "zombie layers" on this side. So, we track
160 // that state with |mDestroyed|. This is similar to, but separate
161 // from, |mLayerManager->IsDestroyed()|; we might have had Destroy()
162 // called on us but the mLayerManager might not be destroyed, or
163 // vice versa. In both cases though, we want to ignore shadow-layer
164 // transactions posted by the child.
165 bool mDestroyed;
166
167 bool mIPCOpen;
168 };
169
170 } // namespace layers
171 } // namespace mozilla
172
173 #endif // MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H

mercurial