Skip to content

Commit

Permalink
Merge pull request #14496 from garbear/stretch-mode
Browse files Browse the repository at this point in the history
Game OSD: Finish renaming "View mode" to "Stretch mode"
  • Loading branch information
garbear committed Oct 2, 2018
2 parents 8f3aeab + b90301d commit 65f5fbb
Show file tree
Hide file tree
Showing 30 changed files with 165 additions and 126 deletions.
4 changes: 2 additions & 2 deletions addons/skin.estuary/xml/Custom_1101_SettingsList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<height>460</height>
<centertop>50%</centertop>
<width>700</width>
<visible>!Window.IsActive(DialogSettings.xml) + !Window.IsActive(DialogSlider.xml) + !Window.IsActive(GameVideoFilter) + !Window.IsActive(GameViewMode) + !Window.IsActive(GameControllers) + !Window.IsActive(GameVideoRotation)</visible>
<visible>!Window.IsActive(DialogSettings.xml) + !Window.IsActive(DialogSlider.xml) + !Window.IsActive(GameVideoFilter) + !Window.IsActive(GameStretchMode) + !Window.IsActive(GameControllers) + !Window.IsActive(GameVideoRotation)</visible>
<animation effect="fade" time="200">VisibleChange</animation>
<include content="DialogBackgroundCommons">
<param name="width" value="700" />
Expand Down Expand Up @@ -127,7 +127,7 @@
<width>700</width>
<include>DialogSettingButton</include>
<label>$LOCALIZE[35233]</label>
<onclick>ActivateWindow(GameViewMode)</onclick>
<onclick>ActivateWindow(GameStretchMode)</onclick>
</control>
<control type="button" id="14106">
<description>Video rotation button</description>
Expand Down
4 changes: 2 additions & 2 deletions addons/skin.estuary/xml/DialogSelect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<include>Animation_DialogPopupOpenClose</include>
<depth>DepthOSD</depth>
<controls>
<include condition="![Window.IsActive(gameviewmode) | Window.IsActive(gamevideofilter) | Window.IsActive(gamevideorotation)]">DefaultDialogSelectLayout</include>
<include condition="![Window.IsActive(gamestretchmode) | Window.IsActive(gamevideofilter) | Window.IsActive(gamevideorotation)]">DefaultDialogSelectLayout</include>
<include condition="Window.IsActive(gamevideofilter)">GameDialogSelectFilterLayout</include>
<include condition="Window.IsActive(gameviewmode)">GameDialogSelectViewLayout</include>
<include condition="Window.IsActive(gamestretchmode)">GameDialogSelectViewLayout</include>
<include condition="Window.IsActive(gamevideorotation)">GameDialogSelectViewLayout</include>
</controls>
</window>
2 changes: 1 addition & 1 deletion addons/skin.estuary/xml/GameOSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<depth>DepthOSD</depth>
<controls>
<control type="group" id="1">
<visible>!Window.IsActive(1101) + !Window.IsActive(GameVideoFilter) + !Window.IsActive(GameViewMode) + !Window.IsActive(GameControllers) + !Window.IsActive(GameVideoRotation)</visible>
<visible>!Window.IsActive(1101) + !Window.IsActive(GameVideoFilter) + !Window.IsActive(GameStretchMode) + !Window.IsActive(GameControllers) + !Window.IsActive(GameVideoRotation)</visible>
<control type="group" id="10">
<visible>System.GetBool(gamesgeneral.showosdhelp)</visible>
<defaultcontrol always="true">1103</defaultcontrol>
Expand Down
8 changes: 4 additions & 4 deletions addons/skin.estuary/xml/Includes_DialogSelect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<width>444</width>
<height>250</height>
<videofilter>$INFO[ListItem.Property(game.videofilter)]</videofilter>
<viewmode>$INFO[ListItem.Property(game.viewmode)]</viewmode>
<stretchmode>$INFO[ListItem.Property(game.stretchmode)]</stretchmode>
<rotation>$INFO[ListItem.Property(game.videorotation)]</rotation>
</control>
<control type="label">
Expand Down Expand Up @@ -220,7 +220,7 @@
<width>444</width>
<height>250</height>
<videofilter>$INFO[ListItem.Property(game.videofilter)]</videofilter>
<viewmode>$INFO[ListItem.Property(game.viewmode)]</viewmode>
<stretchmode>$INFO[ListItem.Property(game.stretchmode)]</stretchmode>
<rotation>$INFO[ListItem.Property(game.videorotation)]</rotation>
</control>
<control type="label">
Expand Down Expand Up @@ -295,7 +295,7 @@
<width>444</width>
<height>250</height>
<videofilter>$INFO[ListItem.Property(game.videofilter)]</videofilter>
<viewmode>$INFO[ListItem.Property(game.viewmode)]</viewmode>
<stretchmode>$INFO[ListItem.Property(game.stretchmode)]</stretchmode>
<rotation>$INFO[ListItem.Property(game.videorotation)]</rotation>
</control>
<control type="label">
Expand Down Expand Up @@ -326,7 +326,7 @@
<width>444</width>
<height>250</height>
<videofilter>$INFO[ListItem.Property(game.videofilter)]</videofilter>
<viewmode>$INFO[ListItem.Property(game.viewmode)]</viewmode>
<stretchmode>$INFO[ListItem.Property(game.stretchmode)]</stretchmode>
<rotation>$INFO[ListItem.Property(game.videorotation)]</rotation>
</control>
<control type="label">
Expand Down
8 changes: 4 additions & 4 deletions xbmc/GUIInfoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2118,10 +2118,10 @@ const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
/// @{
/// \table_start
/// \table_h3{ Labels, Type, Description }
/// \table_row3{ <b>`ViewMode`</b>,
/// \anchor RetroPlayer_ViewMode
/// \table_row3{ <b>`StretchMode`</b>,
/// \anchor RetroPlayer_StretchMode
/// _string_,
/// Returns the view mode of the currently-playing game.\n
/// Returns the stretch mode of the currently-playing game.\n
/// The following values are possible:
/// - normal
/// - 4:3
Expand All @@ -2132,7 +2132,7 @@ const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
///
/// -----------------------------------------------------------------------------
/// @}
const infomap retroplayer[] = {{ "viewmode", RETROPLAYER_VIEWMODE},
const infomap retroplayer[] = {{ "stretchmode", RETROPLAYER_STRETCHMODE},
};

const infomap player_process[] =
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/GameSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum class SCALINGMETHOD
};

