Line data Source code
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_VideoBridgeParent_h_
7 : #define gfx_layers_ipc_VideoBridgeParent_h_
8 :
9 : #include "mozilla/layers/PVideoBridgeParent.h"
10 : #include "mozilla/layers/ISurfaceAllocator.h"
11 :
12 : namespace mozilla {
13 : namespace layers {
14 :
15 : class CompositorThreadHolder;
16 :
17 : class VideoBridgeParent final : public PVideoBridgeParent,
18 : public HostIPCAllocator,
19 : public ShmemAllocator
20 : {
21 : public:
22 : VideoBridgeParent();
23 : ~VideoBridgeParent();
24 :
25 : static VideoBridgeParent* GetSingleton();
26 : TextureHost* LookupTexture(uint64_t aSerial);
27 :
28 : // PVideoBridgeParent
29 : void ActorDestroy(ActorDestroyReason aWhy) override;
30 : PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
31 : const LayersBackend& aLayersBackend,
32 : const TextureFlags& aFlags,
33 : const uint64_t& aSerial) override;
34 : bool DeallocPTextureParent(PTextureParent* actor) override;
35 :
36 : // HostIPCAllocator
37 0 : base::ProcessId GetChildProcessId() override
38 : {
39 0 : return OtherPid();
40 : }
41 : void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override;
42 : void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) override;
43 :
44 : // ISurfaceAllocator
45 0 : ShmemAllocator* AsShmemAllocator() override { return this; }
46 : bool IsSameProcess() const override;
47 0 : bool IPCOpen() const override { return !mClosed; }
48 :
49 : // ShmemAllocator
50 : bool AllocShmem(size_t aSize,
51 : ipc::SharedMemory::SharedMemoryType aType,
52 : ipc::Shmem* aShmem) override;
53 :
54 : bool AllocUnsafeShmem(size_t aSize,
55 : ipc::SharedMemory::SharedMemoryType aType,
56 : ipc::Shmem* aShmem) override;
57 :
58 : void DeallocShmem(ipc::Shmem& aShmem) override;
59 :
60 : private:
61 : void DeallocPVideoBridgeParent() override;
62 :
63 : // This keeps us alive until ActorDestroy(), at which point we do a
64 : // deferred destruction of ourselves.
65 : RefPtr<VideoBridgeParent> mSelfRef;
66 : RefPtr<CompositorThreadHolder> mCompositorThreadRef;
67 :
68 : std::map<uint64_t, PTextureParent*> mTextureMap;
69 :
70 : bool mClosed;
71 : };
72 :
73 : } // namespace layers
74 : } // namespace mozilla
75 :
76 : #endif // gfx_layers_ipc_VideoBridgeParent_h_
|