[Scummvm-git-logs] scummvm master -> 5948d8a4322f5ec51098d0ff6b3222d665e9a2b5

criezy criezy at scummvm.org
Sat Jun 5 13:17:44 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
31a6b39fb3 SDL: Add new pixel perfect stretch mode for OpenGL
5948d8a432 DOC: Document even pixel stretch mode


Commit: 31a6b39fb3f48883436f73e27bebf4ebee112be2
    https://github.com/scummvm/scummvm/commit/31a6b39fb3f48883436f73e27bebf4ebee112be2
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-06-05T14:17:40+01:00

Commit Message:
SDL: Add new pixel perfect stretch mode for OpenGL

This mode ensure that an integral scaling is used both for the width
and for the height. Compared to the old pixel perfect stretch mode
it thus differs in the way it handles the aspect ratio correction.
It may stretch or squeeze the vertical direction to snap it to a
multiple of the original game height.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/windowed.h


diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 45ad4c0fe6..f522259cb5 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -241,6 +241,7 @@ namespace {
 const OSystem::GraphicsMode glStretchModes[] = {
 	{"center", _s("Center"), STRETCH_CENTER},
 	{"pixel-perfect", _s("Pixel-perfect scaling"), STRETCH_INTEGRAL},
+	{"even-pixels", _s("Even pixels scaling"), STRETCH_INTEGRAL_AR},
 	{"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},
diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h
index f261c0f032..e52aa806e4 100644
--- a/backends/graphics/windowed.h
+++ b/backends/graphics/windowed.h
@@ -33,9 +33,10 @@
 enum {
 	STRETCH_CENTER = 0,
 	STRETCH_INTEGRAL = 1,
-	STRETCH_FIT = 2,
-	STRETCH_STRETCH = 3,
-	STRETCH_FIT_FORCE_ASPECT = 4
+	STRETCH_INTEGRAL_AR = 2,
+	STRETCH_FIT = 3,
+	STRETCH_STRETCH = 4,
+	STRETCH_FIT_FORCE_ASPECT = 5
 };
 
 class WindowedGraphicsManager : virtual public GraphicsManager {
@@ -194,11 +195,11 @@ protected:
 			return;
 		}
 
-		populateDisplayAreaDrawRect(getDesiredGameAspectRatio(), getWidth() * getGameRenderScale(), _gameDrawRect);
+		populateDisplayAreaDrawRect(getDesiredGameAspectRatio(), getWidth() * getGameRenderScale(), getHeight() * getGameRenderScale(), _gameDrawRect);
 
 		if (getOverlayHeight()) {
 			const frac_t overlayAspect = intToFrac(getOverlayWidth()) / getOverlayHeight();
-			populateDisplayAreaDrawRect(overlayAspect, getOverlayWidth(), _overlayDrawRect);
+			populateDisplayAreaDrawRect(overlayAspect, getOverlayWidth(), getOverlayHeight(), _overlayDrawRect);
 		}
 
 		if (_overlayVisible) {
@@ -363,7 +364,7 @@ protected:
 	int _cursorX, _cursorY;
 
 private:
-	void populateDisplayAreaDrawRect(const frac_t displayAspect, int originalWidth, Common::Rect &drawRect) const {
+	void populateDisplayAreaDrawRect(const frac_t displayAspect, int originalWidth, int originalHeight, Common::Rect &drawRect) const {
 		int mode = getStretchMode();
 		// Mode Center   = use original size, or divide by an integral amount if window is smaller than game surface
 		// Mode Integral = scale by an integral amount.
@@ -372,7 +373,7 @@ private:
 		// 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) {
+		if (mode == STRETCH_CENTER || mode == STRETCH_INTEGRAL || mode == STRETCH_INTEGRAL_AR) {
 			width = originalWidth;
 			height = intToFrac(width) / displayAspect;
 			if (width > _windowWidth || height > _windowHeight) {
@@ -383,6 +384,17 @@ private:
 				int fac = MIN(_windowWidth / width, _windowHeight / height);
 				width *= fac;
 				height *= fac;
+			}  else if (mode == STRETCH_INTEGRAL_AR) {
+				int targetHeight = height;
+				int horizontalFac = _windowWidth / width;
+				do {
+					width = originalWidth * horizontalFac;
+					int verticalFac = (targetHeight * horizontalFac + originalHeight / 2) / originalHeight;
+					height = originalHeight * verticalFac;
+					--horizontalFac;
+				} while (horizontalFac > 0 && height > _windowHeight);
+				if (height > _windowHeight)
+					height = targetHeight;
 			}
 		} else {
 			frac_t windowAspect = intToFrac(_windowWidth) / _windowHeight;


Commit: 5948d8a4322f5ec51098d0ff6b3222d665e9a2b5
    https://github.com/scummvm/scummvm/commit/5948d8a4322f5ec51098d0ff6b3222d665e9a2b5
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-06-05T14:17:40+01:00

Commit Message:
DOC: Document even pixel stretch mode

Changed paths:
    doc/docportal/advanced_topics/understand_graphics.rst


diff --git a/doc/docportal/advanced_topics/understand_graphics.rst b/doc/docportal/advanced_topics/understand_graphics.rst
index 1cd29a1493..52ac3324b6 100644
--- a/doc/docportal/advanced_topics/understand_graphics.rst
+++ b/doc/docportal/advanced_topics/understand_graphics.rst
@@ -142,6 +142,10 @@ There are five stretch modes:
 
     - For example, a game with an original resolution of 320x200 with aspect ratio correction applied (320x240) and a 3x graphics mode, will be stretched to a multiple of 900x720 pixels: 1800x1440, 2700x2160 and so on.
 
+- Even pixels scaling: scales the image to the highest multiple of the original game width and height. Any empty space is filled with black bars. When aspect ratio is enabled, it may be different from pixel-perfect as it will use a height that is a multiple of the original game height at the cost of not respecting exactly the aspect ratio. This ensure we get even pixels. This stretch mode is only available in OpenGL graphics mode.
+
+    - For example, with a screen resolution of 1920x1080, a game with an original resolution of 320x200 with aspect ratio correction applied (320x240) will be stretched to 1280x1000 (original width of 320 x 4 and original height of 200 x 5) which is a ratio of 320x250 and not 320x240. For comparison the pixel-perfect mode would stretch to 1280x960 (320x240 scaled by a factor 4, which means a scaling of x4.8 on the original height that would introduce some artifacts).
+
 - Fit to window: fits the image to the window, but maintains the aspect ratio and does not stretch it to fill the window.
 - Stretch: stretches the image to fill the window
 - Fit to window (4:3): fits the image to the window, at a forced 4:3 aspect ratio.
@@ -213,4 +217,4 @@ Without anti-aliasing, the computer takes the color it finds at the center of th
 
 Historically, anti-aliasing was done using a method called Supersampling. With this method, each frame is rendered behind-the-scenes to a higher resolution, and then downscaled to produce a much smoother, better looking image. Unfortunately, this method is very GPU-intensive, and too slow.
 
-Multisampling Anti-Aliasing, or MSAA for short, was developed as a much faster alternative; the computer renders as much of the image as possible without anti-aliasing, and then only applies anti-aliasing to the edges. It samples each pixel to find out where the edge is, and how to blend the colors to create a smooth edge. The numbered options in the ScummVM :doc:`../settings/graphics` tab (2x, 4x and 8x), refer to how many samples are taken. 8x MSAA produces a better image than 2x MSAA, but is also more GPU-intensive.
\ No newline at end of file
+Multisampling Anti-Aliasing, or MSAA for short, was developed as a much faster alternative; the computer renders as much of the image as possible without anti-aliasing, and then only applies anti-aliasing to the edges. It samples each pixel to find out where the edge is, and how to blend the colors to create a smooth edge. The numbered options in the ScummVM :doc:`../settings/graphics` tab (2x, 4x and 8x), refer to how many samples are taken. 8x MSAA produces a better image than 2x MSAA, but is also more GPU-intensive.




More information about the Scummvm-git-logs mailing list