diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 005efe8ed960..9273c20345c9 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1059,6 +1059,13 @@ ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch, return true; } +bool +ContentParent::RecvInitVideoDecoderManager(Endpoint* aEndpoint) +{ + GPUProcessManager::Get()->CreateContentVideoDecoderManager(OtherPid(), aEndpoint); + return true; +} + /*static*/ TabParent* ContentParent::CreateBrowserOrApp(const TabContext& aContext, Element* aFrameElement, diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index d579e5c377e8..8192f61a152d 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -271,6 +271,8 @@ public: nsTArray* aPlugins, uint32_t* aNewPluginEpoch) override; + virtual bool RecvInitVideoDecoderManager(Endpoint* endpoint) override; + virtual bool RecvUngrabPointer(const uint32_t& aTime) override; virtual bool RecvRemovePermission(const IPC::Principal& aPrincipal, diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 09b6eeb1775b..3703183c1238 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -56,6 +56,7 @@ include protocol PWebBrowserPersistDocument; include protocol PWebrtcGlobal; include protocol PPresentation; include protocol PVRManager; +include protocol PVideoDecoderManager; include protocol PFlyWebPublishedServer; include DOMTypes; include JavaScriptTypes; @@ -788,6 +789,8 @@ parent: sync PCrashReporter(NativeThreadId tid, uint32_t processType); + sync InitVideoDecoderManager() returns (Endpoint endpoint); + /** * Is this token compatible with the provided version? * diff --git a/dom/media/ipc/PVideoDecoderManager.ipdl b/dom/media/ipc/PVideoDecoderManager.ipdl new file mode 100644 index 000000000000..1f95771c3ac5 --- /dev/null +++ b/dom/media/ipc/PVideoDecoderManager.ipdl @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +include LayersSurfaces; +include "mozilla/dom/MediaIPCUtils.h"; + +namespace mozilla { +namespace dom { + +async protocol PVideoDecoderManager +{ +parent: + + async DeallocateSurfaceDescriptorGPUVideo(SurfaceDescriptorGPUVideo sd); +}; + +} // namespace dom +} // namespace mozilla diff --git a/dom/media/ipc/VideoDecoderManagerChild.cpp b/dom/media/ipc/VideoDecoderManagerChild.cpp new file mode 100644 index 000000000000..d6260bda0448 --- /dev/null +++ b/dom/media/ipc/VideoDecoderManagerChild.cpp @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "VideoDecoderManagerChild.h" +#include "mozilla/dom/ContentChild.h" +#include "MediaPrefs.h" +#include "nsThreadUtils.h" + +namespace mozilla { +namespace dom { + +using namespace ipc; +using namespace layers; +using namespace gfx; + +StaticRefPtr sVideoDecoderChildThread; +static StaticRefPtr sDecoderManager; + +/* static */ void +VideoDecoderManagerChild::Initialize() +{ + MOZ_ASSERT(NS_IsMainThread()); + + MediaPrefs::GetSingleton(); + +#ifdef XP_WIN + if (!MediaPrefs::PDMUseGPUDecoder()) { + return; + } + + // Can't run remote video decoding in the parent process. + if (!ContentChild::GetSingleton()) { + return; + } + + if (!sVideoDecoderChildThread) { + RefPtr childThread; + nsresult rv = NS_NewNamedThread("VideoChild", getter_AddRefs(childThread)); + NS_ENSURE_SUCCESS_VOID(rv); + sVideoDecoderChildThread = childThread; + } + + Endpoint endpoint; + if (!ContentChild::GetSingleton()->SendInitVideoDecoderManager(&endpoint)) { + return; + } + + // TODO: The above message should return an empty endpoint if there wasn't a GPU + // process. Unfortunately IPDL will assert in this case, so it can't actually + // happen. Bug 1302009 is filed for fixing this. + + sDecoderManager = new VideoDecoderManagerChild(); + + RefPtr task = NewRunnableMethod&&>( + sDecoderManager, &VideoDecoderManagerChild::Open, Move(endpoint)); + sVideoDecoderChildThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL); +#else + return; +#endif + +} + +/* static */ void +VideoDecoderManagerChild::Shutdown() +{ + MOZ_ASSERT(NS_IsMainThread()); + + if (sVideoDecoderChildThread) { + MOZ_ASSERT(sDecoderManager); + + sVideoDecoderChildThread->Dispatch(NS_NewRunnableFunction([]() { + sDecoderManager->Close(); + }), NS_DISPATCH_SYNC); + + sDecoderManager = nullptr; + + sVideoDecoderChildThread->Shutdown(); + sVideoDecoderChildThread = nullptr; + } +} + +/* static */ VideoDecoderManagerChild* +VideoDecoderManagerChild::GetSingleton() +{ + return sDecoderManager; +} + +void +VideoDecoderManagerChild::Open(Endpoint&& aEndpoint) +{ + if (!aEndpoint.Bind(this)) { + // We can't recover from this. + MOZ_CRASH("Failed to bind VideoDecoderChild to endpoint"); + } + AddRef(); +} + +void +VideoDecoderManagerChild::DeallocPVideoDecoderManagerChild() +{ + Release(); +} + +void +VideoDecoderManagerChild::DeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) +{ + RefPtr ref = this; + SurfaceDescriptorGPUVideo sd = Move(aSD); + sVideoDecoderChildThread->Dispatch(NS_NewRunnableFunction([ref, sd]() { + ref->SendDeallocateSurfaceDescriptorGPUVideo(sd); + }), NS_DISPATCH_NORMAL); +} + +} // namespace dom +} // namespace mozilla diff --git a/dom/media/ipc/VideoDecoderManagerChild.h b/dom/media/ipc/VideoDecoderManagerChild.h new file mode 100644 index 000000000000..0310e2e46f1d --- /dev/null +++ b/dom/media/ipc/VideoDecoderManagerChild.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef include_dom_ipc_VideoDecoderManagerChild_h +#define include_dom_ipc_VideoDecoderManagerChild_h + +#include "mozilla/RefPtr.h" +#include "mozilla/dom/PVideoDecoderManagerChild.h" + +namespace mozilla { +namespace dom { + +class VideoDecoderManagerChild final : public PVideoDecoderManagerChild +{ +public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderManagerChild) + + static VideoDecoderManagerChild* GetSingleton(); + + // Can be called from any thread, dispatches the request to the IPDL thread internally. + void DeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD); + + void DeallocPVideoDecoderManagerChild() override; + + // Main thread only + static void Initialize(); + static void Shutdown(); + +private: + VideoDecoderManagerChild() + {} + ~VideoDecoderManagerChild() {} + + void Open(Endpoint&& aEndpoint); +}; + +} // namespace dom +} // namespace mozilla + +#endif // include_dom_ipc_VideoDecoderManagerChild_h diff --git a/dom/media/ipc/VideoDecoderManagerParent.cpp b/dom/media/ipc/VideoDecoderManagerParent.cpp new file mode 100644 index 000000000000..0eb786ff7e26 --- /dev/null +++ b/dom/media/ipc/VideoDecoderManagerParent.cpp @@ -0,0 +1,218 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "VideoDecoderManagerParent.h" +#include "base/thread.h" +#include "mozilla/StaticMutex.h" +#include "mozilla/UniquePtr.h" +#include "mozilla/Services.h" +#include "mozilla/Observer.h" +#include "nsIObserverService.h" +#include "nsIObserver.h" +#include "nsIEventTarget.h" +#include "nsThreadUtils.h" +#include "ImageContainer.h" + +#if XP_WIN +#include +#endif + +namespace mozilla { +namespace dom { + +using base::Thread; +using namespace ipc; +using namespace layers; +using namespace gfx; + + +struct ImageMapEntry { + ImageMapEntry() + : mOwner(nullptr) + {} + ImageMapEntry(layers::Image* aImage, VideoDecoderManagerParent* aOwner) + : mImage(aImage) + , mOwner(aOwner) + {} + ~ImageMapEntry() {} + + RefPtr mImage; + VideoDecoderManagerParent* mOwner; +}; +std::map sImageMap; +StaticMutex sImageMutex; + +/* static */ layers::Image* +VideoDecoderManagerParent::LookupImage(const SurfaceDescriptorGPUVideo& aSD) +{ + StaticMutexAutoLock lock(sImageMutex); + return sImageMap[aSD.handle()].mImage; +} + +SurfaceDescriptorGPUVideo +VideoDecoderManagerParent::StoreImage(Image* aImage) +{ + StaticMutexAutoLock lock(sImageMutex); + + static uint64_t sImageCount = 0; + sImageMap[++sImageCount] = ImageMapEntry(aImage, this); + + return SurfaceDescriptorGPUVideo(sImageCount); +} + +void +VideoDecoderManagerParent::ClearAllOwnedImages() +{ + StaticMutexAutoLock lock(sImageMutex); + for (auto it = sImageMap.begin(); it != sImageMap.end();) + { + if ((*it).second.mOwner == this) { + it = sImageMap.erase(it); + } else { + ++it; + } + } +} + +StaticRefPtr sVideoDecoderManagerThread; +StaticRefPtr sVideoDecoderTaskThread; +StaticRefPtr sManagerTaskQueue; + +class ManagerThreadShutdownObserver : public nsIObserver +{ + virtual ~ManagerThreadShutdownObserver() {} +public: + ManagerThreadShutdownObserver() {} + + NS_DECL_ISUPPORTS + + NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic, + const char16_t* aData) override + { + MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0); + + VideoDecoderManagerParent::ShutdownThreads(); + return NS_OK; + } +}; +NS_IMPL_ISUPPORTS(ManagerThreadShutdownObserver, nsIObserver); + +void +VideoDecoderManagerParent::StartupThreads() +{ + MOZ_ASSERT(NS_IsMainThread()); + + if (sVideoDecoderManagerThread) { + return; + } + + nsCOMPtr observerService = services::GetObserverService(); + if (!observerService) { + return; + } + + RefPtr managerThread; + nsresult rv = NS_NewNamedThread("VideoParent", getter_AddRefs(managerThread)); + if (NS_FAILED(rv)) { + return; + } + sVideoDecoderManagerThread = managerThread; +#if XP_WIN + sVideoDecoderManagerThread->Dispatch(NS_NewRunnableFunction([]() { + HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); + MOZ_ASSERT(hr == S_OK); + }), NS_DISPATCH_NORMAL); +#endif + + sManagerTaskQueue = new TaskQueue(managerThread.forget()); + + RefPtr taskThread; + rv = NS_NewNamedThread("VideoTaskQueue", getter_AddRefs(taskThread)); + if (NS_FAILED(rv)) { + sVideoDecoderManagerThread->Shutdown(); + sVideoDecoderManagerThread = nullptr; + return; + } + sVideoDecoderTaskThread = taskThread; + +#ifdef XP_WIN + sVideoDecoderTaskThread->Dispatch(NS_NewRunnableFunction([]() { + HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); + MOZ_ASSERT(hr == S_OK); + }), NS_DISPATCH_NORMAL); +#endif + + ManagerThreadShutdownObserver* obs = new ManagerThreadShutdownObserver(); + observerService->AddObserver(obs, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); +} + +void +VideoDecoderManagerParent::ShutdownThreads() +{ + sManagerTaskQueue->BeginShutdown(); + sManagerTaskQueue->AwaitShutdownAndIdle(); + sVideoDecoderTaskThread->Shutdown(); + sVideoDecoderTaskThread = nullptr; + sVideoDecoderManagerThread->Shutdown(); + sVideoDecoderManagerThread = nullptr; +} + +bool +VideoDecoderManagerParent::CreateForContent(Endpoint&& aEndpoint) +{ + MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU); + MOZ_ASSERT(NS_IsMainThread()); + + StartupThreads(); + if (!sVideoDecoderManagerThread) { + return false; + } + + RefPtr parent = new VideoDecoderManagerParent(); + + RefPtr task = NewRunnableMethod&&>( + parent, &VideoDecoderManagerParent::Open, Move(aEndpoint)); + sVideoDecoderManagerThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL); + return true; +} + +VideoDecoderManagerParent::VideoDecoderManagerParent() +{ + MOZ_COUNT_CTOR(VideoDecoderManagerParent); +} + +VideoDecoderManagerParent::~VideoDecoderManagerParent() +{ + MOZ_COUNT_DTOR(VideoDecoderManagerParent); + + ClearAllOwnedImages(); +} + +void +VideoDecoderManagerParent::Open(Endpoint&& aEndpoint) +{ + if (!aEndpoint.Bind(this)) { + // We can't recover from this. + MOZ_CRASH("Failed to bind VideoDecoderManagerParent to endpoint"); + } + AddRef(); +} + +void +VideoDecoderManagerParent::DeallocPVideoDecoderManagerParent() +{ + Release(); +} + +bool +VideoDecoderManagerParent::RecvDeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) +{ + StaticMutexAutoLock lock(sImageMutex); + sImageMap.erase(aSD.handle()); + return true; +} + +} // namespace dom +} // namespace mozilla diff --git a/dom/media/ipc/VideoDecoderManagerParent.h b/dom/media/ipc/VideoDecoderManagerParent.h new file mode 100644 index 000000000000..71a7c789e162 --- /dev/null +++ b/dom/media/ipc/VideoDecoderManagerParent.h @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef include_dom_ipc_VideoDecoderManagerParent_h +#define include_dom_ipc_VideoDecoderManagerParent_h + +#include "mozilla/dom/PVideoDecoderManagerParent.h" + +namespace mozilla { +namespace dom { + +class VideoDecoderManagerParent final : public PVideoDecoderManagerParent +{ +public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderManagerParent) + + static bool CreateForContent(Endpoint&& aEndpoint); + + // Can be called from any thread + static layers::Image* LookupImage(const SurfaceDescriptorGPUVideo& aSD); + SurfaceDescriptorGPUVideo StoreImage(layers::Image* aImage); + + static void StartupThreads(); + static void ShutdownThreads(); + +protected: + bool RecvDeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) override; + + void ActorDestroy(mozilla::ipc::IProtocolManager::ActorDestroyReason) override {} + + void DeallocPVideoDecoderManagerParent() override; + + private: + VideoDecoderManagerParent(); + ~VideoDecoderManagerParent(); + + void ClearAllOwnedImages(); + + void Open(Endpoint&& aEndpoint); +}; + +} // namespace dom +} // namespace mozilla + +#endif // include_dom_ipc_VideoDecoderManagerParent_h diff --git a/dom/media/ipc/moz.build b/dom/media/ipc/moz.build new file mode 100644 index 000000000000..b3ce8e7b517d --- /dev/null +++ b/dom/media/ipc/moz.build @@ -0,0 +1,26 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + +IPDL_SOURCES += [ + 'PVideoDecoderManager.ipdl', +] + +EXPORTS.mozilla.dom += [ + 'MediaIPCUtils.h', + 'VideoDecoderManagerChild.h', + 'VideoDecoderManagerParent.h', +] + +SOURCES += [ + 'VideoDecoderManagerChild.cpp', + 'VideoDecoderManagerParent.cpp', +] + +include('/ipc/chromium/chromium-config.mozbuild') + + +FINAL_LIBRARY = 'xul' diff --git a/dom/media/moz.build b/dom/media/moz.build index 626ed72f7362..823c5244dcd0 100644 --- a/dom/media/moz.build +++ b/dom/media/moz.build @@ -26,6 +26,7 @@ DIRS += [ 'gmp-plugin', 'gmp-plugin-openh264', 'imagecapture', + 'ipc', 'mediasink', 'mediasource', 'ogg', diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index 8d7446a941e9..fd9689de1f23 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -17,6 +17,7 @@ #include "mozilla/layers/APZThreadUtils.h" #include "mozilla/layers/APZCTreeManager.h" #include "mozilla/layers/CompositorBridgeParent.h" +#include "mozilla/dom/VideoDecoderManagerParent.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/ImageBridgeParent.h" #include "nsDebugImpl.h" @@ -257,6 +258,12 @@ GPUParent::RecvNewContentVRManager(Endpoint&& aEndpoint) return VRManagerParent::CreateForContent(Move(aEndpoint)); } +bool +GPUParent::RecvNewContentVideoDecoderManager(Endpoint&& aEndpoint) +{ + return dom::VideoDecoderManagerParent::CreateForContent(Move(aEndpoint)); +} + bool GPUParent::RecvDeallocateLayerTreeId(const uint64_t& aLayersId) { diff --git a/gfx/ipc/GPUParent.h b/gfx/ipc/GPUParent.h index 6fefb731d660..552d86d07b8e 100644 --- a/gfx/ipc/GPUParent.h +++ b/gfx/ipc/GPUParent.h @@ -41,6 +41,7 @@ public: bool RecvNewContentCompositorBridge(Endpoint&& aEndpoint) override; bool RecvNewContentImageBridge(Endpoint&& aEndpoint) override; bool RecvNewContentVRManager(Endpoint&& aEndpoint) override; + bool RecvNewContentVideoDecoderManager(Endpoint&& aEndpoint) override; bool RecvDeallocateLayerTreeId(const uint64_t& aLayersId) override; bool RecvGetDeviceStatus(GPUDeviceData* aOutStatus) override; bool RecvAddLayerTreeIdMapping(const uint64_t& aLayersId, const ProcessId& aOwnerId) override; diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index 74cacfeddc42..699fd6b0ebb3 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -27,6 +27,8 @@ #include "VsyncBridgeChild.h" #include "VsyncIOThreadHolder.h" #include "VsyncSource.h" +#include "mozilla/dom/VideoDecoderManagerChild.h" +#include "mozilla/dom/VideoDecoderManagerParent.h" namespace mozilla { namespace gfx { @@ -617,6 +619,33 @@ GPUProcessManager::CreateContentVRManager(base::ProcessId aOtherProcess, return true; } +bool +GPUProcessManager::CreateContentVideoDecoderManager(base::ProcessId aOtherProcess, + ipc::Endpoint* aOutEndpoint) +{ + if (!mGPUChild) { + return false; + } + + ipc::Endpoint parentPipe; + ipc::Endpoint childPipe; + + nsresult rv = dom::PVideoDecoderManager::CreateEndpoints( + mGPUChild->OtherPid(), + aOtherProcess, + &parentPipe, + &childPipe); + if (NS_FAILED(rv)) { + gfxCriticalNote << "Could not create content video decoder: " << hexa(int(rv)); + return false; + } + + mGPUChild->SendNewContentVideoDecoderManager(Move(parentPipe)); + + *aOutEndpoint = Move(childPipe); + return true; +} + already_AddRefed GPUProcessManager::GetAPZCTreeManagerForLayers(uint64_t aLayersId) { diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h index 66db7e121632..b7a8011c3de9 100644 --- a/gfx/ipc/GPUProcessManager.h +++ b/gfx/ipc/GPUProcessManager.h @@ -37,6 +37,7 @@ class CompositorWidget; namespace dom { class ContentParent; class TabParent; +class PVideoDecoderManagerChild; } // namespace dom namespace ipc { class GeckoChildProcessHost; @@ -92,6 +93,8 @@ public: ipc::Endpoint* aOutCompositor, ipc::Endpoint* aOutImageBridge, ipc::Endpoint* aOutVRBridge); + bool CreateContentVideoDecoderManager(base::ProcessId aOtherProcess, + ipc::Endpoint* aOutEndPoint); // This returns a reference to the APZCTreeManager to which // pan/zoom-related events can be sent. diff --git a/gfx/ipc/PGPU.ipdl b/gfx/ipc/PGPU.ipdl index 21e6daf9a827..49d4cec8ad65 100644 --- a/gfx/ipc/PGPU.ipdl +++ b/gfx/ipc/PGPU.ipdl @@ -8,6 +8,7 @@ include protocol PCompositorBridge; include protocol PImageBridge; include protocol PVRManager; include protocol PVsyncBridge; +include protocol PVideoDecoderManager; using base::ProcessId from "base/process.h"; using mozilla::TimeDuration from "mozilla/TimeStamp.h"; @@ -56,6 +57,7 @@ parent: async NewContentCompositorBridge(Endpoint endpoint); async NewContentImageBridge(Endpoint endpoint); async NewContentVRManager(Endpoint endpoint); + async NewContentVideoDecoderManager(Endpoint endpoint); async DeallocateLayerTreeId(uint64_t layersId); diff --git a/gfx/layers/client/GPUVideoTextureClient.cpp b/gfx/layers/client/GPUVideoTextureClient.cpp index 41021f6bf43e..0e2d25345be8 100644 --- a/gfx/layers/client/GPUVideoTextureClient.cpp +++ b/gfx/layers/client/GPUVideoTextureClient.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GPUVideoTextureClient.h" +#include "mozilla/dom/VideoDecoderManagerChild.h" namespace mozilla { namespace layers { @@ -34,6 +35,7 @@ GPUVideoTextureData::FillInfo(TextureData::Info& aInfo) const void GPUVideoTextureData::Deallocate(ClientIPCAllocator* aAllocator) { + dom::VideoDecoderManagerChild::GetSingleton()->DeallocateSurfaceDescriptorGPUVideo(mSD); mSD = SurfaceDescriptorGPUVideo(); } diff --git a/gfx/layers/composite/GPUVideoTextureHost.cpp b/gfx/layers/composite/GPUVideoTextureHost.cpp index 6d26147a7068..fc3c3bcb289c 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.cpp +++ b/gfx/layers/composite/GPUVideoTextureHost.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GPUVideoTextureHost.h" +#include "mozilla/dom/VideoDecoderManagerParent.h" #include "ImageContainer.h" namespace mozilla { @@ -14,6 +15,7 @@ GPUVideoTextureHost::GPUVideoTextureHost(TextureFlags aFlags, : TextureHost(aFlags) { MOZ_COUNT_CTOR(GPUVideoTextureHost); + mImage = dom::VideoDecoderManagerParent::LookupImage(aDescriptor); } GPUVideoTextureHost::~GPUVideoTextureHost() diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index a7e44b9d90e0..1c1a66adbf0a 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -67,6 +67,7 @@ #include "FrameLayerBuilder.h" #include "AnimationCommon.h" #include "LayerAnimationInfo.h" +#include "mozilla/dom/VideoDecoderManagerChild.h" #include "AudioChannelService.h" #include "mozilla/dom/PromiseDebugging.h" @@ -307,6 +308,8 @@ nsLayoutStatics::Initialize() MediaDecoder::InitStatics(); + VideoDecoderManagerChild::Initialize(); + PromiseDebugging::Init(); mozilla::dom::devicestorage::DeviceStorageStatics::Initialize(); @@ -390,6 +393,8 @@ nsLayoutStatics::Shutdown() nsAutoCopyListener::Shutdown(); FrameLayerBuilder::Shutdown(); + VideoDecoderManagerChild::Shutdown(); + #ifdef MOZ_ANDROID_OMX AndroidMediaPluginHost::Shutdown(); #endif