// NOTE: Only append
enum class VIEWMODE
enum class STRETCHMODE
{
Normal = 0,
Stretch4x3 = 1,
Expand Down
12 changes: 6 additions & 6 deletions xbmc/cores/RetroPlayer/RetroPlayerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
using namespace KODI;
using namespace RETRO;

std::string CRetroPlayerUtils::ViewModeToDescription(VIEWMODE viewMode)
std::string CRetroPlayerUtils::StretchModeToDescription(STRETCHMODE stretchMode)
{
switch (viewMode)
switch (stretchMode)
{
case VIEWMODE::Normal:
case STRETCHMODE::Normal:
return "normal";
case VIEWMODE::Stretch4x3:
case STRETCHMODE::Stretch4x3:
return "4:3";
case VIEWMODE::Fullscreen:
case STRETCHMODE::Fullscreen:
return "fullscreen";
case VIEWMODE::Original:
case STRETCHMODE::Original:
return "original";
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/RetroPlayer/RetroPlayerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace RETRO
class CRetroPlayerUtils
{
public:
static std::string ViewModeToDescription(VIEWMODE viewMode);
static std::string StretchModeToDescription(STRETCHMODE stretchMode);
};
}
}
4 changes: 2 additions & 2 deletions xbmc/cores/RetroPlayer/guibridge/GUIGameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ void CGUIGameSettings::UpdateSettings()

// Get settings from GUI
std::string videoFilter = m_guiSettings.VideoFilter();
VIEWMODE viewMode = m_guiSettings.ViewMode();
STRETCHMODE stretchMode = m_guiSettings.StretchMode();
unsigned int rotationDegCCW = m_guiSettings.RotationDegCCW();

// Save settings for renderer
m_renderSettings.VideoSettings().SetVideoFilter(videoFilter);
m_renderSettings.VideoSettings().SetRenderViewMode(viewMode);
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
m_renderSettings.VideoSettings().SetRenderRotation(rotationDegCCW);
}
4 changes: 2 additions & 2 deletions xbmc/cores/RetroPlayer/guibridge/IGUIRenderSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ namespace RETRO
virtual bool HasVideoFilter() const { return true; }

/*!
* \brief Returns true if this render target has a view mode set
* \brief Returns true if this render target has a stretch mode set
*/
virtual bool HasViewMode() const { return true; }
virtual bool HasStretchMode() const { return true; }

/*!
* \brief Returns true if this render target has a video rotation set
Expand Down
22 changes: 11 additions & 11 deletions xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ CGUIGameControl::CGUIGameControl(int parentID, int controlID, float posX, float
CGUIGameControl::CGUIGameControl(const CGUIGameControl &other) :
CGUIControl(other),
m_videoFilterInfo(other.m_videoFilterInfo),
m_viewModeInfo(other.m_viewModeInfo),
m_stretchModeInfo(other.m_stretchModeInfo),
m_rotationInfo(other.m_rotationInfo),
m_bHasVideoFilter(other.m_bHasVideoFilter),
m_bHasViewMode(other.m_bHasViewMode),
m_bHasStretchMode(other.m_bHasStretchMode),
m_bHasRotation(other.m_bHasRotation),
m_renderSettings(new CGUIRenderSettings(*this))
{
Expand All @@ -66,9 +66,9 @@ void CGUIGameControl::SetVideoFilter(const GUILIB::GUIINFO::CGUIInfoLabel &video
m_videoFilterInfo = videoFilter;
}

void CGUIGameControl::SetViewMode(const GUILIB::GUIINFO::CGUIInfoLabel &viewMode)
void CGUIGameControl::SetStretchMode(const GUILIB::GUIINFO::CGUIInfoLabel &stretchMode)
{
m_viewModeInfo = viewMode;
m_stretchModeInfo = stretchMode;
}

void CGUIGameControl::SetRotation(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &rotation)
Expand Down Expand Up @@ -141,13 +141,13 @@ void CGUIGameControl::UpdateInfo(const CGUIListItem *item /* = nullptr */)
m_bHasVideoFilter = true;
}

std::string strViewMode = m_viewModeInfo.GetItemLabel(item);
if (StringUtils::IsNaturalNumber(strViewMode))
std::string strStretchMode = m_stretchModeInfo.GetItemLabel(item);
if (StringUtils::IsNaturalNumber(strStretchMode))
{
unsigned int viewMode;
std::istringstream(std::move(strViewMode)) >> viewMode;
m_renderSettings->SetViewMode(static_cast<VIEWMODE>(viewMode));
m_bHasViewMode = true;
unsigned int stretchMode;
std::istringstream(std::move(strStretchMode)) >> stretchMode;
m_renderSettings->SetStretchMode(static_cast<STRETCHMODE>(stretchMode));
m_bHasStretchMode = true;
}

std::string strRotation = m_rotationInfo.GetItemLabel(item);
Expand All @@ -164,7 +164,7 @@ void CGUIGameControl::UpdateInfo(const CGUIListItem *item /* = nullptr */)
void CGUIGameControl::Reset()
{
m_bHasVideoFilter = false;
m_bHasViewMode = false;
m_bHasStretchMode = false;
m_bHasRotation = false;
m_renderSettings->Reset();
}
Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class CGUIGameControl : public CGUIControl

// GUI functions
void SetVideoFilter(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &videoFilter);
void SetViewMode(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &viewMode);
void SetStretchMode(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &stretchMode);
void SetRotation(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &rotation);

// Rendering functions
bool HasVideoFilter() const { return m_bHasVideoFilter; }
bool HasViewMode() const { return m_bHasViewMode; }
bool HasStretchMode() const { return m_bHasStretchMode; }
bool HasRotation() const { return m_bHasRotation; }
IGUIRenderSettings *GetRenderSettings() const;

Expand All @@ -58,12 +58,12 @@ class CGUIGameControl : public CGUIControl

// GUI properties
KODI::GUILIB::GUIINFO::CGUIInfoLabel m_videoFilterInfo;
KODI::GUILIB::GUIINFO::CGUIInfoLabel m_viewModeInfo;
KODI::GUILIB::GUIINFO::CGUIInfoLabel m_stretchModeInfo;
KODI::GUILIB::GUIINFO::CGUIInfoLabel m_rotationInfo;

// Rendering properties
bool m_bHasVideoFilter = false;
bool m_bHasViewMode = false;
bool m_bHasStretchMode = false;
bool m_bHasRotation = false;
std::unique_ptr<CGUIRenderSettings> m_renderSettings;
std::shared_ptr<CGUIRenderHandle> m_renderHandle;
Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ bool CGUIRenderSettings::HasVideoFilter() const
return m_guiControl.HasVideoFilter();
}

bool CGUIRenderSettings::HasViewMode() const
bool CGUIRenderSettings::HasStretchMode() const
{
return m_guiControl.HasViewMode();
return m_guiControl.HasStretchMode();
}

bool CGUIRenderSettings::HasRotation() const
Expand Down Expand Up @@ -75,11 +75,11 @@ void CGUIRenderSettings::SetVideoFilter(const std::string &videoFilter)
m_renderSettings.VideoSettings().SetVideoFilter(videoFilter);
}

void CGUIRenderSettings::SetViewMode(VIEWMODE viewMode)
void CGUIRenderSettings::SetStretchMode(STRETCHMODE stretchMode)
{
CSingleLock lock(m_mutex);

m_renderSettings.VideoSettings().SetRenderViewMode(viewMode);
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
}

void CGUIRenderSettings::SetRotationDegCCW(unsigned int rotationDegCCW)
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace RETRO

// implementation of IGUIRenderSettings
bool HasVideoFilter() const override;
bool HasViewMode() const override;
bool HasStretchMode() const override;
bool HasRotation() const override;
CRenderSettings GetSettings() const override;
CRect GetDimensions() const override;
Expand All @@ -38,7 +38,7 @@ namespace RETRO
void SetSettings(CRenderSettings settings);
void SetDimensions(const CRect &dimensions);
void SetVideoFilter(const std::string &videoFilter);
void SetViewMode(VIEWMODE viewMode);
void SetStretchMode(STRETCHMODE stretchMode);
void SetRotationDegCCW(unsigned int rotationDegCCW);

