Add integer scaling option (#2)

This patch adds option ‚3‘ integer scaling. dst_rect is an integral
multiple of src_rect. Should prevent scaling artifacts.
This commit is contained in:
Stefan 2016-07-14 21:12:29 +02:00 committed by Jools Wills
parent c1a44d38a0
commit ed92568fb6
2 changed files with 26 additions and 1 deletions

View file

@ -632,11 +632,15 @@ extern "C" {
* "1" - Requested video resolution will be scaled to desktop resolution. * "1" - Requested video resolution will be scaled to desktop resolution.
* Aspect ratio of requested video resolution will be respected. * Aspect ratio of requested video resolution will be respected.
* "2" - Requested video resolution will be scaled to desktop resolution. * "2" - Requested video resolution will be scaled to desktop resolution.
* "3" - Requested video resolution will be scaled to desktop resolution.
* Aspect ratio of requested video resolution will be respected.
* If possible output resolution will be integral multiple of video
* resolution.
*/ */
#define SDL_HINT_VIDEO_RPI_SCALE_MODE "SDL_VIDEO_RPI_SCALE_MODE" #define SDL_HINT_VIDEO_RPI_SCALE_MODE "SDL_VIDEO_RPI_SCALE_MODE"
/** /**
* \brief Tell dispmanx to set an specific aspect ratio. * \brief Tell dispmanx to set a specific aspect ratio.
* *
* This hint only applies to the rpi video driver. * This hint only applies to the rpi video driver.
* *

View file

@ -241,12 +241,33 @@ RPI_CreateWindow(_THIS, SDL_Window * window)
float srcAspect = 1; float srcAspect = 1;
float dstAspect = 1; float dstAspect = 1;
int factor_x = 0;
int factor_y = 0;
if (hintScale != NULL) if (hintScale != NULL)
scalemode = *hintScale; scalemode = *hintScale;
/* Create a dispman element and associate a window to it */ /* Create a dispman element and associate a window to it */
switch(scalemode) { switch(scalemode) {
case '3':
/* Pixel perfect scaling mode. */
factor_x = (display->desktop_mode.w / window->w);
factor_y = (display->desktop_mode.h / window->h);
if ((factor_x != 0) && (factor_y != 0)) {
if (factor_x >= factor_y) {
dst_rect.width = window->w * factor_y;
dst_rect.height = window->h * factor_y;
}
else {
dst_rect.width = window->w * factor_x;
dst_rect.height = window->h * factor_x;
}
/* Center window. */
dst_rect.x = (display->desktop_mode.w - dst_rect.width) / 2;
dst_rect.y = (display->desktop_mode.h - dst_rect.height) / 2;
break;
}
/* If integer scale is not possible fallback to mode 1. */
case '1': case '1':
/* Fullscreen mode. */ /* Fullscreen mode. */
/* Calculate source and destination aspect ratios. */ /* Calculate source and destination aspect ratios. */