diff options
-rw-r--r-- | xbmc/settings/DisplaySettings.cpp | 12 | ||||
-rw-r--r-- | xbmc/windowing/Resolution.cpp | 3 | ||||
-rw-r--r-- | xbmc/windowing/Resolution.h | 14 | ||||
-rw-r--r-- | xbmc/windowing/WinSystem.cpp | 36 | ||||
-rw-r--r-- | xbmc/windowing/WinSystem.h | 11 | ||||
-rw-r--r-- | xbmc/windowing/osx/WinSystemOSX.mm | 19 |
6 files changed, 61 insertions, 34 deletions
diff --git a/xbmc/settings/DisplaySettings.cpp b/xbmc/settings/DisplaySettings.cpp index 42f7ba3469..90f70d0552 100644 --- a/xbmc/settings/DisplaySettings.cpp +++ b/xbmc/settings/DisplaySettings.cpp @@ -796,11 +796,13 @@ void CDisplaySettings::SettingOptionsResolutionsFiller(const SettingConstPtr& se std::vector<RESOLUTION_WHR> resolutions = CServiceBroker::GetWinSystem()->ScreenResolutions(info.fRefreshRate); for (std::vector<RESOLUTION_WHR>::const_iterator resolution = resolutions.begin(); resolution != resolutions.end(); ++resolution) { - std::string resLabel = - !resolution->label.empty() - ? resolution->label - : StringUtils::Format("{}x{}{}", resolution->width, resolution->height, - ModeFlagsToString(resolution->flags, false)); + const std::string resLabel = + StringUtils::Format("{}x{}{}{}", resolution->m_screenWidth, resolution->m_screenHeight, + ModeFlagsToString(resolution->flags, false), + resolution->width > resolution->m_screenWidth && + resolution->height > resolution->m_screenHeight + ? " (HiDPI)" + : ""); list.emplace_back(resLabel, resolution->ResInfo_Index); resolutionInfos.insert(std::make_pair((RESOLUTION)resolution->ResInfo_Index, CDisplaySettings::GetInstance().GetResolutionInfo(resolution->ResInfo_Index))); diff --git a/xbmc/windowing/Resolution.cpp b/xbmc/windowing/Resolution.cpp index e4fdae74dc..951ec08035 100644 --- a/xbmc/windowing/Resolution.cpp +++ b/xbmc/windowing/Resolution.cpp @@ -53,8 +53,7 @@ RESOLUTION_INFO::RESOLUTION_INFO(const RESOLUTION_INFO& res) guiInsets(res.guiInsets), strMode(res.strMode), strOutput(res.strOutput), - strId(res.strId), - label(res.label) + strId(res.strId) { bFullScreen = res.bFullScreen; iWidth = res.iWidth; iHeight = res.iHeight; diff --git a/xbmc/windowing/Resolution.h b/xbmc/windowing/Resolution.h index 36fef9406b..0edf0ffe81 100644 --- a/xbmc/windowing/Resolution.h +++ b/xbmc/windowing/Resolution.h @@ -74,19 +74,19 @@ struct RESOLUTION_INFO //!< Specify if it is a fullscreen resolution, otherwise windowed bool bFullScreen; - //!< Width GUI resolution, may differ from the screen value if GUI resolution limit or 3D is set + //!< Width GUI resolution (pixels), may differ from the screen value if GUI resolution limit, 3D is set or in HiDPI screens int iWidth; - //!< Height GUI resolution, may differ from the screen value if GUI resolution limit or 3D is set + //!< Height GUI resolution (pixels), may differ from the screen value if GUI resolution limit, 3D is set or in HiDPI screens int iHeight; //!< Number of pixels of padding between stereoscopic frames int iBlanking; - //!< Screen width + //!< Screen width (logical width in pixels) int iScreenWidth; - //!< Screen height + //!< Screen height (logical height in pixels) int iScreenHeight; //!< The vertical subtitle baseline position, may be changed by Video calibration @@ -110,12 +110,6 @@ struct RESOLUTION_INFO //!< Resolution ID std::string strId; - //! @brief Resolution label - //! @note This label is shown to the user (display settings) and takes precedence over the computation of the label based on the internal properties. - //! e.g. sometimes, as the example of HiDPI resolutions, it is preferable to show a custom label/string instead of the one computed using the width/height - //! of the resolution - std::string label; - public: RESOLUTION_INFO(int width = 1280, int height = 720, float aspect = 0, const std::string &mode = ""); float DisplayRatio() const; diff --git a/xbmc/windowing/WinSystem.cpp b/xbmc/windowing/WinSystem.cpp index 2da986affb..a803466e30 100644 --- a/xbmc/windowing/WinSystem.cpp +++ b/xbmc/windowing/WinSystem.cpp @@ -45,7 +45,14 @@ bool CWinSystemBase::DestroyWindowSystem() return false; } -void CWinSystemBase::UpdateDesktopResolution(RESOLUTION_INFO& newRes, const std::string &output, int width, int height, float refreshRate, uint32_t dwFlags) +void CWinSystemBase::UpdateDesktopResolution(RESOLUTION_INFO& newRes, + const std::string& output, + int width, + int height, + int screenWidth, + int screenHeight, + float refreshRate, + uint32_t dwFlags) { newRes.Overscan.left = 0; newRes.Overscan.top = 0; @@ -58,8 +65,8 @@ void CWinSystemBase::UpdateDesktopResolution(RESOLUTION_INFO& newRes, const std: newRes.fPixelRatio = 1.0f; newRes.iWidth = width; newRes.iHeight = height; - newRes.iScreenWidth = width; - newRes.iScreenHeight = height; + newRes.iScreenWidth = screenWidth; + newRes.iScreenHeight = screenHeight; newRes.strMode = StringUtils::Format("{}: {}x{}", output, width, height); if (refreshRate > 1) newRes.strMode += StringUtils::Format(" @ {:.2f}Hz", refreshRate); @@ -72,6 +79,16 @@ void CWinSystemBase::UpdateDesktopResolution(RESOLUTION_INFO& newRes, const std: newRes.strOutput = output; } +void CWinSystemBase::UpdateDesktopResolution(RESOLUTION_INFO& newRes, + const std::string& output, + int width, + int height, + float refreshRate, + uint32_t dwFlags) +{ + UpdateDesktopResolution(newRes, output, width, height, width, height, refreshRate, dwFlags); +} + void CWinSystemBase::UpdateResolutions() { // add the window res - defaults are fine. @@ -103,18 +120,20 @@ void CWinSystemBase::SetWindowResolution(int width, int height) static void AddResolution(std::vector<RESOLUTION_WHR> &resolutions, unsigned int addindex, float bestRefreshrate) { RESOLUTION_INFO resInfo = CDisplaySettings::GetInstance().GetResolutionInfo(addindex); - int width = resInfo.iScreenWidth; - int height = resInfo.iScreenHeight; + const int width = resInfo.iWidth; + const int height = resInfo.iHeight; + const int screenWidth = resInfo.iScreenWidth; + const int screenHeight = resInfo.iScreenHeight; int flags = resInfo.dwFlags & D3DPRESENTFLAG_MODEMASK; const std::string id = resInfo.strId; - const std::string label = resInfo.label; float refreshrate = resInfo.fRefreshRate; // don't touch RES_DESKTOP for (auto& resolution : resolutions) { if (resolution.width == width && resolution.height == height && - (resolution.flags & D3DPRESENTFLAG_MODEMASK) == flags && resolution.label == label) + resolution.m_screenWidth == screenWidth && resolution.m_screenHeight == screenHeight && + (resolution.flags & D3DPRESENTFLAG_MODEMASK) == flags) { // check if the refresh rate of this resolution is better suited than // the refresh rate of the resolution with the same width/height/interlaced @@ -127,7 +146,8 @@ static void AddResolution(std::vector<RESOLUTION_WHR> &resolutions, unsigned int } } - RESOLUTION_WHR res = {width, height, flags, static_cast<int>(addindex), id, label}; + RESOLUTION_WHR res = {width, height, screenWidth, screenHeight, flags, static_cast<int>(addindex), + id}; resolutions.emplace_back(res); } diff --git a/xbmc/windowing/WinSystem.h b/xbmc/windowing/WinSystem.h index 2baa7a6c61..1047f9b8e1 100644 --- a/xbmc/windowing/WinSystem.h +++ b/xbmc/windowing/WinSystem.h @@ -25,10 +25,11 @@ struct RESOLUTION_WHR { int width; int height; + int m_screenWidth; + int m_screenHeight; int flags; //< only D3DPRESENTFLAG_MODEMASK flags int ResInfo_Index; std::string id; - std::string label; }; struct REFRESHRATE @@ -218,6 +219,14 @@ public: protected: void UpdateDesktopResolution(RESOLUTION_INFO& newRes, const std::string &output, int width, int height, float refreshRate, uint32_t dwFlags); + void UpdateDesktopResolution(RESOLUTION_INFO& newRes, + const std::string& output, + int width, + int height, + int screenWidth, + int screenHeight, + float refreshRate, + uint32_t dwFlags); virtual std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() { return nullptr; } int m_nWidth = 0; diff --git a/xbmc/windowing/osx/WinSystemOSX.mm b/xbmc/windowing/osx/WinSystemOSX.mm index 5b87e6195b..09c6f39156 100644 --- a/xbmc/windowing/osx/WinSystemOSX.mm +++ b/xbmc/windowing/osx/WinSystemOSX.mm @@ -239,9 +239,9 @@ NSUInteger GetDisplayIndex(const std::string& dispName) std::string ComputeVideoModeId( size_t resWidth, size_t resHeight, size_t pixelWidth, size_t pixelHeight, bool interlaced) { - const char* hiDPIdesc = pixelWidth > resWidth && pixelHeight > resHeight ? " (HiDPI)" : ""; const char* interlacedDesc = interlaced ? "i" : "p"; - return StringUtils::Format("{}x{}{}{}", resWidth, resHeight, interlacedDesc, hiDPIdesc); + return StringUtils::Format("{}x{}{}({}x{})", resWidth, resHeight, interlacedDesc, pixelWidth, + pixelHeight); } CFArrayRef CopyAllDisplayModes(CGDirectDisplayID display) @@ -1100,20 +1100,23 @@ void CWinSystemOSX::FillInVideoModes() // NOTE: The refresh rate will be REPORTED AS 0 for many DVI and notebook displays. refreshrate = 60.0; } + const std::string modeId = + ComputeVideoModeId(resWidth, resHeight, pixelWidth, pixelHeight, interlaced); CLog::LogF( LOGINFO, "Found possible resolution for display {} ({}) with {} x {} @ {} Hz (pixel size: " - "{} x {})", - disp, dispName.UTF8String, resWidth, resHeight, refreshrate, pixelWidth, pixelHeight); + "{} x {}{}) (id:{})", + disp, dispName.UTF8String, resWidth, resHeight, refreshrate, pixelWidth, pixelHeight, + pixelWidth > resWidth && pixelHeight > resHeight ? " - HiDPI" : "", modeId); // only add the resolution if it belongs to "our" screen // all others are only logged above... if (disp == dispIdx) { - res.strId = ComputeVideoModeId(resWidth, resHeight, pixelWidth, pixelHeight, interlaced); - res.label = res.strId; + res.strId = modeId; UpdateDesktopResolution(res, (dispName != nil) ? dispName.UTF8String : "Unknown", static_cast<int>(pixelWidth), static_cast<int>(pixelHeight), + static_cast<int>(resWidth), static_cast<int>(resHeight), refreshrate, 0); m_gfxContext->ResetOverscan(res); CDisplaySettings::GetInstance().AddResolutionInfo(res); @@ -1140,10 +1143,10 @@ void CWinSystemOSX::UpdateResolutions() resInfo.strId = ComputeVideoModeId(screenResolution.resWidth, screenResolution.resHeight, screenResolution.pixelWidth, screenResolution.pixelHeight, screenResolution.interlaced); - resInfo.label = resInfo.strId; UpdateDesktopResolution( resInfo, dispName.UTF8String, static_cast<int>(screenResolution.pixelWidth), - static_cast<int>(screenResolution.pixelHeight), screenResolution.refreshrate, 0); + static_cast<int>(screenResolution.pixelHeight), static_cast<int>(screenResolution.resWidth), + static_cast<int>(screenResolution.resHeight), screenResolution.refreshrate, 0); CDisplaySettings::GetInstance().ClearCustomResolutions(); |