sdl, improve window resize handling
authorkub <derkub@gmail.com>
Tue, 10 Sep 2024 20:58:16 +0000 (22:58 +0200)
committerkub <derkub@gmail.com>
Tue, 10 Sep 2024 21:11:58 +0000 (23:11 +0200)
platform/common/menu_pico.c
platform/common/plat_sdl.c
platform/gp2x/plat.c
platform/libpicofe
platform/linux/emu.c
platform/pandora/plat.c
platform/ps2/emu.c
platform/psp/plat.c

index 415e1b5..5bf67b7 100644 (file)
@@ -156,6 +156,8 @@ static void copy_bg(int dir)
 
 static void menu_draw_prep(void)
 {
+       plat_video_menu_update();
+
        if (menu_w == g_menuscreen_w && menu_h == g_menuscreen_h)
                return;
        menu_w = g_menuscreen_w, menu_h = g_menuscreen_h;
index d1e833f..cdcaee7 100644 (file)
@@ -285,6 +285,19 @@ void plat_video_clear_buffers(void)
        }
 }
 
+void plat_video_menu_update(void)
+{
+       // w/h might have changed due to resizing
+       plat_sdl_change_video_mode(g_menuscreen_w, g_menuscreen_h, 1);
+       resize_buffers();
+
+       // update pitch as it is needed by the menu bg scaler
+       if (plat_sdl_overlay || plat_sdl_gl_active)
+               g_menuscreen_pp = g_menuscreen_w;
+       else
+               g_menuscreen_pp = plat_sdl_screen->pitch / 2;
+}
+
 void plat_video_menu_enter(int is_rom_loaded)
 {
        if (SDL_MUSTLOCK(plat_sdl_screen))
@@ -293,16 +306,13 @@ void plat_video_menu_enter(int is_rom_loaded)
 
 void plat_video_menu_begin(void)
 {
-       plat_sdl_change_video_mode(g_menuscreen_w, g_menuscreen_h, 1);
-       resize_buffers();
-       if (plat_sdl_overlay || plat_sdl_gl_active) {
-               g_menuscreen_pp = g_menuscreen_w;
+       plat_video_menu_update(); // just in case
+
+       if (plat_sdl_overlay || plat_sdl_gl_active)
                g_menuscreen_ptr = shadow_fb;
-       }
        else {
                if (SDL_MUSTLOCK(plat_sdl_screen))
                        SDL_LockSurface(plat_sdl_screen);
-               g_menuscreen_pp = plat_sdl_screen->pitch / 2;
                g_menuscreen_ptr = plat_sdl_screen->pixels;
        }
 }
index 96e9be0..422b4dd 100644 (file)
@@ -147,6 +147,11 @@ void gp2x_make_fb_bufferable(int yes)
 }
 
 /* common */
+void plat_video_menu_update(void)
+{
+       // surface is always the screen
+}
+
 void plat_video_menu_enter(int is_rom_loaded)
 {
        if (gp2x_current_bpp != 16 || gp2x_dev_id == GP2X_DEV_WIZ) {
index 9fba90a..fbbf5e3 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 9fba90ac323df5d2ad87735f6033ae720e5cb892
+Subproject commit fbbf5e3fc0aff858e206dd98ce4605b960d397cb
index 736fbb1..9c9d16c 100644 (file)
@@ -341,6 +341,10 @@ void pemu_forced_frame(int no_scale, int do_emu)
 \r
        g_menubg_src_ptr = realloc(g_menubg_src_ptr, g_screen_height * g_screen_ppitch * 2);\r
        memcpy(g_menubg_src_ptr, g_screen_ptr, g_screen_height * g_screen_ppitch * 2);\r
+       g_menubg_src_w = g_screen_width;\r
+       g_menubg_src_h = g_screen_height;\r
+       g_menubg_src_pp = g_screen_ppitch;\r
+\r
        currentConfig.scaling = hs, currentConfig.vscaling = vs;\r
 }\r
 \r
@@ -480,9 +484,6 @@ void pemu_loop_end(void)
        /* do one more frame for menu bg */\r
        plat_video_set_shadow(320, 240);\r
        pemu_forced_frame(0, 1);\r
-       g_menubg_src_w = g_screen_width;\r
-       g_menubg_src_h = g_screen_height;\r
-       g_menubg_src_pp = g_screen_ppitch;\r
        if (ghost_buf) {\r
                free(ghost_buf);\r
                ghost_buf = NULL;\r
index bb7774f..1f056c8 100644 (file)
@@ -199,6 +199,10 @@ void plat_video_toggle_renderer(int change, int is_menu)
                PicoDrawSetOutFormat(PDF_RGB555, 0);\r
 }\r
 \r
+void plat_video_menu_update(void)\r
+{\r
+}\r
+\r
 void plat_video_menu_enter(int is_rom_loaded)\r
 {\r
 }\r
index 09e13d2..cab389c 100644 (file)
@@ -868,6 +868,12 @@ void plat_video_wait_vsync(void)
        gsKit_sync(gsGlobal);
 }
 
+/* update surface data */
+void plat_video_menu_update(void)
+{
+       // surface is always the screen
+}
+
 /* switch from emulation display to menu display */
 void plat_video_menu_enter(int is_rom_loaded)
 {
index 53e1361..0548278 100644 (file)
@@ -98,6 +98,12 @@ void plat_video_wait_vsync(void)
        sceDisplayWaitVblankStart();
 }
 
+/* update surface data */
+void plat_video_menu_update(void)
+{
+       // surface is always the screen
+}
+
 /* switch from emulation display to menu display */
 void plat_video_menu_enter(int is_rom_loaded)
 {