[Scummvm-git-logs] scummvm master -> 5b32f377a9d717a16c57ca09d3223350137bf964
rsn8887
rsn8887 at users.noreply.github.com
Wed Aug 14 03:42:59 CEST 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5b32f377a9 BACKENDS: add Fit to window (4:3) stretch mode to SDL2 backend
Commit: 5b32f377a9d717a16c57ca09d3223350137bf964
https://github.com/scummvm/scummvm/commit/5b32f377a9d717a16c57ca09d3223350137bf964
Author: rsn8887 (rsn8887 at users.noreply.github.com)
Date: 2019-08-13T20:42:56-05:00
Commit Message:
BACKENDS: add Fit to window (4:3) stretch mode to SDL2 backend
Changed paths:
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/windowed.h
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index e14471b..f71aa20 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 b725ca0..66b1476 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)
More information about the Scummvm-git-logs
mailing list