gfx/layers/ipc/LayerTransactionParent.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial