VideoBridgeChild.h (3197B)
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 MOZILLA_GFX_VIDEOBRIDGECHILD_H 8 #define MOZILLA_GFX_VIDEOBRIDGECHILD_H 9 10 #include "mozilla/layers/PVideoBridgeChild.h" 11 #include "mozilla/layers/VideoBridgeUtils.h" 12 #include "ISurfaceAllocator.h" 13 #include "TextureForwarder.h" 14 15 namespace mozilla { 16 namespace layers { 17 18 class SynchronousTask; 19 20 class VideoBridgeChild final : public PVideoBridgeChild, 21 public TextureForwarder { 22 public: 23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoBridgeChild, override); 24 25 static void StartupForGPUProcess(); 26 static void Shutdown(); 27 28 static VideoBridgeChild* GetSingleton(); 29 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); 38 39 mozilla::ipc::IPCResult RecvPing(PingResolver&& aResolver); 40 41 void ActorDestroy(ActorDestroyReason aWhy) override; 42 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; 47 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; 54 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"); 60 } 61 62 // ISurfaceAllocator 63 bool IsSameProcess() const override; 64 65 bool CanSend() { return mCanSend; } 66 67 static void Open(Endpoint<PVideoBridgeChild>&& aEndpoint); 68 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); 78 79 private: 80 VideoBridgeChild(); 81 virtual ~VideoBridgeChild(); 82 83 nsCOMPtr<nsISerialEventTarget> mThread; 84 bool mCanSend; 85 }; 86 87 } // namespace layers 88 } // namespace mozilla 89 90 #endif