diff options
author | montellese <montellese@xbmc.org> | 2013-03-16 16:31:41 +0100 |
---|---|---|
committer | montellese <montellese@xbmc.org> | 2013-04-01 23:10:47 +0200 |
commit | 9b63a8e9631b896a04831eea156bc35b2c080fd7 (patch) | |
tree | 51dde7d77c25fd6da2643f2a4fa615714d53cd26 | |
parent | cdd62b918dc3ff79fa5ffc9fea1b54995d3e3a2b (diff) |
settings: move resolution/calibration settings to CDisplaySettings
39 files changed, 743 insertions, 549 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index ca88b34306..21866daaee 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -95,6 +95,7 @@ #include "powermanagement/DPMSSupport.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" #include "settings/MediaSettings.h" #include "settings/MediaSourceSettings.h" #include "settings/SkinSettings.h" @@ -596,6 +597,12 @@ bool CApplication::Create() Preflight(); g_settings.Initialize(); //Initialize default AdvancedSettings + for (int i = RES_HDTV_1080i; i <= RES_PAL60_16x9; i++) + { + g_graphicsContext.ResetScreenParameters((RESOLUTION)i); + g_graphicsContext.ResetOverscan((RESOLUTION)i, CDisplaySettings::Get().GetResolutionInfo(i).Overscan); + } + #ifdef _LINUX tzset(); // Initialize timezone information variables #endif @@ -717,6 +724,7 @@ bool CApplication::Create() g_settings.RegisterSettingsHandler(&CUPnPSettings::Get()); #endif + g_settings.RegisterSubSettings(&CDisplaySettings::Get()); g_settings.RegisterSubSettings(&CMediaSettings::Get()); g_settings.RegisterSubSettings(&CSkinSettings::Get()); g_settings.RegisterSubSettings(&CViewStateSettings::Get()); @@ -918,9 +926,9 @@ bool CApplication::CreateGUI() int iResolution = g_graphicsContext.GetVideoResolution(); CLog::Log(LOGINFO, "GUI format %ix%i, Display %s", - g_settings.m_ResInfo[iResolution].iWidth, - g_settings.m_ResInfo[iResolution].iHeight, - g_settings.m_ResInfo[iResolution].strMode.c_str()); + CDisplaySettings::Get().GetResolutionInfo(iResolution).iWidth, + CDisplaySettings::Get().GetResolutionInfo(iResolution).iHeight, + CDisplaySettings::Get().GetResolutionInfo(iResolution).strMode.c_str()); g_windowManager.Initialize(); return true; @@ -932,14 +940,14 @@ bool CApplication::InitWindow() // force initial window creation to be windowed, if fullscreen, it will switch to it below // fixes the white screen of death if starting fullscreen and switching to windowed. bool bFullScreen = false; - if (!g_Windowing.CreateNewWindow("XBMC", bFullScreen, g_settings.m_ResInfo[RES_WINDOW], OnEvent)) + if (!g_Windowing.CreateNewWindow("XBMC", bFullScreen, CDisplaySettings::Get().GetResolutionInfo(RES_WINDOW), OnEvent)) { CLog::Log(LOGFATAL, "CApplication::Create: Unable to create window"); return false; } #else bool bFullScreen = g_guiSettings.m_LookAndFeelResolution != RES_WINDOW; - if (!g_Windowing.CreateNewWindow("XBMC", bFullScreen, g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution], OnEvent)) + if (!g_Windowing.CreateNewWindow("XBMC", bFullScreen, CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution), OnEvent)) { CLog::Log(LOGFATAL, "CApplication::Create: Unable to create window"); return false; @@ -3512,6 +3520,7 @@ bool CApplication::Cleanup() g_guiSettings.Clear(); g_advancedSettings.Clear(); + g_settings.UnregisterSubSettings(&CDisplaySettings::Get()); g_settings.UnregisterSubSettings(&CMediaSettings::Get()); g_settings.UnregisterSubSettings(&CSkinSettings::Get()); g_settings.UnregisterSubSettings(&CViewStateSettings::Get()); diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 3e1e8fda66..679c2e2be1 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -43,6 +43,7 @@ #include "windowing/WindowingFactory.h" #include "powermanagement/PowerManager.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" #include "settings/MediaSettings.h" #include "settings/Settings.h" #include "settings/SkinSettings.h" @@ -1507,14 +1508,14 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa case SYSTEM_SCREEN_RESOLUTION: if(g_Windowing.IsFullScreen()) strLabel.Format("%ix%i@%.2fHz - %s (%02.2f fps)", - g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenWidth, - g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenHeight, - g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].fRefreshRate, + CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution).iScreenHeight, + CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution).fRefreshRate, g_localizeStrings.Get(244), GetFPS()); else strLabel.Format("%ix%i - %s (%02.2f fps)", - g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenWidth, - g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenHeight, + CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution).iScreenHeight, g_localizeStrings.Get(242), GetFPS()); return strLabel; break; @@ -1631,13 +1632,13 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa } break; case SYSTEM_SCREEN_MODE: - strLabel = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].strMode; + strLabel = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).strMode; break; case SYSTEM_SCREEN_WIDTH: - strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iScreenWidth); + strLabel.Format("%i", CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iScreenWidth); break; case SYSTEM_SCREEN_HEIGHT: - strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iScreenHeight); + strLabel.Format("%i", CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iScreenHeight); break; case SYSTEM_CURRENT_WINDOW: return g_localizeStrings.Get(g_windowManager.GetFocusedWindow()); diff --git a/xbmc/addons/ScreenSaver.cpp b/xbmc/addons/ScreenSaver.cpp index 7fad3f16e5..cab3bbdb12 100644 --- a/xbmc/addons/ScreenSaver.cpp +++ b/xbmc/addons/ScreenSaver.cpp @@ -18,6 +18,7 @@ * */ #include "ScreenSaver.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "windowing/WindowingFactory.h" @@ -67,7 +68,7 @@ bool CScreenSaver::CreateScreenSaver() m_pInfo->y = 0; m_pInfo->width = iWidth; m_pInfo->height = iHeight; - m_pInfo->pixelRatio = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].fPixelRatio; + m_pInfo->pixelRatio = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).fPixelRatio; m_pInfo->name = strdup(Name().c_str()); m_pInfo->presets = strdup(CSpecialProtocol::TranslatePath(Path()).c_str()); m_pInfo->profile = strdup(CSpecialProtocol::TranslatePath(Profile()).c_str()); diff --git a/xbmc/addons/Visualisation.cpp b/xbmc/addons/Visualisation.cpp index f275fe91a6..e4dccbe399 100644 --- a/xbmc/addons/Visualisation.cpp +++ b/xbmc/addons/Visualisation.cpp @@ -23,6 +23,7 @@ #include "GUIInfoManager.h" #include "Application.h" #include "music/tags/MusicInfoTag.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "windowing/WindowingFactory.h" @@ -76,7 +77,7 @@ bool CVisualisation::Create(int x, int y, int w, int h, void *device) m_pInfo->y = y; m_pInfo->width = w; m_pInfo->height = h; - m_pInfo->pixelRatio = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].fPixelRatio; + m_pInfo->pixelRatio = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).fPixelRatio; m_pInfo->name = strdup(Name().c_str()); m_pInfo->presets = strdup(CSpecialProtocol::TranslatePath(Path()).c_str()); diff --git a/xbmc/cores/VideoRenderers/BaseRenderer.cpp b/xbmc/cores/VideoRenderers/BaseRenderer.cpp index 7090728e31..f75e335d1c 100644 --- a/xbmc/cores/VideoRenderers/BaseRenderer.cpp +++ b/xbmc/cores/VideoRenderers/BaseRenderer.cpp @@ -22,6 +22,7 @@ #include <algorithm> #include "BaseRenderer.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "settings/MediaSettings.h" @@ -83,12 +84,12 @@ void CBaseRenderer::ChooseBestResolution(float fps) } CLog::Log(LOGNOTICE, "Display resolution ADJUST : %s (%d) (weight: %.3f)", - g_settings.m_ResInfo[m_resolution].strMode.c_str(), m_resolution, weight); + CDisplaySettings::Get().GetResolutionInfo(m_resolution).strMode.c_str(), m_resolution, weight); } else #endif CLog::Log(LOGNOTICE, "Display resolution %s : %s (%d)", - m_resolution == RES_DESKTOP ? "DESKTOP" : "USER", g_settings.m_ResInfo[m_resolution].strMode.c_str(), m_resolution); + m_resolution == RES_DESKTOP ? "DESKTOP" : "USER", CDisplaySettings::Get().GetResolutionInfo(m_resolution).strMode.c_str(), m_resolution); } bool CBaseRenderer::FindResolutionFromOverride(float fps, float& weight, bool fallback) @@ -105,31 +106,31 @@ bool CBaseRenderer::FindResolutionFromOverride(float fps, float& weight, bool fa if (!fallback && (fps < override.fpsmin || fps > override.fpsmax)) continue; - for (size_t j = (int)RES_DESKTOP; j < g_settings.m_ResInfo.size(); j++) + for (size_t j = (int)RES_DESKTOP; j < CDisplaySettings::Get().ResolutionInfoSize(); j++) { - if (g_settings.m_ResInfo[j].iScreenWidth == g_settings.m_ResInfo[m_resolution].iScreenWidth - && g_settings.m_ResInfo[j].iScreenHeight == g_settings.m_ResInfo[m_resolution].iScreenHeight - && g_settings.m_ResInfo[j].iScreen == g_settings.m_ResInfo[m_resolution].iScreen) + if (CDisplaySettings::Get().GetResolutionInfo(j).iScreenWidth == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreenWidth + && CDisplaySettings::Get().GetResolutionInfo(j).iScreenHeight == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreenHeight + && CDisplaySettings::Get().GetResolutionInfo(j).iScreen == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreen) { - if (g_settings.m_ResInfo[j].fRefreshRate <= override.refreshmax - && g_settings.m_ResInfo[j].fRefreshRate >= override.refreshmin) + if (CDisplaySettings::Get().GetResolutionInfo(j).fRefreshRate <= override.refreshmax + && CDisplaySettings::Get().GetResolutionInfo(j).fRefreshRate >= override.refreshmin) { m_resolution = (RESOLUTION)j; if (fallback) { CLog::Log(LOGDEBUG, "Found Resolution %s (%d) from fallback (refreshmin:%.3f refreshmax:%.3f)", - g_settings.m_ResInfo[m_resolution].strMode.c_str(), m_resolution, + CDisplaySettings::Get().GetResolutionInfo(m_resolution).strMode.c_str(), m_resolution, override.refreshmin, override.refreshmax); } else { CLog::Log(LOGDEBUG, "Found Resolution %s (%d) from override of fps %.3f (fpsmin:%.3f fpsmax:%.3f refreshmin:%.3f refreshmax:%.3f)", - g_settings.m_ResInfo[m_resolution].strMode.c_str(), m_resolution, fps, + CDisplaySettings::Get().GetResolutionInfo(m_resolution).strMode.c_str(), m_resolution, fps, override.fpsmin, override.fpsmax, override.refreshmin, override.refreshmax); } - weight = RefreshWeight(g_settings.m_ResInfo[m_resolution].fRefreshRate, fps); + weight = RefreshWeight(CDisplaySettings::Get().GetResolutionInfo(m_resolution).fRefreshRate, fps); return true; //fps and refresh match with this override, use this resolution } @@ -149,52 +150,52 @@ void CBaseRenderer::FindResolutionFromFpsMatch(float fps, float& weight) if (weight >= maxWeight) //not a very good match, try a 2:3 cadence instead { CLog::Log(LOGDEBUG, "Resolution %s (%d) not a very good match for fps %.3f (weight: %.3f), trying 2:3 cadence", - g_settings.m_ResInfo[m_resolution].strMode.c_str(), m_resolution, fps, weight); + CDisplaySettings::Get().GetResolutionInfo(m_resolution).strMode.c_str(), m_resolution, fps, weight); m_resolution = FindClosestResolution(fps, 2.5, m_resolution, weight); if (weight >= maxWeight) //2:3 cadence not a good match { CLog::Log(LOGDEBUG, "Resolution %s (%d) not a very good match for fps %.3f with 2:3 cadence (weight: %.3f), choosing 60 hertz", - g_settings.m_ResInfo[m_resolution].strMode.c_str(), m_resolution, fps, weight); + CDisplaySettings::Get().GetResolutionInfo(m_resolution).strMode.c_str(), m_resolution, fps, weight); //get the resolution with the refreshrate closest to 60 hertz - for (size_t i = (int)RES_DESKTOP; i < g_settings.m_ResInfo.size(); i++) + for (size_t i = (int)RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); i++) { - if (MathUtils::round_int(g_settings.m_ResInfo[i].fRefreshRate) == 60 - && g_settings.m_ResInfo[i].iScreenWidth == g_settings.m_ResInfo[m_resolution].iScreenWidth - && g_settings.m_ResInfo[i].iScreenHeight == g_settings.m_ResInfo[m_resolution].iScreenHeight - && g_settings.m_ResInfo[i].iScreen == g_settings.m_ResInfo[m_resolution].iScreen) + if (MathUtils::round_int(CDisplaySettings::Get().GetResolutionInfo(i).fRefreshRate) == 60 + && CDisplaySettings::Get().GetResolutionInfo(i).iScreenWidth == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreenWidth + && CDisplaySettings::Get().GetResolutionInfo(i).iScreenHeight == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreenHeight + && CDisplaySettings::Get().GetResolutionInfo(i).iScreen == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreen) { - if (fabs(g_settings.m_ResInfo[i].fRefreshRate - 60.0) < fabs(g_settings.m_ResInfo[m_resolution].fRefreshRate - 60.0)) + if (fabs(CDisplaySettings::Get().GetResolutionInfo(i).fRefreshRate - 60.0) < fabs(CDisplaySettings::Get().GetResolutionInfo(m_resolution).fRefreshRate - 60.0)) m_resolution = (RESOLUTION)i; } } //60 hertz not available, get the highest refreshrate - if (MathUtils::round_int(g_settings.m_ResInfo[m_resolution].fRefreshRate) != 60) + if (MathUtils::round_int(CDisplaySettings::Get().GetResolutionInfo(m_resolution).fRefreshRate) != 60) { CLog::Log(LOGDEBUG, "60 hertz refreshrate not available, choosing highest"); - for (size_t i = (int)RES_DESKTOP; i < g_settings.m_ResInfo.size(); i++) + for (size_t i = (int)RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); i++) { - if (g_settings.m_ResInfo[i].fRefreshRate > g_settings.m_ResInfo[m_resolution].fRefreshRate - && g_settings.m_ResInfo[i].iScreenWidth == g_settings.m_ResInfo[m_resolution].iScreenWidth - && g_settings.m_ResInfo[i].iScreenHeight == g_settings.m_ResInfo[m_resolution].iScreenHeight - && g_settings.m_ResInfo[i].iScreen == g_settings.m_ResInfo[m_resolution].iScreen) + if (CDisplaySettings::Get().GetResolutionInfo(i).fRefreshRate > CDisplaySettings::Get().GetResolutionInfo(m_resolution).fRefreshRate + && CDisplaySettings::Get().GetResolutionInfo(i).iScreenWidth == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreenWidth + && CDisplaySettings::Get().GetResolutionInfo(i).iScreenHeight == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreenHeight + && CDisplaySettings::Get().GetResolutionInfo(i).iScreen == CDisplaySettings::Get().GetResolutionInfo(m_resolution).iScreen) { m_resolution = (RESOLUTION)i; } } } - weight = RefreshWeight(g_settings.m_ResInfo[m_resolution].fRefreshRate, fps); + weight = RefreshWeight(CDisplaySettings::Get().GetResolutionInfo(m_resolution).fRefreshRate, fps); } } } RESOLUTION CBaseRenderer::FindClosestResolution(float fps, float multiplier, RESOLUTION current, float& weight) { - RESOLUTION_INFO &curr = g_settings.m_ResInfo[current]; + RESOLUTION_INFO &curr = CDisplaySettings::Get().GetResolutionInfo(current); int iScreenWidth = curr.iScreenWidth; int iScreenHeight = curr.iScreenHeight; @@ -235,10 +236,10 @@ RESOLUTION CBaseRenderer::FindClosestResolution(float fps, float multiplier, RES float last_diff = fRefreshRate; // Find closest refresh rate - for (size_t i = (int)RES_DESKTOP; i < g_settings.m_ResInfo.size(); i++) + for (size_t i = (int)RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); i++) { - RESOLUTION_INFO &info = g_settings.m_ResInfo[i]; - RESOLUTION_INFO &best = g_settings.m_ResInfo[current]; + RESOLUTION_INFO &info = CDisplaySettings::Get().GetResolutionInfo(i); + RESOLUTION_INFO &best = CDisplaySettings::Get().GetResolutionInfo(current); //discard resolutions that are not the same width and height //or have a too low refreshrate @@ -277,7 +278,7 @@ RESOLUTION CBaseRenderer::FindClosestResolution(float fps, float multiplier, RES if(m_iFlags & CONF_FLAGS_FORMAT_SBS || m_iFlags & CONF_FLAGS_FORMAT_TB) weight = 0; else - weight = RefreshWeight(g_settings.m_ResInfo[current].fRefreshRate, fRefreshRate * multiplier); + weight = RefreshWeight(CDisplaySettings::Get().GetResolutionInfo(current).fRefreshRate, fRefreshRate * multiplier); return current; } @@ -422,7 +423,7 @@ void CBaseRenderer::CalcNormalDisplayRect(float offsetX, float offsetY, float sc // calculate the correct output frame ratio (using the users pixel ratio setting // and the output pixel ratio setting) - float outputFrameRatio = inputFrameRatio / g_settings.m_ResInfo[GetResolution()].fPixelRatio; + float outputFrameRatio = inputFrameRatio / CDisplaySettings::Get().GetResolutionInfo(GetResolution()).fPixelRatio; // allow a certain error to maximize screen size float fCorrection = screenWidth / screenHeight / outputFrameRatio - 1.0f; @@ -586,8 +587,8 @@ void CBaseRenderer::SetViewMode(int viewMode) // get our calibrated full screen resolution RESOLUTION res = GetResolution(); - float screenWidth = (float)(g_settings.m_ResInfo[res].Overscan.right - g_settings.m_ResInfo[res].Overscan.left); - float screenHeight = (float)(g_settings.m_ResInfo[res].Overscan.bottom - g_settings.m_ResInfo[res].Overscan.top); + float screenWidth = (float)(CDisplaySettings::Get().GetResolutionInfo(res).Overscan.right - CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left); + float screenHeight = (float)(CDisplaySettings::Get().GetResolutionInfo(res).Overscan.bottom - CDisplaySettings::Get().GetResolutionInfo(res).Overscan.top); if(m_iFlags & CONF_FLAGS_FORMAT_SBS) screenWidth /= 2; @@ -600,8 +601,8 @@ void CBaseRenderer::SetViewMode(int viewMode) CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeNormal); // Splitres scaling factor - float xscale = (float)g_settings.m_ResInfo[res].iScreenWidth / (float)g_settings.m_ResInfo[res].iWidth; - float yscale = (float)g_settings.m_ResInfo[res].iScreenHeight / (float)g_settings.m_ResInfo[res].iHeight; + float xscale = (float)CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth / (float)CDisplaySettings::Get().GetResolutionInfo(res).iWidth; + float yscale = (float)CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight / (float)CDisplaySettings::Get().GetResolutionInfo(res).iHeight; screenWidth *= xscale; screenHeight *= yscale; @@ -614,7 +615,7 @@ void CBaseRenderer::SetViewMode(int viewMode) { // zoom image so no black bars g_settings.m_fPixelRatio = 1.0; // calculate the desired output ratio - float outputFrameRatio = sourceFrameRatio * g_settings.m_fPixelRatio / g_settings.m_ResInfo[res].fPixelRatio; + float outputFrameRatio = sourceFrameRatio * g_settings.m_fPixelRatio / CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio; // now calculate the correct zoom amount. First zoom to full height. float newHeight = screenHeight; float newWidth = newHeight * outputFrameRatio; @@ -632,7 +633,7 @@ void CBaseRenderer::SetViewMode(int viewMode) if (res == RES_PAL_4x3 || res == RES_PAL60_4x3 || res == RES_NTSC_4x3 || res == RES_HDTV_480p_4x3) { // stretch to the limits of the 4:3 screen. // incorrect behaviour, but it's what the users want, so... - g_settings.m_fPixelRatio = (screenWidth / screenHeight) * g_settings.m_ResInfo[res].fPixelRatio / sourceFrameRatio; + g_settings.m_fPixelRatio = (screenWidth / screenHeight) * CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio / sourceFrameRatio; } else { @@ -644,7 +645,7 @@ void CBaseRenderer::SetViewMode(int viewMode) else if ( CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeWideZoom || (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == ViewModeWideZoom)) { // super zoom - float stretchAmount = (screenWidth / screenHeight) * g_settings.m_ResInfo[res].fPixelRatio / sourceFrameRatio; + float stretchAmount = (screenWidth / screenHeight) * CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio / sourceFrameRatio; g_settings.m_fPixelRatio = pow(stretchAmount, float(2.0/3.0)); g_settings.m_fZoomAmount = pow(stretchAmount, float((stretchAmount < 1.0) ? -1.0/3.0 : 1.0/3.0)); g_settings.m_bNonLinStretch = true; @@ -661,7 +662,7 @@ void CBaseRenderer::SetViewMode(int viewMode) else { // stretch to the limits of the 16:9 screen. // incorrect behaviour, but it's what the users want, so... - g_settings.m_fPixelRatio = (screenWidth / screenHeight) * g_settings.m_ResInfo[res].fPixelRatio / sourceFrameRatio; + g_settings.m_fPixelRatio = (screenWidth / screenHeight) * CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio / sourceFrameRatio; } } else if (CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeOriginal) @@ -669,7 +670,7 @@ void CBaseRenderer::SetViewMode(int viewMode) g_settings.m_fPixelRatio = 1.0; // get the size of the media file // calculate the desired output ratio - float outputFrameRatio = sourceFrameRatio * g_settings.m_fPixelRatio / g_settings.m_ResInfo[res].fPixelRatio; + float outputFrameRatio = sourceFrameRatio * g_settings.m_fPixelRatio / CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio; // now calculate the correct zoom amount. First zoom to full width. float newWidth = screenWidth; float newHeight = newWidth / outputFrameRatio; diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp index 176d946646..cf4aaf4de1 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp @@ -418,8 +418,8 @@ void CLinuxRendererGLES::RenderUpdate(bool clear, DWORD flags, DWORD alpha) (*m_RenderUpdateCallBackFn)(m_RenderUpdateCallBackCtx, m_sourceRect, m_destRect); RESOLUTION res = GetResolution(); - int iWidth = g_settings.m_ResInfo[res].iWidth; - int iHeight = g_settings.m_ResInfo[res].iHeight; + int iWidth = CDisplaySettings::Get().GetResolutionInfo(res).iWidth; + int iHeight = CDisplaySettings::Get().GetResolutionInfo(res).iHeight; g_graphicsContext.BeginPaint(); diff --git a/xbmc/cores/VideoRenderers/OverlayRenderer.cpp b/xbmc/cores/VideoRenderers/OverlayRenderer.cpp index d8d708fb65..b00f28ebc8 100644 --- a/xbmc/cores/VideoRenderers/OverlayRenderer.cpp +++ b/xbmc/cores/VideoRenderers/OverlayRenderer.cpp @@ -28,6 +28,7 @@ #include "cores/VideoRenderers/RenderManager.h" #include "Application.h" #include "windowing/WindowingFactory.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/MathUtils.h" @@ -198,7 +199,7 @@ void CRenderer::Render(COverlay* o) RESOLUTION_INFO res; g_renderManager.GetVideoRect(rs, rd); rv = g_graphicsContext.GetViewWindow(); - res = g_settings.m_ResInfo[g_renderManager.GetResolution()]; + res = CDisplaySettings::Get().GetResolutionInfo(g_renderManager.GetResolution()); SRenderState state; state.x = o->m_x; diff --git a/xbmc/cores/VideoRenderers/WinRenderer.cpp b/xbmc/cores/VideoRenderers/WinRenderer.cpp index c103c2942a..c32fed6fa3 100644 --- a/xbmc/cores/VideoRenderers/WinRenderer.cpp +++ b/xbmc/cores/VideoRenderers/WinRenderer.cpp @@ -22,6 +22,7 @@ #include "WinRenderer.h" #include "Util.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "settings/MediaSettings.h" @@ -233,8 +234,8 @@ bool CWinRenderer::Configure(unsigned int width, unsigned int height, unsigned i // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); ChooseBestResolution(fps); - m_destWidth = g_settings.m_ResInfo[m_resolution].iWidth; - m_destHeight = g_settings.m_ResInfo[m_resolution].iHeight; + m_destWidth = CDisplaySettings::Get().GetResolutionInfo(m_resolution).iWidth; + m_destHeight = CDisplaySettings::Get().GetResolutionInfo(m_resolution).iHeight; SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); diff --git a/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp b/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp index 78b5d72e92..1d4ca9a185 100644 --- a/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp +++ b/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp @@ -116,8 +116,8 @@ void CComboRenderer::ManageDisplay() float fOffsetX1 = (float)rv.left; float fOffsetY1 = (float)rv.top; float fPixelRatio = g_settings.m_fPixelRatio; - float fMaxScreenWidth = (float)g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iWidth; - float fMaxScreenHeight = (float)g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iHeight; + float fMaxScreenWidth = (float)CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iWidth; + float fMaxScreenHeight = (float)CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iHeight; if (fOffsetX1 < 0) fOffsetX1 = 0; if (fOffsetY1 < 0) fOffsetY1 = 0; if (fScreenWidth + fOffsetX1 > fMaxScreenWidth) fScreenWidth = fMaxScreenWidth - fOffsetX1; diff --git a/xbmc/cores/amlplayer/AMLPlayer.cpp b/xbmc/cores/amlplayer/AMLPlayer.cpp index ba4e2a2467..6840c3ad04 100644 --- a/xbmc/cores/amlplayer/AMLPlayer.cpp +++ b/xbmc/cores/amlplayer/AMLPlayer.cpp @@ -2238,7 +2238,7 @@ void CAMLPlayer::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) // so we have to setup video axis for 720p instead of 1080p... Boooo. display = g_graphicsContext.GetViewWindow(); //RESOLUTION res = g_graphicsContext.GetVideoResolution(); - //display.SetRect(0, 0, g_settings.m_ResInfo[res].iScreenWidth, g_settings.m_ResInfo[res].iScreenHeight); + //display.SetRect(0, 0, CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth, CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight); dst_rect = m_dst_rect; if (gui != display) { diff --git a/xbmc/cores/omxplayer/OMXImage.cpp b/xbmc/cores/omxplayer/OMXImage.cpp index f73485c773..a707488d6b 100644 --- a/xbmc/cores/omxplayer/OMXImage.cpp +++ b/xbmc/cores/omxplayer/OMXImage.cpp @@ -485,7 +485,7 @@ OMX_IMAGE_CODINGTYPE COMXImage::GetCodingType() bool COMXImage::ClampLimits(unsigned int &width, unsigned int &height) { - RESOLUTION_INFO& res_info = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()]; + RESOLUTION_INFO& res_info = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); const bool transposed = m_orientation & 4; const int gui_width = transposed ? res_info.iHeight:res_info.iWidth; const int gui_height = transposed ? res_info.iWidth:res_info.iHeight; @@ -733,8 +733,8 @@ bool COMXImage::Decode(unsigned width, unsigned height) width = height * 16/9; if(!width || !height) { - width = g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth; - height = g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight; + width = CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution).iWidth; + height = CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution).iHeight; } } diff --git a/xbmc/cores/omxplayer/OMXPlayerVideo.cpp b/xbmc/cores/omxplayer/OMXPlayerVideo.cpp index 96a44280df..983bf0f873 100644 --- a/xbmc/cores/omxplayer/OMXPlayerVideo.cpp +++ b/xbmc/cores/omxplayer/OMXPlayerVideo.cpp @@ -727,8 +727,8 @@ void OMXPlayerVideo::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) // to separate video plane that is at display size. CRect gui, display, dst_rect; RESOLUTION res = g_graphicsContext.GetVideoResolution(); - gui.SetRect(0, 0, g_settings.m_ResInfo[res].iWidth, g_settings.m_ResInfo[res].iHeight); - display.SetRect(0, 0, g_settings.m_ResInfo[res].iScreenWidth, g_settings.m_ResInfo[res].iScreenHeight); + gui.SetRect(0, 0, CDisplaySettings::Get().GetResolutionInfo(res).iWidth, CDisplaySettings::Get().GetResolutionInfo(res).iHeight); + display.SetRect(0, 0, CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth, CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight); dst_rect = m_dst_rect; if (gui != display) @@ -755,8 +755,8 @@ void OMXPlayerVideo::RenderUpdateCallBack(const void *ctx, const CRect &SrcRect, void OMXPlayerVideo::ResolutionUpdateCallBack(uint32_t width, uint32_t height) { RESOLUTION res = g_graphicsContext.GetVideoResolution(); - uint32_t video_width = g_settings.m_ResInfo[res].iScreenWidth; - uint32_t video_height = g_settings.m_ResInfo[res].iScreenHeight; + uint32_t video_width = CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth; + uint32_t video_height = CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight; unsigned flags = 0; ERenderFormat format = RENDER_FMT_BYPASS; diff --git a/xbmc/guilib/GraphicContext.cpp b/xbmc/guilib/GraphicContext.cpp index ece7fdcebc..f2947b7a03 100644 --- a/xbmc/guilib/GraphicContext.cpp +++ b/xbmc/guilib/GraphicContext.cpp @@ -23,6 +23,7 @@ #include "threads/SingleLock.h" #include "Application.h" #include "ApplicationMessenger.h" +#include "settings/DisplaySettings.h" #include "settings/GUISettings.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" @@ -254,10 +255,10 @@ const CRect CGraphicContext::GetViewWindow() const if (m_bCalibrating || m_bFullScreenVideo) { CRect rect; - rect.x1 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.left; - rect.y1 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.top; - rect.x2 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.right; - rect.y2 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.bottom; + rect.x1 = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.left; + rect.y1 = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.top; + rect.x2 = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.right; + rect.y2 = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.bottom; return rect; } return m_videoRect; @@ -311,7 +312,7 @@ void CGraphicContext::SetCalibrating(bool bOnOff) bool CGraphicContext::IsValidResolution(RESOLUTION res) { - if (res >= RES_WINDOW && (size_t) res <= g_settings.m_ResInfo.size()) + if (res >= RES_WINDOW && (size_t) res <= CDisplaySettings::Get().ResolutionInfoSize()) { return true; } @@ -363,9 +364,9 @@ void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate) Lock(); - m_iScreenWidth = g_settings.m_ResInfo[res].iWidth; - m_iScreenHeight = g_settings.m_ResInfo[res].iHeight; - m_iScreenId = g_settings.m_ResInfo[res].iScreen; + m_iScreenWidth = CDisplaySettings::Get().GetResolutionInfo(res).iWidth; + m_iScreenHeight = CDisplaySettings::Get().GetResolutionInfo(res).iHeight; + m_iScreenId = CDisplaySettings::Get().GetResolutionInfo(res).iScreen; m_scissors.SetRect(0, 0, (float)m_iScreenWidth, (float)m_iScreenHeight); m_Resolution = res; @@ -376,13 +377,13 @@ void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate) { #if defined (TARGET_DARWIN) || defined (_WIN32) bool blankOtherDisplays = g_guiSettings.GetBool("videoscreen.blankdisplays"); - g_Windowing.SetFullScreen(true, g_settings.m_ResInfo[res], blankOtherDisplays); + g_Windowing.SetFullScreen(true, CDisplaySettings::Get().GetResolutionInfo(res), blankOtherDisplays); #else - g_Windowing.SetFullScreen(true, g_settings.m_ResInfo[res], false); + g_Windowing.SetFullScreen(true, CDisplaySettings::Get().GetResolutionInfo(res), false); #endif } else if (lastRes >= RES_DESKTOP ) - g_Windowing.SetFullScreen(false, g_settings.m_ResInfo[res], false); + g_Windowing.SetFullScreen(false, CDisplaySettings::Get().GetResolutionInfo(res), false); else g_Windowing.ResizeWindow(m_iScreenWidth, m_iScreenHeight, -1, -1); @@ -452,8 +453,8 @@ void CGraphicContext::ResetOverscan(RESOLUTION res, OVERSCAN &overscan) overscan.bottom = 576; break; default: - overscan.right = g_settings.m_ResInfo[res].iWidth; - overscan.bottom = g_settings.m_ResInfo[res].iHeight; + overscan.right = CDisplaySettings::Get().GetResolutionInfo(res).iWidth; + overscan.bottom = CDisplaySettings::Get().GetResolutionInfo(res).iHeight; break; } } @@ -461,135 +462,135 @@ void CGraphicContext::ResetOverscan(RESOLUTION res, OVERSCAN &overscan) void CGraphicContext::ResetScreenParameters(RESOLUTION res) { // For now these are all on the first screen. - g_settings.m_ResInfo[res].iScreen = 0; + CDisplaySettings::Get().GetResolutionInfo(res).iScreen = 0; // 1080i switch (res) { case RES_HDTV_1080i: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 1080); - g_settings.m_ResInfo[res].iWidth = 1920; - g_settings.m_ResInfo[res].iHeight = 1080; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; - g_settings.m_ResInfo[res].fPixelRatio = 1.0f; - g_settings.m_ResInfo[res].strMode ="1080i 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 1080); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 1920; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 1080; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 1.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode ="1080i 16:9"; break; case RES_HDTV_720pSBS: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 720); - g_settings.m_ResInfo[res].iWidth = 640; - g_settings.m_ResInfo[res].iHeight = 720; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS; - g_settings.m_ResInfo[res].fPixelRatio = 1.0f; - g_settings.m_ResInfo[res].strMode = "720pSBS 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 720); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 640; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 720; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 1.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "720pSBS 16:9"; break; case RES_HDTV_720pTB: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 360); - g_settings.m_ResInfo[res].iWidth = 1280; - g_settings.m_ResInfo[res].iHeight = 360; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB; - g_settings.m_ResInfo[res].fPixelRatio = 1.0f; - g_settings.m_ResInfo[res].strMode = "720pTB 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 360); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 1280; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 360; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 1.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "720pTB 16:9"; break; case RES_HDTV_1080pSBS: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 1080); - g_settings.m_ResInfo[res].iWidth = 960; - g_settings.m_ResInfo[res].iHeight = 1080; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS; - g_settings.m_ResInfo[res].fPixelRatio = 1.0f; - g_settings.m_ResInfo[res].strMode = "1080pSBS 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 1080); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 960; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 1080; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 1.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "1080pSBS 16:9"; break; case RES_HDTV_1080pTB: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 540); - g_settings.m_ResInfo[res].iWidth = 1920; - g_settings.m_ResInfo[res].iHeight = 540; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB; - g_settings.m_ResInfo[res].fPixelRatio = 1.0f; - g_settings.m_ResInfo[res].strMode = "1080pTB 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 540); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 1920; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 540; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 1.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "1080pTB 16:9"; break; case RES_HDTV_720p: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 720); - g_settings.m_ResInfo[res].iWidth = 1280; - g_settings.m_ResInfo[res].iHeight = 720; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN; - g_settings.m_ResInfo[res].fPixelRatio = 1.0f; - g_settings.m_ResInfo[res].strMode = "720p 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 720); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 1280; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 720; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 1.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "720p 16:9"; break; case RES_HDTV_480p_4x3: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 480); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 480; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE; - g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f; - g_settings.m_ResInfo[res].strMode = "480p 4:3"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.9 * 480); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 480; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_PROGRESSIVE; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 4320.0f / 4739.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "480p 4:3"; break; case RES_HDTV_480p_16x9: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 480); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 480; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN; - g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f; - g_settings.m_ResInfo[res].strMode = "480p 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 480); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 480; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "480p 16:9"; break; case RES_NTSC_4x3: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 480); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 480; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED; - g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f; - g_settings.m_ResInfo[res].strMode = "NTSC 4:3"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.9 * 480); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 480; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_INTERLACED; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 4320.0f / 4739.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "NTSC 4:3"; break; case RES_NTSC_16x9: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 480); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 480; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; - g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f; - g_settings.m_ResInfo[res].strMode = "NTSC 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 480); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 480; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "NTSC 16:9"; break; case RES_PAL_4x3: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 576); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 576; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED; - g_settings.m_ResInfo[res].fPixelRatio = 128.0f / 117.0f; - g_settings.m_ResInfo[res].strMode = "PAL 4:3"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.9 * 576); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 576; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_INTERLACED; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 128.0f / 117.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "PAL 4:3"; break; case RES_PAL_16x9: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 576); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 576; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; - g_settings.m_ResInfo[res].fPixelRatio = 128.0f / 117.0f*4.0f / 3.0f; - g_settings.m_ResInfo[res].strMode = "PAL 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 576); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 576; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 128.0f / 117.0f*4.0f / 3.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "PAL 16:9"; break; case RES_PAL60_4x3: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 480); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 480; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED; - g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f; - g_settings.m_ResInfo[res].strMode = "PAL60 4:3"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.9 * 480); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 480; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_INTERLACED; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 4320.0f / 4739.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "PAL60 4:3"; break; case RES_PAL60_16x9: - g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 480); - g_settings.m_ResInfo[res].iWidth = 720; - g_settings.m_ResInfo[res].iHeight = 480; - g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; - g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f; - g_settings.m_ResInfo[res].strMode = "PAL60 16:9"; + CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles = (int)(0.965 * 480); + CDisplaySettings::Get().GetResolutionInfo(res).iWidth = 720; + CDisplaySettings::Get().GetResolutionInfo(res).iHeight = 480; + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN; + CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f; + CDisplaySettings::Get().GetResolutionInfo(res).strMode = "PAL60 16:9"; break; default: break; } - g_settings.m_ResInfo[res].iScreenWidth = g_settings.m_ResInfo[res].iWidth; - g_settings.m_ResInfo[res].iScreenHeight = g_settings.m_ResInfo[res].iHeight; - ResetOverscan(res, g_settings.m_ResInfo[res].Overscan); + CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth = CDisplaySettings::Get().GetResolutionInfo(res).iWidth; + CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight = CDisplaySettings::Get().GetResolutionInfo(res).iHeight; + ResetOverscan(res, CDisplaySettings::Get().GetResolutionInfo(res).Overscan); } float CGraphicContext::GetPixelRatio(RESOLUTION iRes) const { - if (iRes >= 0 && iRes < (int)g_settings.m_ResInfo.size()) - return g_settings.m_ResInfo[iRes].fPixelRatio; + if (iRes >= 0 && iRes < (int)CDisplaySettings::Get().ResolutionInfoSize()) + return CDisplaySettings::Get().GetResolutionInfo(iRes).fPixelRatio; return 0.0f; } @@ -610,7 +611,7 @@ void CGraphicContext::ApplyStateBlock() const RESOLUTION_INFO &CGraphicContext::GetResInfo() const { - return g_settings.m_ResInfo[m_Resolution]; + return CDisplaySettings::Get().GetResolutionInfo(m_Resolution); } void CGraphicContext::SetScalingResolution(const RESOLUTION_INFO &res, bool needsScaling) @@ -630,10 +631,10 @@ void CGraphicContext::SetScalingResolution(const RESOLUTION_INFO &res, bool need { fFromWidth = (float)res.iWidth; fFromHeight = (float)res.iHeight; - fToPosX = (float)g_settings.m_ResInfo[m_Resolution].Overscan.left; - fToPosY = (float)g_settings.m_ResInfo[m_Resolution].Overscan.top; - fToWidth = (float)g_settings.m_ResInfo[m_Resolution].Overscan.right - fToPosX; - fToHeight = (float)g_settings.m_ResInfo[m_Resolution].Overscan.bottom - fToPosY; + fToPosX = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.left; + fToPosY = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.top; + fToWidth = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.right - fToPosX; + fToHeight = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).Overscan.bottom - fToPosY; } if(!g_guiSkinzoom) // lookup gui setting if we didn't have it already @@ -649,7 +650,7 @@ void CGraphicContext::SetScalingResolution(const RESOLUTION_INFO &res, bool need // adjust for aspect ratio as zoom is given in the vertical direction and we don't // do aspect ratio corrections in the gui code - fZoom = fZoom / g_settings.m_ResInfo[m_Resolution].fPixelRatio; + fZoom = fZoom / CDisplaySettings::Get().GetResolutionInfo(m_Resolution).fPixelRatio; fToPosY -= fToHeight * fZoom * 0.5f; fToHeight *= fZoom + 1.0f; @@ -705,8 +706,8 @@ float CGraphicContext::GetScalingPixelRatio() const // but only once it's been corrected for the skin -> screen coordinates scaling float winWidth = (float)m_windowResolution.iWidth; float winHeight = (float)m_windowResolution.iHeight; - float outWidth = (float)g_settings.m_ResInfo[m_Resolution].iWidth; - float outHeight = (float)g_settings.m_ResInfo[m_Resolution].iHeight; + float outWidth = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iWidth; + float outHeight = (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iHeight; float outPR = GetPixelRatio(m_Resolution); return outPR * (outWidth / outHeight) / (winWidth / winHeight); @@ -791,8 +792,8 @@ float CGraphicContext::GetFPS() const { if (m_Resolution != RES_INVALID) { - if (g_settings.m_ResInfo[m_Resolution].fRefreshRate > 0) - return g_settings.m_ResInfo[m_Resolution].fRefreshRate; + if (CDisplaySettings::Get().GetResolutionInfo(m_Resolution).fRefreshRate > 0) + return CDisplaySettings::Get().GetResolutionInfo(m_Resolution).fRefreshRate; if (m_Resolution == RES_PAL_4x3 || m_Resolution == RES_PAL_16x9) return 50.0f; if (m_Resolution == RES_HDTV_1080i) @@ -877,7 +878,7 @@ void CGraphicContext::GetAllowedResolutions(vector<RESOLUTION> &res) res.push_back(RES_WINDOW); res.push_back(RES_DESKTOP); - for (size_t r = (size_t) RES_CUSTOM; r < g_settings.m_ResInfo.size(); r++) + for (size_t r = (size_t) RES_CUSTOM; r < CDisplaySettings::Get().ResolutionInfoSize(); r++) { res.push_back((RESOLUTION) r); } diff --git a/xbmc/interfaces/legacy/Window.cpp b/xbmc/interfaces/legacy/Window.cpp index c4478b0fac..95e551467e 100644 --- a/xbmc/interfaces/legacy/Window.cpp +++ b/xbmc/interfaces/legacy/Window.cpp @@ -26,6 +26,7 @@ #include "guilib/GUICheckMarkControl.h" #include "guilib/GUIRadioButtonControl.h" #include "guilib/GUIWindowManager.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "Application.h" #include "ApplicationMessenger.h" @@ -634,7 +635,7 @@ namespace XBMCAddon throw WindowException("Invalid resolution."); SingleLockWithDelayGuard gslock(g_graphicsContext,languageHook); - ref(window)->SetCoordsRes(g_settings.m_ResInfo[res]); + ref(window)->SetCoordsRes(CDisplaySettings::Get().GetResolutionInfo(res)); } void Window::setProperty(const char* key, const String& value) diff --git a/xbmc/music/karaoke/karaokelyricscdg.cpp b/xbmc/music/karaoke/karaokelyricscdg.cpp index 90b83aeb03..153efdc8ab 100644 --- a/xbmc/music/karaoke/karaokelyricscdg.cpp +++ b/xbmc/music/karaoke/karaokelyricscdg.cpp @@ -20,6 +20,7 @@ #include "system.h" #include "filesystem/File.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "guilib/Texture.h" #include "guilib/GUITexture.h" @@ -186,10 +187,10 @@ void CKaraokeLyricsCDG::Render() // Get screen coordinates RESOLUTION res = g_graphicsContext.GetVideoResolution(); - CRect vertCoords((float)g_settings.m_ResInfo[res].Overscan.left, - (float)g_settings.m_ResInfo[res].Overscan.top, - (float)g_settings.m_ResInfo[res].Overscan.right, - (float)g_settings.m_ResInfo[res].Overscan.bottom); + CRect vertCoords((float)CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left, + (float)CDisplaySettings::Get().GetResolutionInfo(res).Overscan.top, + (float)CDisplaySettings::Get().GetResolutionInfo(res).Overscan.right, + (float)CDisplaySettings::Get().GetResolutionInfo(res).Overscan.bottom); CGUITexture::DrawQuad(vertCoords, 0xffffffff, m_pCdgTexture, &texCoords); } diff --git a/xbmc/music/karaoke/karaokelyricstext.cpp b/xbmc/music/karaoke/karaokelyricstext.cpp index d778647b0c..22cd199632 100644 --- a/xbmc/music/karaoke/karaokelyricstext.cpp +++ b/xbmc/music/karaoke/karaokelyricstext.cpp @@ -23,6 +23,7 @@ #include <math.h> #include "utils/CharsetConverter.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "guilib/GUITextLayout.h" @@ -315,7 +316,7 @@ void CKaraokeLyricsText::Render() // Calculate drawing parameters RESOLUTION resolution = g_graphicsContext.GetVideoResolution(); g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false); - float maxWidth = (float) g_settings.m_ResInfo[resolution].Overscan.right - g_settings.m_ResInfo[resolution].Overscan.left; + float maxWidth = (float) CDisplaySettings::Get().GetResolutionInfo(resolution).Overscan.right - CDisplaySettings::Get().GetResolutionInfo(resolution).Overscan.left; // We must only fall through for STATE_DRAW_SYLLABLE or STATE_PREAMBLE if ( updateText ) @@ -375,9 +376,9 @@ void CKaraokeLyricsText::Render() m_preambleLayout->Update( m_currentPreamble, maxWidth * 0.9f ); } - float x = maxWidth * 0.5f + g_settings.m_ResInfo[resolution].Overscan.left; - float y = (float)g_settings.m_ResInfo[resolution].Overscan.top + - (g_settings.m_ResInfo[resolution].Overscan.bottom - g_settings.m_ResInfo[resolution].Overscan.top) / 8; + float x = maxWidth * 0.5f + CDisplaySettings::Get().GetResolutionInfo(resolution).Overscan.left; + float y = (float)CDisplaySettings::Get().GetResolutionInfo(resolution).Overscan.top + + (CDisplaySettings::Get().GetResolutionInfo(resolution).Overscan.bottom - CDisplaySettings::Get().GetResolutionInfo(resolution).Overscan.top) / 8; float textWidth, textHeight; m_karaokeLayout->GetTextExtent(textWidth, textHeight); @@ -461,7 +462,7 @@ void CKaraokeLyricsText::rescanLyrics() // Second, add spaces if less than 5%, and rescan to gather more data. bool add_spaces = (syllables && (spaces * 100 / syllables < 5)) ? true : false; RESOLUTION res = g_graphicsContext.GetVideoResolution(); - float maxWidth = (float) g_settings.m_ResInfo[res].Overscan.right - g_settings.m_ResInfo[res].Overscan.left; + float maxWidth = (float) CDisplaySettings::Get().GetResolutionInfo(res).Overscan.right - CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left; CStdString line_text; int prev_line_idx = -1; diff --git a/xbmc/music/karaoke/karaokevideobackground.cpp b/xbmc/music/karaoke/karaokevideobackground.cpp index 2718fd57b7..af41a1b52f 100644 --- a/xbmc/music/karaoke/karaokevideobackground.cpp +++ b/xbmc/music/karaoke/karaokevideobackground.cpp @@ -31,6 +31,7 @@ #include "DllSwScale.h" #include "filesystem/SpecialProtocol.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" #include "video/FFmpegVideoDecoder.h" #include "system.h" @@ -63,10 +64,10 @@ bool KaraokeVideoBackground::openVideoFile( const CStdString& filename ) // Find out the necessary aspect ratio for height (assuming fit by width) and width (assuming fit by height) RESOLUTION res = g_graphicsContext.GetVideoResolution(); - m_displayLeft = g_settings.m_ResInfo[res].Overscan.left; - m_displayRight = g_settings.m_ResInfo[res].Overscan.right; - m_displayTop = g_settings.m_ResInfo[res].Overscan.top; - m_displayBottom = g_settings.m_ResInfo[res].Overscan.bottom; + m_displayLeft = CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left; + m_displayRight = CDisplaySettings::Get().GetResolutionInfo(res).Overscan.right; + m_displayTop = CDisplaySettings::Get().GetResolutionInfo(res).Overscan.top; + m_displayBottom = CDisplaySettings::Get().GetResolutionInfo(res).Overscan.bottom; int screen_width = m_displayRight - m_displayLeft; int screen_height = m_displayBottom - m_displayTop; diff --git a/xbmc/osx/IOSScreenManager.mm b/xbmc/osx/IOSScreenManager.mm index db7b341ba0..1582fadae4 100644 --- a/xbmc/osx/IOSScreenManager.mm +++ b/xbmc/osx/IOSScreenManager.mm @@ -24,6 +24,7 @@ #include <sys/resource.h> #include <signal.h> #include "utils/log.h" +#include "settings/DisplaySettings.h" #include "threads/Event.h" #include "Application.h" #include "WindowingFactory.h" @@ -239,7 +240,7 @@ static CEvent screenChangeEvent; //change back to internal screen if([[UIScreen screens] count] == 1 && _screenIdx != 0) { - RESOLUTION_INFO res = g_settings.m_ResInfo[RES_DESKTOP];//internal screen default res + RESOLUTION_INFO res = CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP);//internal screen default res g_Windowing.SetFullScreen(true, res, false); } } diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index 77fdc34490..27e10523a3 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -33,6 +33,7 @@ #include "GUIDialogPictureInfo.h" #include "GUIUserMessages.h" #include "guilib/GUIWindowManager.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "FileItem.h" @@ -462,8 +463,8 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re m_bLoadNextPic = false; // load using the background loader int maxWidth, maxHeight; - GetCheckedSize((float)g_settings.m_ResInfo[m_Resolution].iWidth * m_fZoom, - (float)g_settings.m_ResInfo[m_Resolution].iHeight * m_fZoom, + GetCheckedSize((float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iWidth * m_fZoom, + (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iHeight * m_fZoom, maxWidth, maxHeight); if (!m_slides->Get(m_iCurrentSlide)->IsVideo()) m_pBackgroundLoader->LoadPic(m_iCurrentPic, m_iCurrentSlide, m_slides->Get(m_iCurrentSlide)->GetPath(), maxWidth, maxHeight); @@ -483,8 +484,8 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re { // reload the image if we need to CLog::Log(LOGDEBUG, "Reloading the current image %s at zoom level %i", m_slides->Get(m_iCurrentSlide)->GetPath().c_str(), m_iZoomFactor); // first, our maximal size for this zoom level - int maxWidth = (int)((float)g_settings.m_ResInfo[m_Resolution].iWidth * m_fZoom); - int maxHeight = (int)((float)g_settings.m_ResInfo[m_Resolution].iWidth * m_fZoom); + int maxWidth = (int)((float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iWidth * m_fZoom); + int maxHeight = (int)((float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iWidth * m_fZoom); // the actual maximal size of the image to optimize the sizing based on the known sizing (aspect ratio) int width, height; @@ -505,8 +506,8 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re { // load the next image CLog::Log(LOGDEBUG, "Loading the next image %s", m_slides->Get(m_iNextSlide)->GetPath().c_str()); int maxWidth, maxHeight; - GetCheckedSize((float)g_settings.m_ResInfo[m_Resolution].iWidth * m_fZoom, - (float)g_settings.m_ResInfo[m_Resolution].iHeight * m_fZoom, + GetCheckedSize((float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iWidth * m_fZoom, + (float)CDisplaySettings::Get().GetResolutionInfo(m_Resolution).iHeight * m_fZoom, maxWidth, maxHeight); if (!m_slides->Get(m_iNextSlide)->IsVideo()) m_pBackgroundLoader->LoadPic(1 - m_iCurrentPic, m_iNextSlide, m_slides->Get(m_iNextSlide)->GetPath(), maxWidth, maxHeight); diff --git a/xbmc/pictures/SlideShowPicture.cpp b/xbmc/pictures/SlideShowPicture.cpp index e46743d5d2..b4014c70b1 100644 --- a/xbmc/pictures/SlideShowPicture.cpp +++ b/xbmc/pictures/SlideShowPicture.cpp @@ -22,6 +22,7 @@ #include "system.h" #include "guilib/Texture.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "windowing/WindowingFactory.h" @@ -136,8 +137,8 @@ void CSlideShowPic::SetTexture(int iSlideNumber, CBaseTexture* pTexture, DISPLAY if (m_displayEffect == EFFECT_PANORAMA) { RESOLUTION iRes = g_graphicsContext.GetVideoResolution(); - float fScreenWidth = (float)g_settings.m_ResInfo[iRes].Overscan.right - g_settings.m_ResInfo[iRes].Overscan.left; - float fScreenHeight = (float)g_settings.m_ResInfo[iRes].Overscan.bottom - g_settings.m_ResInfo[iRes].Overscan.top; + float fScreenWidth = (float)CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.right - CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.left; + float fScreenHeight = (float)CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.bottom - CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.top; if (m_fWidth > m_fHeight) { @@ -395,12 +396,12 @@ void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyreg // calculate where we should render (and how large it should be) // calculate aspect ratio correction factor RESOLUTION iRes = g_graphicsContext.GetVideoResolution(); - float fOffsetX = (float)g_settings.m_ResInfo[iRes].Overscan.left; - float fOffsetY = (float)g_settings.m_ResInfo[iRes].Overscan.top; - float fScreenWidth = (float)g_settings.m_ResInfo[iRes].Overscan.right - g_settings.m_ResInfo[iRes].Overscan.left; - float fScreenHeight = (float)g_settings.m_ResInfo[iRes].Overscan.bottom - g_settings.m_ResInfo[iRes].Overscan.top; + float fOffsetX = (float)CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.left; + float fOffsetY = (float)CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.top; + float fScreenWidth = (float)CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.right - CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.left; + float fScreenHeight = (float)CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.bottom - CDisplaySettings::Get().GetResolutionInfo(iRes).Overscan.top; - float fPixelRatio = g_settings.m_ResInfo[iRes].fPixelRatio; + float fPixelRatio = CDisplaySettings::Get().GetResolutionInfo(iRes).fPixelRatio; // Rotate the image as needed float x[4]; diff --git a/xbmc/rendering/gl/RenderSystemGL.cpp b/xbmc/rendering/gl/RenderSystemGL.cpp index 71f26473ac..43a20dd07e 100644 --- a/xbmc/rendering/gl/RenderSystemGL.cpp +++ b/xbmc/rendering/gl/RenderSystemGL.cpp @@ -26,6 +26,7 @@ #include "RenderSystemGL.h" #include "guilib/GraphicContext.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" #include "utils/log.h" #include "utils/GLUtils.h" #include "utils/TimeUtils.h" @@ -469,7 +470,7 @@ bool CRenderSystemGL::TestRender() { static float theta = 0.0; - //RESOLUTION_INFO resInfo = g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution]; + //RESOLUTION_INFO resInfo = CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution]; //glViewport(0, 0, resInfo.iWidth, resInfo.iHeight); glPushMatrix(); diff --git a/xbmc/rendering/gles/RenderSystemGLES.cpp b/xbmc/rendering/gles/RenderSystemGLES.cpp index 1a33fef366..8b47b08a74 100644 --- a/xbmc/rendering/gles/RenderSystemGLES.cpp +++ b/xbmc/rendering/gles/RenderSystemGLES.cpp @@ -428,7 +428,7 @@ bool CRenderSystemGLES::TestRender() { static float theta = 0.0; - //RESOLUTION_INFO resInfo = g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution]; + //RESOLUTION_INFO resInfo = CDisplaySettings::Get().GetResolutionInfo(g_guiSettings.m_LookAndFeelResolution); //glViewport(0, 0, resInfo.iWidth, resInfo.iHeight); g_matrices.PushMatrix(); diff --git a/xbmc/settings/DisplaySettings.cpp b/xbmc/settings/DisplaySettings.cpp new file mode 100644 index 0000000000..58f5442b1f --- /dev/null +++ b/xbmc/settings/DisplaySettings.cpp @@ -0,0 +1,285 @@ +/* + * Copyright (C) 2013 Team XBMC + * http://www.xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "system.h" +#include "DisplaySettings.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/XBMCTinyXML.h" +#include "utils/XMLUtils.h" + +using namespace std; + +static RESOLUTION_INFO EmptyResolution; +static RESOLUTION_INFO EmptyModifiableResolution; + +CDisplaySettings::CDisplaySettings() +{ + m_resolutions.insert(m_resolutions.begin(), RES_CUSTOM, RESOLUTION_INFO()); +} + +CDisplaySettings::~CDisplaySettings() +{ } + +CDisplaySettings& CDisplaySettings::Get() +{ + static CDisplaySettings sDisplaySettings; + return sDisplaySettings; +} + +bool CDisplaySettings::Load(const TiXmlNode *settings) +{ + CSingleLock lock(m_critical); + m_calibrations.clear(); + + if (settings == NULL) + return false; + + const TiXmlElement *pElement = settings->FirstChildElement("resolutions"); + if (!pElement) + { + CLog::Log(LOGERROR, "CDisplaySettings: settings file doesn't contain <resolutions>"); + return false; + } + + const TiXmlElement *pResolution = pElement->FirstChildElement("resolution"); + while (pResolution) + { + // get the data for this calibration + RESOLUTION_INFO cal; + + XMLUtils::GetString(pResolution, "description", cal.strMode); + XMLUtils::GetInt(pResolution, "subtitles", cal.iSubtitles); + XMLUtils::GetFloat(pResolution, "pixelratio", cal.fPixelRatio); +#ifdef HAS_XRANDR + XMLUtils::GetFloat(pResolution, "refreshrate", cal.fRefreshRate); + XMLUtils::GetString(pResolution, "output", cal.strOutput); + XMLUtils::GetString(pResolution, "xrandrid", cal.strId); +#endif + + const TiXmlElement *pOverscan = pResolution->FirstChildElement("overscan"); + if (pOverscan) + { + XMLUtils::GetInt(pOverscan, "left", cal.Overscan.left); + XMLUtils::GetInt(pOverscan, "top", cal.Overscan.top); + XMLUtils::GetInt(pOverscan, "right", cal.Overscan.right); + XMLUtils::GetInt(pOverscan, "bottom", cal.Overscan.bottom); + } + + // mark calibration as not updated + // we must not delete those, resolution just might not be available + cal.iWidth = cal.iHeight = 0; + + // store calibration, avoid adding duplicates + bool found = false; + for (ResolutionInfos::const_iterator it = m_calibrations.begin(); it != m_calibrations.end(); ++it) + { + if (it->strMode.Equals(cal.strMode)) + { + found = true; + break; + } + } + if (!found) + m_calibrations.push_back(cal); + + // iterate around + pResolution = pResolution->NextSiblingElement("resolution"); + } + + ApplyCalibrations(); + return true; +} + +bool CDisplaySettings::Save(TiXmlNode *settings) const +{ + if (settings == NULL) + return false; + + CSingleLock lock(m_critical); + TiXmlElement xmlRootElement("resolutions"); + TiXmlNode *pRoot = settings->InsertEndChild(xmlRootElement); + if (pRoot == NULL) + return false; + + // save calibrations + for (ResolutionInfos::const_iterator it = m_calibrations.begin(); it != m_calibrations.end(); ++it) + { + // Write the resolution tag + TiXmlElement resElement("resolution"); + TiXmlNode *pNode = pRoot->InsertEndChild(resElement); + if (pNode == NULL) + return false; + + // Now write each of the pieces of information we need... + XMLUtils::SetString(pNode, "description", it->strMode); + XMLUtils::SetInt(pNode, "subtitles", it->iSubtitles); + XMLUtils::SetFloat(pNode, "pixelratio", it->fPixelRatio); +#ifdef HAS_XRANDR + XMLUtils::SetFloat(pNode, "refreshrate", it->fRefreshRate); + XMLUtils::SetString(pNode, "output", it->strOutput); + XMLUtils::SetString(pNode, "xrandrid", it->strId); +#endif + + // create the overscan child + TiXmlElement overscanElement("overscan"); + TiXmlNode *pOverscanNode = pNode->InsertEndChild(overscanElement); + if (pOverscanNode == NULL) + return false; + + XMLUtils::SetInt(pOverscanNode, "left", it->Overscan.left); + XMLUtils::SetInt(pOverscanNode, "top", it->Overscan.top); + XMLUtils::SetInt(pOverscanNode, "right", it->Overscan.right); + XMLUtils::SetInt(pOverscanNode, "bottom", it->Overscan.bottom); + } + + return true; +} + +void CDisplaySettings::Clear() +{ + CSingleLock lock(m_critical); + m_calibrations.clear(); + m_resolutions.clear(); +} + +const RESOLUTION_INFO& CDisplaySettings::GetResolutionInfo(size_t index) const +{ + CSingleLock lock(m_critical); + if (index >= m_resolutions.size()) + return EmptyResolution; + + return m_resolutions[index]; +} + +const RESOLUTION_INFO& CDisplaySettings::GetResolutionInfo(RESOLUTION resolution) const +{ + if (resolution <= RES_INVALID) + return EmptyResolution; + + return GetResolutionInfo((size_t)resolution); +} + +RESOLUTION_INFO& CDisplaySettings::GetResolutionInfo(size_t index) +{ + CSingleLock lock(m_critical); + if (index >= m_resolutions.size()) + { + EmptyModifiableResolution = RESOLUTION_INFO(); + return EmptyModifiableResolution; + } + + return m_resolutions[index]; +} + +RESOLUTION_INFO& CDisplaySettings::GetResolutionInfo(RESOLUTION resolution) +{ + if (resolution <= RES_INVALID) + { + EmptyModifiableResolution = RESOLUTION_INFO(); + return EmptyModifiableResolution; + } + + return GetResolutionInfo((size_t)resolution); +} + +void CDisplaySettings::AddResolutionInfo(const RESOLUTION_INFO &resolution) +{ + CSingleLock lock(m_critical); + m_resolutions.push_back(resolution); +} + +void CDisplaySettings::ApplyCalibrations() +{ + CSingleLock lock(m_critical); + // apply all calibrations to the resolutions + for (ResolutionInfos::const_iterator itCal = m_calibrations.begin(); itCal != m_calibrations.end(); ++itCal) + { + // find resolutions + for (size_t res = 0; res < m_resolutions.size(); ++res) + { + if (res == RES_WINDOW) + continue; + if (itCal->strMode.Equals(m_resolutions[res].strMode)) + { + // overscan + m_resolutions[res].Overscan.left = itCal->Overscan.left; + if (m_resolutions[res].Overscan.left < -m_resolutions[res].iWidth/4) + m_resolutions[res].Overscan.left = -m_resolutions[res].iWidth/4; + if (m_resolutions[res].Overscan.left > m_resolutions[res].iWidth/4) + m_resolutions[res].Overscan.left = m_resolutions[res].iWidth/4; + + m_resolutions[res].Overscan.top = itCal->Overscan.top; + if (m_resolutions[res].Overscan.top < -m_resolutions[res].iHeight/4) + m_resolutions[res].Overscan.top = -m_resolutions[res].iHeight/4; + if (m_resolutions[res].Overscan.top > m_resolutions[res].iHeight/4) + m_resolutions[res].Overscan.top = m_resolutions[res].iHeight/4; + + m_resolutions[res].Overscan.right = itCal->Overscan.right; + if (m_resolutions[res].Overscan.right < m_resolutions[res].iWidth / 2) + m_resolutions[res].Overscan.right = m_resolutions[res].iWidth / 2; + if (m_resolutions[res].Overscan.right > m_resolutions[res].iWidth * 3/2) + m_resolutions[res].Overscan.right = m_resolutions[res].iWidth *3/2; + + m_resolutions[res].Overscan.bottom = itCal->Overscan.bottom; + if (m_resolutions[res].Overscan.bottom < m_resolutions[res].iHeight / 2) + m_resolutions[res].Overscan.bottom = m_resolutions[res].iHeight / 2; + if (m_resolutions[res].Overscan.bottom > m_resolutions[res].iHeight * 3/2) + m_resolutions[res].Overscan.bottom = m_resolutions[res].iHeight * 3/2; + + m_resolutions[res].iSubtitles = itCal->iSubtitles; + if (m_resolutions[res].iSubtitles < m_resolutions[res].iHeight / 2) + m_resolutions[res].iSubtitles = m_resolutions[res].iHeight / 2; + if (m_resolutions[res].iSubtitles > m_resolutions[res].iHeight* 5/4) + m_resolutions[res].iSubtitles = m_resolutions[res].iHeight* 5/4; + + m_resolutions[res].fPixelRatio = itCal->fPixelRatio; + if (m_resolutions[res].fPixelRatio < 0.5f) + m_resolutions[res].fPixelRatio = 0.5f; + if (m_resolutions[res].fPixelRatio > 2.0f) + m_resolutions[res].fPixelRatio = 2.0f; + break; + } + } + } +} + +void CDisplaySettings::UpdateCalibrations() +{ + CSingleLock lock(m_critical); + for (size_t res = RES_DESKTOP; res < m_resolutions.size(); ++res) + { + // find calibration + bool found = false; + for (ResolutionInfos::iterator itCal = m_calibrations.begin(); itCal != m_calibrations.end(); ++itCal) + { + if (itCal->strMode.Equals(m_resolutions[res].strMode)) + { + // TODO: erase calibrations with default values + *itCal = m_resolutions[res]; + found = true; + break; + } + } + + if (!found) + m_calibrations.push_back(m_resolutions[res]); + } +} diff --git a/xbmc/settings/DisplaySettings.h b/xbmc/settings/DisplaySettings.h new file mode 100644 index 0000000000..12c35456a5 --- /dev/null +++ b/xbmc/settings/DisplaySettings.h @@ -0,0 +1,60 @@ +#pragma once +/* + * Copyright (C) 2013 Team XBMC + * http://www.xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <vector> + +#include "guilib/Resolution.h" +#include "settings/ISubSettings.h" +#include "threads/CriticalSection.h" + +class TiXmlNode; + +class CDisplaySettings : public ISubSettings +{ +public: + static CDisplaySettings& Get(); + + virtual bool Load(const TiXmlNode *settings); + virtual bool Save(TiXmlNode *settings) const; + virtual void Clear(); + + const RESOLUTION_INFO& GetResolutionInfo(size_t index) const; + const RESOLUTION_INFO& GetResolutionInfo(RESOLUTION resolution) const; + RESOLUTION_INFO& GetResolutionInfo(size_t index); + RESOLUTION_INFO& GetResolutionInfo(RESOLUTION resolution); + size_t ResolutionInfoSize() const { return m_resolutions.size(); } + void AddResolutionInfo(const RESOLUTION_INFO &resolution); + + void ApplyCalibrations(); + void UpdateCalibrations(); + +protected: + CDisplaySettings(); + CDisplaySettings(const CDisplaySettings&); + CDisplaySettings const& operator=(CDisplaySettings const&); + virtual ~CDisplaySettings(); + +private: + typedef std::vector<RESOLUTION_INFO> ResolutionInfos; + ResolutionInfos m_resolutions; + ResolutionInfos m_calibrations; + CCriticalSection m_critical; +}; diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp index a5a33e678a..04d29884b7 100644 --- a/xbmc/settings/GUISettings.cpp +++ b/xbmc/settings/GUISettings.cpp @@ -32,6 +32,7 @@ #include "AdvancedSettings.h" #include "guilib/LocalizeStrings.h" #include "utils/CharsetConverter.h" +#include "settings/DisplaySettings.h" #include "utils/StringUtils.h" #include "utils/SystemInfo.h" #include "utils/log.h" @@ -409,7 +410,7 @@ void CGUISettings::Initialize() AddInt(vs, "videoscreen.screen", 240, 0, -1, 1, 32, SPIN_CONTROL_TEXT); #endif // this setting would ideally not be saved, as its value is systematically derived from videoscreen.screenmode. - // contains an index to the g_settings.m_ResInfo array. the only meaningful fields are iScreen, iWidth, iHeight. + // contains an index to the resolution info array in CDisplaySettings. the only meaningful fields are iScreen, iWidth, iHeight. #if defined(TARGET_DARWIN) #if !defined(TARGET_DARWIN_IOS_ATV2) AddInt(vs, "videoscreen.resolution", 131, -1, 0, 1, INT_MAX, SPIN_CONTROL_TEXT); @@ -1604,9 +1605,9 @@ RESOLUTION CGUISettings::GetResFromString(const CStdString &res) // find the closest match to these in our res vector. If we have the screen, we score the res RESOLUTION bestRes = RES_DESKTOP; float bestScore = FLT_MAX; - for (unsigned int i = RES_DESKTOP; i < g_settings.m_ResInfo.size(); ++i) + for (unsigned int i = RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); ++i) { - const RESOLUTION_INFO &info = g_settings.m_ResInfo[i]; + const RESOLUTION_INFO &info = CDisplaySettings::Get().GetResolutionInfo(i); if (info.iScreen != screen) continue; float score = 10 * (square_error((float)info.iScreenWidth, (float)width) + @@ -1631,9 +1632,9 @@ void CGUISettings::SetResolution(RESOLUTION res) mode = "DESKTOP"; else if (res == RES_WINDOW) mode = "WINDOW"; - else if (res >= RES_CUSTOM && res < (RESOLUTION)g_settings.m_ResInfo.size()) + else if (res >= RES_CUSTOM && res < (RESOLUTION)CDisplaySettings::Get().ResolutionInfoSize()) { - const RESOLUTION_INFO &info = g_settings.m_ResInfo[res]; + const RESOLUTION_INFO &info = CDisplaySettings::Get().GetResolutionInfo(res); mode.Format("%1i%05i%05i%09.5f%s", info.iScreen, info.iScreenWidth, info.iScreenHeight, info.fRefreshRate, (info.dwFlags & D3DPRESENTFLAG_INTERLACED) ? "i":"p"); diff --git a/xbmc/settings/Makefile b/xbmc/settings/Makefile index 35f892bd6a..4790e9fd7e 100644 --- a/xbmc/settings/Makefile +++ b/xbmc/settings/Makefile @@ -1,4 +1,5 @@ SRCS=AdvancedSettings.cpp \ + DisplaySettings.cpp \ GUISettings.cpp \ MediaSettings.cpp \ MediaSourceSettings.cpp \ diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index 8f18e00169..efbc15b305 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -103,17 +103,6 @@ void CSettings::UnregisterSubSettings(ISubSettings *subSettings) void CSettings::Initialize() { - RESOLUTION_INFO res; - vector<RESOLUTION_INFO>::iterator it = m_ResInfo.begin(); - - m_ResInfo.insert(it, RES_CUSTOM, res); - - for (int i = RES_HDTV_1080i; i <= RES_PAL60_16x9; i++) - { - g_graphicsContext.ResetScreenParameters((RESOLUTION)i); - g_graphicsContext.ResetOverscan((RESOLUTION)i, m_ResInfo[i].Overscan); - } - m_videoStacking = false; m_bMyMusicSongInfoInVis = true; // UNUSED - depreciated. @@ -270,170 +259,6 @@ bool CSettings::GetFloat(const TiXmlElement* pRootElement, const char *tagName, return false; } -bool CSettings::LoadCalibration(const TiXmlElement* pRoot, const CStdString& strSettingsFile) -{ - m_Calibrations.clear(); - - const TiXmlElement *pElement = pRoot->FirstChildElement("resolutions"); - if (!pElement) - { - CLog::Log(LOGERROR, "%s Doesn't contain <resolutions>", strSettingsFile.c_str()); - return false; - } - const TiXmlElement *pResolution = pElement->FirstChildElement("resolution"); - while (pResolution) - { - // get the data for this calibration - RESOLUTION_INFO cal; - - XMLUtils::GetString(pResolution, "description", cal.strMode); - XMLUtils::GetInt(pResolution, "subtitles", cal.iSubtitles); - XMLUtils::GetFloat(pResolution, "pixelratio", cal.fPixelRatio); -#ifdef HAS_XRANDR - XMLUtils::GetFloat(pResolution, "refreshrate", cal.fRefreshRate); - XMLUtils::GetString(pResolution, "output", cal.strOutput); - XMLUtils::GetString(pResolution, "xrandrid", cal.strId); -#endif - - const TiXmlElement *pOverscan = pResolution->FirstChildElement("overscan"); - if (pOverscan) - { - XMLUtils::GetInt(pOverscan, "left", cal.Overscan.left); - XMLUtils::GetInt(pOverscan, "top", cal.Overscan.top); - XMLUtils::GetInt(pOverscan, "right", cal.Overscan.right); - XMLUtils::GetInt(pOverscan, "bottom", cal.Overscan.bottom); - } - - // mark calibration as not updated - // we must not delete those, resolution just might not be available - cal.iWidth = cal.iHeight = 0; - - // store calibration, avoid adding duplicates - bool found = false; - for (std::vector<RESOLUTION_INFO>::iterator it = m_Calibrations.begin(); it != m_Calibrations.end(); ++it) - { - if (it->strMode.Equals(cal.strMode)) - { - found = true; - break; - } - } - if (!found) - m_Calibrations.push_back(cal); - - // iterate around - pResolution = pResolution->NextSiblingElement("resolution"); - } - ApplyCalibrations(); - return true; -} - -void CSettings::ApplyCalibrations() -{ - // apply all calibrations to the resolutions - for (size_t i = 0; i < m_Calibrations.size(); ++i) - { - // find resolutions - for (size_t res = 0; res < m_ResInfo.size(); ++res) - { - if (res == RES_WINDOW) - continue; - if (m_Calibrations[i].strMode.Equals(m_ResInfo[res].strMode)) - { - // overscan - m_ResInfo[res].Overscan.left = m_Calibrations[i].Overscan.left; - if (m_ResInfo[res].Overscan.left < -m_ResInfo[res].iWidth/4) - m_ResInfo[res].Overscan.left = -m_ResInfo[res].iWidth/4; - if (m_ResInfo[res].Overscan.left > m_ResInfo[res].iWidth/4) - m_ResInfo[res].Overscan.left = m_ResInfo[res].iWidth/4; - - m_ResInfo[res].Overscan.top = m_Calibrations[i].Overscan.top; - if (m_ResInfo[res].Overscan.top < -m_ResInfo[res].iHeight/4) - m_ResInfo[res].Overscan.top = -m_ResInfo[res].iHeight/4; - if (m_ResInfo[res].Overscan.top > m_ResInfo[res].iHeight/4) - m_ResInfo[res].Overscan.top = m_ResInfo[res].iHeight/4; - - m_ResInfo[res].Overscan.right = m_Calibrations[i].Overscan.right; - if (m_ResInfo[res].Overscan.right < m_ResInfo[res].iWidth / 2) - m_ResInfo[res].Overscan.right = m_ResInfo[res].iWidth / 2; - if (m_ResInfo[res].Overscan.right > m_ResInfo[res].iWidth * 3/2) - m_ResInfo[res].Overscan.right = m_ResInfo[res].iWidth *3/2; - - m_ResInfo[res].Overscan.bottom = m_Calibrations[i].Overscan.bottom; - if (m_ResInfo[res].Overscan.bottom < m_ResInfo[res].iHeight / 2) - m_ResInfo[res].Overscan.bottom = m_ResInfo[res].iHeight / 2; - if (m_ResInfo[res].Overscan.bottom > m_ResInfo[res].iHeight * 3/2) - m_ResInfo[res].Overscan.bottom = m_ResInfo[res].iHeight * 3/2; - - m_ResInfo[res].iSubtitles = m_Calibrations[i].iSubtitles; - if (m_ResInfo[res].iSubtitles < m_ResInfo[res].iHeight / 2) - m_ResInfo[res].iSubtitles = m_ResInfo[res].iHeight / 2; - if (m_ResInfo[res].iSubtitles > m_ResInfo[res].iHeight* 5/4) - m_ResInfo[res].iSubtitles = m_ResInfo[res].iHeight* 5/4; - - m_ResInfo[res].fPixelRatio = m_Calibrations[i].fPixelRatio; - if (m_ResInfo[res].fPixelRatio < 0.5f) - m_ResInfo[res].fPixelRatio = 0.5f; - if (m_ResInfo[res].fPixelRatio > 2.0f) - m_ResInfo[res].fPixelRatio = 2.0f; - break; - } - } - } -} - -void CSettings::UpdateCalibrations() -{ - for (size_t res = RES_DESKTOP; res < m_ResInfo.size(); ++res) - { - // find calibration - bool found = false; - for (std::vector<RESOLUTION_INFO>::iterator it = m_Calibrations.begin(); it != m_Calibrations.end(); ++it) - { - if (it->strMode.Equals(m_ResInfo[res].strMode)) - { - // TODO: erase calibrations with default values - (*it) = m_ResInfo[res]; - found = true; - break; - } - } - if (!found) - m_Calibrations.push_back(m_ResInfo[res]); - } -} - -bool CSettings::SaveCalibration(TiXmlNode* pRootNode) const -{ - TiXmlElement xmlRootElement("resolutions"); - TiXmlNode *pRoot = pRootNode->InsertEndChild(xmlRootElement); - - // save calibrations - for (size_t i = 0 ; i < m_Calibrations.size() ; i++) - { - // Write the resolution tag - TiXmlElement resElement("resolution"); - TiXmlNode *pNode = pRoot->InsertEndChild(resElement); - // Now write each of the pieces of information we need... - XMLUtils::SetString(pNode, "description", m_Calibrations[i].strMode); - XMLUtils::SetInt(pNode, "subtitles", m_Calibrations[i].iSubtitles); - XMLUtils::SetFloat(pNode, "pixelratio", m_Calibrations[i].fPixelRatio); -#ifdef HAS_XRANDR - XMLUtils::SetFloat(pNode, "refreshrate", m_Calibrations[i].fRefreshRate); - XMLUtils::SetString(pNode, "output", m_Calibrations[i].strOutput); - XMLUtils::SetString(pNode, "xrandrid", m_Calibrations[i].strId); -#endif - // create the overscan child - TiXmlElement overscanElement("overscan"); - TiXmlNode *pOverscanNode = pNode->InsertEndChild(overscanElement); - XMLUtils::SetInt(pOverscanNode, "left", m_Calibrations[i].Overscan.left); - XMLUtils::SetInt(pOverscanNode, "top", m_Calibrations[i].Overscan.top); - XMLUtils::SetInt(pOverscanNode, "right", m_Calibrations[i].Overscan.right); - XMLUtils::SetInt(pOverscanNode, "bottom", m_Calibrations[i].Overscan.bottom); - } - return true; -} - bool CSettings::LoadSettings(const CStdString& strSettingsFile) { // load the xml file @@ -504,7 +329,6 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile) GetFloat(pElement, "fvolumelevel", m_fVolumeLevel, VOLUME_MAXIMUM, VOLUME_MINIMUM, VOLUME_MAXIMUM); } - LoadCalibration(pRootElement, strSettingsFile); g_guiSettings.LoadXML(pRootElement); // load any ISubSettings implementations @@ -575,8 +399,6 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo XMLUtils::SetBoolean(pNode, "mute", m_bMute); XMLUtils::SetFloat(pNode, "fvolumelevel", m_fVolumeLevel); - SaveCalibration(pRoot); - if (localSettings) // local settings to save localSettings->SaveXML(pRoot); else // save the global settings @@ -788,9 +610,6 @@ void CSettings::Clear() m_defaultMusicLibSource.clear(); - m_ResInfo.clear(); - m_Calibrations.clear(); - OnSettingsCleared(); for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h index 19729791fe..f046232fe2 100644 --- a/xbmc/settings/Settings.h +++ b/xbmc/settings/Settings.h @@ -218,9 +218,6 @@ public: int GetCurrentProfileId() const; - std::vector<RESOLUTION_INFO> m_ResInfo; - std::vector<RESOLUTION_INFO> m_Calibrations; - // utility functions for user data folders //uses HasSlashAtEnd to determine if a directory or file was meant @@ -259,12 +256,7 @@ public: static bool GetString(const TiXmlElement* pRootElement, const char *strTagName, CStdString& strValue, const CStdString& strDefaultValue); bool GetString(const TiXmlElement* pRootElement, const char *strTagName, char *szValue, const CStdString& strDefaultValue); - void ApplyCalibrations(); - void UpdateCalibrations(); protected: - bool LoadCalibration(const TiXmlElement* pElement, const CStdString& strSettingsFile); - bool SaveCalibration(TiXmlNode* pRootNode) const; - bool LoadSettings(const CStdString& strSettingsFile); // bool SaveSettings(const CStdString& strSettingsFile) const; diff --git a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp index 4a94ecc346..e6db776e9e 100644 --- a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp @@ -88,6 +88,7 @@ #include <map> #include "settings/Settings.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" #include "settings/MediaSourceSettings.h" #include "input/MouseStat.h" #if defined(TARGET_WINDOWS) @@ -2325,7 +2326,7 @@ DisplayMode CGUIWindowSettingsCategory::FillInScreens(CStdString strSetting, RES if (res == RES_WINDOW) mode = DM_WINDOWED; else - mode = g_settings.m_ResInfo[res].iScreen; + mode = CDisplaySettings::Get().GetResolutionInfo(res).iScreen; // we expect "videoscreen.screen" but it might be hidden on some platforms, // so check that we actually have a visable control. @@ -2342,8 +2343,8 @@ DisplayMode CGUIWindowSettingsCategory::FillInScreens(CStdString strSetting, RES for (int idx = 0; idx < g_Windowing.GetNumScreens(); idx++) { - strScreen.Format(g_localizeStrings.Get(241), g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen + 1); - pControl->AddLabel(strScreen, g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen); + strScreen.Format(g_localizeStrings.Get(241), CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen + 1); + pControl->AddLabel(strScreen, CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen); } pControl->SetValue(mode); g_guiSettings.SetInt("videoscreen.screen", mode); @@ -2378,8 +2379,8 @@ void CGUIWindowSettingsCategory::FillInResolutions(CStdString strSetting, Displa (resolutions[idx].interlaced == D3DPRESENTFLAG_INTERLACED) ? "i" : "p"); pControl->AddLabel(strRes, resolutions[idx].ResInfo_Index); - RESOLUTION_INFO res1 = g_settings.m_ResInfo[res]; - RESOLUTION_INFO res2 = g_settings.m_ResInfo[resolutions[idx].ResInfo_Index]; + RESOLUTION_INFO res1 = CDisplaySettings::Get().GetResolutionInfo(res); + RESOLUTION_INFO res2 = CDisplaySettings::Get().GetResolutionInfo(resolutions[idx].ResInfo_Index); if ( res1.iScreen == res2.iScreen && res1.iScreenWidth == res2.iScreenWidth && res1.iScreenHeight == res2.iScreenHeight @@ -2399,7 +2400,7 @@ void CGUIWindowSettingsCategory::FillInResolutions(CStdString strSetting, Displa else { for (int idx=0; idx < g_Windowing.GetNumScreens(); idx++) - if (g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen == mode) + if (CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen == mode) { autoresolution = RES_DESKTOP + idx; break; @@ -2423,10 +2424,10 @@ void CGUIWindowSettingsCategory::FillInRefreshRates(CStdString strSetting, RESOL vector<REFRESHRATE> refreshrates; if (res > RES_WINDOW) - refreshrates = g_Windowing.RefreshRates(g_settings.m_ResInfo[res].iScreen, - g_settings.m_ResInfo[res].iScreenWidth, - g_settings.m_ResInfo[res].iScreenHeight, - g_settings.m_ResInfo[res].dwFlags); + refreshrates = g_Windowing.RefreshRates(CDisplaySettings::Get().GetResolutionInfo(res).iScreen, + CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight, + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags); // The control setting doesn't exist when not in standalone mode, don't manipulate it BaseSettingControlPtr control = GetSetting(strSetting); @@ -2461,7 +2462,7 @@ void CGUIWindowSettingsCategory::FillInRefreshRates(CStdString strSetting, RESOL if (res == RES_WINDOW) newresolution = RES_WINDOW; else - newresolution = (RESOLUTION) g_Windowing.DefaultRefreshRate(g_settings.m_ResInfo[res].iScreen, refreshrates).ResInfo_Index; + newresolution = (RESOLUTION) g_Windowing.DefaultRefreshRate(CDisplaySettings::Get().GetResolutionInfo(res).iScreen, refreshrates).ResInfo_Index; if (pControl) pControl->SetValue(newresolution); diff --git a/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp b/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp index 01cee782dd..ba88d613b0 100644 --- a/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp +++ b/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp @@ -26,6 +26,7 @@ #include "cores/VideoRenderers/RenderManager.h" #endif #include "Application.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "guilib/GUIWindowManager.h" @@ -72,7 +73,7 @@ bool CGUIWindowSettingsScreenCalibration::OnAction(const CAction &action) CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); pDialog->SetHeading(20325); CStdString strText; - strText.Format(g_localizeStrings.Get(20326).c_str(), g_settings.m_ResInfo[m_Res[m_iCurRes]].strMode.c_str()); + strText.Format(g_localizeStrings.Get(20326).c_str(), CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).strMode.c_str()); pDialog->SetLine(0, strText); pDialog->SetLine(1, 20327); pDialog->SetChoice(0, 222); @@ -117,7 +118,7 @@ bool CGUIWindowSettingsScreenCalibration::OnMessage(CGUIMessage& message) { case GUI_MSG_WINDOW_DEINIT: { - g_settings.UpdateCalibrations(); + CDisplaySettings::Get().UpdateCalibrations(); g_settings.Save(); g_graphicsContext.SetCalibrating(false); g_windowManager.ShowOverlay(OVERLAY_STATE_SHOWN); @@ -249,47 +250,47 @@ void CGUIWindowSettingsScreenCalibration::ResetControls() CGUIMoverControl *pControl = (CGUIMoverControl*)GetControl(CONTROL_TOP_LEFT); if (pControl) { - pControl->SetLimits( -g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth / 4, - -g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight / 4, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth / 4, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight / 4); - pControl->SetPosition((float)g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.left, - (float)g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.top); - pControl->SetLocation(g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.left, - g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.top, false); + pControl->SetLimits( -CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth / 4, + -CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight / 4, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth / 4, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight / 4); + pControl->SetPosition((float)CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.left, + (float)CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.top); + pControl->SetLocation(CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.left, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.top, false); } pControl = (CGUIMoverControl*)GetControl(CONTROL_BOTTOM_RIGHT); if (pControl) { - pControl->SetLimits(g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth*3 / 4, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight*3 / 4, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth*5 / 4, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight*5 / 4); - pControl->SetPosition((float)g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.right - (int)pControl->GetWidth(), - (float)g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.bottom - (int)pControl->GetHeight()); - pControl->SetLocation(g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.right, - g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.bottom, false); + pControl->SetLimits(CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth*3 / 4, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight*3 / 4, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth*5 / 4, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight*5 / 4); + pControl->SetPosition((float)CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.right - (int)pControl->GetWidth(), + (float)CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.bottom - (int)pControl->GetHeight()); + pControl->SetLocation(CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.right, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.bottom, false); } // Subtitles and OSD controls can only move up and down pControl = (CGUIMoverControl*)GetControl(CONTROL_SUBTITLES); if (pControl) { - pControl->SetLimits(0, g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight*3 / 4, - 0, g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight*5 / 4); - pControl->SetPosition((g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth - pControl->GetWidth()) * 0.5f, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iSubtitles - pControl->GetHeight()); - pControl->SetLocation(0, g_settings.m_ResInfo[m_Res[m_iCurRes]].iSubtitles, false); + pControl->SetLimits(0, CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight*3 / 4, + 0, CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight*5 / 4); + pControl->SetPosition((CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth - pControl->GetWidth()) * 0.5f, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iSubtitles - pControl->GetHeight()); + pControl->SetLocation(0, CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iSubtitles, false); } // lastly the pixel ratio control... CGUIResizeControl *pResize = (CGUIResizeControl*)GetControl(CONTROL_PIXEL_RATIO); if (pResize) { - pResize->SetLimits(g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth*0.25f, g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight*0.5f, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth*0.75f, g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight*0.5f); - pResize->SetHeight(g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight * 0.5f); - pResize->SetWidth(pResize->GetHeight() / g_settings.m_ResInfo[m_Res[m_iCurRes]].fPixelRatio); - pResize->SetPosition((g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth - pResize->GetWidth()) / 2, - (g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight - pResize->GetHeight()) / 2); + pResize->SetLimits(CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth*0.25f, CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight*0.5f, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth*0.75f, CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight*0.5f); + pResize->SetHeight(CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight * 0.5f); + pResize->SetWidth(pResize->GetHeight() / CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).fPixelRatio); + pResize->SetPosition((CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth - pResize->GetWidth()) / 2, + (CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight - pResize->GetHeight()) / 2); } // Enable the default control EnableControl(m_iControl); @@ -305,11 +306,11 @@ void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl) { float fWidth = (float)pControl->GetWidth(); float fHeight = (float)pControl->GetHeight(); - g_settings.m_ResInfo[m_Res[m_iCurRes]].fPixelRatio = fHeight / fWidth; + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).fPixelRatio = fHeight / fWidth; // recenter our control... - pControl->SetPosition((g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth - pControl->GetWidth()) / 2, - (g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight - pControl->GetHeight()) / 2); - strStatus.Format("%s (%5.3f)", g_localizeStrings.Get(275).c_str(), g_settings.m_ResInfo[m_Res[m_iCurRes]].fPixelRatio); + pControl->SetPosition((CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth - pControl->GetWidth()) / 2, + (CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight - pControl->GetHeight()) / 2); + strStatus.Format("%s (%5.3f)", g_localizeStrings.Get(275).c_str(), CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).fPixelRatio); SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 278); } } @@ -322,8 +323,8 @@ void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl) { case CONTROL_TOP_LEFT: { - g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.left = pControl->GetXLocation(); - g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.top = pControl->GetYLocation(); + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.left = pControl->GetXLocation(); + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.top = pControl->GetYLocation(); strStatus.Format("%s (%i,%i)", g_localizeStrings.Get(272).c_str(), pControl->GetXLocation(), pControl->GetYLocation()); SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 276); } @@ -331,10 +332,10 @@ void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl) case CONTROL_BOTTOM_RIGHT: { - g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.right = pControl->GetXLocation(); - g_settings.m_ResInfo[m_Res[m_iCurRes]].Overscan.bottom = pControl->GetYLocation(); - int iXOff1 = g_settings.m_ResInfo[m_Res[m_iCurRes]].iWidth - pControl->GetXLocation(); - int iYOff1 = g_settings.m_ResInfo[m_Res[m_iCurRes]].iHeight - pControl->GetYLocation(); + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.right = pControl->GetXLocation(); + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).Overscan.bottom = pControl->GetYLocation(); + int iXOff1 = CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iWidth - pControl->GetXLocation(); + int iYOff1 = CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iHeight - pControl->GetYLocation(); strStatus.Format("%s (%i,%i)", g_localizeStrings.Get(273).c_str(), iXOff1, iYOff1); SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 276); } @@ -342,7 +343,7 @@ void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl) case CONTROL_SUBTITLES: { - g_settings.m_ResInfo[m_Res[m_iCurRes]].iSubtitles = pControl->GetYLocation(); + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iSubtitles = pControl->GetYLocation(); strStatus.Format("%s (%i)", g_localizeStrings.Get(274).c_str(), pControl->GetYLocation()); SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 277); } @@ -353,12 +354,12 @@ void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl) // set the label control correctly CStdString strText; if (g_Windowing.IsFullScreen()) - strText.Format("%ix%i@%.2f - %s | %s", g_settings.m_ResInfo[m_Res[m_iCurRes]].iScreenWidth, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iScreenHeight, g_settings.m_ResInfo[m_Res[m_iCurRes]].fRefreshRate, + strText.Format("%ix%i@%.2f - %s | %s", CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iScreenHeight, CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).fRefreshRate, g_localizeStrings.Get(244).c_str(), strStatus.c_str()); else - strText.Format("%ix%i - %s | %s", g_settings.m_ResInfo[m_Res[m_iCurRes]].iScreenWidth, - g_settings.m_ResInfo[m_Res[m_iCurRes]].iScreenHeight, + strText.Format("%ix%i - %s | %s", CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(m_Res[m_iCurRes]).iScreenHeight, g_localizeStrings.Get(242).c_str(), strStatus.c_str()); SET_CONTROL_LABEL(CONTROL_LABEL_ROW1, strText); diff --git a/xbmc/settings/windows/GUIWindowTestPattern.cpp b/xbmc/settings/windows/GUIWindowTestPattern.cpp index 5100dab1ab..a815aad0d3 100644 --- a/xbmc/settings/windows/GUIWindowTestPattern.cpp +++ b/xbmc/settings/windows/GUIWindowTestPattern.cpp @@ -21,6 +21,7 @@ */ #include "GUIWindowTestPattern.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "guilib/GUIWindowManager.h" #include "guilib/Key.h" @@ -84,10 +85,10 @@ void CGUIWindowTestPattern::Render() { BeginRender(); - int top = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].Overscan.top; - int bottom = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].Overscan.bottom; - int left = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].Overscan.left; - int right = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].Overscan.right; + int top = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).Overscan.top; + int bottom = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).Overscan.bottom; + int left = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).Overscan.left; + int right = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).Overscan.right; switch (m_pattern) { diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index 0d26a97f1c..943e588aac 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -41,6 +41,7 @@ #include "dialogs/GUIDialogNumeric.h" #include "dialogs/GUIDialogKaiToast.h" #include "guilib/GUISliderControl.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/MediaSettings.h" #include "guilib/GUISelectButtonControl.h" @@ -533,7 +534,7 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) break; case ACTION_SUBTITLE_VSHIFT_UP: { - RESOLUTION_INFO& res_info = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()]; + RESOLUTION_INFO& res_info = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); int subalign = g_guiSettings.GetInt("subtitles.align"); if ((subalign == SUBTITLE_ALIGN_BOTTOM_OUTSIDE) || (subalign == SUBTITLE_ALIGN_TOP_INSIDE)) { @@ -559,7 +560,7 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) } case ACTION_SUBTITLE_VSHIFT_DOWN: { - RESOLUTION_INFO& res_info = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()]; + RESOLUTION_INFO& res_info = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); int subalign = g_guiSettings.GetInt("subtitles.align"); if ((subalign == SUBTITLE_ALIGN_BOTTOM_OUTSIDE) || (subalign == SUBTITLE_ALIGN_TOP_INSIDE)) { @@ -585,7 +586,7 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) } case ACTION_SUBTITLE_ALIGN: { - RESOLUTION_INFO& res_info = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()]; + RESOLUTION_INFO& res_info = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); int subalign = g_guiSettings.GetInt("subtitles.align"); subalign++; @@ -961,8 +962,8 @@ void CGUIWindowFullScreen::FrameMove() { // Splitres scaling factor RESOLUTION res = g_graphicsContext.GetVideoResolution(); - float xscale = (float)g_settings.m_ResInfo[res].iScreenWidth / (float)g_settings.m_ResInfo[res].iWidth; - float yscale = (float)g_settings.m_ResInfo[res].iScreenHeight / (float)g_settings.m_ResInfo[res].iHeight; + float xscale = (float)CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth / (float)CDisplaySettings::Get().GetResolutionInfo(res).iWidth; + float yscale = (float)CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight / (float)CDisplaySettings::Get().GetResolutionInfo(res).iHeight; CStdString strSizing; strSizing.Format(g_localizeStrings.Get(245), @@ -980,13 +981,13 @@ void CGUIWindowFullScreen::FrameMove() CStdString strStatus; if (g_Windowing.IsFullScreen()) strStatus.Format("%s %ix%i@%.2fHz - %s", - g_localizeStrings.Get(13287), g_settings.m_ResInfo[iResolution].iScreenWidth, - g_settings.m_ResInfo[iResolution].iScreenHeight, g_settings.m_ResInfo[iResolution].fRefreshRate, + g_localizeStrings.Get(13287), CDisplaySettings::Get().GetResolutionInfo(iResolution).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(iResolution).iScreenHeight, CDisplaySettings::Get().GetResolutionInfo(iResolution).fRefreshRate, g_localizeStrings.Get(244)); else strStatus.Format("%s %ix%i - %s", - g_localizeStrings.Get(13287), g_settings.m_ResInfo[iResolution].iScreenWidth, - g_settings.m_ResInfo[iResolution].iScreenHeight, g_localizeStrings.Get(242)); + g_localizeStrings.Get(13287), CDisplaySettings::Get().GetResolutionInfo(iResolution).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(iResolution).iScreenHeight, g_localizeStrings.Get(242)); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3); msg.SetLabel(strStatus); @@ -1112,17 +1113,17 @@ void CGUIWindowFullScreen::RenderTTFSubtitles() RESOLUTION res = g_graphicsContext.GetVideoResolution(); g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false); - float maxWidth = (float) g_settings.m_ResInfo[res].Overscan.right - g_settings.m_ResInfo[res].Overscan.left; + float maxWidth = (float) CDisplaySettings::Get().GetResolutionInfo(res).Overscan.right - CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left; m_subsLayout->Update(subtitleText, maxWidth * 0.9f, false, true); // true to force LTR reading order (most Hebrew subs are this format) int subalign = g_guiSettings.GetInt("subtitles.align"); float textWidth, textHeight; m_subsLayout->GetTextExtent(textWidth, textHeight); - float x = maxWidth * 0.5f + g_settings.m_ResInfo[res].Overscan.left; - float y = (float) g_settings.m_ResInfo[res].iSubtitles; + float x = maxWidth * 0.5f + CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left; + float y = (float) CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles; if (subalign == SUBTITLE_ALIGN_MANUAL) - y = (float) g_settings.m_ResInfo[res].iSubtitles - textHeight; + y = (float) CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles - textHeight; else { SPlayerVideoStreamInfo info; @@ -1135,12 +1136,12 @@ void CGUIWindowFullScreen::RenderTTFSubtitles() // use the manual distance to the screenbottom as an offset to the automatic location if ((subalign == SUBTITLE_ALIGN_BOTTOM_INSIDE) || (subalign == SUBTITLE_ALIGN_TOP_OUTSIDE)) - y -= textHeight + g_graphicsContext.GetHeight() - g_settings.m_ResInfo[res].iSubtitles; + y -= textHeight + g_graphicsContext.GetHeight() - CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles; else - y += g_graphicsContext.GetHeight() - g_settings.m_ResInfo[res].iSubtitles; + y += g_graphicsContext.GetHeight() - CDisplaySettings::Get().GetResolutionInfo(res).iSubtitles; - y = std::max(y, (float) g_settings.m_ResInfo[res].Overscan.top); - y = std::min(y, g_settings.m_ResInfo[res].Overscan.bottom - textHeight); + y = std::max(y, (float) CDisplaySettings::Get().GetResolutionInfo(res).Overscan.top); + y = std::min(y, CDisplaySettings::Get().GetResolutionInfo(res).Overscan.bottom - textHeight); } m_subsLayout->RenderOutline(x, y, 0, 0xFF000000, XBFONT_CENTER_X, maxWidth); diff --git a/xbmc/windowing/WinSystem.cpp b/xbmc/windowing/WinSystem.cpp index c02cd78136..34c9265b5a 100644 --- a/xbmc/windowing/WinSystem.cpp +++ b/xbmc/windowing/WinSystem.cpp @@ -19,6 +19,7 @@ */ #include "WinSystem.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" @@ -46,7 +47,7 @@ CWinSystemBase::~CWinSystemBase() bool CWinSystemBase::InitWindowSystem() { UpdateResolutions(); - g_settings.ApplyCalibrations(); + CDisplaySettings::Get().ApplyCalibrations(); return true; } @@ -76,7 +77,7 @@ void CWinSystemBase::UpdateDesktopResolution(RESOLUTION_INFO& newRes, int screen void CWinSystemBase::UpdateResolutions() { // add the window res - defaults are fine. - RESOLUTION_INFO& window = g_settings.m_ResInfo[RES_WINDOW]; + RESOLUTION_INFO& window = CDisplaySettings::Get().GetResolutionInfo(RES_WINDOW); window.bFullScreen = false; if (window.iWidth == 0) window.iWidth = 720; @@ -92,7 +93,7 @@ void CWinSystemBase::UpdateResolutions() void CWinSystemBase::SetWindowResolution(int width, int height) { - RESOLUTION_INFO& window = g_settings.m_ResInfo[RES_WINDOW]; + RESOLUTION_INFO& window = CDisplaySettings::Get().GetResolutionInfo(RES_WINDOW); window.iWidth = width; window.iHeight = height; window.iScreenWidth = width; @@ -104,7 +105,7 @@ void CWinSystemBase::SetWindowResolution(int width, int height) int CWinSystemBase::DesktopResolution(int screen) { for (int idx = 0; idx < GetNumScreens(); idx++) - if (g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen == screen) + if (CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen == screen) return RES_DESKTOP + idx; // Uh? something's wrong, fallback to default res of main screen return RES_DESKTOP; @@ -112,9 +113,9 @@ int CWinSystemBase::DesktopResolution(int screen) static void AddResolution(vector<RESOLUTION_WHR> &resolutions, unsigned int addindex) { - int width = g_settings.m_ResInfo[addindex].iScreenWidth; - int height = g_settings.m_ResInfo[addindex].iScreenHeight; - int interlaced = g_settings.m_ResInfo[addindex].dwFlags & D3DPRESENTFLAG_INTERLACED; + int width = CDisplaySettings::Get().GetResolutionInfo(addindex).iScreenWidth; + int height = CDisplaySettings::Get().GetResolutionInfo(addindex).iScreenHeight; + int interlaced = CDisplaySettings::Get().GetResolutionInfo(addindex).dwFlags & D3DPRESENTFLAG_INTERLACED; for (unsigned int idx = 0; idx < resolutions.size(); idx++) if ( resolutions[idx].width == width @@ -137,8 +138,8 @@ vector<RESOLUTION_WHR> CWinSystemBase::ScreenResolutions(int screen) { vector<RESOLUTION_WHR> resolutions; - for (unsigned int idx = RES_DESKTOP; idx < g_settings.m_ResInfo.size(); idx++) - if (g_settings.m_ResInfo[idx].iScreen == screen) + for (unsigned int idx = RES_DESKTOP; idx < CDisplaySettings::Get().ResolutionInfoSize(); idx++) + if (CDisplaySettings::Get().GetResolutionInfo(idx).iScreen == screen) AddResolution(resolutions, idx); // Can't assume a sort order @@ -149,7 +150,7 @@ vector<RESOLUTION_WHR> CWinSystemBase::ScreenResolutions(int screen) static void AddRefreshRate(vector<REFRESHRATE> &refreshrates, unsigned int addindex) { - float RefreshRate = g_settings.m_ResInfo[addindex].fRefreshRate; + float RefreshRate = CDisplaySettings::Get().GetResolutionInfo(addindex).fRefreshRate; for (unsigned int idx = 0; idx < refreshrates.size(); idx++) if ( refreshrates[idx].RefreshRate == RefreshRate) @@ -168,11 +169,11 @@ vector<REFRESHRATE> CWinSystemBase::RefreshRates(int screen, int width, int heig { vector<REFRESHRATE> refreshrates; - for (unsigned int idx = RES_DESKTOP; idx < g_settings.m_ResInfo.size(); idx++) - if ( g_settings.m_ResInfo[idx].iScreen == screen - && g_settings.m_ResInfo[idx].iScreenWidth == width - && g_settings.m_ResInfo[idx].iScreenHeight == height - && (g_settings.m_ResInfo[idx].dwFlags & D3DPRESENTFLAG_INTERLACED) == (dwFlags & D3DPRESENTFLAG_INTERLACED)) + for (unsigned int idx = RES_DESKTOP; idx < CDisplaySettings::Get().ResolutionInfoSize(); idx++) + if ( CDisplaySettings::Get().GetResolutionInfo(idx).iScreen == screen + && CDisplaySettings::Get().GetResolutionInfo(idx).iScreenWidth == width + && CDisplaySettings::Get().GetResolutionInfo(idx).iScreenHeight == height + && (CDisplaySettings::Get().GetResolutionInfo(idx).dwFlags & D3DPRESENTFLAG_INTERLACED) == (dwFlags & D3DPRESENTFLAG_INTERLACED)) AddRefreshRate(refreshrates, idx); // Can't assume a sort order @@ -185,7 +186,7 @@ REFRESHRATE CWinSystemBase::DefaultRefreshRate(int screen, vector<REFRESHRATE> r { REFRESHRATE bestmatch = rates[0]; float bestfitness = -1.0f; - float targetfps = g_settings.m_ResInfo[DesktopResolution(screen)].fRefreshRate; + float targetfps = CDisplaySettings::Get().GetResolutionInfo(DesktopResolution(screen)).fRefreshRate; for (unsigned i = 0; i < rates.size(); i++) { diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp index 20979c580f..bea3e3eb4c 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -24,6 +24,7 @@ #include <SDL/SDL_syswm.h> #include "WinSystemX11.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "guilib/Texture.h" #include "guilib/DispResource.h" @@ -113,7 +114,7 @@ bool CWinSystemX11::DestroyWindowSystem() bool CWinSystemX11::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { - RESOLUTION_INFO& desktop = g_settings.m_ResInfo[RES_DESKTOP]; + RESOLUTION_INFO& desktop = CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP); if (fullScreen && (res.iWidth != desktop.iWidth || res.iHeight != desktop.iHeight || @@ -232,9 +233,9 @@ void CWinSystemX11::UpdateResolutions() { XOutput out = g_xrandr.GetCurrentOutput(); XMode mode = g_xrandr.GetCurrentMode(out.name); - UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, mode.w, mode.h, mode.hz); - g_settings.m_ResInfo[RES_DESKTOP].strId = mode.id; - g_settings.m_ResInfo[RES_DESKTOP].strOutput = out.name; + UpdateDesktopResolution(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP), 0, mode.w, mode.h, mode.hz); + CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).strId = mode.id; + CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).strOutput = out.name; } else #endif @@ -242,7 +243,7 @@ void CWinSystemX11::UpdateResolutions() int x11screen = DefaultScreen(m_dpy); int w = DisplayWidth(m_dpy, x11screen); int h = DisplayHeight(m_dpy, x11screen); - UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, w, h, 0.0); + UpdateDesktopResolution(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP), 0, w, h, 0.0); } @@ -291,7 +292,7 @@ void CWinSystemX11::UpdateResolutions() res.dwFlags = 0; g_graphicsContext.ResetOverscan(res); - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } } #endif diff --git a/xbmc/windowing/X11/WinSystemX11GLES.cpp b/xbmc/windowing/X11/WinSystemX11GLES.cpp index 64cc6563dd..7975c573c0 100644 --- a/xbmc/windowing/X11/WinSystemX11GLES.cpp +++ b/xbmc/windowing/X11/WinSystemX11GLES.cpp @@ -25,6 +25,7 @@ #include "utils/log.h" #include <SDL/SDL_syswm.h> #include "filesystem/SpecialProtocol.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "guilib/Texture.h" #include "windowing/X11/XRandR.h" @@ -256,16 +257,16 @@ void CWinSystemX11GLES::UpdateResolutions() { XOutput out = g_xrandr.GetCurrentOutput(); XMode mode = g_xrandr.GetCurrentMode(out.name); - UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, mode.w, mode.h, mode.hz); - g_settings.m_ResInfo[RES_DESKTOP].strId = mode.id; - g_settings.m_ResInfo[RES_DESKTOP].strOutput = out.name; + UpdateDesktopResolution(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP), 0, mode.w, mode.h, mode.hz); + CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).strId = mode.id; + CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).strOutput = out.name; } #else { int x11screen = DefaultScreen(m_dpy); int w = DisplayWidth(m_dpy, x11screen); int h = DisplayHeight(m_dpy, x11screen); - UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, w, h, 0.0); + UpdateDesktopResolution(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP), 0, w, h, 0.0); } #endif @@ -313,7 +314,7 @@ void CWinSystemX11GLES::UpdateResolutions() res.dwFlags = 0; g_graphicsContext.ResetOverscan(res); - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } } #endif diff --git a/xbmc/windowing/egl/WinSystemEGL.cpp b/xbmc/windowing/egl/WinSystemEGL.cpp index 9773fc4f7b..5e155a2676 100644 --- a/xbmc/windowing/egl/WinSystemEGL.cpp +++ b/xbmc/windowing/egl/WinSystemEGL.cpp @@ -23,6 +23,7 @@ #include "WinSystemEGL.h" #include "filesystem/SpecialProtocol.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "utils/log.h" @@ -319,15 +320,14 @@ void CWinSystemEGL::UpdateResolutions() { // if this is a new setting, // create a new empty setting to fill in. - if ((int)g_settings.m_ResInfo.size() <= res_index) + if ((int)CDisplaySettings::Get().ResolutionInfoSize() <= res_index) { RESOLUTION_INFO res; - - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } g_graphicsContext.ResetOverscan(resolutions[i]); - g_settings.m_ResInfo[res_index] = resolutions[i]; + CDisplaySettings::Get().GetResolutionInfo(res_index) = resolutions[i]; CLog::Log(LOGNOTICE, "Found resolution %d x %d for display %d with %d x %d%s @ %f Hz\n", resolutions[i].iWidth, @@ -359,9 +359,9 @@ void CWinSystemEGL::UpdateResolutions() resDesktop.fRefreshRate, (int)ResDesktop, (int)RES_DESKTOP); - RESOLUTION_INFO desktop = g_settings.m_ResInfo[RES_DESKTOP]; - g_settings.m_ResInfo[RES_DESKTOP] = g_settings.m_ResInfo[ResDesktop]; - g_settings.m_ResInfo[ResDesktop] = desktop; + RESOLUTION_INFO desktop = CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP); + CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP) = CDisplaySettings::Get().GetResolutionInfo(ResDesktop); + CDisplaySettings::Get().GetResolutionInfo(ResDesktop) = desktop; } } @@ -444,7 +444,7 @@ EGLContext CWinSystemEGL::GetEGLContext() // the logic in this function should match whether CBaseRenderer::FindClosestResolution picks a 3D mode bool CWinSystemEGL::Support3D(int width, int height, uint32_t mode) const { - RESOLUTION_INFO &curr = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()]; + RESOLUTION_INFO &curr = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); // if we are using automatic hdmi mode switching if (g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF) @@ -471,9 +471,9 @@ bool CWinSystemEGL::Support3D(int width, int height, uint32_t mode) const searchHeight /= 2; } // only search the custom resolutions - for (unsigned int i = (int)RES_DESKTOP; i < g_settings.m_ResInfo.size(); i++) + for (unsigned int i = (int)RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); i++) { - RESOLUTION_INFO res = g_settings.m_ResInfo[i]; + RESOLUTION_INFO res = CDisplaySettings::Get().GetResolutionInfo(i); if(res.iScreenWidth == searchWidth && res.iScreenHeight == searchHeight && (res.dwFlags & mode)) return true; } diff --git a/xbmc/windowing/osx/WinSystemIOS.mm b/xbmc/windowing/osx/WinSystemIOS.mm index 8fe2e02115..68bb1fb063 100644 --- a/xbmc/windowing/osx/WinSystemIOS.mm +++ b/xbmc/windowing/osx/WinSystemIOS.mm @@ -30,6 +30,7 @@ #include "WinSystemIOS.h" #include "utils/log.h" #include "filesystem/SpecialProtocol.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "guilib/Texture.h" #include <vector> @@ -208,12 +209,12 @@ void CWinSystemIOS::UpdateResolutions() //first screen goes into the current desktop mode if(GetScreenResolution(&w, &h, &fps, 0)) { - UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, w, h, fps); + UpdateDesktopResolution(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP), 0, w, h, fps); } #ifndef TARGET_DARWIN_IOS_ATV2 //see resolution.h enum RESOLUTION for how the resolutions - //have to appear in the g_settings.m_ResInfo vector + //have to appear in the resolution info vector in CDisplaySettings //add the desktop resolutions of the other screens for(int i = 1; i < GetNumScreens(); i++) { @@ -222,12 +223,12 @@ void CWinSystemIOS::UpdateResolutions() if(GetScreenResolution(&w, &h, &fps, i)) { UpdateDesktopResolution(res, i, w, h, fps); - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } } //now just fill in the possible reolutions for the attached screens - //and push to the m_ResInfo vector + //and push to the resolution info vector FillInVideoModes(); #endif //TARGET_DARWIN_IOS_ATV2 } @@ -268,7 +269,7 @@ void CWinSystemIOS::FillInVideoModes() //the same resolution twice... - thats why i add a FIXME here. res.strMode.Format("%dx%d @ %.2f", w, h, refreshrate); g_graphicsContext.ResetOverscan(res); - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } } } diff --git a/xbmc/windowing/osx/WinSystemOSX.mm b/xbmc/windowing/osx/WinSystemOSX.mm index b18bbcf511..457b1602bf 100644 --- a/xbmc/windowing/osx/WinSystemOSX.mm +++ b/xbmc/windowing/osx/WinSystemOSX.mm @@ -28,6 +28,7 @@ #include "Application.h" #include "guilib/DispResource.h" #include "guilib/GUIWindowManager.h" +#include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" #include "input/KeyboardStat.h" @@ -497,7 +498,7 @@ static void DisplayReconfigured(CGDirectDisplayID display, return; NSScreen* pScreen = nil; - unsigned int screenIdx = g_settings.m_ResInfo[res].iScreen; + unsigned int screenIdx = CDisplaySettings::Get().GetResolutionInfo(res).iScreen; if ( screenIdx < [[NSScreen screens] count] ) { @@ -724,7 +725,7 @@ bool CWinSystemOSX::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool bl { needtoshowme = false; ShowHideNSWindow([last_view window], needtoshowme); - RESOLUTION_INFO& window = g_settings.m_ResInfo[RES_WINDOW]; + RESOLUTION_INFO& window = CDisplaySettings::Get().GetResolutionInfo(RES_WINDOW); CWinSystemOSX::SetFullScreen(false, window, blankOtherDisplays); needtoshowme = true; } @@ -958,10 +959,10 @@ void CWinSystemOSX::UpdateResolutions() // first screen goes into the current desktop mode GetScreenResolution(&w, &h, &fps, 0); - UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, w, h, fps); + UpdateDesktopResolution(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP), 0, w, h, fps); // see resolution.h enum RESOLUTION for how the resolutions - // have to appear in the g_settings.m_ResInfo vector + // have to appear in the resolution info vector in CDisplaySettings // add the desktop resolutions of the other screens for(int i = 1; i < GetNumScreens(); i++) { @@ -969,13 +970,13 @@ void CWinSystemOSX::UpdateResolutions() // get current resolution of screen i GetScreenResolution(&w, &h, &fps, i); UpdateDesktopResolution(res, i, w, h, fps); - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } if (m_can_display_switch) { // now just fill in the possible reolutions for the attached screens - // and push to the m_ResInfo vector + // and push to the resolution info vector FillInVideoModes(); } } @@ -1235,7 +1236,7 @@ void CWinSystemOSX::FillInVideoModes() // the same resolution twice... - thats why i add a FIXME here. res.strMode.Format("%dx%d @ %.2f", w, h, refreshrate); g_graphicsContext.ResetOverscan(res); - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } } } diff --git a/xbmc/windowing/windows/WinSystemWin32.cpp b/xbmc/windowing/windows/WinSystemWin32.cpp index 2b76b6d287..b3656433dc 100644 --- a/xbmc/windowing/windows/WinSystemWin32.cpp +++ b/xbmc/windowing/windows/WinSystemWin32.cpp @@ -22,6 +22,7 @@ #include "WinEventsWin32.h" #include "settings/Settings.h" #include "resource.h" +#include "settings/DisplaySettings.h" #include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "utils/log.h" @@ -213,7 +214,7 @@ bool CWinSystemWin32::BlankNonActiveMonitors(bool bBlank) bool CWinSystemWin32::CenterWindow() { - RESOLUTION_INFO DesktopRes = g_settings.m_ResInfo[RES_DESKTOP]; + RESOLUTION_INFO DesktopRes = CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP); m_nLeft = (DesktopRes.iWidth / 2) - (m_nWidth / 2); m_nTop = (DesktopRes.iHeight / 2) - (m_nHeight / 2); @@ -300,13 +301,13 @@ void CWinSystemWin32::RestoreDesktopResolution(int screen) int resIdx = RES_DESKTOP; for (int idx = RES_DESKTOP; idx < RES_DESKTOP + GetNumScreens(); idx++) { - if (g_settings.m_ResInfo[idx].iScreen == screen) + if (CDisplaySettings::Get().GetResolutionInfo(idx).iScreen == screen) { resIdx = idx; break; } } - ChangeResolution(g_settings.m_ResInfo[resIdx]); + ChangeResolution(CDisplaySettings::Get().GetResolutionInfo(resIdx)); } const MONITOR_DETAILS &CWinSystemWin32::GetMonitor(int screen) const @@ -476,8 +477,8 @@ void CWinSystemWin32::UpdateResolutions() refreshRate = (float)m_MonitorsInfo[m_nPrimary].RefreshRate; dwFlags = m_MonitorsInfo[m_nPrimary].Interlaced ? D3DPRESENTFLAG_INTERLACED : 0; - UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, w, h, refreshRate, dwFlags); - CLog::Log(LOGNOTICE, "Primary mode: %s", g_settings.m_ResInfo[RES_DESKTOP].strMode.c_str()); + UpdateDesktopResolution(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP), 0, w, h, refreshRate, dwFlags); + CLog::Log(LOGNOTICE, "Primary mode: %s", CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).strMode.c_str()); // Desktop resolution of the other screens if(m_MonitorsInfo.size() >= 2) @@ -499,7 +500,7 @@ void CWinSystemWin32::UpdateResolutions() RESOLUTION_INFO res; UpdateDesktopResolution(res, xbmcmonitor++, w, h, refreshRate, dwFlags); - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); CLog::Log(LOGNOTICE, "Secondary mode: %s", res.strMode.c_str()); } } @@ -535,17 +536,19 @@ void CWinSystemWin32::UpdateResolutions() void CWinSystemWin32::AddResolution(const RESOLUTION_INFO &res) { - for (unsigned int i = 0; i < g_settings.m_ResInfo.size(); i++) - if (g_settings.m_ResInfo[i].iScreen == res.iScreen && - g_settings.m_ResInfo[i].iWidth == res.iWidth && - g_settings.m_ResInfo[i].iHeight == res.iHeight && - g_settings.m_ResInfo[i].iScreenWidth == res.iScreenWidth && - g_settings.m_ResInfo[i].iScreenHeight== res.iScreenHeight && - g_settings.m_ResInfo[i].fRefreshRate == res.fRefreshRate && - g_settings.m_ResInfo[i].dwFlags == res.dwFlags) + for (unsigned int i = 0; i < CDisplaySettings::Get().ResolutionInfoSize(); i++) + { + if (CDisplaySettings::Get().GetResolutionInfo(i).iScreen == res.iScreen && + CDisplaySettings::Get().GetResolutionInfo(i).iWidth == res.iWidth && + CDisplaySettings::Get().GetResolutionInfo(i).iHeight == res.iHeight && + CDisplaySettings::Get().GetResolutionInfo(i).iScreenWidth == res.iScreenWidth && + CDisplaySettings::Get().GetResolutionInfo(i).iScreenHeight== res.iScreenHeight && + CDisplaySettings::Get().GetResolutionInfo(i).fRefreshRate == res.fRefreshRate && + CDisplaySettings::Get().GetResolutionInfo(i).dwFlags == res.dwFlags) return; // already have this resolution + } - g_settings.m_ResInfo.push_back(res); + CDisplaySettings::Get().AddResolutionInfo(res); } bool CWinSystemWin32::UpdateResolutionsInternal() |