From 5fbc5b601076292b83e1b5e1911d4ae696322d64 Mon Sep 17 00:00:00 2001 From: thexai <58434170+thexai@users.noreply.github.com> Date: Sat, 28 Dec 2019 21:11:26 +0100 Subject: [PATCH] Some performance improvements: Since GetHDRDisplayStatus() is relativity slow function prefer avoid use it when is posible. Is used cached status isHDROutput() and more fast IsDisplayHDREnabled() method based on GetDesc1 inside ResizeBuffers(). Anterior approach is not causing issues but now is better. Separate 10bSwapchain flag from HDROutput flag. Some renaming and code styling. Refactor to avoid if defs --- .../resources/strings.po | 4 +- xbmc/Application.cpp | 5 +- .../VideoRenderers/HwDecRender/DXVAHD.cpp | 10 +--- .../VideoShaders/WinVideoFilter.cpp | 2 +- .../VideoRenderers/windows/RendererBase.cpp | 47 +++++++--------- .../VideoRenderers/windows/RendererDXVA.cpp | 4 +- .../windows/RendererShaders.cpp | 3 +- xbmc/guilib/guiinfo/SystemGUIInfo.cpp | 15 +---- xbmc/interfaces/builtins/GUIBuiltins.cpp | 7 +-- xbmc/platform/win32/WIN32Util.cpp | 8 --- xbmc/platform/win32/WIN32Util.h | 2 - xbmc/rendering/dx/DeviceResources.cpp | 55 +++++++++++++++++-- xbmc/rendering/dx/DeviceResources.h | 7 ++- xbmc/windowing/WinSystem.h | 2 + xbmc/windowing/windows/WinSystemWin32.cpp | 10 ++++ xbmc/windowing/windows/WinSystemWin32.h | 5 +- 16 files changed, 104 insertions(+), 82 deletions(-) diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index ebf9b2ceff50e..f5e91bcba8b21 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -6131,12 +6131,12 @@ msgstr "" #: addons/skin.estuary/xml/DialogButtonMenu.xml msgctxt "#13037" -msgid "Toggle Windows HDR On" +msgid "Toggle display HDR on" msgstr "" #: addons/skin.estuary/xml/DialogButtonMenu.xml msgctxt "#13038" -msgid "Toggle Windows HDR Off" +msgid "Toggle display HDR off" msgstr "" #empty strings from id 13039 to 13049 diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index bd46b04e09420..e1b811a24f251 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -490,9 +490,10 @@ bool CApplication::Create(const CAppParamParser ¶ms) CLog::Log(LOGNOTICE, "%s", CWIN32Util::GetResInfoString().c_str()); CLog::Log(LOGNOTICE, "Running with %s rights", (CWIN32Util::IsCurrentUserLocalAdministrator() == TRUE) ? "administrator" : "restricted"); CLog::Log(LOGNOTICE, "Aero is %s", (g_sysinfo.IsAeroDisabled() == true) ? "disabled" : "enabled"); - if (CWIN32Util::GetHDRDisplayStatus()) + int hDR = CWIN32Util::GetHDRDisplayStatus(); + if (hDR > 0) CLog::Log(LOGNOTICE, "HDR Display capable is detected and Windows HDR switch is %s", - (CWIN32Util::IsDisplayHDREnabled() == true) ? "ON" : "OFF"); + (hDR == 2) ? "ON" : "OFF"); else CLog::Log(LOGNOTICE, "Display is not HDR capable"); #endif diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DXVAHD.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DXVAHD.cpp index d448b5e16de6e..94789f1376c0b 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DXVAHD.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DXVAHD.cpp @@ -35,12 +35,6 @@ do { \ } \ } while(0); -template -T from_rational(uint64_t default_factor, AVRational rat) -{ - return static_cast(default_factor * rat.num / rat.den); -} - CProcessorHD::CProcessorHD() { DX::Windowing()->Register(this); @@ -514,7 +508,7 @@ bool CProcessorHD::Render(CRect src, CRect dst, ID3D11Resource* target, CRenderB ? DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709 : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; - if (DX::DeviceResources::Get()->Is10BitSwapchain()) + if (DX::DeviceResources::Get()->IsHDROutput()) { if ((views[2]->color_transfer == AVCOL_TRC_SMPTE2084 || views[2]->color_transfer == AVCOL_TRC_ARIB_STD_B67) && @@ -538,7 +532,7 @@ bool CProcessorHD::Render(CRect src, CRect dst, ID3D11Resource* target, CRenderB // makes target available for processing in shaders videoCtx1->VideoProcessorSetOutputShaderUsage(m_pVideoProcessor.Get(), 1); - if (DX::DeviceResources::Get()->Is10BitSwapchain() && m_bSupportHDR10 && + if (DX::DeviceResources::Get()->IsHDROutput() && m_bSupportHDR10 && views[2]->color_transfer == AVCOL_TRC_SMPTE2084 && views[2]->primaries == AVCOL_PRI_BT2020) { ComPtr videoCtx2; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/WinVideoFilter.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/WinVideoFilter.cpp index f1818b41f506d..5d00b17680a46 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/WinVideoFilter.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/WinVideoFilter.cpp @@ -228,7 +228,7 @@ bool COutputShader::Create(bool useLUT, bool useDithering, int ditherDepth, bool { m_useLut = useLUT; m_ditherDepth = ditherDepth; - m_toneMapping = toneMapping && !DX::DeviceResources::Get()->Is10BitSwapchain(); + m_toneMapping = toneMapping && !DX::DeviceResources::Get()->IsHDROutput(); CWinShader::CreateVertexBuffer(4, sizeof(Vertex)); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererBase.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererBase.cpp index 738502f025a45..bfcc0be7181ba 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererBase.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererBase.cpp @@ -10,7 +10,6 @@ #include "DVDCodecs/Video/DVDVideoCodec.h" #include "DVDCodecs/Video/DXVA.h" -#include "platform/win32/WIN32Util.h" #include "Process/VideoBuffer.h" #include "VideoRenderers/BaseRenderer.h" #include "VideoRenderers/RenderFlags.h" @@ -131,13 +130,10 @@ CRendererBase::CRendererBase(CVideoSettings& videoSettings) CRendererBase::~CRendererBase() { - if (DX::DeviceResources::Get()->Is10BitSwapchain()) + if (DX::DeviceResources::Get()->IsHDROutput()) { - if (CWIN32Util::IsDisplayHDREnabled()) - { - CLog::LogF(LOGDEBUG, "Restoring SDR rendering"); - DX::DeviceResources::Get()->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709); - } + CLog::LogF(LOGDEBUG, "Restoring SDR rendering"); + DX::DeviceResources::Get()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709); } Flush(false); } @@ -171,7 +167,7 @@ bool CRendererBase::Configure(const VideoPicture& picture, float fps, unsigned o m_fps = fps; m_renderOrientation = orientation; - if (DX::DeviceResources::Get()->Is10BitSwapchain()) + if (DX::DeviceResources::Get()->IsHDROutput()) { m_lastHdr10 = {}; m_isHdrEnabled = false; @@ -214,7 +210,7 @@ void CRendererBase::Render(CD3DTexture& target, const CRect& sourceRect, const C return; } - if (DX::DeviceResources::Get()->Is10BitSwapchain()) + if (DX::DeviceResources::Get()->IsHDROutput()) { // HDR10 if (buf->color_transfer == AVCOL_TRC_SMPTE2084 && buf->primaries == AVCOL_PRI_BT2020) @@ -233,14 +229,11 @@ void CRendererBase::Render(CD3DTexture& target, const CRect& sourceRect, const C else { // Sets HDR10 metadata and enables HDR10 color space (switch to HDR rendering) - if (CWIN32Util::IsDisplayHDREnabled()) - { - DX::DeviceResources::Get()->SetHdrMetaData(hdr10); - CLog::LogF(LOGNOTICE, "Switching to HDR rendering"); - DX::DeviceResources::Get()->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020); - m_isHdrEnabled = true; - m_lastHdr10 = hdr10; - } + DX::DeviceResources::Get()->SetHdrMetaData(hdr10); + CLog::LogF(LOGNOTICE, "Switching to HDR rendering"); + DX::DeviceResources::Get()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020); + m_isHdrEnabled = true; + m_lastHdr10 = hdr10; } m_iCntMetaData = 0; } @@ -249,13 +242,10 @@ void CRendererBase::Render(CD3DTexture& target, const CRect& sourceRect, const C { if (!m_isHlgEnabled) { - if (CWIN32Util::IsDisplayHDREnabled()) - { - // Switch to HLG rendering (internally converts HLG to HDR10) - CLog::LogF(LOGNOTICE, "Switching to HLG rendering"); - DX::DeviceResources::Get()->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020); - m_isHlgEnabled = true; - } + // Switch to HLG rendering (internally converts HLG to HDR10) + CLog::LogF(LOGNOTICE, "Switching to HLG rendering"); + DX::DeviceResources::Get()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020); + m_isHlgEnabled = true; } } // Rec. 2020 @@ -265,7 +255,7 @@ void CRendererBase::Render(CD3DTexture& target, const CRect& sourceRect, const C { // Switch to Rec.2020 rendering CLog::LogF(LOGNOTICE, "Switching to Rec.2020 rendering"); - DX::DeviceResources::Get()->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020); + DX::DeviceResources::Get()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020); m_isRec2020Enabled = true; } } @@ -278,7 +268,7 @@ void CRendererBase::Render(CD3DTexture& target, const CRect& sourceRect, const C { // If more than 60 frames are received without HDR10 metadata switch to SDR rendering CLog::LogF(LOGNOTICE, "Switching to SDR rendering"); - DX::DeviceResources::Get()->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709); + DX::DeviceResources::Get()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709); m_isHdrEnabled = false; m_iCntMetaData = 0; } @@ -287,7 +277,7 @@ void CRendererBase::Render(CD3DTexture& target, const CRect& sourceRect, const C { // Switch to SDR rendering CLog::LogF(LOGNOTICE, "Switching to SDR rendering"); - DX::DeviceResources::Get()->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709); + DX::DeviceResources::Get()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709); m_isHlgEnabled = false; m_isRec2020Enabled = false; } @@ -491,7 +481,8 @@ void CRendererBase::CheckVideoParameters() CRenderBuffer* buf = m_renderBuffers[m_iBufferIndex]; bool toneMap = false; - if (m_videoSettings.m_ToneMapMethod != VS_TONEMAPMETHOD_OFF) + if (m_videoSettings.m_ToneMapMethod != VS_TONEMAPMETHOD_OFF && + !DX::DeviceResources::Get()->IsHDROutput()) { if (buf->hasLightMetadata || buf->hasDisplayMetadata && buf->displayMetadata.has_luminance) toneMap = true; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.cpp index af0f73c32d5ee..990f2302310fb 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.cpp @@ -183,9 +183,7 @@ CRect CRendererDXVA::ApplyTransforms(const CRect& destRect) const bool CRendererDXVA::UseToneMapping() const { // use mapping only if processor doesn't support HDR10 - // and is not 10 bit swapchain (HDR to SDR conversion) - return !m_processor->HasHDR10Support() && !DX::DeviceResources::Get()->Is10BitSwapchain() && - __super::UseToneMapping(); + return !m_processor->HasHDR10Support() && __super::UseToneMapping(); } void CRendererDXVA::FillBuffersSet(CRenderBuffer* (&buffers)[8]) diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.cpp index fd8b50ea74638..ba7c868f86713 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.cpp @@ -135,7 +135,8 @@ void CRendererShaders::UpdateVideoFilters() AVColorPrimaries dstPrimaries = AVCOL_PRI_BT709; - if (DX::DeviceResources::Get()->Is10BitSwapchain()) + if (DX::DeviceResources::Get()->IsHDROutput() && + (m_srcPrimaries == AVCOL_PRI_BT709 || m_srcPrimaries == AVCOL_PRI_BT2020)) dstPrimaries = m_srcPrimaries; if (!m_colorShader->Create(m_format, dstPrimaries, m_srcPrimaries)) diff --git a/xbmc/guilib/guiinfo/SystemGUIInfo.cpp b/xbmc/guilib/guiinfo/SystemGUIInfo.cpp index 97fa6014c27f5..d430e5b119758 100644 --- a/xbmc/guilib/guiinfo/SystemGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/SystemGUIInfo.cpp @@ -20,9 +20,6 @@ #if defined(TARGET_DARWIN_OSX) #include "platform/darwin/osx/smc.h" #endif -#if defined(TARGET_WINDOWS) -#include "platform/win32/WIN32Util.h" -#endif #include "powermanagement/PowerManager.h" #include "profiles/ProfileManager.h" #include "settings/AdvancedSettings.h" @@ -574,18 +571,10 @@ bool CSystemGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int context value = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_showExitButton; return true; case SYSTEM_IS_HDR_DISPLAY_OFF: -#if defined(TARGET_WINDOWS) - value = (1 == CWIN32Util::GetHDRDisplayStatus()); -#else - value = false; -#endif + value = (1 == CServiceBroker::GetWinSystem()->GetHDRDisplayStatus()); return true; case SYSTEM_IS_HDR_DISPLAY_ON: -#if defined(TARGET_WINDOWS) - value = (2 == CWIN32Util::GetHDRDisplayStatus()); -#else - value = false; -#endif + value = (2 == CServiceBroker::GetWinSystem()->GetHDRDisplayStatus()); return true; case SYSTEM_HAS_LOGINSCREEN: value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->UsingLoginScreen(); diff --git a/xbmc/interfaces/builtins/GUIBuiltins.cpp b/xbmc/interfaces/builtins/GUIBuiltins.cpp index 77c40b115af8e..e497374bf55e8 100644 --- a/xbmc/interfaces/builtins/GUIBuiltins.cpp +++ b/xbmc/interfaces/builtins/GUIBuiltins.cpp @@ -22,9 +22,6 @@ #include "input/WindowTranslator.h" #include "input/actions/ActionTranslator.h" #include "messaging/ApplicationMessenger.h" -#if defined(TARGET_WINDOWS) -#include "platform/win32/WIN32Util.h" -#endif #include "settings/AdvancedSettings.h" #include "settings/SettingsComponent.h" #include "utils/AlarmClock.h" @@ -383,10 +380,8 @@ static int ToggleDirty(const std::vector&) */ static int ToggleDisplayHDR(const std::vector&) { -#if defined(TARGET_WINDOWS) - CWIN32Util::ToggleWindowsHDR(); + CServiceBroker::GetWinSystem()->ToggleDisplayHDR(); CApplicationMessenger::GetInstance().SendMsg(TMSG_RESTARTAPP); -#endif return 0; } diff --git a/xbmc/platform/win32/WIN32Util.cpp b/xbmc/platform/win32/WIN32Util.cpp index 0169245918ee9..731b5f4e91c8b 100644 --- a/xbmc/platform/win32/WIN32Util.cpp +++ b/xbmc/platform/win32/WIN32Util.cpp @@ -1377,11 +1377,3 @@ int CWIN32Util::GetHDRDisplayStatus() return status; } - -bool CWIN32Util::IsDisplayHDREnabled() -{ - if (GetHDRDisplayStatus() == 2) - return true; - - return false; -} diff --git a/xbmc/platform/win32/WIN32Util.h b/xbmc/platform/win32/WIN32Util.h index 642a7d5cf073d..62a4750d754cb 100644 --- a/xbmc/platform/win32/WIN32Util.h +++ b/xbmc/platform/win32/WIN32Util.h @@ -64,8 +64,6 @@ class CWIN32Util static std::string WUSysMsg(DWORD dwError); static bool SetThreadLocalLocale(bool enable = true); - // HDR display support static void ToggleWindowsHDR(); static int GetHDRDisplayStatus(); - static bool IsDisplayHDREnabled(); }; diff --git a/xbmc/rendering/dx/DeviceResources.cpp b/xbmc/rendering/dx/DeviceResources.cpp index cbdb500c44de8..5bf3ba3caeba1 100644 --- a/xbmc/rendering/dx/DeviceResources.cpp +++ b/xbmc/rendering/dx/DeviceResources.cpp @@ -14,7 +14,6 @@ #include "windowing/GraphicContext.h" #include "messaging/ApplicationMessenger.h" #include "platform/win32/CharsetConverter.h" -#include "platform/win32/WIN32Util.h" #include "ServiceBroker.h" #include "settings/AdvancedSettings.h" #include "settings/SettingsComponent.h" @@ -517,7 +516,7 @@ void DX::DeviceResources::ResizeBuffers() bool bHWStereoEnabled = RENDER_STEREO_MODE_HARDWAREBASED == CServiceBroker::GetWinSystem()->GetGfxContext().GetStereoMode(); bool windowed = true; - bool isHdrEnabled = CWIN32Util::IsDisplayHDREnabled(); + bool isHdrEnabled = false; HRESULT hr = E_FAIL; DXGI_SWAP_CHAIN_DESC1 scDesc = { 0 }; @@ -532,6 +531,7 @@ void DX::DeviceResources::ResizeBuffers() // check if swapchain needs to be recreated m_swapChain->GetDesc1(&scDesc); + isHdrEnabled = IsDisplayHDREnabled(); if ((scDesc.Stereo == TRUE) != bHWStereoEnabled || (m_Is10bSwapchain != isHdrEnabled)) { @@ -630,13 +630,25 @@ void DX::DeviceResources::ResizeBuffers() if (swapChainDesc.Format == DXGI_FORMAT_R10G10B10A2_UNORM) { + std::string txOutput; m_Is10bSwapchain = true; - CLog::LogF(LOGNOTICE, "10 bit swapchain is used."); + if (isHdrEnabled) + { + m_IsHDROutput = true; + txOutput = "HDR"; + } + else + { + m_IsHDROutput = false; + txOutput = "SDR"; + } + CLog::LogF(LOGNOTICE, "10 bit swapchain is used with {0:s} output", txOutput); } else { m_Is10bSwapchain = false; - CLog::LogF(LOGNOTICE, "8 bit swapchain is used."); + m_IsHDROutput = false; + CLog::LogF(LOGNOTICE, "8 bit swapchain is used with SDR output"); } hr = swapChain.As(&m_swapChain); CHECK_ERR(); @@ -648,6 +660,8 @@ void DX::DeviceResources::ResizeBuffers() hr = m_d3dDevice.As(&dxgiDevice); CHECK_ERR(); dxgiDevice->SetMaximumFrameLatency(1); } + + CLog::LogF(LOGDEBUG, "end resize buffers."); } // These resources need to be recreated every time the window size is changed. @@ -1233,7 +1247,7 @@ void DX::DeviceResources::SetHdrMetaData(DXGI_HDR_METADATA_HDR10& hdr10) const } } -void DX::DeviceResources::SetColorSpace1(const DXGI_COLOR_SPACE_TYPE colorSpace) const +void DX::DeviceResources::SetHdrColorSpace(const DXGI_COLOR_SPACE_TYPE colorSpace) const { ComPtr swapChain3; @@ -1268,3 +1282,34 @@ void DX::DeviceResources::SetColorSpace1(const DXGI_COLOR_SPACE_TYPE colorSpace) } } } + +bool DX::DeviceResources::IsDisplayHDREnabled() const +{ + ComPtr pOutput; + ComPtr pOutput6; + DXGI_OUTPUT_DESC1 od = {}; + + if (m_swapChain == nullptr) + return false; + + if (SUCCEEDED(m_swapChain->GetContainingOutput(pOutput.GetAddressOf()))) + { + if (SUCCEEDED(pOutput.As(&pOutput6))) + { + if (SUCCEEDED(pOutput6->GetDesc1(&od))) + { + CLog::LogF(LOGDEBUG, "DXGI GetDesc1 success"); + if (od.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) + { + return true; + } + } + else + { + CLog::LogF(LOGERROR, "DXGI GetDesc1 failed"); + } + } + } + + return false; +} diff --git a/xbmc/rendering/dx/DeviceResources.h b/xbmc/rendering/dx/DeviceResources.h index 872dd2b915f4a..933976826172d 100644 --- a/xbmc/rendering/dx/DeviceResources.h +++ b/xbmc/rendering/dx/DeviceResources.h @@ -79,9 +79,11 @@ namespace DX bool SetFullScreen(bool fullscreen, RESOLUTION_INFO& res); + // HDR display support + bool IsDisplayHDREnabled() const; void SetHdrMetaData(DXGI_HDR_METADATA_HDR10& hdr10) const; - void SetColorSpace1(const DXGI_COLOR_SPACE_TYPE colorSpace) const; - bool Is10BitSwapchain() const { return m_Is10bSwapchain; } + void SetHdrColorSpace(const DXGI_COLOR_SPACE_TYPE colorSpace) const; + bool IsHDROutput() const { return m_IsHDROutput; } DXGI_HDR_METADATA_HDR10 GetHdr10Display() const; // DX resources registration @@ -165,5 +167,6 @@ namespace DX bool m_stereoEnabled; bool m_bDeviceCreated; bool m_Is10bSwapchain; + bool m_IsHDROutput; }; } diff --git a/xbmc/windowing/WinSystem.h b/xbmc/windowing/WinSystem.h index bc7cb07cb7a7a..be8dddaa41d8a 100644 --- a/xbmc/windowing/WinSystem.h +++ b/xbmc/windowing/WinSystem.h @@ -157,6 +157,8 @@ class CWinSystemBase std::shared_ptr GetDPMSManager(); virtual bool SetHDR(const VideoPicture* videoPicture) { return false; }; virtual bool IsHDRDisplay() { return false; }; + virtual void ToggleDisplayHDR() { return; }; + virtual int GetHDRDisplayStatus() { return 0; }; static const char* SETTING_WINSYSTEM_IS_HDR_DISPLAY; diff --git a/xbmc/windowing/windows/WinSystemWin32.cpp b/xbmc/windowing/windows/WinSystemWin32.cpp index 505358e4d517b..f433d344e53a7 100644 --- a/xbmc/windowing/windows/WinSystemWin32.cpp +++ b/xbmc/windowing/windows/WinSystemWin32.cpp @@ -19,6 +19,7 @@ #include "filesystem/SpecialProtocol.h" #include "messaging/ApplicationMessenger.h" #include "platform/Environment.h" +#include "platform/win32/WIN32Util.h" #include "rendering/dx/ScreenshotSurfaceWindows.h" #include "resource.h" #include "settings/AdvancedSettings.h" @@ -1194,3 +1195,12 @@ bool CWinSystemWin32::MessagePump() return m_winEvents->MessagePump(); } +void CWinSystemWin32::ToggleDisplayHDR() +{ + CWIN32Util::ToggleWindowsHDR(); +} + +int CWinSystemWin32::GetHDRDisplayStatus() +{ + return CWIN32Util::GetHDRDisplayStatus(); +} diff --git a/xbmc/windowing/windows/WinSystemWin32.h b/xbmc/windowing/windows/WinSystemWin32.h index 2a90819178d97..07a3cf8c9ec81 100644 --- a/xbmc/windowing/windows/WinSystemWin32.h +++ b/xbmc/windowing/windows/WinSystemWin32.h @@ -124,10 +124,13 @@ class CWinSystemWin32 : public CWinSystemBase void SetSizeMoveMode(bool mode) { m_bSizeMoveEnabled = mode; } bool IsInSizeMoveMode() const { return m_bSizeMoveEnabled; } + // HDR display support + void ToggleDisplayHDR() override; + int GetHDRDisplayStatus() override; + // winevents override bool MessagePump() override; - protected: bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override = 0; virtual void UpdateStates(bool fullScreen);