Skip to content

Commit

Permalink
cleanup resolutions, drop resoltion info < RES_WINDOW
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Aug 7, 2018
1 parent ed7ecfd commit 7576b56
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 274 deletions.
28 changes: 2 additions & 26 deletions xbmc/addons/interfaces/GUI/AddonCallbacksGUI.cpp
Expand Up @@ -536,32 +536,8 @@ int CAddonCallbacksGUI::Window_GetFocusId(void *addonData, GUIHANDLE handle)

bool CAddonCallbacksGUI::Window_SetCoordinateResolution(void *addonData, GUIHANDLE handle, int res)
{
CAddonInterfaces* helper = (CAddonInterfaces*) addonData;
if (!helper)
return false;

CAddonCallbacksGUI* guiHelper = static_cast<CAddonCallbacksGUI*>(helper->GUILib_GetHelper());

if (!handle)
{
CLog::Log(LOGERROR, "SetCoordinateResolution: %s/%s - No Window", CAddonInfo::TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
return false;
}

if (res < RES_HDTV_1080i || res > RES_AUTORES)
{
CLog::Log(LOGERROR, "SetCoordinateResolution: %s/%s - Invalid resolution", CAddonInfo::TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
return false;
}

CGUIAddonWindow *pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
CGUIWindow *pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(pAddonWindow->m_iWindowId);
if (!pWindow)
return false;

pWindow->SetCoordsRes((RESOLUTION)res);

return true;
CLog::Log(LOGERROR, "SetCoordinateResolution: not implemented");
return false;
}

void CAddonCallbacksGUI::Window_SetProperty(void *addonData, GUIHANDLE handle, const char *key, const char *value)
Expand Down
28 changes: 6 additions & 22 deletions xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp
Expand Up @@ -433,7 +433,6 @@ void CBaseRenderer::SetViewMode(int viewMode)
m_videoSettings.m_ViewMode = viewMode;

// get our calibrated full screen resolution
RESOLUTION res = CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution();
RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo();
float screenWidth = (float)(info.Overscan.right - info.Overscan.left);
float screenHeight = (float)(info.Overscan.bottom - info.Overscan.top);
Expand Down Expand Up @@ -474,17 +473,9 @@ void CBaseRenderer::SetViewMode(int viewMode)
else if (m_videoSettings.m_ViewMode == ViewModeStretch4x3)
{ // stretch image to 4:3 ratio
CDisplaySettings::GetInstance().SetZoomAmount(1.0);
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...
CDisplaySettings::GetInstance().SetPixelRatio((screenWidth / screenHeight) * info.fPixelRatio / sourceFrameRatio);
}
else
{
// now we need to set CDisplaySettings::GetInstance().GetPixelRatio() so that
// fOutputFrameRatio = 4:3.
CDisplaySettings::GetInstance().SetPixelRatio((4.0f / 3.0f) / sourceFrameRatio);
}
// now we need to set CDisplaySettings::GetInstance().GetPixelRatio() so that
// fOutputFrameRatio = 4:3.
CDisplaySettings::GetInstance().SetPixelRatio((4.0f / 3.0f) / sourceFrameRatio);
}
else if (m_videoSettings.m_ViewMode == ViewModeWideZoom ||
(is43 && CServiceBroker::GetSettings().GetInt(CSettings::SETTING_VIDEOPLAYER_STRETCH43) == ViewModeWideZoom))
Expand All @@ -500,16 +491,9 @@ void CBaseRenderer::SetViewMode(int viewMode)
CServiceBroker::GetSettings().GetInt(CSettings::SETTING_VIDEOPLAYER_STRETCH43) == ViewModeStretch16x9Nonlin)))
{ // stretch image to 16:9 ratio
CDisplaySettings::GetInstance().SetZoomAmount(1.0);
if (res == RES_PAL_4x3 || res == RES_PAL60_4x3 || res == RES_NTSC_4x3 || res == RES_HDTV_480p_4x3)
{ // now we need to set CDisplaySettings::GetInstance().GetPixelRatio() so that
// outputFrameRatio = 16:9.
CDisplaySettings::GetInstance().SetPixelRatio((16.0f / 9.0f) / sourceFrameRatio);
}
else
{ // stretch to the limits of the 16:9 screen.
// incorrect behaviour, but it's what the users want, so...
CDisplaySettings::GetInstance().SetPixelRatio((screenWidth / screenHeight) * info.fPixelRatio / sourceFrameRatio);
}
// stretch to the limits of the 16:9 screen.
// incorrect behaviour, but it's what the users want, so...
CDisplaySettings::GetInstance().SetPixelRatio((screenWidth / screenHeight) * info.fPixelRatio / sourceFrameRatio);
bool nonlin = (is43 && CServiceBroker::GetSettings().GetInt(CSettings::SETTING_VIDEOPLAYER_STRETCH43) == ViewModeStretch16x9Nonlin) ||
m_videoSettings.m_ViewMode == ViewModeStretch16x9Nonlin;
CDisplaySettings::GetInstance().SetNonLinearStretched(nonlin);
Expand Down
29 changes: 0 additions & 29 deletions xbmc/interfaces/builtins/GUIBuiltins.cpp
Expand Up @@ -333,34 +333,6 @@ static int SetLanguage(const std::vector<std::string>& params)
return 0;
}

/*! \brief Set GUI resolution.
* \param params The parameters.
* \details params[0] = A resolution identifier.
*/
static int SetResolution(const std::vector<std::string>& params)
{
RESOLUTION res = RES_PAL_4x3;
std::string paramlow(params[0]);
StringUtils::ToLower(paramlow);
if (paramlow == "pal") res = RES_PAL_4x3;
else if (paramlow == "pal16x9") res = RES_PAL_16x9;
else if (paramlow == "ntsc") res = RES_NTSC_4x3;
else if (paramlow == "ntsc16x9") res = RES_NTSC_16x9;
else if (paramlow == "720p") res = RES_HDTV_720p;
else if (paramlow == "720psbs") res = RES_HDTV_720pSBS;
else if (paramlow == "720ptb") res = RES_HDTV_720pTB;
else if (paramlow == "1080psbs") res = RES_HDTV_1080pSBS;
else if (paramlow == "1080ptb") res = RES_HDTV_1080pTB;
else if (paramlow == "1080i") res = RES_HDTV_1080i;
if (CServiceBroker::GetWinSystem()->GetGfxContext().IsValidResolution(res))
{
CDisplaySettings::GetInstance().SetCurrentResolution(res, true);
g_application.ReloadSkin();
}

return 0;
}

/*! \brief Set a property in a window.
* \param params The parameters.
* \details params[0] = The property to set.
Expand Down Expand Up @@ -589,7 +561,6 @@ CBuiltins::CommandMap CGUIBuiltins::GetOperations() const
{"refreshrss", {"Reload RSS feeds from RSSFeeds.xml", 0, RefreshRSS}},
{"replacewindow", {"Replaces the current window with the new one", 1, ActivateWindow<true>}},
{"replacewindowandfocus", {"Replaces the current window with the new one and sets focus to the specified id", 1, ActivateAndFocus<true>}},
{"resolution", {"Change Kodi's Resolution", 1, SetResolution}},
{"setguilanguage", {"Set GUI Language", 1, SetLanguage}},
{"setproperty", {"Sets a window property for the current focused window/dialog (key,value)", 2, SetProperty}},
{"setstereomode", {"Changes the stereo mode of the GUI. Params can be: toggle, next, previous, select, tomono or any of the supported stereomodes (off, split_vertical, split_horizontal, row_interleaved, hardware_based, anaglyph_cyan_red, anaglyph_green_magenta, anaglyph_yellow_blue, monoscopic)", 1, SetStereoMode}},
Expand Down
6 changes: 1 addition & 5 deletions xbmc/interfaces/legacy/Window.cpp
Expand Up @@ -605,11 +605,7 @@ namespace XBMCAddon
void Window::setCoordinateResolution(long res)
{
XBMC_TRACE;
if (res < RES_HDTV_1080i || res > RES_AUTORES)
throw WindowException("Invalid resolution.");

SingleLockWithDelayGuard gslock(CServiceBroker::GetWinSystem()->GetGfxContext(),languageHook);
ref(window)->SetCoordsRes(CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo((RESOLUTION)res));
throw WindowException("not implemented.");
}

void Window::setProperty(const char* key, const String& value)
Expand Down
171 changes: 6 additions & 165 deletions xbmc/windowing/GraphicContext.cpp
Expand Up @@ -387,7 +387,7 @@ void CGraphicContext::SetVideoResolutionInternal(RESOLUTION res, bool forceUpdat
RESOLUTION lastRes = m_Resolution;

// If the user asked us to guess, go with desktop
if (res == RES_AUTORES || !IsValidResolution(res))
if (!IsValidResolution(res))
{
res = RES_DESKTOP;
}
Expand Down Expand Up @@ -549,181 +549,26 @@ void CGraphicContext::ResetOverscan(RESOLUTION res, OVERSCAN &overscan)
{
overscan.left = 0;
overscan.top = 0;
switch (res)
{
case RES_HDTV_1080i:
overscan.right = 1920;
overscan.bottom = 1080;
break;
case RES_HDTV_720pSBS:
overscan.right = 640;
overscan.bottom = 720;
break;
case RES_HDTV_720pTB:
overscan.right = 1280;
overscan.bottom = 360;
break;
case RES_HDTV_1080pSBS:
overscan.right = 960;
overscan.bottom = 1080;
break;
case RES_HDTV_1080pTB:
overscan.right = 1920;
overscan.bottom = 540;
break;
case RES_HDTV_720p:
overscan.right = 1280;
overscan.bottom = 720;
break;
case RES_HDTV_480p_16x9:
case RES_HDTV_480p_4x3:
case RES_NTSC_16x9:
case RES_NTSC_4x3:
case RES_PAL60_16x9:
case RES_PAL60_4x3:
overscan.right = 720;
overscan.bottom = 480;
break;
case RES_PAL_16x9:
case RES_PAL_4x3:
overscan.right = 720;
overscan.bottom = 576;
break;
default:
RESOLUTION_INFO info = GetResInfo(res);
overscan.right = info.iWidth;
overscan.bottom = info.iHeight;
break;
}

RESOLUTION_INFO info = GetResInfo(res);
overscan.right = info.iWidth;
overscan.bottom = info.iHeight;
}

void CGraphicContext::ResetScreenParameters(RESOLUTION res)
{
// For now these are all on the first screen.
RESOLUTION_INFO& info = CDisplaySettings::GetInstance().GetResolutionInfo(res);

// 1080i
switch (res)
{
case RES_HDTV_1080i:
info.iSubtitles = (int)(0.965 * 1080);
info.iWidth = 1920;
info.iHeight = 1080;
info.dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
info.fPixelRatio = 1.0f;
info.strMode ="1080i 16:9";
break;
case RES_HDTV_720pSBS:
info.iSubtitles = (int)(0.965 * 720);
info.iWidth = 640;
info.iHeight = 720;
info.dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS;
info.fPixelRatio = 2.0f;
info.strMode = "720pSBS 16:9";
break;
case RES_HDTV_720pTB:
info.iSubtitles = (int)(0.965 * 720);
info.iWidth = 1280;
info.iHeight = 720;
info.dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB;
info.fPixelRatio = 0.5f;
info.strMode = "720pTB 16:9";
break;
case RES_HDTV_1080pSBS:
info.iSubtitles = (int)(0.965 * 1080);
info.iWidth = 1920;
info.iHeight = 1080;
info.dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS;
info.fPixelRatio = 2.0f;
info.strMode = "1080pSBS 16:9";
break;
case RES_HDTV_1080pTB:
info.iSubtitles = (int)(0.965 * 1080);
info.iWidth = 1920;
info.iHeight = 1080;
info.dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB;
info.fPixelRatio = 0.5f;
info.strMode = "1080pTB 16:9";
break;
case RES_HDTV_720p:
info.iSubtitles = (int)(0.965 * 720);
info.iWidth = 1280;
info.iHeight = 720;
info.dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN;
info.fPixelRatio = 1.0f;
info.strMode = "720p 16:9";
break;
case RES_HDTV_480p_4x3:
info.iSubtitles = (int)(0.9 * 480);
info.iWidth = 720;
info.iHeight = 480;
info.dwFlags = D3DPRESENTFLAG_PROGRESSIVE;
info.fPixelRatio = 4320.0f / 4739.0f;
info.strMode = "480p 4:3";
break;
case RES_HDTV_480p_16x9:
info.iSubtitles = (int)(0.965 * 480);
info.iWidth = 720;
info.iHeight = 480;
info.dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN;
info.fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f;
info.strMode = "480p 16:9";
break;
case RES_NTSC_4x3:
info.iSubtitles = (int)(0.9 * 480);
info.iWidth = 720;
info.iHeight = 480;
info.dwFlags = D3DPRESENTFLAG_INTERLACED;
info.fPixelRatio = 4320.0f / 4739.0f;
info.strMode = "NTSC 4:3";
break;
case RES_NTSC_16x9:
info.iSubtitles = (int)(0.965 * 480);
info.iWidth = 720;
info.iHeight = 480;
info.dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
info.fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f;
info.strMode = "NTSC 16:9";
break;
case RES_PAL_4x3:
info.iSubtitles = (int)(0.9 * 576);
info.iWidth = 720;
info.iHeight = 576;
info.dwFlags = D3DPRESENTFLAG_INTERLACED;
info.fPixelRatio = 128.0f / 117.0f;
info.strMode = "PAL 4:3";
break;
case RES_PAL_16x9:
info.iSubtitles = (int)(0.965 * 576);
info.iWidth = 720;
info.iHeight = 576;
info.dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
info.fPixelRatio = 128.0f / 117.0f*4.0f / 3.0f;
info.strMode = "PAL 16:9";
break;
case RES_PAL60_4x3:
info.iSubtitles = (int)(0.9 * 480);
info.iWidth = 720;
info.iHeight = 480;
info.dwFlags = D3DPRESENTFLAG_INTERLACED;
info.fPixelRatio = 4320.0f / 4739.0f;
info.strMode = "PAL60 4:3";
break;
case RES_PAL60_16x9:
info.iSubtitles = (int)(0.965 * 480);
info.iWidth = 720;
info.iHeight = 480;
info.dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
info.fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f;
info.strMode = "PAL60 16:9";
break;
case RES_WINDOW:
info.iSubtitles = (int)(0.965 * info.iHeight);
info.fPixelRatio = 1.0;
break;
default:
break;
}

info.iScreenWidth = info.iWidth;
info.iScreenHeight = info.iHeight;
ResetOverscan(res, info.Overscan);
Expand Down Expand Up @@ -1075,10 +920,6 @@ float CGraphicContext::GetFPS() const
RESOLUTION_INFO info = GetResInfo();
if (info.fRefreshRate > 0)
return info.fRefreshRate;
if (m_Resolution == RES_PAL_4x3 || m_Resolution == RES_PAL_16x9)
return 50.0f;
if (m_Resolution == RES_HDTV_1080i)
return 30.0f;
}
return 60.0f;
}
Expand Down
26 changes: 4 additions & 22 deletions xbmc/windowing/Resolution.h
Expand Up @@ -15,30 +15,12 @@ typedef int DisplayMode;
#define DM_WINDOWED -1
#define DM_FULLSCREEN 0

enum RESOLUTION {
enum RESOLUTION
{
RES_INVALID = -1,
RES_HDTV_1080i = 0,
RES_HDTV_720pSBS = 1,
RES_HDTV_720pTB = 2,
RES_HDTV_1080pSBS = 3,
RES_HDTV_1080pTB = 4,
RES_HDTV_720p = 5,
RES_HDTV_480p_4x3 = 6,
RES_HDTV_480p_16x9 = 7,
RES_NTSC_4x3 = 8,
RES_NTSC_16x9 = 9,
RES_PAL_4x3 = 10,
RES_PAL_16x9 = 11,
RES_PAL60_4x3 = 12,
RES_PAL60_16x9 = 13,
RES_AUTORES = 14,
RES_WINDOW = 15,
RES_DESKTOP = 16, // Desktop resolution for primary screen
RES_CUSTOM = 16 + 1, // Desktop resolution for screen #2
// ...
// 12 + N - 1 // Desktop resolution for screen N
// 12 + N // First additional resolution, in a N screen configuration.
// 12 + N + ... // Other resolutions, in any order
RES_DESKTOP = 16, // Desktop resolution
RES_CUSTOM = 16 + 1, // First additional resolution
};

struct OVERSCAN
Expand Down
5 changes: 0 additions & 5 deletions xbmc/windowing/WinSystem.cpp
Expand Up @@ -22,11 +22,6 @@
CWinSystemBase::CWinSystemBase()
{
m_gfxContext.reset(new CGraphicContext());
for (int i = RES_HDTV_1080i; i <= RES_PAL60_16x9; i++)
{
m_gfxContext->ResetScreenParameters((RESOLUTION)i);
m_gfxContext->ResetOverscan((RESOLUTION)i, CDisplaySettings::GetInstance().GetResolutionInfo(i).Overscan);
}
}

CWinSystemBase::~CWinSystemBase() = default;
Expand Down

0 comments on commit 7576b56

Please sign in to comment.