From 21e209de05a7f4712a567eb83d98a887b9c33c20 Mon Sep 17 00:00:00 2001 From: Darren Alton Date: Wed, 4 Jul 2012 15:01:43 -0400 Subject: [PATCH] Add "scaled" and "pixelperfect" layer sizes. (notaz: adjusted coding style to keet it consistent) --- README.OMAP | 2 ++ src/video/omapdss/osdl_video.c | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.OMAP b/README.OMAP index ad662a3..1c04162 100644 --- a/README.OMAP +++ b/README.OMAP @@ -52,6 +52,8 @@ SDL_OMAP_LAYER_SIZE: Valid values: "WxH", for example "640x480" "fullscreen" to cover whole screen. + "scaled" to upscale the screen proportionally, letterboxing or pillarboxing. + "pixelperfect" to upscale by a whole-number factor (e.g. 2x or 3x size). SDL_OMAP_BORDER_CUT: This can be used to move parts of SDL surface out of screen, in other diff --git a/src/video/omapdss/osdl_video.c b/src/video/omapdss/osdl_video.c index b6abb93..f64f4e1 100644 --- a/src/video/omapdss/osdl_video.c +++ b/src/video/omapdss/osdl_video.c @@ -22,6 +22,8 @@ #include "linux/fbdev.h" #include "linux/xenv.h" +#define MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) + struct omapfb_state { struct omapfb_plane_info pi; struct omapfb_mem_info mi; @@ -300,13 +302,28 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, tmp = getenv("SDL_OMAP_LAYER_SIZE"); if (tmp != NULL) { - if (strcasecmp(tmp, "fullscreen") == 0) + if (strcasecmp(tmp, "fullscreen") == 0) { w = screen_w, h = screen_h; - else if (sscanf(tmp, "%dx%d", &tmp_w, &tmp_h) == 2) + } + else if (strcasecmp(tmp, "scaled") == 0) { + float factor = MIN(((float)screen_w) / width, ((float)screen_h) / height); + w = (int)(factor*width), h = (int)(factor*height); + } + else if (strcasecmp(tmp, "pixelperfect") == 0) { + float factor = MIN(((float)screen_w) / width, ((float)screen_h) / height); + w = ((int)factor) * width, h = ((int)factor) * height; + /* factor < 1.f => 0x0 layer, so fall back to 'scaled' */ + if (!w || !h) { + w = (int)(factor * width), h = (int)(factor * height); + } + } + else if (sscanf(tmp, "%dx%d", &tmp_w, &tmp_h) == 2) { w = tmp_w, h = tmp_h; - else + } + else { err("layer size specified incorrectly, " "should be like 800x480"); + } } /* the layer can't be set larger than screen */ -- 2.39.2