- if (!scon->texture) {
- return;
- }
-
- rect.x = x;
- rect.y = y;
- rect.w = w;
- rect.h = h;
-
- SDL_UpdateTexture(scon->texture, NULL, surface_data(surf),
- surface_stride(surf));
- SDL_RenderCopy(scon->real_renderer, scon->texture, &rect, &rect);
- SDL_RenderPresent(scon->real_renderer);
-}
-
-static void do_sdl_resize(struct sdl2_state *scon, int width, int height,
- int bpp)
-{
- int flags;
-
- if (scon->real_window && scon->real_renderer) {
- if (width && height) {
- SDL_RenderSetLogicalSize(scon->real_renderer, width, height);
- SDL_SetWindowSize(scon->real_window, width, height);
- } else {
- SDL_DestroyRenderer(scon->real_renderer);
- SDL_DestroyWindow(scon->real_window);
- scon->real_renderer = NULL;
- scon->real_window = NULL;
- }
- } else {
- if (!width || !height) {
- return;
- }
- flags = 0;
- if (gui_fullscreen) {
- flags |= SDL_WINDOW_FULLSCREEN;
- } else {
- flags |= SDL_WINDOW_RESIZABLE;
- }
-
- scon->real_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
- SDL_WINDOWPOS_UNDEFINED,
- width, height, flags);
- scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
- sdl_update_caption(scon);
- }
-}
-
-static void sdl_switch(DisplayChangeListener *dcl,
- DisplaySurface *new_surface)
-{
- struct sdl2_state *scon = container_of(dcl, struct sdl2_state, dcl);
- int format = 0;
- int idx = scon->idx;
- DisplaySurface *old_surface = scon->surface;
-
- /* temporary hack: allows to call sdl_switch to handle scaling changes */
- if (new_surface) {
- scon->surface = new_surface;
- }
-
- if (!new_surface && idx > 0) {
- scon->surface = NULL;
- }