Skip to content

Commit

Permalink
sdl, improve window resize handling
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Sep 10, 2024
1 parent 1909e86 commit 7f4bfa9
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 10 deletions.
2 changes: 2 additions & 0 deletions platform/common/menu_pico.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 16 additions & 6 deletions platform/common/plat_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
}
}
Expand Down
5 changes: 5 additions & 0 deletions platform/gp2x/plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion platform/libpicofe
Submodule libpicofe updated 4 files
+6 −1 input.c
+1 −0 plat.h
+9 −4 plat_sdl.c
+1 −0 plat_sdl.h
7 changes: 4 additions & 3 deletions platform/linux/emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ void pemu_forced_frame(int no_scale, int do_emu)

g_menubg_src_ptr = realloc(g_menubg_src_ptr, g_screen_height * g_screen_ppitch * 2);
memcpy(g_menubg_src_ptr, g_screen_ptr, g_screen_height * g_screen_ppitch * 2);
g_menubg_src_w = g_screen_width;
g_menubg_src_h = g_screen_height;
g_menubg_src_pp = g_screen_ppitch;

currentConfig.scaling = hs, currentConfig.vscaling = vs;
}

Expand Down Expand Up @@ -480,9 +484,6 @@ void pemu_loop_end(void)
/* do one more frame for menu bg */
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;
g_menubg_src_pp = g_screen_ppitch;
if (ghost_buf) {
free(ghost_buf);
ghost_buf = NULL;
Expand Down
4 changes: 4 additions & 0 deletions platform/pandora/plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ void plat_video_toggle_renderer(int change, int is_menu)
PicoDrawSetOutFormat(PDF_RGB555, 0);
}

void plat_video_menu_update(void)
{
}

void plat_video_menu_enter(int is_rom_loaded)
{
}
Expand Down
6 changes: 6 additions & 0 deletions platform/ps2/emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions platform/psp/plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 7f4bfa9

Please sign in to comment.