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"
18 class SynchronousTask
;
20 class VideoBridgeChild final
: public PVideoBridgeChild
,
21 public TextureForwarder
{
23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoBridgeChild
, override
);
25 static void StartupForGPUProcess();
26 static void Shutdown();
28 static VideoBridgeChild
* GetSingleton();
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
;
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
;
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
;
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");
63 bool IsSameProcess() const override
;
65 bool CanSend() { return mCanSend
; }
67 static void Open(Endpoint
<PVideoBridgeChild
>&& aEndpoint
);
70 void HandleFatalError(const char* aMsg
) override
;
71 bool DispatchAllocShmemInternal(size_t aSize
, mozilla::ipc::Shmem
* aShmem
,
73 void ProxyAllocShmemNow(SynchronousTask
* aTask
, size_t aSize
,
74 mozilla::ipc::Shmem
* aShmem
, bool aUnsafe
,
76 void ProxyDeallocShmemNow(SynchronousTask
* aTask
, mozilla::ipc::Shmem
* aShmem
,
81 virtual ~VideoBridgeChild();
83 nsCOMPtr
<nsISerialEventTarget
> mThread
;
88 } // namespace mozilla