From 5aa5700685ef6b5cb05d8590023668761ff396f3 Mon Sep 17 00:00:00 2001 From: kub Date: Sun, 12 Feb 2023 22:51:44 +0000 Subject: [PATCH] platform sdl, fix minor bug in window size handling --- platform/common/plat_sdl.c | 27 +++++++++++++++++++++------ platform/linux/emu.c | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/platform/common/plat_sdl.c b/platform/common/plat_sdl.c index 24224ce4..de4b0549 100644 --- a/platform/common/plat_sdl.c +++ b/platform/common/plat_sdl.c @@ -161,6 +161,14 @@ void plat_video_set_size(int w, int h) } } +void plat_video_set_shadow(int w, int h) +{ + g_screen_width = w; + g_screen_height = h; + g_screen_ppitch = w; + g_screen_ptr = shadow_fb; +} + void plat_video_flip(void) { resize_buffers(); @@ -292,8 +300,13 @@ void plat_video_loop_prepare(void) // switch over to scaled output if available, but keep the aspect ratio if (plat_sdl_overlay || plat_sdl_gl_active) { - g_screen_width = (240 * g_menuscreen_w / g_menuscreen_h) & ~1; - g_screen_height = 240; + if (g_menuscreen_w * 240 >= g_menuscreen_h * 320) { + g_screen_width = (240 * g_menuscreen_w/g_menuscreen_h) & ~1; + g_screen_height= 240; + } else { + g_screen_width = 320; + g_screen_height= (320 * g_menuscreen_h/g_menuscreen_w) & ~1; + } g_screen_ppitch = g_screen_width; g_screen_ptr = shadow_fb; } @@ -317,10 +330,12 @@ void plat_early_init(void) static void plat_sdl_resize(int w, int h) { // take over new settings - g_menuscreen_h = plat_sdl_screen->h; - g_menuscreen_w = plat_sdl_screen->w; - resize_buffers(); - rendstatus_old = -1; + if (plat_sdl_screen->w != area.w || plat_sdl_screen->h != area.h) { + g_menuscreen_h = plat_sdl_screen->h; + g_menuscreen_w = plat_sdl_screen->w; + resize_buffers(); + rendstatus_old = -1; + } } static void plat_sdl_quit(void) diff --git a/platform/linux/emu.c b/platform/linux/emu.c index 746109b4..f4a1c51b 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -442,7 +442,7 @@ void pemu_loop_prep(void) void pemu_loop_end(void) { /* do one more frame for menu bg */ - plat_video_set_size(320, 240); + plat_video_set_shadow(320, 240); pemu_forced_frame(0, 1); g_menubg_src_w = g_screen_width; g_menubg_src_h = g_screen_height; -- 2.39.2