Skip to content

Commit

Permalink
resolutions, squash me
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Sep 20, 2015
1 parent 10191e4 commit 2d7c97f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 56 deletions.
32 changes: 3 additions & 29 deletions xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
22 changes: 9 additions & 13 deletions xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h
Expand Up @@ -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
Expand All @@ -128,18 +127,15 @@ class CBaseRenderer
static void SettingOptionsRenderMethodsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current, 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;
Expand Down
4 changes: 0 additions & 4 deletions xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp
Expand Up @@ -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();

Expand Down Expand Up @@ -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;

Expand Down
17 changes: 13 additions & 4 deletions xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp
Expand Up @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions xbmc/guilib/GraphicContext.cpp
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/GraphicContext.h
Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/Resolution.cpp
Expand Up @@ -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
{
Expand Down

0 comments on commit 2d7c97f

Please sign in to comment.