diff options
author | rsn8887 | 2019-08-13 18:05:26 -0500 |
---|---|---|
committer | rsn8887 | 2019-08-13 20:42:56 -0500 |
commit | 5b32f377a9d717a16c57ca09d3223350137bf964 (patch) | |
tree | 938af532d2707fa0ea836dab685bddeb0d956c0b | |
parent | 59cff4b20670f948a8c66f09e79e3c73da5cb69e (diff) | |
download | scummvm-rg350-5b32f377a9d717a16c57ca09d3223350137bf964.tar.gz scummvm-rg350-5b32f377a9d717a16c57ca09d3223350137bf964.tar.bz2 scummvm-rg350-5b32f377a9d717a16c57ca09d3223350137bf964.zip |
BACKENDS: add Fit to window (4:3) stretch mode to SDL2 backend
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 1 | ||||
-rw-r--r-- | backends/graphics/windowed.h | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index e14471b067..f71aa20865 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -76,6 +76,7 @@ const OSystem::GraphicsMode s_supportedStretchModes[] = { {"pixel-perfect", _s("Pixel-perfect scaling"), STRETCH_INTEGRAL}, {"fit", _s("Fit to window"), STRETCH_FIT}, {"stretch", _s("Stretch to window"), STRETCH_STRETCH}, + {"fit_force_aspect", _s("Fit to window (4:3)"), STRETCH_FIT_FORCE_ASPECT}, {nullptr, nullptr, 0} }; #endif diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h index b725ca08b4..66b1476d22 100644 --- a/backends/graphics/windowed.h +++ b/backends/graphics/windowed.h @@ -34,7 +34,8 @@ enum { STRETCH_CENTER = 0, STRETCH_INTEGRAL = 1, STRETCH_FIT = 2, - STRETCH_STRETCH = 3 + STRETCH_STRETCH = 3, + STRETCH_FIT_FORCE_ASPECT = 4 }; class WindowedGraphicsManager : virtual public GraphicsManager { @@ -341,6 +342,7 @@ private: // Mode Integral = scale by an integral amount. // Mode Fit = scale to fit the window while respecting the aspect ratio // Mode Stretch = scale and stretch to fit the window without respecting the aspect ratio + // Mode Fit Force Aspect = scale to fit the window while forcing a 4:3 aspect ratio int width = 0, height = 0; if (mode == STRETCH_CENTER || mode == STRETCH_INTEGRAL) { @@ -359,7 +361,13 @@ private: frac_t windowAspect = intToFrac(_windowWidth) / _windowHeight; width = _windowWidth; height = _windowHeight; - if (mode != STRETCH_STRETCH) { + if (mode == STRETCH_FIT_FORCE_ASPECT) { + frac_t ratio = intToFrac(4) / 3; + if (windowAspect < ratio) + height = intToFrac(width) / ratio; + else if (windowAspect > ratio) + width = fracToInt(height * ratio); + } else if (mode != STRETCH_STRETCH) { if (windowAspect < displayAspect) height = intToFrac(width) / displayAspect; else if (windowAspect > displayAspect) |