summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2017-11-10 22:45:32 -0500
committerLioncash <mathew1800@gmail.com>2017-11-18 23:17:56 -0500
commit10697bcbe3c84599f11f49dfc38358a2e9b7140f (patch)
tree58127ae3106da02b7e9356a7a8b6cc3d27d63bcc /Source
parent609a17a0cd41a12c0fbf9a7c47c8889232594778 (diff)
VideoConfig: Make AspectMode an enum class
Makes for more strongly-typed identifiers (and doesn't pollute surrounding namespaces)
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/Config/GraphicsSettings.cpp4
-rw-r--r--Source/Core/DolphinQt2/HotkeyScheduler.cpp5
-rw-r--r--Source/Core/VideoBackends/Vulkan/Renderer.cpp17
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp40
-rw-r--r--Source/Core/VideoCommon/VideoConfig.cpp8
-rw-r--r--Source/Core/VideoCommon/VideoConfig.h12
6 files changed, 45 insertions, 41 deletions
diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp
index f95e44a92a..fab173d04d 100644
--- a/Source/Core/Core/Config/GraphicsSettings.cpp
+++ b/Source/Core/Core/Config/GraphicsSettings.cpp
@@ -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<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"},
- static_cast<int>(ASPECT_AUTO)};
+ static_cast<int>(AspectMode::Auto)};
const ConfigInfo<bool> GFX_CROP{{System::GFX, "Settings", "Crop"}, false};
const ConfigInfo<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES{
{System::GFX, "Settings", "SafeTextureCacheColorSamples"}, 128};
diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.cpp b/Source/Core/DolphinQt2/HotkeyScheduler.cpp
index 547e4676de..e8e4038779 100644
--- a/Source/Core/DolphinQt2/HotkeyScheduler.cpp
+++ b/Source/Core/DolphinQt2/HotkeyScheduler.cpp
@@ -221,7 +221,10 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_TOGGLE_CROP))
g_Config.bCrop = !g_Config.bCrop;
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))
g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam;
if (IsHotkey(HK_TOGGLE_XFBCOPIES))
diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp
index d72f2929c3..18a0b415ed 100644
--- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp
+++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp
@@ -717,10 +717,10 @@ void Renderer::CheckForSurfaceChange()
void Renderer::CheckForConfigChanges()
{
// Save the video config so we can compare against to determine which settings have changed.
- int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
- int old_aspect_ratio = g_ActiveConfig.iAspectRatio;
- int old_efb_scale = g_ActiveConfig.iEFBScale;
- bool old_force_filtering = g_ActiveConfig.bForceFiltering;
+ const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
+ const AspectMode old_aspect_mode = g_ActiveConfig.aspect_mode;
+ const int old_efb_scale = g_ActiveConfig.iEFBScale;
+ const bool old_force_filtering = g_ActiveConfig.bForceFiltering;
// Copy g_Config to g_ActiveConfig.
// 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();
// Determine which (if any) settings have changed.
- bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
- bool force_texture_filtering_changed = old_force_filtering != g_ActiveConfig.bForceFiltering;
- bool efb_scale_changed = old_efb_scale != g_ActiveConfig.iEFBScale;
- bool aspect_changed = old_aspect_ratio != g_ActiveConfig.iAspectRatio;
+ const bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
+ const bool force_texture_filtering_changed =
+ old_force_filtering != g_ActiveConfig.bForceFiltering;
+ 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.
TextureCache::GetInstance()->OnConfigChanged(g_ActiveConfig);
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 0db81bb885..2f6eccdf75 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -312,19 +312,20 @@ void Renderer::DrawDebugText()
break;
}
const char* ar_text = "";
- switch (g_ActiveConfig.iAspectRatio)
+ switch (g_ActiveConfig.aspect_mode)
{
- case ASPECT_AUTO:
+ case AspectMode::Auto:
ar_text = "Auto";
break;
- case ASPECT_STRETCH:
+ case AspectMode::Stretch:
ar_text = "Stretch";
break;
- case ASPECT_ANALOG:
+ case AspectMode::Analog:
ar_text = "Force 4:3";
break;
- case ASPECT_ANALOG_WIDE:
+ case AspectMode::AnalogWide:
ar_text = "Force 16:9";
+ break;
}
const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM";
@@ -381,15 +382,15 @@ void Renderer::DrawDebugText()
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.
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
- if (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
- (g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide))
+ if (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
+ (g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide))
{
return AspectToWidescreen(VideoInterface::GetAspectRatio());
}
@@ -428,21 +429,20 @@ void Renderer::UpdateDrawRectangle()
float source_aspect = VideoInterface::GetAspectRatio();
if (m_aspect_wide)
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;
break;
- case ASPECT_ANALOG:
+ case AspectMode::Analog:
target_aspect = VideoInterface::GetAspectRatio();
break;
- case ASPECT_ANALOG_WIDE:
+ case AspectMode::AnalogWide:
target_aspect = AspectToWidescreen(VideoInterface::GetAspectRatio());
break;
- default:
- // ASPECT_AUTO
+ case AspectMode::Auto:
target_aspect = source_aspect;
break;
}
@@ -475,10 +475,10 @@ void Renderer::UpdateDrawRectangle()
draw_height = crop_height = 1;
// 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 ||
- (g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide)) ?
+ float expected_aspect = (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
+ (g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide)) ?
(16.0f / 9.0f) :
(4.0f / 3.0f);
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.
float current_aspect = scaled_width / scaled_height;
- float expected_aspect = (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE ||
- (g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && m_aspect_wide)) ?
+ float expected_aspect = (g_ActiveConfig.aspect_mode == AspectMode::AnalogWide ||
+ (g_ActiveConfig.aspect_mode != AspectMode::Analog && m_aspect_wide)) ?
(16.0f / 9.0f) :
(4.0f / 3.0f);
if (current_aspect > expected_aspect)
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp
index 1f6e5a38c7..fb9dd96130 100644
--- a/Source/Core/VideoCommon/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/VideoConfig.cpp
@@ -61,11 +61,11 @@ void VideoConfig::Refresh()
iAdapter = Config::Get(Config::GFX_ADAPTER);
bWidescreenHack = Config::Get(Config::GFX_WIDESCREEN_HACK);
- const int aspect_ratio = Config::Get(Config::GFX_ASPECT_RATIO);
- if (aspect_ratio == ASPECT_AUTO)
- iAspectRatio = Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO);
+ const auto config_aspect_mode = static_cast<AspectMode>(Config::Get(Config::GFX_ASPECT_RATIO));
+ if (config_aspect_mode == AspectMode::Auto)
+ aspect_mode = static_cast<AspectMode>(Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO));
else
- iAspectRatio = aspect_ratio;
+ aspect_mode = config_aspect_mode;
bCrop = Config::Get(Config::GFX_CROP);
iSafeTextureCache_ColorSamples = Config::Get(Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES);
bShowFPS = Config::Get(Config::GFX_SHOW_FPS);
diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h
index 03f8a7368c..0a2f8d44f7 100644
--- a/Source/Core/VideoCommon/VideoConfig.h
+++ b/Source/Core/VideoCommon/VideoConfig.h
@@ -24,12 +24,12 @@
constexpr int EFB_SCALE_AUTO_INTEGRAL = 0;
-enum AspectMode
+enum class AspectMode
{
- ASPECT_AUTO = 0,
- ASPECT_ANALOG_WIDE = 1,
- ASPECT_ANALOG = 2,
- ASPECT_STRETCH = 3,
+ Auto,
+ AnalogWide,
+ Analog,
+ Stretch,
};
enum StereoMode
@@ -63,7 +63,7 @@ struct VideoConfig final
// General
bool bVSync;
bool bWidescreenHack;
- int iAspectRatio;
+ AspectMode aspect_mode;
bool bCrop; // Aspect ratio controls.
bool bShaderCache;