private:
Expand Down
6 changes: 3 additions & 3 deletions xbmc/cores/RetroPlayer/rendering/RPRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ std::shared_ptr<CRPBaseRenderer> CRPRenderManager::GetRenderer(const IGUIRenderS
if (renderer)
{
renderer->SetScalingMethod(effectiveRenderSettings.VideoSettings().GetScalingMethod());
renderer->SetViewMode(effectiveRenderSettings.VideoSettings().GetRenderViewMode());
renderer->SetStretchMode(effectiveRenderSettings.VideoSettings().GetRenderStretchMode());
renderer->SetRenderRotation(effectiveRenderSettings.VideoSettings().GetRenderRotation());
}

Expand Down Expand Up @@ -616,8 +616,8 @@ CRenderVideoSettings CRPRenderManager::GetEffectiveSettings(const IGUIRenderSett
{
if (settings->HasVideoFilter())
effectiveSettings.SetVideoFilter(settings->GetSettings().VideoSettings().GetVideoFilter());
if (settings->HasViewMode())
effectiveSettings.SetRenderViewMode(settings->GetSettings().VideoSettings().GetRenderViewMode());
if (settings->HasStretchMode())
effectiveSettings.SetRenderStretchMode(settings->GetSettings().VideoSettings().GetRenderStretchMode());
if (settings->HasRotation())
effectiveSettings.SetRenderRotation(settings->GetSettings().VideoSettings().GetRenderRotation());
}
Expand Down
31 changes: 22 additions & 9 deletions xbmc/cores/RetroPlayer/rendering/RenderUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@
using namespace KODI;
using namespace RETRO;

void CRenderUtils::CalculateViewMode(VIEWMODE viewMode, unsigned int rotationDegCCW, unsigned int sourceWidth, unsigned int sourceHeight, float screenWidth, float screenHeight, float &pixelRatio, float &zoomAmount)
void CRenderUtils::CalculateStretchMode(STRETCHMODE stretchMode,
unsigned int rotationDegCCW,
unsigned int sourceWidth,
unsigned int sourceHeight,
float screenWidth,
float screenHeight,
float &pixelRatio,
float &zoomAmount)
{
const float sourceFrameRatio = static_cast<float>(sourceWidth) / static_cast<float>(sourceHeight);

switch (viewMode)
switch (stretchMode)
{
case VIEWMODE::Normal:
case STRETCHMODE::Normal:
{
switch (rotationDegCCW)
{
Expand All @@ -38,23 +45,23 @@ void CRenderUtils::CalculateViewMode(VIEWMODE viewMode, unsigned int rotationDeg

break;
}
case VIEWMODE::Stretch4x3:
case STRETCHMODE::Stretch4x3:
{
// Stretch to 4:3 ratio
pixelRatio = (4.0f / 3.0f) / sourceFrameRatio;
zoomAmount = 1.0f;

break;
}
case VIEWMODE::Fullscreen:
case STRETCHMODE::Fullscreen:
{
// Stretch to the limits of the screen
pixelRatio = (screenWidth / screenHeight) / sourceFrameRatio;
zoomAmount = 1.0f;

break;
}
case VIEWMODE::Original:
case STRETCHMODE::Original:
{
switch (rotationDegCCW)
{
Expand Down Expand Up @@ -100,7 +107,10 @@ void CRenderUtils::CalculateViewMode(VIEWMODE viewMode, unsigned int rotationDeg
}
}

void CRenderUtils::CalcNormalRenderRect(const CRect &viewRect, float outputFrameRatio, float zoomAmount, CRect &destRect)
void CRenderUtils::CalcNormalRenderRect(const CRect &viewRect,
float outputFrameRatio,
float zoomAmount,
CRect &destRect)
{
const float offsetX = viewRect.x1;
const float offsetY = viewRect.y1;
Expand Down Expand Up @@ -144,7 +154,9 @@ void CRenderUtils::CalcNormalRenderRect(const CRect &viewRect, float outputFrame
destRect.y2 = destRect.y1 + MathUtils::round_int(newHeight);
}

void CRenderUtils::ClipRect(const CRect &viewRect, CRect &sourceRect, CRect &destRect)
void CRenderUtils::ClipRect(const CRect &viewRect,
CRect &sourceRect,
CRect &destRect)
{
const float offsetX = viewRect.x1;
const float offsetY = viewRect.y1;
Expand All @@ -164,7 +176,8 @@ void CRenderUtils::ClipRect(const CRect &viewRect, CRect &sourceRect, CRect &des
}
}

std::array<CPoint, 4> CRenderUtils::ReorderDrawPoints(const CRect &destRect, unsigned int orientationDegCCW)
std::array<CPoint, 4> CRenderUtils::ReorderDrawPoints(const CRect &destRect,
unsigned int orientationDegCCW)
{
std::array<CPoint, 4> rotatedDestCoords{};

Expand Down
Loading

0 comments on commit 65f5fbb

Please sign in to comment.