From 2d7c97f3c2a1f2eb5c2a0a6282f3368f5eddfddf Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sun, 20 Sep 2015 13:19:31 +0200 Subject: [PATCH] resolutions, squash me --- .../VideoRenderers/BaseRenderer.cpp | 32 ++----------------- .../VideoPlayer/VideoRenderers/BaseRenderer.h | 22 ++++++------- .../VideoRenderers/LinuxRendererGL.cpp | 4 --- .../VideoRenderers/RenderManager.cpp | 17 +++++++--- xbmc/guilib/GraphicContext.cpp | 6 ++-- xbmc/guilib/GraphicContext.h | 2 +- xbmc/guilib/Resolution.cpp | 2 +- 7 files changed, 29 insertions(+), 56 deletions(-) diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp index d9f465d0e0865..169b0461aa9a6 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp @@ -41,7 +41,6 @@ CBaseRenderer::CBaseRenderer() m_sourceFrameRatio = 1.0f; m_sourceWidth = 720; m_sourceHeight = 480; - m_resolution = RES_DESKTOP; m_fps = 0.0f; m_renderOrientation = 0; m_oldRenderOrientation = 0; @@ -78,31 +77,6 @@ void CBaseRenderer::RegisterRenderFeaturesCallBack(const void *ctx, RenderFeatur m_RenderFeaturesCallBackCtx = ctx; } -void CBaseRenderer::ChooseBestResolution(float fps) -{ - if (fps == 0.0) - return; - - // Adjust refreshrate to match source fps -#if !defined(TARGET_DARWIN_IOS) - if (CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ADJUSTREFRESHRATE) != ADJUST_REFRESHRATE_OFF) - { - m_resolution = CResolutionUtils::ChooseBestResolution(fps, m_sourceWidth, CONF_FLAGS_STEREO_MODE_MASK(m_iFlags)); - } - else -#endif - CLog::Log(LOGNOTICE, "Display resolution %s : %s (%d)", - m_resolution == RES_DESKTOP ? "DESKTOP" : "USER", g_graphicsContext.GetResInfo(m_resolution).strMode.c_str(), m_resolution); -} - -RESOLUTION CBaseRenderer::GetResolution() const -{ - if (g_graphicsContext.IsFullScreenRoot() && (g_graphicsContext.IsFullScreenVideo() || g_graphicsContext.IsCalibrating())) - return m_resolution; - - return g_graphicsContext.GetVideoResolution(); -} - float CBaseRenderer::GetAspectRatio() const { float width = (float)m_sourceWidth; @@ -224,7 +198,7 @@ void CBaseRenderer::CalcNormalDisplayRect(float offsetX, float offsetY, float sc // calculate the correct output frame ratio (using the users pixel ratio setting // and the output pixel ratio setting) - float outputFrameRatio = inputFrameRatio / g_graphicsContext.GetResInfo(GetResolution()).fPixelRatio; + float outputFrameRatio = inputFrameRatio / g_graphicsContext.GetResInfo().fPixelRatio; // allow a certain error to maximize screen size float fCorrection = screenWidth / screenHeight / outputFrameRatio - 1.0f; @@ -430,8 +404,8 @@ void CBaseRenderer::SetViewMode(int viewMode) CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode = viewMode; // get our calibrated full screen resolution - RESOLUTION res = GetResolution(); - RESOLUTION_INFO info = g_graphicsContext.GetResInfo(m_resolution); + RESOLUTION res = g_graphicsContext.GetVideoResolution(); + RESOLUTION_INFO info = g_graphicsContext.GetResInfo(); float screenWidth = (float)(info.Overscan.right - info.Overscan.left); float screenHeight = (float)(info.Overscan.bottom - info.Overscan.top); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h index 4381f636510ab..d547f539bbb4b 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h @@ -112,7 +112,6 @@ class CBaseRenderer ERenderFormat GetRenderFormat() { return m_format; } void SetViewMode(int viewMode); - RESOLUTION GetResolution() const; /*! \brief Get video rectangle and view window \param source is original size of the video @@ -128,18 +127,15 @@ class CBaseRenderer static void SettingOptionsRenderMethodsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t, void *data); protected: - void ChooseBestResolution(float fps); - void CalcNormalDisplayRect(float offsetX, float offsetY, float screenWidth, float screenHeight, float inputFrameRatio, float zoomAmount, float verticalShift); - void CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height); - void ManageDisplay(); - - virtual void ReorderDrawPoints();//might be overwritten (by egl e.x.) - void saveRotatedCoords();//saves the current state of m_rotatedDestCoords - void syncDestRectToRotatedPoints();//sync any changes of m_destRect to m_rotatedDestCoords - void restoreRotatedCoords();//restore the current state of m_rotatedDestCoords from saveRotatedCoords - void MarkDirty(); - - RESOLUTION m_resolution; // the resolution we're running in + void CalcNormalDisplayRect(float offsetX, float offsetY, float screenWidth, float screenHeight, float inputFrameRatio, float zoomAmount, float verticalShift); + void CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height); + void ManageDisplay(); + virtual void ReorderDrawPoints();//might be overwritten (by egl e.x.) + void saveRotatedCoords();//saves the current state of m_rotatedDestCoords + void syncDestRectToRotatedPoints();//sync any changes of m_destRect to m_rotatedDestCoords + void restoreRotatedCoords();//restore the current state of m_rotatedDestCoords from saveRotatedCoords + void MarkDirty(); + unsigned int m_sourceWidth; unsigned int m_sourceHeight; float m_sourceFrameRatio; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp index 1df43eadaea17..f8af95568a970 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp @@ -259,7 +259,6 @@ bool CLinuxRendererGL::Configure(unsigned int width, unsigned int height, unsign // Calculate the input frame aspect ratio. CalculateFrameAspectRatio(d_width, d_height); - ChooseBestResolution(fps); SetViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); @@ -681,9 +680,6 @@ void CLinuxRendererGL::PreInit() m_bConfigured = false; m_bValidated = false; UnInit(); - m_resolution = CDisplaySettings::GetInstance().GetCurrentResolution(); - if ( m_resolution == RES_WINDOW ) - m_resolution = RES_DESKTOP; m_iYV12RenderBuffer = 0; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp index fd8f5191f17aa..a2a6b4e2ab089 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp @@ -957,11 +957,20 @@ void CRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, RESOLUTION CRenderManager::GetResolution() { + RESOLUTION res = g_graphicsContext.GetVideoResolution(); + CSharedLock lock(m_sharedSection); - if (m_pRenderer) - return m_pRenderer->GetResolution(); - else - return RES_INVALID; + if (m_renderState == STATE_UNCONFIGURED) + return res; + +#if defined(TARGET_DARWIN_IOS) + return res; +#endif + + if (CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ADJUSTREFRESHRATE) != ADJUST_REFRESHRATE_OFF) + res = CResolutionUtils::ChooseBestResolution(m_fps, m_width, CONF_FLAGS_STEREO_MODE_MASK(m_flags)); + + return res; } float CRenderManager::GetMaximumFPS() diff --git a/xbmc/guilib/GraphicContext.cpp b/xbmc/guilib/GraphicContext.cpp index 3182594d4d56d..1a0157664dcf1 100644 --- a/xbmc/guilib/GraphicContext.cpp +++ b/xbmc/guilib/GraphicContext.cpp @@ -327,20 +327,18 @@ void CGraphicContext::SetFullScreenVideo(bool bOnOff) Lock(); m_bFullScreenVideo = bOnOff; -#if defined(HAS_VIDEO_PLAYBACK) if(m_bFullScreenRoot) { bool allowDesktopRes = CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ADJUSTREFRESHRATE) == ADJUST_REFRESHRATE_ALWAYS; - if(m_bFullScreenVideo || (!allowDesktopRes && g_application.m_pPlayer->IsPlayingVideo())) + if (m_bFullScreenVideo || (!allowDesktopRes && g_application.m_pPlayer->IsPlayingVideo())) SetVideoResolution(g_application.m_pPlayer->GetRenderResolution()); - else if(CDisplaySettings::GetInstance().GetCurrentResolution() > RES_DESKTOP) + else if (CDisplaySettings::GetInstance().GetCurrentResolution() > RES_DESKTOP) SetVideoResolution(CDisplaySettings::GetInstance().GetCurrentResolution()); else SetVideoResolution(RES_DESKTOP); } else SetVideoResolution(RES_WINDOW); -#endif Unlock(); } diff --git a/xbmc/guilib/GraphicContext.h b/xbmc/guilib/GraphicContext.h index bafd60a0a5339..b9e0db5dfca3e 100644 --- a/xbmc/guilib/GraphicContext.h +++ b/xbmc/guilib/GraphicContext.h @@ -66,7 +66,7 @@ enum VIEW_TYPE { VIEW_TYPE_NONE = 0, enum AdjustRefreshRate { - ADJUST_REFRESHRATE_OFF = 0, + ADJUST_REFRESHRATE_OFF = 0, ADJUST_REFRESHRATE_ALWAYS, ADJUST_REFRESHRATE_ON_STARTSTOP }; diff --git a/xbmc/guilib/Resolution.cpp b/xbmc/guilib/Resolution.cpp index b9f8ab550547f..b0554c22d1c93 100644 --- a/xbmc/guilib/Resolution.cpp +++ b/xbmc/guilib/Resolution.cpp @@ -61,7 +61,7 @@ float RESOLUTION_INFO::DisplayRatio() const RESOLUTION CResolutionUtils::ChooseBestResolution(float fps, int width, bool is3D) { - RESOLUTION res; + RESOLUTION res = g_graphicsContext.GetVideoResolution(); float weight; if (!FindResolutionFromOverride(fps, width, is3D, res, weight, false)) //find a refreshrate from overrides {