1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef MOZILLA_LAYERS_COMPOSITABLETRANSACTIONPARENT_H
8 #define MOZILLA_LAYERS_COMPOSITABLETRANSACTIONPARENT_H
9 
10 #include <vector>                // for vector
11 #include "mozilla/Attributes.h"  // for override
12 #include "mozilla/NotNull.h"
13 #include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
14 #include "mozilla/layers/LayersMessages.h"     // for EditReply, etc
15 #include "mozilla/layers/TextureClient.h"
16 #include "CompositableHost.h"
17 
18 namespace mozilla {
19 namespace layers {
20 
21 // Since PCompositble has two potential manager protocols, we can't just call
22 // the Manager() method usually generated when there's one manager protocol,
23 // so both manager protocols implement this and we keep a reference to them
24 // through this interface.
25 class CompositableParentManager : public HostIPCAllocator {
26  public:
27   CompositableParentManager() = default;
28 
29   void DestroyActor(const OpDestroy& aOp);
30 
UpdateFwdTransactionId(uint64_t aTransactionId)31   void UpdateFwdTransactionId(uint64_t aTransactionId) {
32     MOZ_ASSERT(mFwdTransactionId < aTransactionId);
33     mFwdTransactionId = aTransactionId;
34   }
35 
GetFwdTransactionId()36   uint64_t GetFwdTransactionId() { return mFwdTransactionId; }
37 
38   RefPtr<CompositableHost> AddCompositable(const CompositableHandle& aHandle,
39                                            const TextureInfo& aInfo,
40                                            bool aUseWebRender);
41   RefPtr<CompositableHost> FindCompositable(
42       const CompositableHandle& aHandle, bool aAllowDisablingWebRender = false);
43 
44  protected:
45   /**
46    * Handle the IPDL messages that affect PCompositable actors.
47    */
48   bool ReceiveCompositableUpdate(const CompositableOperation& aEdit);
49   bool ReceiveCompositableUpdate(const CompositableOperationDetail& aDetail,
50                                  NotNull<CompositableHost*> aCompositable);
51 
52   void ReleaseCompositable(const CompositableHandle& aHandle);
53 
54   uint64_t mFwdTransactionId = 0;
55 
56   /**
57    * Mapping form IDs to CompositableHosts.
58    */
59   std::map<uint64_t, RefPtr<CompositableHost>> mCompositables;
60 };
61 
62 }  // namespace layers
63 }  // namespace mozilla
64 
65 #endif
66