diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 6291d96df7..fdc06b1234 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1022,10 +1022,9 @@ mozilla::ipc::IPCResult ContentParent::RecvLaunchRDDProcess( Preferences::GetBool("media.rdd-process.enabled", false)) { RDDProcessManager* rdd = RDDProcessManager::Get(); if (rdd) { - bool rddOpened = rdd->LaunchRDDProcess(); - if (rddOpened) { - rddOpened = rdd->CreateContentBridge(OtherPid(), aEndpoint); - } + rdd->LaunchRDDProcess(); + + bool rddOpened = rdd->CreateContentBridge(OtherPid(), aEndpoint); if (NS_WARN_IF(!rddOpened)) { *aRv = NS_ERROR_NOT_AVAILABLE; diff --git a/dom/media/ipc/PRDD.ipdl b/dom/media/ipc/PRDD.ipdl index bc65fa616b..a738ed5efa 100644 --- a/dom/media/ipc/PRDD.ipdl +++ b/dom/media/ipc/PRDD.ipdl @@ -2,13 +2,11 @@ * 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 GraphicsMessages; include MemoryReportTypes; include PrefsTypes; include protocol PProfiler; include protocol PRemoteDecoderManager; -include protocol PVideoBridge; using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h"; @@ -22,9 +20,7 @@ protocol PRDD { parent: - async Init(GfxVarUpdate[] vars, - FileDescriptor? sandboxBroker, - bool startMacSandbox); + async Init(FileDescriptor? sandboxBroker, bool startMacSandbox); async InitProfiler(Endpoint endpoint); @@ -38,11 +34,9 @@ parent: async PreferenceUpdate(Pref pref); - async UpdateVar(GfxVarUpdate var); - - async InitVideoBridge(Endpoint endpoint); - child: + // args TBD, sent when init complete. Occurs once, after Init(). + async InitComplete(); async InitCrashReporter(Shmem shmem, NativeThreadId threadId); diff --git a/dom/media/ipc/PRemoteDecoderManager.ipdl b/dom/media/ipc/PRemoteDecoderManager.ipdl index 1ca87cde0f..2d6561a957 100644 --- a/dom/media/ipc/PRemoteDecoderManager.ipdl +++ b/dom/media/ipc/PRemoteDecoderManager.ipdl @@ -33,7 +33,7 @@ sync protocol PRemoteDecoderManager parent: sync PRemoteDecoder(RemoteDecoderInfoIPDL info, OptionSet options, - TextureFactoryIdentifier? identifier) + TextureFactoryIdentifier identifier) returns (bool success, nsCString aErrorDescription); diff --git a/dom/media/ipc/RDDChild.cpp b/dom/media/ipc/RDDChild.cpp index 6caca06e98..416bed1665 100644 --- a/dom/media/ipc/RDDChild.cpp +++ b/dom/media/ipc/RDDChild.cpp @@ -3,11 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "RDDChild.h" -#include "mozilla/RDDProcessManager.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/ipc/CrashReporterHost.h" -#include "mozilla/gfx/gfxVars.h" -#include "mozilla/gfx/GPUProcessManager.h" #if defined(XP_LINUX) && defined(MOZ_SANDBOX) # include "mozilla/SandboxBroker.h" @@ -22,9 +19,8 @@ namespace mozilla { using namespace layers; -using namespace gfx; -RDDChild::RDDChild(RDDProcessHost* aHost) : mHost(aHost) { +RDDChild::RDDChild(RDDProcessHost* aHost) : mHost(aHost), mRDDReady(false) { MOZ_COUNT_CTOR(RDDChild); } @@ -48,23 +44,34 @@ bool RDDChild::Init(bool aStartMacSandbox) { } #endif // XP_LINUX && MOZ_SANDBOX - nsTArray updates = gfxVars::FetchNonDefaultVars(); - - SendInit(updates, brokerFd, aStartMacSandbox); + SendInit(brokerFd, aStartMacSandbox); #ifdef MOZ_GECKO_PROFILER Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid())); #endif - gfxVars::AddReceiver(this); - auto* gpm = gfx::GPUProcessManager::Get(); - if (gpm) { - gpm->AddListener(this); + return true; +} + +bool RDDChild::EnsureRDDReady() { + if (mRDDReady) { + return true; } + mRDDReady = true; return true; } +mozilla::ipc::IPCResult RDDChild::RecvInitComplete() { + // We synchronously requested RDD parameters before this arrived. + if (mRDDReady) { + return IPC_OK(); + } + + mRDDReady = true; + return IPC_OK(); +} + bool RDDChild::SendRequestMemoryReport(const uint32_t& aGeneration, const bool& aAnonymize, const bool& aMinimizeMemoryUsage, @@ -75,15 +82,6 @@ bool RDDChild::SendRequestMemoryReport(const uint32_t& aGeneration, return true; } -void RDDChild::OnCompositorUnexpectedShutdown() { - auto* rddm = RDDProcessManager::Get(); - if (rddm) { - rddm->CreateVideoBridge(); - } -} - -void RDDChild::OnVarChanged(const GfxVarUpdate& aVar) { SendUpdateVar(aVar); } - mozilla::ipc::IPCResult RDDChild::RecvAddMemoryReport( const MemoryReport& aReport) { if (mMemoryReportRequest) { @@ -106,13 +104,6 @@ void RDDChild::ActorDestroy(ActorDestroyReason aWhy) { GenerateCrashReport(OtherPid()); } - auto* gpm = gfx::GPUProcessManager::Get(); - if (gpm) { - // Note: the manager could have shutdown already. - gpm->RemoveListener(this); - } - - gfxVars::RemoveReceiver(this); mHost->OnChannelClosed(); } diff --git a/dom/media/ipc/RDDChild.h b/dom/media/ipc/RDDChild.h index 89a396a1ae..d021bb0b06 100644 --- a/dom/media/ipc/RDDChild.h +++ b/dom/media/ipc/RDDChild.h @@ -7,8 +7,6 @@ #include "mozilla/ipc/CrashReporterHelper.h" #include "mozilla/UniquePtr.h" -#include "mozilla/gfx/gfxVarReceiver.h" -#include "mozilla/gfx/GPUProcessListener.h" namespace mozilla { @@ -23,9 +21,7 @@ class MemoryReportRequestHost; class RDDProcessHost; class RDDChild final : public PRDDChild, - public ipc::CrashReporterHelper, - public gfx::gfxVarReceiver, - public gfx::GPUProcessListener { + public ipc::CrashReporterHelper { typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost; public: @@ -34,8 +30,10 @@ class RDDChild final : public PRDDChild, bool Init(bool aStartMacSandbox); - void OnCompositorUnexpectedShutdown() override; - void OnVarChanged(const GfxVarUpdate& aVar) override; + bool EnsureRDDReady(); + + // PRDDChild overrides. + mozilla::ipc::IPCResult RecvInitComplete(); void ActorDestroy(ActorDestroyReason aWhy) override; @@ -55,6 +53,7 @@ class RDDChild final : public PRDDChild, #if defined(XP_LINUX) && defined(MOZ_SANDBOX) UniquePtr mSandboxBroker; #endif + bool mRDDReady; }; } // namespace mozilla diff --git a/dom/media/ipc/RDDParent.cpp b/dom/media/ipc/RDDParent.cpp index 1fd0eca978..e989f95fd8 100644 --- a/dom/media/ipc/RDDParent.cpp +++ b/dom/media/ipc/RDDParent.cpp @@ -16,7 +16,6 @@ #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" -#include "mozilla/gfx/gfxVars.h" #if defined(XP_LINUX) && defined(MOZ_SANDBOX) # include "mozilla/Sandbox.h" @@ -40,7 +39,6 @@ namespace mozilla { using namespace ipc; -using namespace gfx; static RDDParent* sRDDParent; @@ -83,8 +81,6 @@ bool RDDParent::Init(base::ProcessId aParentPid, const char* aParentBuildID, return false; } - gfxVars::Initialize(); - mozilla::ipc::SetThisProcessName("RDD Process"); return true; } @@ -117,12 +113,8 @@ static void StartRDDMacSandbox() { #endif mozilla::ipc::IPCResult RDDParent::RecvInit( - nsTArray&& vars, const Maybe& aBrokerFd, - bool aStartMacSandbox) { - for (const auto& var : vars) { - gfxVars::ApplyUpdate(var); - } - + const Maybe& aBrokerFd, bool aStartMacSandbox) { + Unused << SendInitComplete(); #if defined(MOZ_SANDBOX) # if defined(XP_MACOSX) // Close all current connections to the WindowServer. This ensures that the @@ -149,11 +141,6 @@ mozilla::ipc::IPCResult RDDParent::RecvInit( return IPC_OK(); } -IPCResult RDDParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { - gfxVars::ApplyUpdate(aUpdate); - return IPC_OK(); -} - mozilla::ipc::IPCResult RDDParent::RecvInitProfiler( Endpoint&& aEndpoint) { #ifdef MOZ_GECKO_PROFILER @@ -170,15 +157,6 @@ mozilla::ipc::IPCResult RDDParent::RecvNewContentRemoteDecoderManager( return IPC_OK(); } -mozilla::ipc::IPCResult RDDParent::RecvInitVideoBridge( - Endpoint&& aEndpoint) { - if (!RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess( - std::move(aEndpoint))) { - return IPC_FAIL_NO_REASON(this); - } - return IPC_OK(); -} - mozilla::ipc::IPCResult RDDParent::RecvRequestMemoryReport( const uint32_t& aGeneration, const bool& aAnonymize, const bool& aMinimizeMemoryUsage, const Maybe& aDMDFile) { @@ -219,9 +197,6 @@ void RDDParent::ActorDestroy(ActorDestroyReason aWhy) { } #endif - RemoteDecoderManagerParent::ShutdownVideoBridge(); - - gfxVars::Shutdown(); CrashReporterClient::DestroySingleton(); XRE_ShutdownChildProcess(); } diff --git a/dom/media/ipc/RDDParent.h b/dom/media/ipc/RDDParent.h index afc4d816e3..e84117ae2b 100644 --- a/dom/media/ipc/RDDParent.h +++ b/dom/media/ipc/RDDParent.h @@ -22,22 +22,18 @@ class RDDParent final : public PRDDParent { bool Init(base::ProcessId aParentPid, const char* aParentBuildID, MessageLoop* aIOLoop, IPC::Channel* aChannel); - mozilla::ipc::IPCResult RecvInit(nsTArray&& vars, - const Maybe& aBrokerFd, + mozilla::ipc::IPCResult RecvInit(const Maybe& aBrokerFd, bool aStartMacSandbox); mozilla::ipc::IPCResult RecvInitProfiler( Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvNewContentRemoteDecoderManager( Endpoint&& aEndpoint); - mozilla::ipc::IPCResult RecvInitVideoBridge( - Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvRequestMemoryReport( const uint32_t& generation, const bool& anonymize, const bool& minimizeMemoryUsage, const Maybe& DMDFile); mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref); - mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref); void ActorDestroy(ActorDestroyReason aWhy) override; diff --git a/dom/media/ipc/RDDProcessManager.cpp b/dom/media/ipc/RDDProcessManager.cpp index 81f2e39a58..ae415a19bb 100644 --- a/dom/media/ipc/RDDProcessManager.cpp +++ b/dom/media/ipc/RDDProcessManager.cpp @@ -9,9 +9,6 @@ #include "mozilla/Preferences.h" #include "mozilla/StaticPrefs_media.h" #include "mozilla/dom/ContentParent.h" -#include "mozilla/gfx/GPUProcessManager.h" -#include "mozilla/layers/VideoBridgeParent.h" -#include "mozilla/layers/CompositorThread.h" #include "nsAppRunner.h" #include "nsContentUtils.h" #include "RDDChild.h" @@ -19,8 +16,7 @@ namespace mozilla { -using namespace gfx; -using namespace layers; +using namespace mozilla::layers; static StaticAutoPtr sRDDSingleton; @@ -101,9 +97,9 @@ void RDDProcessManager::OnPreferenceChange(const char16_t* aData) { } } -bool RDDProcessManager::LaunchRDDProcess() { +void RDDProcessManager::LaunchRDDProcess() { if (mProcess) { - return true; + return; } mNumProcessAttempts++; @@ -118,24 +114,30 @@ bool RDDProcessManager::LaunchRDDProcess() { mProcess = new RDDProcessHost(this); if (!mProcess->Launch(extraArgs)) { DestroyProcess(); - return false; - } - if (!EnsureRDDReady()) { - return false; } - - return CreateVideoBridge(); } bool RDDProcessManager::EnsureRDDReady() { - if (mProcess && !mProcess->IsConnected() && !mProcess->WaitForLaunch()) { - // If this fails, we should have fired OnProcessLaunchComplete and - // removed the process. - MOZ_ASSERT(!mProcess && !mRDDChild); - return false; + if (mProcess && !mProcess->IsConnected()) { + if (!mProcess->WaitForLaunch()) { + // If this fails, we should have fired OnProcessLaunchComplete and + // removed the process. + MOZ_ASSERT(!mProcess && !mRDDChild); + return false; + } } - return true; + if (mRDDChild) { + if (mRDDChild->EnsureRDDReady()) { + return true; + } + + // If the initialization above fails, we likely have a RDD process teardown + // waiting in our message queue (or will soon). + DestroyProcess(); + } + + return false; } void RDDProcessManager::OnProcessLaunchComplete(RDDProcessHost* aHost) { @@ -216,6 +218,10 @@ void RDDProcessManager::DestroyProcess() { bool RDDProcessManager::CreateContentBridge( base::ProcessId aOtherProcess, ipc::Endpoint* aOutRemoteDecoderManager) { + if (!EnsureRDDReady() || !StaticPrefs::media_rdd_process_enabled()) { + return false; + } + ipc::Endpoint parentPipe; ipc::Endpoint childPipe; @@ -233,39 +239,6 @@ bool RDDProcessManager::CreateContentBridge( return true; } -bool RDDProcessManager::CreateVideoBridge() { - ipc::Endpoint parentPipe; - ipc::Endpoint childPipe; - - GPUProcessManager* gpuManager = GPUProcessManager::Get(); - base::ProcessId gpuProcessPid = gpuManager ? gpuManager->GPUProcessPid() : -1; - - // The child end is the producer of video frames; the parent end is the - // consumer. - base::ProcessId childPid = RDDProcessPid(); - base::ProcessId parentPid = - gpuProcessPid != -1 ? gpuProcessPid : base::GetCurrentProcId(); - - nsresult rv = PVideoBridge::CreateEndpoints(parentPid, childPid, &parentPipe, - &childPipe); - if (NS_FAILED(rv)) { - MOZ_LOG(sPDMLog, LogLevel::Debug, - ("Could not create video bridge: %d", int(rv))); - DestroyProcess(); - return false; - } - - mRDDChild->SendInitVideoBridge(std::move(childPipe)); - if (gpuProcessPid != -1) { - gpuManager->InitVideoBridge(std::move(parentPipe)); - } else { - VideoBridgeParent::Open(std::move(parentPipe), - VideoBridgeSource::RddProcess); - } - - return true; -} - base::ProcessId RDDProcessManager::RDDProcessPid() { base::ProcessId rddPid = mRDDChild ? mRDDChild->OtherPid() : -1; return rddPid; diff --git a/dom/media/ipc/RDDProcessManager.h b/dom/media/ipc/RDDProcessManager.h index f0ace81b80..63b8684fd5 100644 --- a/dom/media/ipc/RDDProcessManager.h +++ b/dom/media/ipc/RDDProcessManager.h @@ -17,8 +17,6 @@ class RDDChild; // objects that may live in another process. Currently, it provides access // to the RDD process via ContentParent. class RDDProcessManager final : public RDDProcessHost::Listener { - friend class RDDChild; - public: static void Initialize(); static void Shutdown(); @@ -27,7 +25,7 @@ class RDDProcessManager final : public RDDProcessHost::Listener { ~RDDProcessManager(); // If not using a RDD process, launch a new RDD process asynchronously. - bool LaunchRDDProcess(); + void LaunchRDDProcess(); // Ensure that RDD-bound methods can be used. If no RDD process is being // used, or one is launched and ready, this function returns immediately. @@ -62,8 +60,6 @@ class RDDProcessManager final : public RDDProcessHost::Listener { bool AttemptedRDDProcess() const { return mNumProcessAttempts > 0; } private: - bool CreateVideoBridge(); - // Called from our xpcom-shutdown observer. void OnXPCOMShutdown(); void OnPreferenceChange(const char16_t* aData); diff --git a/dom/media/ipc/RemoteAudioDecoder.cpp b/dom/media/ipc/RemoteAudioDecoder.cpp index 4e9b1cd6b3..5351393747 100644 --- a/dom/media/ipc/RemoteAudioDecoder.cpp +++ b/dom/media/ipc/RemoteAudioDecoder.cpp @@ -63,8 +63,9 @@ MediaResult RemoteAudioDecoderChild::InitIPDL( mIPDLSelfRef = this; bool success = false; nsCString errorDescription; + layers::TextureFactoryIdentifier defaultIdent; Unused << manager->SendPRemoteDecoderConstructor( - this, aAudioInfo, aOptions, Nothing(), &success, &errorDescription); + this, aAudioInfo, aOptions, defaultIdent, &success, &errorDescription); return success ? MediaResult(NS_OK) : MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, errorDescription); } diff --git a/dom/media/ipc/RemoteDecoderManagerChild.cpp b/dom/media/ipc/RemoteDecoderManagerChild.cpp index 9456cfcb9f..d6a359f775 100644 --- a/dom/media/ipc/RemoteDecoderManagerChild.cpp +++ b/dom/media/ipc/RemoteDecoderManagerChild.cpp @@ -136,7 +136,7 @@ AbstractThread* RemoteDecoderManagerChild::GetManagerAbstractThread() { PRemoteDecoderChild* RemoteDecoderManagerChild::AllocPRemoteDecoderChild( const RemoteDecoderInfoIPDL& /* not used */, const CreateDecoderParams::OptionSet& aOptions, - const Maybe& aIdentifier, bool* aSuccess, + const layers::TextureFactoryIdentifier& aIdentifier, bool* aSuccess, nsCString* /* not used */) { // RemoteDecoderModule is responsible for creating RemoteDecoderChild // classes. @@ -153,10 +153,6 @@ bool RemoteDecoderManagerChild::DeallocPRemoteDecoderChild( return true; } -RemoteDecoderManagerChild::RemoteDecoderManagerChild( - layers::VideoBridgeSource aSource) - : mSource(aSource) {} - void RemoteDecoderManagerChild::OpenForRDDProcess( Endpoint&& aEndpoint) { MOZ_ASSERT(NS_GetCurrentThread() == GetManagerThread()); @@ -172,8 +168,7 @@ void RemoteDecoderManagerChild::OpenForRDDProcess( } sRemoteDecoderManagerChildForRDDProcess = nullptr; if (aEndpoint.IsValid()) { - RefPtr manager = - new RemoteDecoderManagerChild(VideoBridgeSource::RddProcess); + RefPtr manager = new RemoteDecoderManagerChild(); if (aEndpoint.Bind(manager)) { sRemoteDecoderManagerChildForRDDProcess = manager; manager->InitIPDL(); @@ -187,8 +182,7 @@ void RemoteDecoderManagerChild::OpenForGPUProcess( // fail since this is as close to being recreated as we will ever be. sRemoteDecoderManagerChildForGPUProcess = nullptr; if (aEndpoint.IsValid()) { - RefPtr manager = - new RemoteDecoderManagerChild(VideoBridgeSource::GpuProcess); + RefPtr manager = new RemoteDecoderManagerChild(); if (aEndpoint.Bind(manager)) { sRemoteDecoderManagerChildForGPUProcess = manager; manager->InitIPDL(); diff --git a/dom/media/ipc/RemoteDecoderManagerChild.h b/dom/media/ipc/RemoteDecoderManagerChild.h index 6a4a8adf71..af204f3b93 100644 --- a/dom/media/ipc/RemoteDecoderManagerChild.h +++ b/dom/media/ipc/RemoteDecoderManagerChild.h @@ -4,7 +4,6 @@ #ifndef include_dom_media_ipc_RemoteDecoderManagerChild_h #define include_dom_media_ipc_RemoteDecoderManagerChild_h #include "mozilla/PRemoteDecoderManagerChild.h" -#include "mozilla/layers/VideoBridgeUtils.h" namespace mozilla { @@ -60,7 +59,6 @@ class RemoteDecoderManagerChild final : public PRemoteDecoderManagerChild, void RunWhenGPUProcessRecreated(already_AddRefed aTask); bool CanSend(); - layers::VideoBridgeSource GetSource() const { return mSource; } protected: void InitIPDL(); @@ -73,15 +71,15 @@ class RemoteDecoderManagerChild final : public PRemoteDecoderManagerChild, PRemoteDecoderChild* AllocPRemoteDecoderChild( const RemoteDecoderInfoIPDL& aRemoteDecoderInfo, const CreateDecoderParams::OptionSet& aOptions, - const Maybe& aIdentifier, - bool* aSuccess, nsCString* aErrorDescription); + const layers::TextureFactoryIdentifier& aIdentifier, bool* aSuccess, + nsCString* aErrorDescription); bool DeallocPRemoteDecoderChild(PRemoteDecoderChild* actor); private: // Main thread only static void InitializeThread(); - explicit RemoteDecoderManagerChild(layers::VideoBridgeSource aSource); + RemoteDecoderManagerChild() = default; ~RemoteDecoderManagerChild() = default; static void OpenForRDDProcess( @@ -91,9 +89,6 @@ class RemoteDecoderManagerChild final : public PRemoteDecoderManagerChild, RefPtr mIPDLSelfRef; - // The associated source of this decoder manager - layers::VideoBridgeSource mSource; - // Should only ever be accessed on the manager thread. bool mCanSend = false; }; diff --git a/dom/media/ipc/RemoteDecoderManagerParent.cpp b/dom/media/ipc/RemoteDecoderManagerParent.cpp index fdc2ead214..b612c05d87 100644 --- a/dom/media/ipc/RemoteDecoderManagerParent.cpp +++ b/dom/media/ipc/RemoteDecoderManagerParent.cpp @@ -73,7 +73,6 @@ class RemoteDecoderManagerThreadShutdownObserver : public nsIObserver { const char16_t* aData) override { MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0); - RemoteDecoderManagerParent::ShutdownVideoBridge(); RemoteDecoderManagerParent::ShutdownThreads(); return NS_OK; } @@ -113,9 +112,8 @@ bool RemoteDecoderManagerParent::StartupThreads() { #endif if (XRE_IsGPUProcess()) { sRemoteDecoderManagerParentThread->Dispatch( - NS_NewRunnableFunction( - "RemoteDecoderManagerParent::StartupThreads", - []() { layers::VideoBridgeChild::StartupForGPUProcess(); }), + NS_NewRunnableFunction("RemoteDecoderManagerParent::StartupThreads", + []() { layers::VideoBridgeChild::Startup(); }), NS_DISPATCH_NORMAL); } @@ -172,25 +170,6 @@ bool RemoteDecoderManagerParent::CreateForContent( return true; } -bool RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess( - Endpoint&& aEndpoint) { - // We never want to decode in the GPU process, but output - // frames to the parent process. - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_RDD); - MOZ_ASSERT(NS_IsMainThread()); - - if (!StartupThreads()) { - return false; - } - - RefPtr task = - NewRunnableFunction("gfx::VideoBridgeChild::Open", - &VideoBridgeChild::Open, std::move(aEndpoint)); - sRemoteDecoderManagerParentThread->Dispatch(task.forget(), - NS_DISPATCH_NORMAL); - return true; -} - RemoteDecoderManagerParent::RemoteDecoderManagerParent( RemoteDecoderManagerThreadHolder* aHolder) : mThreadHolder(aHolder) { @@ -209,7 +188,7 @@ void RemoteDecoderManagerParent::ActorDestroy( PRemoteDecoderParent* RemoteDecoderManagerParent::AllocPRemoteDecoderParent( const RemoteDecoderInfoIPDL& aRemoteDecoderInfo, const CreateDecoderParams::OptionSet& aOptions, - const Maybe& aIdentifier, bool* aSuccess, + const layers::TextureFactoryIdentifier& aIdentifier, bool* aSuccess, nsCString* aErrorDescription) { RefPtr decodeTaskQueue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER), diff --git a/dom/media/ipc/RemoteDecoderManagerParent.h b/dom/media/ipc/RemoteDecoderManagerParent.h index 07bc041bac..1deaee1fa7 100644 --- a/dom/media/ipc/RemoteDecoderManagerParent.h +++ b/dom/media/ipc/RemoteDecoderManagerParent.h @@ -4,7 +4,6 @@ #ifndef include_dom_media_ipc_RemoteDecoderManagerParent_h #define include_dom_media_ipc_RemoteDecoderManagerParent_h #include "mozilla/PRemoteDecoderManagerParent.h" -#include "mozilla/layers/VideoBridgeChild.h" namespace mozilla { @@ -19,9 +18,6 @@ class RemoteDecoderManagerParent final : public PRemoteDecoderManagerParent { static bool CreateForContent( Endpoint&& aEndpoint); - static bool CreateVideoBridgeToOtherProcess( - Endpoint&& aEndpoint); - // Can be called from any thread SurfaceDescriptorGPUVideo StoreImage(layers::Image* aImage, layers::TextureClient* aTexture); @@ -37,8 +33,8 @@ class RemoteDecoderManagerParent final : public PRemoteDecoderManagerParent { PRemoteDecoderParent* AllocPRemoteDecoderParent( const RemoteDecoderInfoIPDL& aRemoteDecoderInfo, const CreateDecoderParams::OptionSet& aOptions, - const Maybe& aIdentifier, - bool* aSuccess, nsCString* aErrorDescription); + const layers::TextureFactoryIdentifier& aIdentifier, bool* aSuccess, + nsCString* aErrorDescription); bool DeallocPRemoteDecoderParent(PRemoteDecoderParent* actor); mozilla::ipc::IPCResult RecvReadback(const SurfaceDescriptorGPUVideo& aSD, diff --git a/dom/media/ipc/RemoteDecoderModule.cpp b/dom/media/ipc/RemoteDecoderModule.cpp index 77fac8d51e..0504e4ccbb 100644 --- a/dom/media/ipc/RemoteDecoderModule.cpp +++ b/dom/media/ipc/RemoteDecoderModule.cpp @@ -144,11 +144,8 @@ already_AddRefed RemoteDecoderModule::CreateVideoDecoder( // thread during this single dispatch. RefPtr task = NS_NewRunnableFunction("RemoteDecoderModule::CreateVideoDecoder", [&]() { - result = child->InitIPDL( - aParams.VideoConfig(), aParams.mRate.mValue, aParams.mOptions, - aParams.mKnowsCompositor - ? &aParams.mKnowsCompositor->GetTextureFactoryIdentifier() - : nullptr); + result = child->InitIPDL(aParams.VideoConfig(), aParams.mRate.mValue, + aParams.mOptions); if (NS_FAILED(result)) { // Release RemoteVideoDecoderChild here, while we're on // manager thread. Don't just let the RefPtr go out of scope. diff --git a/dom/media/ipc/RemoteMediaData.h b/dom/media/ipc/RemoteMediaData.h deleted file mode 100644 index d6f19b1beb..0000000000 --- a/dom/media/ipc/RemoteMediaData.h +++ /dev/null @@ -1,150 +0,0 @@ -/* 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 mozilla_dom_media_ipc_RemoteMediaData_h -#define mozilla_dom_media_ipc_RemoteMediaData_h - -#include "PlatformDecoderModule.h" -#include "ipc/IPCMessageUtils.h" -#include "mozilla/GfxMessageUtils.h" -#include "mozilla/PMediaDecoderParams.h" -#include "mozilla/RemoteImageHolder.h" -#include "mozilla/gfx/Rect.h" - -namespace mozilla { - -//----------------------------------------------------------------------------- -// Declaration of the IPDL type |struct RemoteVideoData| -// -// We can't use the generated binding in order to use move semantics properly -// (see bug 1664362) -class RemoteVideoData final { - private: - typedef mozilla::MediaDataIPDL MediaDataIPDL; - typedef mozilla::gfx::IntSize IntSize; - typedef mozilla::RemoteImageHolder RemoteImageHolder; - - public: - RemoteVideoData() = default; - - RemoteVideoData(const MediaDataIPDL& aBase, const IntSize& aDisplay, - RemoteImageHolder&& aImage, int32_t aFrameID) - : mBase(aBase), - mDisplay(aDisplay), - mImage(std::move(aImage)), - mFrameID(aFrameID) {} - - // This is equivalent to the old RemoteVideoDataIPDL object and is similar to - // the RemoteAudioDataIPDL object. To ensure style consistency we use the IPDL - // naming convention here. - MediaDataIPDL& base() { return mBase; } - const MediaDataIPDL& base() const { return mBase; } - - IntSize& display() { return mDisplay; } - const IntSize& display() const { return mDisplay; } - - RemoteImageHolder& image() { return mImage; } - const RemoteImageHolder& image() const { return mImage; } - - int32_t& frameID() { return mFrameID; } - const int32_t& frameID() const { return mFrameID; } - - private: - friend struct ipc::IPDLParamTraits; - MediaDataIPDL mBase; - IntSize mDisplay; - RemoteImageHolder mImage; - int32_t mFrameID; -}; - -// Until bug 1572054 is resolved, we can't move our objects when using IPDL's -// union or array. They are always copied. So we make the class refcounted to -// and always pass it by pointed to bypass the problem for now. -class ArrayOfRemoteVideoData final { - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ArrayOfRemoteVideoData) - public: - ArrayOfRemoteVideoData() = default; - ArrayOfRemoteVideoData(ArrayOfRemoteVideoData&& aOther) - : mArray(std::move(aOther.mArray)) {} - explicit ArrayOfRemoteVideoData(nsTArray&& aOther) - : mArray(std::move(aOther)) {} - ArrayOfRemoteVideoData(const ArrayOfRemoteVideoData& aOther) { - MOZ_CRASH("Should never be used but declared by generated IPDL binding"); - } - ArrayOfRemoteVideoData& operator=(ArrayOfRemoteVideoData&& aOther) { - if (this != &aOther) { - mArray = std::move(aOther.mArray); - } - return *this; - } - ArrayOfRemoteVideoData& operator=(nsTArray&& aOther) { - mArray = std::move(aOther); - return *this; - } - - void AppendElements(nsTArray&& aOther) { - mArray.AppendElements(std::move(aOther)); - } - void Append(RemoteVideoData&& aVideo) { - mArray.AppendElement(std::move(aVideo)); - } - const nsTArray& Array() const { return mArray; } - nsTArray& Array() { return mArray; } - - private: - ~ArrayOfRemoteVideoData() = default; - friend struct ipc::IPDLParamTraits; - nsTArray mArray; -}; - -namespace ipc { - -template <> -struct IPDLParamTraits { - typedef RemoteVideoData paramType; - static void Write(IPC::Message* aMsg, ipc::IProtocol* aActor, - paramType&& aVar) { - WriteIPDLParam(aMsg, aActor, std::move(aVar.mBase)); - WriteIPDLParam(aMsg, aActor, std::move(aVar.mDisplay)); - WriteIPDLParam(aMsg, aActor, std::move(aVar.mImage)); - aMsg->WriteBytes(&aVar.mFrameID, 4); - } - - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor, paramType* aVar) { - if (!ReadIPDLParam(aMsg, aIter, aActor, &aVar->mBase) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mDisplay) || - !ReadIPDLParam(aMsg, aIter, aActor, &aVar->mImage) || - !aMsg->ReadBytesInto(aIter, &aVar->mFrameID, 4)) { - return false; - } - return true; - } -}; - -template <> -struct IPDLParamTraits { - typedef mozilla::ArrayOfRemoteVideoData paramType; - static void Write(IPC::Message* aMsg, mozilla::ipc::IProtocol* aActor, - paramType* aVar) { - WriteIPDLParam(aMsg, aActor, std::move(aVar->mArray)); - } - - static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, - mozilla::ipc::IProtocol* aActor, RefPtr* aVar) { - nsTArray array; - if (!ReadIPDLParam(aMsg, aIter, aActor, &array)) { - return false; - } - auto results = MakeRefPtr(std::move(array)); - *aVar = std::move(results); - return true; - } -}; - -} // namespace ipc - -} // namespace mozilla - -#endif // mozilla_dom_media_ipc_RemoteMediaData_h \ No newline at end of file diff --git a/dom/media/ipc/RemoteVideoDecoder.cpp b/dom/media/ipc/RemoteVideoDecoder.cpp index db005adbfd..0af70efca3 100644 --- a/dom/media/ipc/RemoteVideoDecoder.cpp +++ b/dom/media/ipc/RemoteVideoDecoder.cpp @@ -35,34 +35,13 @@ class KnowsCompositorVideo : public layers::KnowsCompositor { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(KnowsCompositorVideo, override) layers::TextureForwarder* GetTextureForwarder() override { - auto* vbc = VideoBridgeChild::GetSingleton(); - return (vbc && vbc->CanSend()) ? vbc : nullptr; + return VideoBridgeChild::GetSingleton(); } layers::LayersIPCActor* GetLayersIPCActor() override { - return GetTextureForwarder(); - } - - static already_AddRefed TryCreateForIdentifier( - const layers::TextureFactoryIdentifier& aIdentifier) { - VideoBridgeChild* child = VideoBridgeChild::GetSingleton(); - if (!child) { - return nullptr; - } - - // The RDD process will never use hardware decoding since it's - // sandboxed, so don't bother trying to create a sync object. - TextureFactoryIdentifier ident = aIdentifier; - if (XRE_IsRDDProcess()) { - ident.mSyncHandle = 0; - } - - RefPtr knowsCompositor = new KnowsCompositorVideo(); - knowsCompositor->IdentifyTextureHost(ident); - return knowsCompositor.forget(); + return VideoBridgeChild::GetSingleton(); } private: - KnowsCompositorVideo() = default; virtual ~KnowsCompositorVideo() = default; }; @@ -140,21 +119,12 @@ MediaResult RemoteVideoDecoderChild::ProcessOutput( AssertOnManagerThread(); MOZ_ASSERT(aDecodedData.type() == DecodedOutputIPDL::TArrayOfRemoteVideoDataIPDL); - const nsTArray& arrayData = aDecodedData.get_ArrayOfRemoteVideoDataIPDL(); for (auto&& data : arrayData) { - RefPtr image; - if (data.sd().type() == SurfaceDescriptor::TSurfaceDescriptorBuffer) { - image = DeserializeImage(data.sd().get_SurfaceDescriptorBuffer(), - data.frameSize()); - } else { - // The Image here creates a TextureData object that takes ownership - // of the SurfaceDescriptor, and is responsible for making sure that - // it gets deallocated. - image = new GPUVideoImage(GetManager(), data.sd(), data.frameSize()); - } + RefPtr image = DeserializeImage( + data.sd().get_SurfaceDescriptorBuffer(), data.frameSize()); RefPtr video = VideoData::CreateFromImage( data.display(), data.base().offset(), data.base().time(), @@ -165,6 +135,7 @@ MediaResult RemoteVideoDecoderChild::ProcessOutput( // OOM return MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__); } + mDecodedData.AppendElement(std::move(video)); } return NS_OK; @@ -172,8 +143,7 @@ MediaResult RemoteVideoDecoderChild::ProcessOutput( MediaResult RemoteVideoDecoderChild::InitIPDL( const VideoInfo& aVideoInfo, float aFramerate, - const CreateDecoderParams::OptionSet& aOptions, - const layers::TextureFactoryIdentifier* aIdentifier) { + const CreateDecoderParams::OptionSet& aOptions) { RefPtr manager = RemoteDecoderManagerChild::GetRDDProcessSingleton(); @@ -194,8 +164,9 @@ MediaResult RemoteVideoDecoderChild::InitIPDL( bool success = false; nsCString errorDescription; VideoDecoderInfoIPDL decoderInfo(aVideoInfo, aFramerate); + TextureFactoryIdentifier defaultIdent; Unused << manager->SendPRemoteDecoderConstructor(this, decoderInfo, aOptions, - ToMaybe(aIdentifier), + defaultIdent, &success, &errorDescription); return success ? MediaResult(NS_OK) @@ -205,6 +176,36 @@ MediaResult RemoteVideoDecoderChild::InitIPDL( GpuRemoteVideoDecoderChild::GpuRemoteVideoDecoderChild() : RemoteVideoDecoderChild(true) {} +MediaResult GpuRemoteVideoDecoderChild::ProcessOutput( + const DecodedOutputIPDL& aDecodedData) { + AssertOnManagerThread(); + MOZ_ASSERT(aDecodedData.type() == + DecodedOutputIPDL::TArrayOfRemoteVideoDataIPDL); + const nsTArray& arrayData = + aDecodedData.get_ArrayOfRemoteVideoDataIPDL(); + + for (auto&& data : arrayData) { + // The Image here creates a TextureData object that takes ownership + // of the SurfaceDescriptor, and is responsible for making sure that + // it gets deallocated. + RefPtr image = + new GPUVideoImage(GetManager(), data.sd(), data.frameSize()); + + RefPtr video = VideoData::CreateFromImage( + data.display(), data.base().offset(), data.base().time(), + data.base().duration(), image, data.base().keyframe(), + data.base().timecode()); + + if (!video) { + // OOM + return MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__); + } + + mDecodedData.AppendElement(std::move(video)); + } + return NS_OK; +} + MediaResult GpuRemoteVideoDecoderChild::InitIPDL( const VideoInfo& aVideoInfo, float aFramerate, const CreateDecoderParams::OptionSet& aOptions, @@ -235,7 +236,7 @@ MediaResult GpuRemoteVideoDecoderChild::InitIPDL( nsCString errorDescription; VideoDecoderInfoIPDL decoderInfo(aVideoInfo, aFramerate); Unused << manager->SendPRemoteDecoderConstructor(this, decoderInfo, aOptions, - Some(aIdentifier), &success, + aIdentifier, &success, &errorDescription); return success ? MediaResult(NS_OK) @@ -245,18 +246,14 @@ MediaResult GpuRemoteVideoDecoderChild::InitIPDL( RemoteVideoDecoderParent::RemoteVideoDecoderParent( RemoteDecoderManagerParent* aParent, const VideoInfo& aVideoInfo, float aFramerate, const CreateDecoderParams::OptionSet& aOptions, - const Maybe& aIdentifier, + const layers::TextureFactoryIdentifier& aIdentifier, TaskQueue* aManagerTaskQueue, TaskQueue* aDecodeTaskQueue, bool* aSuccess, nsCString* aErrorDescription) : RemoteDecoderParent(aParent, aManagerTaskQueue, aDecodeTaskQueue), mVideoInfo(aVideoInfo) { - if (aIdentifier) { - // Check to see if we have a direct PVideoBridge connection to the - // destination process specified in aIdentifier, and create a - // KnowsCompositor representing that connection if so. If this fails, then - // we fall back to returning the decoded frames directly via Output(). - mKnowsCompositor = - KnowsCompositorVideo::TryCreateForIdentifier(*aIdentifier); + if (XRE_IsGPUProcess()) { + mKnowsCompositor = new KnowsCompositorVideo(); + mKnowsCompositor->IdentifyTextureHost(aIdentifier); } CreateDecoderParams params(mVideoInfo); @@ -308,14 +305,13 @@ MediaResult RemoteVideoDecoderParent::ProcessDecodedData( DecodedOutputIPDL& aDecodedData) { MOZ_ASSERT(OnManagerThread()); - nsTArray array; - // If the video decoder bridge has shut down, stop. if (mKnowsCompositor && !mKnowsCompositor->GetTextureForwarder()) { - aDecodedData = std::move(array); return NS_OK; } + nsTArray array; + for (const auto& data : aData) { MOZ_ASSERT(data->mType == MediaData::Type::VIDEO_DATA, "Can only decode videos using RemoteDecoderParent!"); diff --git a/dom/media/ipc/RemoteVideoDecoder.h b/dom/media/ipc/RemoteVideoDecoder.h index c546905195..382d88bc39 100644 --- a/dom/media/ipc/RemoteVideoDecoder.h +++ b/dom/media/ipc/RemoteVideoDecoder.h @@ -23,8 +23,7 @@ class RemoteVideoDecoderChild : public RemoteDecoderChild { MOZ_IS_CLASS_INIT MediaResult InitIPDL(const VideoInfo& aVideoInfo, float aFramerate, - const CreateDecoderParams::OptionSet& aOptions, - const layers::TextureFactoryIdentifier* aIdentifier); + const CreateDecoderParams::OptionSet& aOptions); MediaResult ProcessOutput(const DecodedOutputIPDL& aDecodedData) override; @@ -43,16 +42,19 @@ class GpuRemoteVideoDecoderChild final : public RemoteVideoDecoderChild { MediaResult InitIPDL(const VideoInfo& aVideoInfo, float aFramerate, const CreateDecoderParams::OptionSet& aOptions, const layers::TextureFactoryIdentifier& aIdentifier); + + MediaResult ProcessOutput(const DecodedOutputIPDL& aDecodedData) override; }; class RemoteVideoDecoderParent final : public RemoteDecoderParent { public: - RemoteVideoDecoderParent( - RemoteDecoderManagerParent* aParent, const VideoInfo& aVideoInfo, - float aFramerate, const CreateDecoderParams::OptionSet& aOptions, - const Maybe& aIdentifier, - TaskQueue* aManagerTaskQueue, TaskQueue* aDecodeTaskQueue, bool* aSuccess, - nsCString* aErrorDescription); + RemoteVideoDecoderParent(RemoteDecoderManagerParent* aParent, + const VideoInfo& aVideoInfo, float aFramerate, + const CreateDecoderParams::OptionSet& aOptions, + const layers::TextureFactoryIdentifier& aIdentifier, + TaskQueue* aManagerTaskQueue, + TaskQueue* aDecodeTaskQueue, bool* aSuccess, + nsCString* aErrorDescription); protected: MediaResult ProcessDecodedData(const MediaDataDecoder::DecodedData& aData, diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index f4a92a4191..3bc59fd881 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -34,7 +34,6 @@ #include "mozilla/layers/LayerTreeOwnerTracker.h" #include "mozilla/layers/UiCompositorControllerParent.h" #include "mozilla/layers/MemoryReportingMLGPU.h" -#include "mozilla/layers/VideoBridgeParent.h" #include "mozilla/webrender/RenderThread.h" #include "mozilla/webrender/WebRenderAPI.h" #include "mozilla/HangDetails.h" @@ -296,12 +295,6 @@ mozilla::ipc::IPCResult GPUParent::RecvInitImageBridge( return IPC_OK(); } -mozilla::ipc::IPCResult GPUParent::RecvInitVideoBridge( - Endpoint&& aEndpoint) { - VideoBridgeParent::Open(std::move(aEndpoint), VideoBridgeSource::RddProcess); - return IPC_OK(); -} - #ifdef MOZ_VR mozilla::ipc::IPCResult GPUParent::RecvInitVRManager( Endpoint&& aEndpoint) { diff --git a/gfx/ipc/GPUParent.h b/gfx/ipc/GPUParent.h index c4d624d662..837553be54 100644 --- a/gfx/ipc/GPUParent.h +++ b/gfx/ipc/GPUParent.h @@ -44,8 +44,6 @@ class GPUParent final : public PGPUParent { Endpoint&& aVsyncEndpoint); mozilla::ipc::IPCResult RecvInitImageBridge( Endpoint&& aEndpoint); - mozilla::ipc::IPCResult RecvInitVideoBridge( - Endpoint&& aEndpoint); #ifdef MOZ_VR mozilla::ipc::IPCResult RecvInitVRManager( Endpoint&& aEndpoint); diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index bee5205b75..2d83763684 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -971,12 +971,6 @@ void GPUProcessManager::CreateContentRemoteDecoderManager( *aOutEndpoint = std::move(childPipe); } -void GPUProcessManager::InitVideoBridge(ipc::Endpoint&& aVideoBridge) { - if (EnsureGPUReady()) { - mGPUChild->SendInitVideoBridge(std::move(aVideoBridge)); - } -} - void GPUProcessManager::MapLayerTreeId(LayersId aLayersId, base::ProcessId aOwningId) { LayerTreeOwnerTracker::Get()->Map(aLayersId, aOwningId); diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h index cecdbf66ad..20cc6f7ea3 100644 --- a/gfx/ipc/GPUProcessManager.h +++ b/gfx/ipc/GPUProcessManager.h @@ -30,7 +30,6 @@ class CompositorUpdateObserver; class PCompositorBridgeChild; class PCompositorManagerChild; class PImageBridgeChild; -class PVideoBridgeParent; class RemoteCompositorSession; class InProcessCompositorSession; class UiCompositorControllerChild; @@ -71,7 +70,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener { typedef layers::PCompositorBridgeChild PCompositorBridgeChild; typedef layers::PCompositorManagerChild PCompositorManagerChild; typedef layers::PImageBridgeChild PImageBridgeChild; - typedef layers::PVideoBridgeParent PVideoBridgeParent; typedef layers::RemoteCompositorSession RemoteCompositorSession; typedef layers::InProcessCompositorSession InProcessCompositorSession; typedef layers::UiCompositorControllerChild UiCompositorControllerChild; @@ -107,9 +105,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener { mozilla::ipc::Endpoint* aOutVideoManager, nsTArray* aNamespaces); - // Initialize GPU process with consuming end of PVideoBridge. - void InitVideoBridge(mozilla::ipc::Endpoint&& aVideoBridge); - // Maps the layer tree and process together so that aOwningPID is allowed // to access aLayersId across process. void MapLayerTreeId(LayersId aLayersId, base::ProcessId aOwningId); diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 0bc39f4d01..762f2e4360 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -22,7 +22,6 @@ #include "nsRect.h" #include "nsRegion.h" #include "mozilla/Array.h" -#include "mozilla/layers/VideoBridgeUtils.h" #include diff --git a/gfx/ipc/PGPU.ipdl b/gfx/ipc/PGPU.ipdl index 56ce7e2f0c..a4497e114e 100644 --- a/gfx/ipc/PGPU.ipdl +++ b/gfx/ipc/PGPU.ipdl @@ -14,7 +14,6 @@ include protocol PProfiler; include protocol PVRGPU; include protocol PVRManager; #endif -include protocol PVideoBridge; include protocol PVsyncBridge; include protocol PUiCompositorController; include protocol PRemoteDecoderManager; @@ -59,7 +58,6 @@ parent: async InitCompositorManager(Endpoint endpoint); async InitVsyncBridge(Endpoint endpoint); async InitImageBridge(Endpoint endpoint); - async InitVideoBridge(Endpoint endpoint); #ifdef MOZ_VR async InitVRManager(Endpoint endpoint); // Forward GPU process its endpoints to the VR process. diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 7055602a67..d76799d08d 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -36,13 +36,15 @@ #ifndef XPCOM_GLUE_AVOID_NSPR /** * We need to be able to hold a reference to a Moz2D SourceSurface from Image - * subclasses. Whilst SourceSurface is atomic refcounted and thus safe to - * AddRef/Release on any thread, it is potentially a problem since clean up code - * may need to run on a the main thread. + * subclasses. This is potentially a problem since Images can be addrefed + * or released off the main thread. We can ensure that we never AddRef + * a SourceSurface off the main thread, but we might want to Release due + * to an Image being destroyed off the main thread. * * We use nsCountedRef to reference the - * SourceSurface. When Releasing, if we're not on the main thread, we post an - * event to the main thread to do the actual release. + * SourceSurface. When AddRefing, we assert that we're on the main thread. + * When Releasing, if we're not on the main thread, we post an event to + * the main thread to do the actual release. */ class nsMainThreadSourceSurfaceRef; @@ -76,7 +78,11 @@ class nsAutoRefTraits { nsCOMPtr runnable = new SurfaceReleaser(aRawRef); NS_DispatchToMainThread(runnable); } - static void AddRef(RawRef aRawRef) { aRawRef->AddRef(); } + static void AddRef(RawRef aRawRef) { + NS_ASSERTION(NS_IsMainThread(), + "Can only add a reference on the main thread"); + aRawRef->AddRef(); + } }; class nsOwningThreadSourceSurfaceRef; diff --git a/gfx/layers/client/GPUVideoTextureClient.cpp b/gfx/layers/client/GPUVideoTextureClient.cpp index 501a3cd0f1..e939f818b5 100644 --- a/gfx/layers/client/GPUVideoTextureClient.cpp +++ b/gfx/layers/client/GPUVideoTextureClient.cpp @@ -14,12 +14,9 @@ using namespace gfx; GPUVideoTextureData::GPUVideoTextureData(RemoteDecoderManagerChild* aManager, const SurfaceDescriptorGPUVideo& aSD, const gfx::IntSize& aSize) - : mManager(aManager), - mSD(aSD), mSize(aSize) { - mSD.source() = Some(mManager->GetSource()); -} + : mManager(aManager), mSD(aSD), mSize(aSize) {} - GPUVideoTextureData::~GPUVideoTextureData() {} +GPUVideoTextureData::~GPUVideoTextureData() {} bool GPUVideoTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) { aOutDescriptor = mSD; diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index f4630a19c1..f21ef5a9b7 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -1375,7 +1375,7 @@ void TextureClient::GPUVideoDesc(SurfaceDescriptorGPUVideo* const aOutDesc) { MOZ_RELEASE_ASSERT(mData); mData->GetSubDescriptor(&subDesc); - *aOutDesc = SurfaceDescriptorGPUVideo(handle, std::move(subDesc), Nothing()); + *aOutDesc = SurfaceDescriptorGPUVideo(handle, std::move(subDesc)); } class MemoryTextureReadLock : public NonBlockingTextureReadLock { diff --git a/gfx/layers/composite/GPUVideoTextureHost.cpp b/gfx/layers/composite/GPUVideoTextureHost.cpp index a35c51f158..7e9b2636f1 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.cpp +++ b/gfx/layers/composite/GPUVideoTextureHost.cpp @@ -10,9 +10,9 @@ namespace mozilla { namespace layers { -GPUVideoTextureHost::GPUVideoTextureHost( - TextureFlags aFlags, const SurfaceDescriptorGPUVideo& aDescriptor) - : TextureHost(aFlags), mDescriptor(aDescriptor) { +GPUVideoTextureHost::GPUVideoTextureHost(TextureFlags aFlags, + TextureHost* aWrappedTextureHost) + : TextureHost(aFlags), mWrappedTextureHost(aWrappedTextureHost) { MOZ_COUNT_CTOR(GPUVideoTextureHost); } @@ -22,62 +22,48 @@ GPUVideoTextureHost::~GPUVideoTextureHost() { GPUVideoTextureHost* GPUVideoTextureHost::CreateFromDescriptor( TextureFlags aFlags, const SurfaceDescriptorGPUVideo& aDescriptor) { - return new GPUVideoTextureHost(aFlags, aDescriptor); -} - -TextureHost* GPUVideoTextureHost::EnsureWrappedTextureHost() { - if (mWrappedTextureHost) { - return mWrappedTextureHost; - } - - // In the future when the RDD process has a PVideoBridge connection, - // then there might be two VideoBridgeParents (one within the GPU process, - // one from RDD). We'll need to flag which one to use to lookup our - // descriptor, or just try both. - mWrappedTextureHost = - VideoBridgeParent::GetSingleton(mDescriptor.source())->LookupTexture(mDescriptor.handle()); - - if (mWrappedTextureHost && mExternalImageId.isSome()) { - mWrappedTextureHost->CreateRenderTexture(mExternalImageId.ref()); + TextureHost* wrappedTextureHost = + VideoBridgeParent::GetSingleton()->LookupTexture(aDescriptor.handle()); + if (!wrappedTextureHost) { + return nullptr; } - - return mWrappedTextureHost; + return new GPUVideoTextureHost(aFlags, wrappedTextureHost); } bool GPUVideoTextureHost::Lock() { - if (!EnsureWrappedTextureHost()) { + if (!mWrappedTextureHost) { return false; } - return EnsureWrappedTextureHost()->Lock(); + return mWrappedTextureHost->Lock(); } void GPUVideoTextureHost::Unlock() { - if (!EnsureWrappedTextureHost()) { + if (!mWrappedTextureHost) { return; } - EnsureWrappedTextureHost()->Unlock(); + mWrappedTextureHost->Unlock(); } bool GPUVideoTextureHost::BindTextureSource( CompositableTextureSourceRef& aTexture) { - if (!EnsureWrappedTextureHost()) { + if (!mWrappedTextureHost) { return false; } - return EnsureWrappedTextureHost()->BindTextureSource(aTexture); + return mWrappedTextureHost->BindTextureSource(aTexture); } bool GPUVideoTextureHost::AcquireTextureSource( CompositableTextureSourceRef& aTexture) { - if (!EnsureWrappedTextureHost()) { + if (!mWrappedTextureHost) { return false; } - return EnsureWrappedTextureHost()->AcquireTextureSource(aTexture); + return mWrappedTextureHost->AcquireTextureSource(aTexture); } void GPUVideoTextureHost::SetTextureSourceProvider( TextureSourceProvider* aProvider) { - if (EnsureWrappedTextureHost()) { - EnsureWrappedTextureHost()->SetTextureSourceProvider(aProvider); + if (mWrappedTextureHost) { + mWrappedTextureHost->SetTextureSourceProvider(aProvider); } } @@ -111,62 +97,38 @@ gfx::SurfaceFormat GPUVideoTextureHost::GetFormat() const { bool GPUVideoTextureHost::HasIntermediateBuffer() const { MOZ_ASSERT(mWrappedTextureHost); - if (!mWrappedTextureHost) { - return false; - } return mWrappedTextureHost->HasIntermediateBuffer(); } void GPUVideoTextureHost::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { - MOZ_ASSERT(mExternalImageId.isNothing()); - - mExternalImageId = Some(aExternalImageId); - - // When mWrappedTextureHost already exist, call CreateRenderTexture() here. - // In other cases, EnsureWrappedTextureHost() handles CreateRenderTexture(). - - if (mWrappedTextureHost) { - mWrappedTextureHost->CreateRenderTexture(aExternalImageId); - return; - } + MOZ_ASSERT(mWrappedTextureHost); - MOZ_ASSERT(EnsureWrappedTextureHost()); - EnsureWrappedTextureHost(); + mWrappedTextureHost->CreateRenderTexture(aExternalImageId); } -uint32_t GPUVideoTextureHost::NumSubTextures() { - MOZ_ASSERT(EnsureWrappedTextureHost()); - if (!EnsureWrappedTextureHost()) { - return 0; - } - return EnsureWrappedTextureHost()->NumSubTextures(); +uint32_t GPUVideoTextureHost::NumSubTextures() const { + MOZ_ASSERT(mWrappedTextureHost); + return mWrappedTextureHost->NumSubTextures(); } void GPUVideoTextureHost::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, const wr::ExternalImageId& aExtID) { - MOZ_ASSERT(EnsureWrappedTextureHost()); - if (!EnsureWrappedTextureHost()) { - return; - } - EnsureWrappedTextureHost()->PushResourceUpdates(aResources, aOp, aImageKeys, - aExtID); + MOZ_ASSERT(mWrappedTextureHost); + mWrappedTextureHost->PushResourceUpdates(aResources, aOp, aImageKeys, aExtID); } void GPUVideoTextureHost::PushDisplayItems( wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) { - MOZ_ASSERT(EnsureWrappedTextureHost()); + MOZ_ASSERT(mWrappedTextureHost); MOZ_ASSERT(aImageKeys.length() > 0); - if (!EnsureWrappedTextureHost()) { - return; - } - EnsureWrappedTextureHost()->PushDisplayItems(aBuilder, aBounds, aClip, - aFilter, aImageKeys); + mWrappedTextureHost->PushDisplayItems(aBuilder, aBounds, aClip, aFilter, + aImageKeys); } } // namespace layers diff --git a/gfx/layers/composite/GPUVideoTextureHost.h b/gfx/layers/composite/GPUVideoTextureHost.h index e2c2d45a4e..6e821c36d0 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.h +++ b/gfx/layers/composite/GPUVideoTextureHost.h @@ -49,7 +49,7 @@ class GPUVideoTextureHost : public TextureHost { void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; - uint32_t NumSubTextures() override; + uint32_t NumSubTextures() const override; void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, @@ -62,14 +62,9 @@ class GPUVideoTextureHost : public TextureHost { const Range& aImageKeys) override; protected: - GPUVideoTextureHost(TextureFlags aFlags, - const SurfaceDescriptorGPUVideo& aDescriptor); - - TextureHost* EnsureWrappedTextureHost(); + GPUVideoTextureHost(TextureFlags aFlags, TextureHost* aWrappedTextureHost); RefPtr mWrappedTextureHost; - SurfaceDescriptorGPUVideo mDescriptor; - wr::MaybeExternalImageId mExternalImageId; }; } // namespace layers diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index b7cba0d8a7..d6739b8d1e 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -578,7 +578,7 @@ void BufferTextureHost::CreateRenderTexture( texture.forget()); } -uint32_t BufferTextureHost::NumSubTextures() { +uint32_t BufferTextureHost::NumSubTextures() const { if (GetFormat() == gfx::SurfaceFormat::YUV) { return 3; } diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index 25c4ef9ca6..9674f77128 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -650,7 +650,7 @@ class TextureHost : public AtomicRefCountedWithFinalize { /// Returns the number of actual textures that will be used to render this. /// For example in a lot of YUV cases it will be 3 - virtual uint32_t NumSubTextures() { return 1; } + virtual uint32_t NumSubTextures() const { return 1; } enum ResourceUpdateOp { ADD_IMAGE, @@ -787,7 +787,7 @@ class BufferTextureHost : public TextureHost { void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; - uint32_t NumSubTextures() override; + uint32_t NumSubTextures() const override; void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 8f83f6db76..7a51f3909a 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -982,7 +982,7 @@ void DXGITextureHostD3D11::CreateRenderTexture( texture.forget()); } -uint32_t DXGITextureHostD3D11::NumSubTextures() { +uint32_t DXGITextureHostD3D11::NumSubTextures() const { switch (GetFormat()) { case gfx::SurfaceFormat::R8G8B8X8: case gfx::SurfaceFormat::R8G8B8A8: @@ -1244,7 +1244,7 @@ void DXGIYCbCrTextureHostD3D11::CreateRenderTexture( texture.forget()); } -uint32_t DXGIYCbCrTextureHostD3D11::NumSubTextures() { +uint32_t DXGIYCbCrTextureHostD3D11::NumSubTextures() const { // ycbcr use 3 sub textures. return 3; } diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index 3c55abd154..ecf72e704d 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -346,7 +346,7 @@ class DXGITextureHostD3D11 : public TextureHost { void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; - uint32_t NumSubTextures() override; + uint32_t NumSubTextures() const override; void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, @@ -414,7 +414,7 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost { void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; - uint32_t NumSubTextures() override; + uint32_t NumSubTextures() const override; void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index a53a030f32..c229da0897 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -16,7 +16,6 @@ using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h"; using mozilla::gfx::IntSize from "mozilla/gfx/Point.h"; using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h"; using gfxImageFormat from "gfxTypes.h"; -using mozilla::layers::MaybeVideoBridgeSource from "mozilla/layers/VideoBridgeUtils.h"; namespace mozilla { namespace layers { @@ -97,7 +96,6 @@ union GPUVideoSubDescriptor { struct SurfaceDescriptorGPUVideo { uint64_t handle; GPUVideoSubDescriptor subdesc; - MaybeVideoBridgeSource source; }; struct RGBDescriptor { diff --git a/gfx/layers/ipc/VideoBridgeChild.cpp b/gfx/layers/ipc/VideoBridgeChild.cpp index 5cae54f3d8..3e246a14c9 100644 --- a/gfx/layers/ipc/VideoBridgeChild.cpp +++ b/gfx/layers/ipc/VideoBridgeChild.cpp @@ -5,52 +5,41 @@ #include "VideoBridgeChild.h" #include "VideoBridgeParent.h" #include "CompositorThread.h" -#include "mozilla/dom/ContentChild.h" namespace mozilla { namespace layers { -StaticRefPtr sVideoBridge; +StaticRefPtr sVideoBridgeChildSingleton; /* static */ -void VideoBridgeChild::StartupForGPUProcess() { - ipc::Endpoint parentPipe; - ipc::Endpoint childPipe; +void VideoBridgeChild::Startup() { + sVideoBridgeChildSingleton = new VideoBridgeChild(); + RefPtr parent = new VideoBridgeParent(); - PVideoBridge::CreateEndpoints(base::GetCurrentProcId(), - base::GetCurrentProcId(), &parentPipe, - &childPipe); + MessageLoop* loop = CompositorThreadHolder::Loop(); - VideoBridgeChild::Open(std::move(childPipe)); - VideoBridgeParent::Open(std::move(parentPipe), VideoBridgeSource::GpuProcess); -} - -void VideoBridgeChild::Open(Endpoint&& aEndpoint) { - MOZ_ASSERT(!sVideoBridge || !sVideoBridge->CanSend()); - sVideoBridge = new VideoBridgeChild(); - - if (!aEndpoint.Bind(sVideoBridge)) { - // We can't recover from this. - MOZ_CRASH("Failed to bind VideoBridgeChild to endpoint"); - } + sVideoBridgeChildSingleton->Open(parent->GetIPCChannel(), loop, + ipc::ChildSide); + sVideoBridgeChildSingleton->mIPDLSelfRef = sVideoBridgeChildSingleton; + parent->SetOtherProcessId(base::GetCurrentProcId()); } /* static */ void VideoBridgeChild::Shutdown() { - if (sVideoBridge) { - sVideoBridge->Close(); - sVideoBridge = nullptr; + if (sVideoBridgeChildSingleton) { + sVideoBridgeChildSingleton->Close(); + sVideoBridgeChildSingleton = nullptr; } } VideoBridgeChild::VideoBridgeChild() - : mIPDLSelfRef(this), - mMessageLoop(MessageLoop::current()), - mCanSend(true) {} + : mMessageLoop(MessageLoop::current()), mCanSend(true) {} VideoBridgeChild::~VideoBridgeChild() {} -VideoBridgeChild* VideoBridgeChild::GetSingleton() { return sVideoBridge; } +VideoBridgeChild* VideoBridgeChild::GetSingleton() { + return sVideoBridgeChildSingleton; +} bool VideoBridgeChild::AllocUnsafeShmem( size_t aSize, ipc::SharedMemory::SharedMemoryType aType, @@ -101,9 +90,5 @@ bool VideoBridgeChild::IsSameProcess() const { return OtherPid() == base::GetCurrentProcId(); } -void VideoBridgeChild::HandleFatalError(const char* aMsg) const { - dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid()); -} - } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/VideoBridgeChild.h b/gfx/layers/ipc/VideoBridgeChild.h index d53fbde4d6..e5bb21295d 100644 --- a/gfx/layers/ipc/VideoBridgeChild.h +++ b/gfx/layers/ipc/VideoBridgeChild.h @@ -6,7 +6,6 @@ #define MOZILLA_GFX_VIDEOBRIDGECHILD_H #include "mozilla/layers/PVideoBridgeChild.h" -#include "mozilla/layers/VideoBridgeUtils.h" #include "ISurfaceAllocator.h" #include "TextureForwarder.h" @@ -18,7 +17,7 @@ class VideoBridgeChild final : public PVideoBridgeChild, public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoBridgeChild, override); - static void StartupForGPUProcess(); + static void Startup(); static void Shutdown(); static VideoBridgeChild* GetSingleton(); @@ -63,11 +62,6 @@ class VideoBridgeChild final : public PVideoBridgeChild, bool CanSend() { return mCanSend; } - static void Open(Endpoint&& aEndpoint); - - protected: - void HandleFatalError(const char* aMsg) const override; - private: VideoBridgeChild(); virtual ~VideoBridgeChild(); diff --git a/gfx/layers/ipc/VideoBridgeParent.cpp b/gfx/layers/ipc/VideoBridgeParent.cpp index cabbcb8069..8ff656d988 100644 --- a/gfx/layers/ipc/VideoBridgeParent.cpp +++ b/gfx/layers/ipc/VideoBridgeParent.cpp @@ -5,7 +5,6 @@ #include "VideoBridgeParent.h" #include "CompositorThread.h" #include "mozilla/layers/TextureHost.h" -#include "mozilla/layers/VideoBridgeUtils.h" namespace mozilla { namespace layers { @@ -13,66 +12,19 @@ namespace layers { using namespace mozilla::ipc; using namespace mozilla::gfx; -static VideoBridgeParent* sVideoBridgeFromRddProcess; -static VideoBridgeParent* sVideoBridgeFromGpuProcess; +static VideoBridgeParent* sVideoBridgeSingleton; -VideoBridgeParent::VideoBridgeParent(VideoBridgeSource aSource) - : mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()), - mClosed(false) { +VideoBridgeParent::VideoBridgeParent() : mClosed(false) { mSelfRef = this; - switch (aSource) { - default: - MOZ_CRASH("Unhandled case"); - case VideoBridgeSource::RddProcess: - sVideoBridgeFromRddProcess = this; - break; - case VideoBridgeSource::GpuProcess: - sVideoBridgeFromGpuProcess = this; - break; - } + sVideoBridgeSingleton = this; + mCompositorThreadRef = CompositorThreadHolder::GetSingleton(); } -VideoBridgeParent::~VideoBridgeParent() { - if (sVideoBridgeFromRddProcess == this) { - sVideoBridgeFromRddProcess = nullptr; - } - if (sVideoBridgeFromGpuProcess == this) { - sVideoBridgeFromGpuProcess = nullptr; - } -} +VideoBridgeParent::~VideoBridgeParent() { sVideoBridgeSingleton = nullptr; } /* static */ -void VideoBridgeParent::Open(Endpoint&& aEndpoint, - VideoBridgeSource aSource) { - RefPtr parent = new VideoBridgeParent(aSource); - - CompositorThreadHolder::Loop()->PostTask( - NewRunnableMethod&&>( - "gfx::layers::VideoBridgeParent::Bind", parent, - &VideoBridgeParent::Bind, std::move(aEndpoint))); -} - -void VideoBridgeParent::Bind(Endpoint&& aEndpoint) { - if (!aEndpoint.Bind(this)) { - // We can't recover from this. - MOZ_CRASH("Failed to bind VideoBridgeParent to endpoint"); - } -} - -/* static */ -VideoBridgeParent* VideoBridgeParent::GetSingleton( - Maybe& aSource) { - MOZ_ASSERT(aSource.isSome()); - switch (aSource.value()) { - default: - MOZ_CRASH("Unhandled case"); - case VideoBridgeSource::RddProcess: - MOZ_ASSERT(sVideoBridgeFromRddProcess); - return sVideoBridgeFromRddProcess; - case VideoBridgeSource::GpuProcess: - MOZ_ASSERT(sVideoBridgeFromGpuProcess); - return sVideoBridgeFromGpuProcess; - } +VideoBridgeParent* VideoBridgeParent::GetSingleton() { + return sVideoBridgeSingleton; } TextureHost* VideoBridgeParent::LookupTexture(uint64_t aSerial) { @@ -85,7 +37,7 @@ void VideoBridgeParent::ActorDestroy(ActorDestroyReason aWhy) { } void VideoBridgeParent::ActorDealloc() { - mCompositorThreadHolder = nullptr; + mCompositorThreadRef = nullptr; mSelfRef = nullptr; } diff --git a/gfx/layers/ipc/VideoBridgeParent.h b/gfx/layers/ipc/VideoBridgeParent.h index f9448f21e5..515a1b5ee2 100644 --- a/gfx/layers/ipc/VideoBridgeParent.h +++ b/gfx/layers/ipc/VideoBridgeParent.h @@ -11,20 +11,16 @@ namespace mozilla { namespace layers { -enum class VideoBridgeSource : uint8_t; class CompositorThreadHolder; class VideoBridgeParent final : public PVideoBridgeParent, public HostIPCAllocator, public ShmemAllocator { public: + VideoBridgeParent(); ~VideoBridgeParent(); - static VideoBridgeParent* GetSingleton(Maybe& aSource); - - static void Open(Endpoint&& aEndpoint, - VideoBridgeSource aSource); - + static VideoBridgeParent* GetSingleton(); TextureHost* LookupTexture(uint64_t aSerial); // PVideoBridgeParent @@ -58,15 +54,12 @@ class VideoBridgeParent final : public PVideoBridgeParent, void DeallocShmem(ipc::Shmem& aShmem) override; private: - explicit VideoBridgeParent(VideoBridgeSource aSource); - void Bind(Endpoint&& aEndpoint); - void ActorDealloc() override; // This keeps us alive until ActorDestroy(), at which point we do a // deferred destruction of ourselves. RefPtr mSelfRef; - RefPtr mCompositorThreadHolder; + RefPtr mCompositorThreadRef; std::map mTextureMap; diff --git a/gfx/layers/ipc/VideoBridgeUtils.h b/gfx/layers/ipc/VideoBridgeUtils.h deleted file mode 100644 index 9ff096fe76..0000000000 --- a/gfx/layers/ipc/VideoBridgeUtils.h +++ /dev/null @@ -1,35 +0,0 @@ -/* 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 IPC_VideoBridgeUtils_h -#define IPC_VideoBridgeUtils_h - -#include "ipc/IPCMessageUtils.h" - -namespace mozilla { -namespace layers { - -enum class VideoBridgeSource : uint8_t { - RddProcess, - GpuProcess, - _Count, -}; - -typedef Maybe MaybeVideoBridgeSource; - -} // namespace layers -} // namespace mozilla - -namespace IPC { - -template <> -struct ParamTraits - : public ContiguousEnumSerializer< - mozilla::layers::VideoBridgeSource, - mozilla::layers::VideoBridgeSource::RddProcess, - mozilla::layers::VideoBridgeSource::_Count> {}; - -} // namespace IPC - -#endif // IPC_VideoBridgeUtils_h diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index ed076b9ff7..1fe6f01ada 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -223,7 +223,6 @@ EXPORTS.mozilla.layers += [ 'ipc/UiCompositorControllerParent.h', 'ipc/VideoBridgeChild.h', 'ipc/VideoBridgeParent.h', - 'ipc/VideoBridgeUtils.h', 'LayerAttributes.h', 'LayerMetricsWrapper.h', 'LayersHelpers.h', diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp index 93cf844822..74122d441a 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp @@ -137,7 +137,7 @@ void MacIOSurfaceTextureHostOGL::CreateRenderTexture( texture.forget()); } -uint32_t MacIOSurfaceTextureHostOGL::NumSubTextures() { +uint32_t MacIOSurfaceTextureHostOGL::NumSubTextures() const { switch (GetFormat()) { case gfx::SurfaceFormat::R8G8B8X8: case gfx::SurfaceFormat::R8G8B8A8: diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h index 008357e546..0b04d3e747 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h @@ -64,7 +64,7 @@ class MacIOSurfaceTextureHostOGL : public TextureHost { void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; - uint32_t NumSubTextures() override; + uint32_t NumSubTextures() const override; void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, diff --git a/gfx/layers/wr/AsyncImagePipelineManager.cpp b/gfx/layers/wr/AsyncImagePipelineManager.cpp index f9fc8a88dc..dca5cff664 100644 --- a/gfx/layers/wr/AsyncImagePipelineManager.cpp +++ b/gfx/layers/wr/AsyncImagePipelineManager.cpp @@ -221,9 +221,8 @@ Maybe AsyncImagePipelineManager::UpdateImageKeys( return Nothing(); } - if (!texture || texture->NumSubTextures() == 0) { - // We don't have a new texture or texture does not have SubTextures, there - // isn't much we can do. + if (!texture) { + // We don't have a new texture, there isn't much we can do. aKeys = aPipeline->mKeys; return Nothing(); } @@ -242,7 +241,6 @@ Maybe AsyncImagePipelineManager::UpdateImageKeys( // The non-external image code path falls back to converting the texture into // an rgb image. auto numKeys = useExternalImage ? texture->NumSubTextures() : 1; - MOZ_ASSERT(numKeys > 0); // If we already had a texture and the format hasn't changed, better to reuse // the image keys than create new ones. diff --git a/gfx/layers/wr/WebRenderTextureHost.cpp b/gfx/layers/wr/WebRenderTextureHost.cpp index 98c7d87396..b41f03ef96 100644 --- a/gfx/layers/wr/WebRenderTextureHost.cpp +++ b/gfx/layers/wr/WebRenderTextureHost.cpp @@ -206,7 +206,7 @@ bool WebRenderTextureHost::HasIntermediateBuffer() const { return mWrappedTextureHost->HasIntermediateBuffer(); } -uint32_t WebRenderTextureHost::NumSubTextures() { +uint32_t WebRenderTextureHost::NumSubTextures() const { MOZ_ASSERT(mWrappedTextureHost); return mWrappedTextureHost->NumSubTextures(); } diff --git a/gfx/layers/wr/WebRenderTextureHost.h b/gfx/layers/wr/WebRenderTextureHost.h index ad915f246d..550fa986ef 100644 --- a/gfx/layers/wr/WebRenderTextureHost.h +++ b/gfx/layers/wr/WebRenderTextureHost.h @@ -68,7 +68,7 @@ class WebRenderTextureHost : public TextureHost { bool HasIntermediateBuffer() const override; - uint32_t NumSubTextures() override; + uint32_t NumSubTextures() const override; void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp,