qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 08/12] sdl2: add+use sdl2_2d_redraw function.
Date: Fri, 19 Dec 2014 10:17:02 +0100	[thread overview]
Message-ID: <1418980626-22747-9-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1418980626-22747-1-git-send-email-kraxel@redhat.com>

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>
---
 include/ui/sdl2.h |  1 +
 ui/sdl2-2d.c      | 11 +++++++++++
 ui/sdl2.c         | 17 ++++++-----------
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index fd6bfdd..d0ce0b0 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -25,5 +25,6 @@ void sdl2_2d_update(DisplayChangeListener *dcl,
                     int x, int y, int w, int h);
 void sdl2_2d_switch(DisplayChangeListener *dcl,
                     DisplaySurface *new_surface);
+void sdl2_2d_redraw(struct sdl2_console *scon);
 
 #endif /* SDL2_H */
diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c
index 29ada53..40a552c 100644
--- a/ui/sdl2-2d.c
+++ b/ui/sdl2-2d.c
@@ -100,4 +100,15 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,
                                       SDL_TEXTUREACCESS_STREAMING,
                                       surface_width(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));
 }
diff --git a/ui/sdl2.c b/ui/sdl2.c
index eff9cb3..064f18a 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -316,8 +316,7 @@ static void toggle_full_screen(struct sdl2_console *scon)
         }
         SDL_SetWindowFullscreen(scon->real_window, 0);
     }
-    graphic_hw_invalidate(scon->dcl.con);
-    graphic_hw_update(scon->dcl.con);
+    sdl2_2d_redraw(scon);
 }
 
 static void handle_keydown(SDL_Event *ev)
@@ -365,8 +364,8 @@ static void handle_keydown(SDL_Event *ev)
         case SDL_SCANCODE_U:
             sdl2_window_destroy(scon);
             sdl2_window_create(scon);
-            graphic_hw_invalidate(scon->dcl.con);
-            graphic_hw_update(scon->dcl.con);
+            /* re-create texture */
+            sdl2_2d_switch(&scon->dcl, scon->surface);
             gui_keysym = 1;
             break;
 #if 0
@@ -385,8 +384,7 @@ static void handle_keydown(SDL_Event *ev)
                 fprintf(stderr, "%s: scale to %dx%d\n",
                         __func__, width, height);
                 sdl_scale(scon, width, height);
-                graphic_hw_invalidate(NULL);
-                graphic_hw_update(NULL);
+                sdl2_2d_redraw(scon);
                 gui_keysym = 1;
             }
 #endif
@@ -511,7 +509,6 @@ static void handle_mousewheel(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);
 
     switch (ev->window.event) {
@@ -523,12 +520,10 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
             info.height = ev->window.data2;
             dpy_set_ui_info(scon->dcl.con, &info);
         }
-        graphic_hw_invalidate(scon->dcl.con);
-        graphic_hw_update(scon->dcl.con);
+        sdl2_2d_redraw(scon);
         break;
     case SDL_WINDOWEVENT_EXPOSED:
-        SDL_GetWindowSize(SDL_GetWindowFromID(ev->window.windowID), &w, &h);
-        sdl2_2d_update(dcl, 0, 0, w, h);
+        sdl2_2d_redraw(scon);
         break;
     case SDL_WINDOWEVENT_FOCUS_GAINED:
     case SDL_WINDOWEVENT_ENTER:
-- 
1.8.3.1

  parent reply	other threads:[~2014-12-19  9:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19  9:16 [Qemu-devel] [PULL 00/12] sdl2: fixes, cleanups and opengl preparation Gerd Hoffmann
2014-12-19  9:16 ` [Qemu-devel] [PULL 01/12] sdl: move version logic from source code to makefile Gerd Hoffmann
2014-12-19  9:16 ` [Qemu-devel] [PULL 02/12] sdl2: rename sdl2_state to sdl2_console, move to header file Gerd Hoffmann
2014-12-19  9:16 ` [Qemu-devel] [PULL 03/12] sdl2: move keyboard input code to new sdl2-input.c Gerd Hoffmann
2014-12-19  9:16 ` [Qemu-devel] [PULL 04/12] sdl2: turn on keyboard grabs Gerd Hoffmann
2014-12-19  9:16 ` [Qemu-devel] [PULL 05/12] sdl2: move sdl_update to new sdl2-2d.c Gerd Hoffmann
2014-12-19  9:17 ` [Qemu-devel] [PULL 06/12] sdl2: overhaul window size handling Gerd Hoffmann
2014-12-19  9:17 ` [Qemu-devel] [PULL 07/12] sdl2: move sdl_switch to sdl2-2d.c Gerd Hoffmann
2014-12-19  9:17 ` Gerd Hoffmann [this message]
2014-12-19  9:17 ` [Qemu-devel] [PULL 09/12] sdl2: factor out sdl2_poll_events Gerd Hoffmann
2014-12-19  9:17 ` [Qemu-devel] [PULL 10/12] sdl2: move sdl2_2d_refresh to sdl2-2d.c Gerd Hoffmann
2014-12-19  9:17 ` [Qemu-devel] [PULL 11/12] sdl2: Use correct sdl2_console for window events Gerd Hoffmann
2014-12-19  9:17 ` [Qemu-devel] [PULL 12/12] sdl2: Work around SDL2 SDL_ShowWindow() bug Gerd Hoffmann
2014-12-22 10:57 ` [Qemu-devel] [PULL 00/12] sdl2: fixes, cleanups and opengl preparation Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418980626-22747-9-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).