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