no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / gfx / layers / ipc / VideoBridgeChild.h
blobb72289e4b693573bc533b4d16d3da691ff8cab0f
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/. */
7 #ifndef MOZILLA_GFX_VIDEOBRIDGECHILD_H
8 #define MOZILLA_GFX_VIDEOBRIDGECHILD_H
10 #include "mozilla/layers/PVideoBridgeChild.h"
11 #include "mozilla/layers/VideoBridgeUtils.h"
12 #include "ISurfaceAllocator.h"
13 #include "TextureForwarder.h"
15 namespace mozilla {
16 namespace layers {
18 class SynchronousTask;
20 class VideoBridgeChild final : public PVideoBridgeChild,
21 public TextureForwarder {
22 public:
23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoBridgeChild, override);
25 static void StartupForGPUProcess();
26 static void Shutdown();
28 static VideoBridgeChild* GetSingleton();
30 // PVideoBridgeChild
31 PTextureChild* AllocPTextureChild(const SurfaceDescriptor& aSharedData,
32 ReadLockDescriptor& aReadLock,
33 const LayersBackend& aLayersBackend,
34 const TextureFlags& aFlags,
35 const dom::ContentParentId& aContentId,
36 const uint64_t& aSerial);
37 bool DeallocPTextureChild(PTextureChild* actor);
39 mozilla::ipc::IPCResult RecvPing(PingResolver&& aResolver);
41 void ActorDestroy(ActorDestroyReason aWhy) override;
43 // ISurfaceAllocator
44 bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override;
45 bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override;
46 bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
48 // TextureForwarder
49 PTextureChild* CreateTexture(
50 const SurfaceDescriptor& aSharedData, ReadLockDescriptor&& aReadLock,
51 LayersBackend aLayersBackend, TextureFlags aFlags,
52 const dom::ContentParentId& aContentId, uint64_t aSerial,
53 wr::MaybeExternalImageId& aExternalImageId) override;
55 // ClientIPCAllocator
56 base::ProcessId GetParentPid() const override { return OtherPid(); }
57 nsISerialEventTarget* GetThread() const override { return mThread; }
58 void CancelWaitForNotifyNotUsed(uint64_t aTextureId) override {
59 MOZ_ASSERT(false, "NO RECYCLING HERE");
62 // ISurfaceAllocator
63 bool IsSameProcess() const override;
65 bool CanSend() { return mCanSend; }
67 static void Open(Endpoint<PVideoBridgeChild>&& aEndpoint);
69 protected:
70 void HandleFatalError(const char* aMsg) override;
71 bool DispatchAllocShmemInternal(size_t aSize, mozilla::ipc::Shmem* aShmem,
72 bool aUnsafe);
73 void ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize,
74 mozilla::ipc::Shmem* aShmem, bool aUnsafe,
75 bool* aSuccess);
76 void ProxyDeallocShmemNow(SynchronousTask* aTask, mozilla::ipc::Shmem* aShmem,
77 bool* aResult);
79 private:
80 VideoBridgeChild();
81 virtual ~VideoBridgeChild();
83 nsCOMPtr<nsISerialEventTarget> mThread;
84 bool mCanSend;
87 } // namespace layers
88 } // namespace mozilla
90 #endif