From: notaz Date: Tue, 22 Nov 2011 23:07:50 +0000 (+0200) Subject: adjust default layer size to fit screen X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=sdl_omap.git;a=commitdiff_plain;h=f151701dfcb28c9ce6adb5f5c8c89a97d74a5076 adjust default layer size to fit screen --- diff --git a/src/video/omapdss/osdl_video.c b/src/video/omapdss/osdl_video.c index ee4c95a..d00b6b9 100644 --- a/src/video/omapdss/osdl_video.c +++ b/src/video/omapdss/osdl_video.c @@ -224,6 +224,7 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, { int x = 0, y = 0, w = width, h = height; /* layer size and pos */ int screen_w = w, screen_h = h; + int tmp_w, tmp_h; const char *tmp; int ret, fd; @@ -262,15 +263,24 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, tmp = getenv("SDL_OMAP_LAYER_SIZE"); if (tmp != NULL) { - int w_, h_; if (strcasecmp(tmp, "fullscreen") == 0) w = screen_w, h = screen_h; - else if (sscanf(tmp, "%dx%d", &w_, &h_) == 2) - w = w_, h = h_; + else if (sscanf(tmp, "%dx%d", &tmp_w, &tmp_h) == 2) + w = tmp_w, h = tmp_h; else err("layer size specified incorrectly, " "should be like 800x480"); } + else { + /* the layer can't be set larger than screen */ + tmp_w = w, tmp_h = h; + if (w > screen_w) + w = screen_w; + if (h > screen_h) + h = screen_h; + if (w != tmp_w || h != tmp_h) + log("layer resized %dx%d -> %dx%d to fit screen", tmp_w, tmp_h, w, h); + } x = screen_w / 2 - w / 2; y = screen_h / 2 - h / 2;