mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-20 00:22:02 -06:00
sdl2: add+use sdl2_2d_redraw function.
Add a new sdl2_2d_redraw function for a complete screen refresh, so we can stop using graphic_hw_invalidate for that. There is no need to bother console / gfx emulation code if we are just going to re-blit the screen after window resizes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
2c3056f182
commit
0d01b7ce61
3 changed files with 18 additions and 11 deletions
|
@ -25,5 +25,6 @@ void sdl2_2d_update(DisplayChangeListener *dcl,
|
||||||
int x, int y, int w, int h);
|
int x, int y, int w, int h);
|
||||||
void sdl2_2d_switch(DisplayChangeListener *dcl,
|
void sdl2_2d_switch(DisplayChangeListener *dcl,
|
||||||
DisplaySurface *new_surface);
|
DisplaySurface *new_surface);
|
||||||
|
void sdl2_2d_redraw(struct sdl2_console *scon);
|
||||||
|
|
||||||
#endif /* SDL2_H */
|
#endif /* SDL2_H */
|
||||||
|
|
11
ui/sdl2-2d.c
11
ui/sdl2-2d.c
|
@ -100,4 +100,15 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
surface_width(new_surface),
|
surface_width(new_surface),
|
||||||
surface_height(new_surface));
|
surface_height(new_surface));
|
||||||
|
sdl2_2d_redraw(scon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sdl2_2d_redraw(struct sdl2_console *scon)
|
||||||
|
{
|
||||||
|
if (!scon->surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sdl2_2d_update(&scon->dcl, 0, 0,
|
||||||
|
surface_width(scon->surface),
|
||||||
|
surface_height(scon->surface));
|
||||||
}
|
}
|
||||||
|
|
17
ui/sdl2.c
17
ui/sdl2.c
|
@ -316,8 +316,7 @@ static void toggle_full_screen(struct sdl2_console *scon)
|
||||||
}
|
}
|
||||||
SDL_SetWindowFullscreen(scon->real_window, 0);
|
SDL_SetWindowFullscreen(scon->real_window, 0);
|
||||||
}
|
}
|
||||||
graphic_hw_invalidate(scon->dcl.con);
|
sdl2_2d_redraw(scon);
|
||||||
graphic_hw_update(scon->dcl.con);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_keydown(SDL_Event *ev)
|
static void handle_keydown(SDL_Event *ev)
|
||||||
|
@ -365,8 +364,8 @@ static void handle_keydown(SDL_Event *ev)
|
||||||
case SDL_SCANCODE_U:
|
case SDL_SCANCODE_U:
|
||||||
sdl2_window_destroy(scon);
|
sdl2_window_destroy(scon);
|
||||||
sdl2_window_create(scon);
|
sdl2_window_create(scon);
|
||||||
graphic_hw_invalidate(scon->dcl.con);
|
/* re-create texture */
|
||||||
graphic_hw_update(scon->dcl.con);
|
sdl2_2d_switch(&scon->dcl, scon->surface);
|
||||||
gui_keysym = 1;
|
gui_keysym = 1;
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -385,8 +384,7 @@ static void handle_keydown(SDL_Event *ev)
|
||||||
fprintf(stderr, "%s: scale to %dx%d\n",
|
fprintf(stderr, "%s: scale to %dx%d\n",
|
||||||
__func__, width, height);
|
__func__, width, height);
|
||||||
sdl_scale(scon, width, height);
|
sdl_scale(scon, width, height);
|
||||||
graphic_hw_invalidate(NULL);
|
sdl2_2d_redraw(scon);
|
||||||
graphic_hw_update(NULL);
|
|
||||||
gui_keysym = 1;
|
gui_keysym = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -511,7 +509,6 @@ static void handle_mousewheel(SDL_Event *ev)
|
||||||
|
|
||||||
static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
|
static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
|
||||||
{
|
{
|
||||||
int w, h;
|
|
||||||
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
|
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
|
||||||
|
|
||||||
switch (ev->window.event) {
|
switch (ev->window.event) {
|
||||||
|
@ -523,12 +520,10 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
|
||||||
info.height = ev->window.data2;
|
info.height = ev->window.data2;
|
||||||
dpy_set_ui_info(scon->dcl.con, &info);
|
dpy_set_ui_info(scon->dcl.con, &info);
|
||||||
}
|
}
|
||||||
graphic_hw_invalidate(scon->dcl.con);
|
sdl2_2d_redraw(scon);
|
||||||
graphic_hw_update(scon->dcl.con);
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_EXPOSED:
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
SDL_GetWindowSize(SDL_GetWindowFromID(ev->window.windowID), &w, &h);
|
sdl2_2d_redraw(scon);
|
||||||
sdl2_2d_update(dcl, 0, 0, w, h);
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue