diff --git a/dom/media/ipc/RDDParent.cpp b/dom/media/ipc/RDDParent.cpp index 95702fc5a0f1..9bbd5ae18cb7 100644 --- a/dom/media/ipc/RDDParent.cpp +++ b/dom/media/ipc/RDDParent.cpp @@ -10,6 +10,7 @@ # include # include "WMF.h" +# include "WMFDecoderModule.h" # include "mozilla/WinDllServices.h" # include "mozilla/gfx/DeviceManagerDx.h" #else @@ -24,6 +25,7 @@ #include "mozilla/Preferences.h" #include "mozilla/RemoteDecoderManagerChild.h" #include "mozilla/RemoteDecoderManagerParent.h" +#include "mozilla/ScopeExit.h" #include "mozilla/TimeStamp.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/gfx/gfxVars.h" @@ -151,6 +153,18 @@ mozilla::ipc::IPCResult RDDParent::RecvInit( } IPCResult RDDParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { +#if defined(XP_WIN) + auto scopeExit = MakeScopeExit( + [couldUseHWDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding()] { + if (couldUseHWDecoder != gfx::gfxVars::CanUseHardwareVideoDecoding()) { + // The capabilities of the system may have changed, force a refresh by + // re-initializing the WMF PDM. + WMFDecoderModule::Init(); + Unused << RDDParent::GetSingleton()->SendUpdateMediaCodecsSupported( + PDMFactory::Supported(true /* force refresh */)); + } + }); +#endif gfxVars::ApplyUpdate(aUpdate); return IPC_OK(); } diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp index 016a1be43098..38d44946fad1 100644 --- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -618,8 +618,10 @@ void PDMFactory::SetCDMProxy(CDMProxy* aProxy) { } /* static */ -PDMFactory::MediaCodecsSupported PDMFactory::Supported() { - static MediaCodecsSupported supported = []() { +PDMFactory::MediaCodecsSupported PDMFactory::Supported(bool aForceRefresh) { + MOZ_ASSERT(NS_IsMainThread()); + + static auto calculate = []() { auto pdm = MakeRefPtr(); MediaCodecsSupported supported; // H264 and AAC depends on external framework that must be dynamically @@ -665,7 +667,11 @@ PDMFactory::MediaCodecsSupported PDMFactory::Supported() { supported += MediaCodecs::Wave; } return supported; - }(); + }; + static MediaCodecsSupported supported = calculate(); + if (aForceRefresh) { + supported = calculate(); + } return supported; } diff --git a/dom/media/platforms/PDMFactory.h b/dom/media/platforms/PDMFactory.h index 643e571375b2..3194e28d8d57 100644 --- a/dom/media/platforms/PDMFactory.h +++ b/dom/media/platforms/PDMFactory.h @@ -87,7 +87,7 @@ class PDMFactory final { using MediaCodecsSupported = EnumSet; - static MediaCodecsSupported Supported(); + static MediaCodecsSupported Supported(bool aForceRefresh = false); static bool SupportsMimeType(const nsACString& aMimeType, const MediaCodecsSupported& aSupported); diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index f57500388f56..550f51bd42c8 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -6,22 +6,32 @@ #ifdef XP_WIN # include "WMF.h" +# include "WMFDecoderModule.h" #endif -#include "GPUParent.h" -#include "gfxConfig.h" -#include "gfxCrashReporterUtils.h" -#include "GfxInfoBase.h" -#include "gfxPlatform.h" #include "GLContextProvider.h" +#include "GPUParent.h" #include "GPUProcessHost.h" #include "GPUProcessManager.h" +#include "GfxInfoBase.h" +#include "ProcessUtils.h" +#include "VRGPUChild.h" +#include "VRManager.h" +#include "VRManagerParent.h" +#include "VsyncBridgeParent.h" +#include "cairo.h" +#include "gfxConfig.h" +#include "gfxCrashReporterUtils.h" +#include "gfxPlatform.h" #include "mozilla/Assertions.h" +#include "mozilla/HangDetails.h" #include "mozilla/PerfStats.h" +#include "mozilla/Preferences.h" +#include "mozilla/RemoteDecoderManagerChild.h" +#include "mozilla/RemoteDecoderManagerParent.h" +#include "mozilla/ScopeExit.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" -#include "mozilla/RemoteDecoderManagerChild.h" -#include "mozilla/RemoteDecoderManagerParent.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/gfxVars.h" @@ -29,43 +39,37 @@ #include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" #include "mozilla/layers/APZInputBridgeParent.h" -#include "mozilla/layers/APZThreadUtils.h" #include "mozilla/layers/APZPublicUtils.h" // for apz::InitializeGlobalState +#include "mozilla/layers/APZThreadUtils.h" #include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/CompositorManagerParent.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/ImageBridgeParent.h" #include "mozilla/layers/LayerTreeOwnerTracker.h" -#include "mozilla/layers/UiCompositorControllerParent.h" #include "mozilla/layers/MemoryReportingMLGPU.h" +#include "mozilla/layers/UiCompositorControllerParent.h" #include "mozilla/layers/VideoBridgeParent.h" #include "mozilla/webrender/RenderThread.h" #include "mozilla/webrender/WebRenderAPI.h" -#include "mozilla/HangDetails.h" -#include "mozilla/Preferences.h" -#include "nscore.h" #include "nsDebugImpl.h" #include "nsIGfxInfo.h" #include "nsThreadManager.h" +#include "nscore.h" #include "prenv.h" -#include "ProcessUtils.h" -#include "VRGPUChild.h" -#include "VRManager.h" -#include "VRManagerParent.h" -#include "VsyncBridgeParent.h" -#include "cairo.h" #include "skia/include/core/SkGraphics.h" #if defined(XP_WIN) +# include +# include + +# include "mozilla/WindowsVersion.h" # include "mozilla/gfx/DeviceManagerDx.h" # include "mozilla/widget/WinCompositorWindowThread.h" -# include "mozilla/WindowsVersion.h" -# include -# include #else # include #endif #ifdef MOZ_WIDGET_GTK # include + # include "skia/include/ports/SkTypeface_cairo.h" #endif #ifdef MOZ_GECKO_PROFILER @@ -374,6 +378,18 @@ mozilla::ipc::IPCResult GPUParent::RecvInitProfiler( } mozilla::ipc::IPCResult GPUParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { +#if defined(XP_WIN) + auto scopeExit = MakeScopeExit( + [couldUseHWDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding()] { + if (couldUseHWDecoder != gfx::gfxVars::CanUseHardwareVideoDecoding()) { + // The capabilities of the system may have changed, force a refresh by + // re-initializing the WMF PDM. + WMFDecoderModule::Init(); + Unused << GPUParent::GetSingleton()->SendUpdateMediaCodecsSupported( + PDMFactory::Supported(true /* force refresh */)); + } + }); +#endif gfxVars::ApplyUpdate(aUpdate); return IPC_OK(); }