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 MOZILLA_GFX_VIDEOBRIDGECHILD_H
7 : #define MOZILLA_GFX_VIDEOBRIDGECHILD_H
8 :
9 : #include "mozilla/layers/PVideoBridgeChild.h"
10 : #include "ISurfaceAllocator.h"
11 : #include "TextureForwarder.h"
12 :
13 : namespace mozilla {
14 : namespace layers {
15 :
16 : class VideoBridgeChild final : public PVideoBridgeChild
17 : , public TextureForwarder
18 : {
19 : public:
20 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoBridgeChild, override);
21 :
22 : static void Startup();
23 : static void Shutdown();
24 :
25 : static VideoBridgeChild* GetSingleton();
26 :
27 : // PVideoBridgeChild
28 : PTextureChild* AllocPTextureChild(const SurfaceDescriptor& aSharedData,
29 : const LayersBackend& aLayersBackend,
30 : const TextureFlags& aFlags,
31 : const uint64_t& aSerial) override;
32 : bool DeallocPTextureChild(PTextureChild* actor) override;
33 :
34 : void ActorDestroy(ActorDestroyReason aWhy) override;
35 : void DeallocPVideoBridgeChild() override;
36 :
37 :
38 : // ISurfaceAllocator
39 : bool AllocUnsafeShmem(size_t aSize,
40 : mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
41 : mozilla::ipc::Shmem* aShmem) override;
42 : bool AllocShmem(size_t aSize,
43 : mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
44 : mozilla::ipc::Shmem* aShmem) override;
45 : bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
46 :
47 : // TextureForwarder
48 : PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData,
49 : LayersBackend aLayersBackend,
50 : TextureFlags aFlags,
51 : uint64_t aSerial,
52 : wr::MaybeExternalImageId& aExternalImageId,
53 : nsIEventTarget* aTarget = nullptr) override;
54 :
55 : // ClientIPCAllocator
56 0 : base::ProcessId GetParentPid() const override { return OtherPid(); }
57 0 : MessageLoop * GetMessageLoop() const override { return mMessageLoop; }
58 0 : void CancelWaitForRecycle(uint64_t aTextureId) override { MOZ_ASSERT(false, "NO RECYCLING HERE"); }
59 :
60 : // ISurfaceAllocator
61 : bool IsSameProcess() const override;
62 :
63 0 : bool CanSend() { return mCanSend; }
64 :
65 : private:
66 : VideoBridgeChild();
67 : ~VideoBridgeChild();
68 :
69 : RefPtr<VideoBridgeChild> mIPDLSelfRef;
70 : MessageLoop* mMessageLoop;
71 : bool mCanSend;
72 : };
73 :
74 : } // namespace layers
75 : } // namespace mozilla
76 :
77 : #endif
|