VideoConfig: Make AspectMode an enum class
Makes for more strongly-typed identifiers (and doesn't pollute surrounding namespaces)
This commit is contained in:
parent
609a17a0cd
commit
10697bcbe3
|
@ -22,9 +22,9 @@ const ConfigInfo<int> GFX_ADAPTER{{System::GFX, "Hardware", "Adapter"}, 0};
|
||||||
|
|
||||||
const ConfigInfo<bool> GFX_WIDESCREEN_HACK{{System::GFX, "Settings", "wideScreenHack"}, false};
|
const ConfigInfo<bool> GFX_WIDESCREEN_HACK{{System::GFX, "Settings", "wideScreenHack"}, false};
|
||||||
const ConfigInfo<int> GFX_ASPECT_RATIO{{System::GFX, "Settings", "AspectRatio"},
|
const ConfigInfo<int> GFX_ASPECT_RATIO{{System::GFX, "Settings", "AspectRatio"},
|
||||||
static_cast<int>(ASPECT_AUTO)};
|
static_cast<int>(AspectMode::Auto)};
|
||||||
const ConfigInfo<int> GFX_SUGGESTED_ASPECT_RATIO{{System::GFX, "Settings", "SuggestedAspectRatio"},
|
const ConfigInfo<int> GFX_SUGGESTED_ASPECT_RATIO{{System::GFX, "Settings", "SuggestedAspectRatio"},
|
||||||
static_cast<int>(ASPECT_AUTO)};
|
static_cast<int>(AspectMode::Auto)};
|
||||||
const ConfigInfo<bool> GFX_CROP{{System::GFX, "Settings", "Crop"}, false};
|
const ConfigInfo<bool> GFX_CROP{{System::GFX, "Settings", "Crop"}, false};
|
||||||
const ConfigInfo<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES{
|
const ConfigInfo<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES{
|
||||||
{System::GFX, "Settings", "SafeTextureCacheColorSamples"}, 128};
|
{System::GFX, "Settings", "SafeTextureCacheColorSamples"}, 128};
|
||||||
|
|
|
@ -221,7 +221,10 @@ void HotkeyScheduler::Run()
|
||||||
if (IsHotkey(HK_TOGGLE_CROP))
|
if (IsHotkey(HK_TOGGLE_CROP))
|
||||||
g_Config.bCrop = !g_Config.bCrop;
|
g_Config.bCrop = !g_Config.bCrop;
|
||||||
if (IsHotkey(HK_TOGGLE_AR))
|
if (IsHotkey(HK_TOGGLE_AR))
|
||||||
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
|
{
|
||||||
|
g_Config.aspect_mode =
|
||||||
|
static_cast<AspectMode>((static_cast<int>(g_Config.aspect_mode) + 1) & 3);
|
||||||
|
}
|
||||||
if (IsHotkey(HK_TOGGLE_EFBCOPIES))
|
if (IsHotkey(HK_TOGGLE_EFBCOPIES))
|
||||||
g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam;
|
g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam;
|
||||||
if (IsHotkey(HK_TOGGLE_XFBCOPIES))
|
if (IsHotkey(HK_TOGGLE_XFBCOPIES))
|
||||||
|
|
|
@ -717,10 +717,10 @@ void Renderer::CheckForSurfaceChange()
|
||||||
void Renderer::CheckForConfigChanges()
|
void Renderer::CheckForConfigChanges()
|
||||||
{
|
{
|
||||||
// Save the video config so we can compare against to determine which settings have changed.
|
// Save the video config so we can compare against to determine which settings have changed.
|
||||||
int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
|
const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
|
||||||
int old_aspect_ratio = g_ActiveConfig.iAspectRatio;
|
const AspectMode old_aspect_mode = g_ActiveConfig.aspect_mode;
|
||||||
int old_efb_scale = g_ActiveConfig.iEFBScale;
|
const int old_efb_scale = g_ActiveConfig.iEFBScale;
|
||||||
bool old_force_filtering = g_ActiveConfig.bForceFiltering;
|
const bool old_force_filtering = g_ActiveConfig.bForceFiltering;
|
||||||
|
|
||||||
// Copy g_Config to g_ActiveConfig.
|
// Copy g_Config to g_ActiveConfig.
|
||||||
// NOTE: This can potentially race with the UI thread, however if it does, the changes will be
|
// NOTE: This can potentially race with the UI thread, however if it does, the changes will be
|
||||||
|
@ -728,10 +728,11 @@ void Renderer::CheckForConfigChanges()
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
|
|
||||||
// Determine which (if any) settings have changed.
|
// Determine which (if any) settings have changed.
|
||||||
bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
|
const bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
|
||||||
bool force_texture_filtering_changed = old_force_filtering != g_ActiveConfig.bForceFiltering;
|
const bool force_texture_filtering_changed =
|
||||||
bool efb_scale_changed = old_efb_scale != g_ActiveConfig.iEFBScale;
|
old_force_filtering != g_ActiveConfig.bForceFiltering;
|
||||||
bool aspect_changed = old_aspect_ratio != g_ActiveConfig.iAspectRatio;
|
const bool efb_scale_changed = old_efb_scale != g_ActiveConfig.iEFBScale;
|
||||||
|
const bool aspect_changed = old_aspect_mode != g_ActiveConfig.aspect_mode;
|
||||||
|
|
||||||
// Update texture cache settings with any changed options.
|
// Update texture cache settings with any changed options.
|
||||||
TextureCache::GetInstance()->OnConfigChanged(g_ActiveConfig);
|
TextureCache::GetInstance()->OnConfigChanged(g_ActiveConfig);
|
||||||
|
|
|
@ -312,19 +312,20 @@ void Renderer::DrawDebugText()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const char* ar_text = "";
|
const char* ar_text = "";
|
||||||
switch (g_ActiveConfig.iAspectRatio)
|
switch (g_ActiveConfig.aspect_mode)
|
||||||
{
|
{
|
||||||
case ASPECT_AUTO:
|
case AspectMode::Auto:
|
||||||
ar_text = "Auto";
|
ar_text = "Auto";
|
||||||
break;
|
break;
|
||||||
case ASPECT_STRETCH:
|
case AspectMode::Stretch:
|
||||||
ar_text = "Stretch";
|
ar_text = "Stretch";
|
||||||
break;
|
break;
|
||||||
case ASPECT_ANALOG:
|
case AspectMode::Analog:
|
||||||
ar_text = "Force 4:3";
|
ar_text = "Force 4:3";
|
||||||
break;
|
break;
|
||||||
case ASPECT_ANALOG_WIDE:
|
case AspectMode::AnalogWide:
|
||||||
ar_text = "Force 16:9";
|
ar_text = "Force 16:9";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM";
|
const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM";
|
||||||
|
@ -381,15 +382,15 @@ void Renderer::DrawDebugText()
|
||||||
|
|
||||||
float Renderer::CalculateDrawAspectRatio() const
|
float Renderer::CalculateDrawAspectRatio() const
|
||||||
{
|
{
|
||||||
if (g_ActiveConfig.iAspectRatio == ASPECT_STRETCH)
|
if (g_ActiveConfig.aspect_mode == AspectMode::Stretch)
|
||||||
{
|
{
|
||||||
// If stretch is enabled, we prefer the aspect ratio of the window.
|
// If stretch is enabled, we prefer the aspect ratio of the window.
|
||||||
return (static_cast<float>(m_backbuffer_width) / static_cast<float>(m_backbuffer_height));
|
return (static_cast<float>(m_backbuffer_width) / static_cast<float>(m_backbuffer_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
|
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
|
||||||
if (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
|
if (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
|
||||||
(g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide))
|
(g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide))
|
||||||
{
|
{
|
||||||
return AspectToWidescreen(VideoInterface::GetAspectRatio());
|
return AspectToWidescreen(VideoInterface::GetAspectRatio());
|
||||||
}
|
}
|
||||||
|
@ -428,21 +429,20 @@ void Renderer::UpdateDrawRectangle()
|
||||||
float source_aspect = VideoInterface::GetAspectRatio();
|
float source_aspect = VideoInterface::GetAspectRatio();
|
||||||
if (m_aspect_wide)
|
if (m_aspect_wide)
|
||||||
source_aspect = AspectToWidescreen(source_aspect);
|
source_aspect = AspectToWidescreen(source_aspect);
|
||||||
float target_aspect;
|
float target_aspect = 0.0f;
|
||||||
|
|
||||||
switch (g_ActiveConfig.iAspectRatio)
|
switch (g_ActiveConfig.aspect_mode)
|
||||||
{
|
{
|
||||||
case ASPECT_STRETCH:
|
case AspectMode::Stretch:
|
||||||
target_aspect = win_width / win_height;
|
target_aspect = win_width / win_height;
|
||||||
break;
|
break;
|
||||||
case ASPECT_ANALOG:
|
case AspectMode::Analog:
|
||||||
target_aspect = VideoInterface::GetAspectRatio();
|
target_aspect = VideoInterface::GetAspectRatio();
|
||||||
break;
|
break;
|
||||||
case ASPECT_ANALOG_WIDE:
|
case AspectMode::AnalogWide:
|
||||||
target_aspect = AspectToWidescreen(VideoInterface::GetAspectRatio());
|
target_aspect = AspectToWidescreen(VideoInterface::GetAspectRatio());
|
||||||
break;
|
break;
|
||||||
default:
|
case AspectMode::Auto:
|
||||||
// ASPECT_AUTO
|
|
||||||
target_aspect = source_aspect;
|
target_aspect = source_aspect;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -475,10 +475,10 @@ void Renderer::UpdateDrawRectangle()
|
||||||
draw_height = crop_height = 1;
|
draw_height = crop_height = 1;
|
||||||
|
|
||||||
// crop the picture to a standard aspect ratio
|
// crop the picture to a standard aspect ratio
|
||||||
if (g_ActiveConfig.bCrop && g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
|
if (g_ActiveConfig.bCrop && g_ActiveConfig.aspect_mode != AspectMode::Stretch)
|
||||||
{
|
{
|
||||||
float expected_aspect = (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
|
float expected_aspect = (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
|
||||||
(g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide)) ?
|
(g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide)) ?
|
||||||
(16.0f / 9.0f) :
|
(16.0f / 9.0f) :
|
||||||
(4.0f / 3.0f);
|
(4.0f / 3.0f);
|
||||||
if (crop_width / crop_height >= expected_aspect)
|
if (crop_width / crop_height >= expected_aspect)
|
||||||
|
@ -550,8 +550,8 @@ std::tuple<int, int> Renderer::CalculateOutputDimensions(int width, int height)
|
||||||
{
|
{
|
||||||
// Force 4:3 or 16:9 by cropping the image.
|
// Force 4:3 or 16:9 by cropping the image.
|
||||||
float current_aspect = scaled_width / scaled_height;
|
float current_aspect = scaled_width / scaled_height;
|
||||||
float expected_aspect = (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
|
float expected_aspect = (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
|
||||||
(g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide)) ?
|
(g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide)) ?
|
||||||
(16.0f / 9.0f) :
|
(16.0f / 9.0f) :
|
||||||
(4.0f / 3.0f);
|
(4.0f / 3.0f);
|
||||||
if (current_aspect > expected_aspect)
|
if (current_aspect > expected_aspect)
|
||||||
|
|
|
@ -61,11 +61,11 @@ void VideoConfig::Refresh()
|
||||||
iAdapter = Config::Get(Config::GFX_ADAPTER);
|
iAdapter = Config::Get(Config::GFX_ADAPTER);
|
||||||
|
|
||||||
bWidescreenHack = Config::Get(Config::GFX_WIDESCREEN_HACK);
|
bWidescreenHack = Config::Get(Config::GFX_WIDESCREEN_HACK);
|
||||||
const int aspect_ratio = Config::Get(Config::GFX_ASPECT_RATIO);
|
const auto config_aspect_mode = static_cast<AspectMode>(Config::Get(Config::GFX_ASPECT_RATIO));
|
||||||
if (aspect_ratio == ASPECT_AUTO)
|
if (config_aspect_mode == AspectMode::Auto)
|
||||||
iAspectRatio = Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO);
|
aspect_mode = static_cast<AspectMode>(Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO));
|
||||||
else
|
else
|
||||||
iAspectRatio = aspect_ratio;
|
aspect_mode = config_aspect_mode;
|
||||||
bCrop = Config::Get(Config::GFX_CROP);
|
bCrop = Config::Get(Config::GFX_CROP);
|
||||||
iSafeTextureCache_ColorSamples = Config::Get(Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES);
|
iSafeTextureCache_ColorSamples = Config::Get(Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES);
|
||||||
bShowFPS = Config::Get(Config::GFX_SHOW_FPS);
|
bShowFPS = Config::Get(Config::GFX_SHOW_FPS);
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
|
|
||||||
constexpr int EFB_SCALE_AUTO_INTEGRAL = 0;
|
constexpr int EFB_SCALE_AUTO_INTEGRAL = 0;
|
||||||
|
|
||||||
enum AspectMode
|
enum class AspectMode
|
||||||
{
|
{
|
||||||
ASPECT_AUTO = 0,
|
Auto,
|
||||||
ASPECT_ANALOG_WIDE = 1,
|
AnalogWide,
|
||||||
ASPECT_ANALOG = 2,
|
Analog,
|
||||||
ASPECT_STRETCH = 3,
|
Stretch,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum StereoMode
|
enum StereoMode
|
||||||
|
@ -63,7 +63,7 @@ struct VideoConfig final
|
||||||
// General
|
// General
|
||||||
bool bVSync;
|
bool bVSync;
|
||||||
bool bWidescreenHack;
|
bool bWidescreenHack;
|
||||||
int iAspectRatio;
|
AspectMode aspect_mode;
|
||||||
bool bCrop; // Aspect ratio controls.
|
bool bCrop; // Aspect ratio controls.
|
||||||
bool bShaderCache;
|
bool bShaderCache;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue