aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/windowed.h
diff options
context:
space:
mode:
authorrsn88872019-08-13 18:05:26 -0500
committerrsn88872019-08-13 20:42:56 -0500
commit5b32f377a9d717a16c57ca09d3223350137bf964 (patch)
tree938af532d2707fa0ea836dab685bddeb0d956c0b /backends/graphics/windowed.h
parent59cff4b20670f948a8c66f09e79e3c73da5cb69e (diff)
downloadscummvm-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
Diffstat (limited to 'backends/graphics/windowed.h')
-rw-r--r--backends/graphics/windowed.h12
1 files changed, 10 insertions, 2 deletions
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)