#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"
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
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());
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;
// 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;
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());
#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"
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;
}
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());
*
*/
#include "ScreenSaver.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "windowing/WindowingFactory.h"
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());
#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"
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());
#include <algorithm>
#include "BaseRenderer.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "settings/GUISettings.h"
#include "settings/MediaSettings.h"
}
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)
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
}
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;
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
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;
}
// 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;
// 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;
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;
{ // 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;
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
{
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;
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)
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;
(*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();
#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"
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;
#include "WinRenderer.h"
#include "Util.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "settings/GUISettings.h"
#include "settings/MediaSettings.h"
// 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();
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;
// 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)
{
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;
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;
}
}
// 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)
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;
#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"
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;
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;
}
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;
{
#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);
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;
}
}
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;
}
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)
{
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
// 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;
// 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);
{
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)
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);
}
#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"
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)
#include "system.h"
#include "filesystem/File.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "guilib/Texture.h"
#include "guilib/GUITexture.h"
// 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);
}
#include <math.h>
#include "utils/CharsetConverter.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "settings/GUISettings.h"
#include "guilib/GUITextLayout.h"
// 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 )
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);
// 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;
#include "DllSwScale.h"
#include "filesystem/SpecialProtocol.h"
#include "settings/AdvancedSettings.h"
+#include "settings/DisplaySettings.h"
#include "video/FFmpegVideoDecoder.h"
#include "system.h"
// 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;
#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"
//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);
}
}
#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"
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);
{ // 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;
{ // 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);
#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"
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)
{
// 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];
#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"
{
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();
{
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();
--- /dev/null
+/*
+ * 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]);
+ }
+}
--- /dev/null
+#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;
+};
#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"
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);
// 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) +
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");
SRCS=AdvancedSettings.cpp \
+ DisplaySettings.cpp \
GUISettings.cpp \
MediaSettings.cpp \
MediaSourceSettings.cpp \
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.
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
GetFloat(pElement, "fvolumelevel", m_fVolumeLevel, VOLUME_MAXIMUM, VOLUME_MINIMUM, VOLUME_MAXIMUM);
}
- LoadCalibration(pRootElement, strSettingsFile);
g_guiSettings.LoadXML(pRootElement);
// load any ISubSettings implementations
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
m_defaultMusicLibSource.clear();
- m_ResInfo.clear();
- m_Calibrations.clear();
-
OnSettingsCleared();
for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++)
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
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;
#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)
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.
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);
(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
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;
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);
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);
#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"
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);
{
case GUI_MSG_WINDOW_DEINIT:
{
- g_settings.UpdateCalibrations();
+ CDisplaySettings::Get().UpdateCalibrations();
g_settings.Save();
g_graphicsContext.SetCalibrating(false);
g_windowManager.ShowOverlay(OVERLAY_STATE_SHOWN);
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);
{
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);
}
}
{
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);
}
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);
}
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);
}
// 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);
*/
#include "GUIWindowTestPattern.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/Key.h"
{
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)
{
#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"
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))
{
}
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))
{
}
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++;
{
// 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),
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);
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;
// 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);
*/
#include "WinSystem.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "settings/GUISettings.h"
bool CWinSystemBase::InitWindowSystem()
{
UpdateResolutions();
- g_settings.ApplyCalibrations();
+ CDisplaySettings::Get().ApplyCalibrations();
return true;
}
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;
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;
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;
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
{
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
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)
{
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
{
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++)
{
#include <SDL/SDL_syswm.h>
#include "WinSystemX11.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "guilib/Texture.h"
#include "guilib/DispResource.h"
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 ||
{
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
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);
}
res.dwFlags = 0;
g_graphicsContext.ResetOverscan(res);
- g_settings.m_ResInfo.push_back(res);
+ CDisplaySettings::Get().AddResolutionInfo(res);
}
}
#endif
#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"
{
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
res.dwFlags = 0;
g_graphicsContext.ResetOverscan(res);
- g_settings.m_ResInfo.push_back(res);
+ CDisplaySettings::Get().AddResolutionInfo(res);
}
}
#endif
#include "WinSystemEGL.h"
#include "filesystem/SpecialProtocol.h"
+#include "settings/DisplaySettings.h"
#include "settings/Settings.h"
#include "settings/GUISettings.h"
#include "utils/log.h"
{
// 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,
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;
}
}
// 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)
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;
}
#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>
//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++)
{
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
}
//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);
}
}
}
#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"
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] )
{
{
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;
}
// 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++)
{
// 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();
}
}
// 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);
}
}
}
#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"
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);
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
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)
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());
}
}
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()