qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [RfC PATCH 08/12] console: rework DisplaySurface handling [dcl/ui side]
Date: Fri,  1 Mar 2013 10:00:39 +0100	[thread overview]
Message-ID: <1362128443-15687-9-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1362128443-15687-1-git-send-email-kraxel@redhat.com>

Replace the dpy_gfx_resize and dpy_gfx_setdata DisplayChangeListener
callbacks with a dpy_gfx_switch callback which notifies the ui code
when the framebuffer backing storage changes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qxl.c                   |    9 +++++----
 include/ui/console.h       |    7 +++----
 include/ui/spice-display.h |    3 ++-
 ui/console.c               |    8 ++++----
 ui/gtk.c                   |   15 ++++++++-------
 ui/sdl.c                   |   10 +++++-----
 ui/spice-display.c         |   12 +++++++-----
 ui/vnc.c                   |   21 +++++----------------
 8 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index 8177008..1ec03a5 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1875,13 +1875,14 @@ static void display_update(DisplayChangeListener *dcl,
     }
 }
 
-static void display_resize(DisplayChangeListener *dcl,
-                           struct DisplayState *ds)
+static void display_switch(DisplayChangeListener *dcl,
+                           struct DisplayState *ds,
+                           struct DisplaySurface *surface)
 {
     PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
 
     if (qxl->mode == QXL_MODE_VGA) {
-        qemu_spice_display_resize(&qxl->ssd);
+        qemu_spice_display_switch(&qxl->ssd, surface);
     }
 }
 
@@ -1902,7 +1903,7 @@ static void display_refresh(DisplayChangeListener *dcl,
 static DisplayChangeListenerOps display_listener_ops = {
     .dpy_name        = "spice/qxl",
     .dpy_gfx_update  = display_update,
-    .dpy_gfx_resize  = display_resize,
+    .dpy_gfx_switch  = display_switch,
     .dpy_refresh     = display_refresh,
 };
 
diff --git a/include/ui/console.h b/include/ui/console.h
index bbf3b1d..f15a541 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -156,10 +156,9 @@ typedef struct DisplayChangeListenerOps {
     void (*dpy_gfx_update)(DisplayChangeListener *dcl,
                            struct DisplayState *s,
                            int x, int y, int w, int h);
-    void (*dpy_gfx_resize)(DisplayChangeListener *dcl,
-                           struct DisplayState *s);
-    void (*dpy_gfx_setdata)(DisplayChangeListener *dcl,
-                            struct DisplayState *s);
+    void (*dpy_gfx_switch)(DisplayChangeListener *dcl,
+                           struct DisplayState *s,
+                           struct DisplaySurface *new_surface);
     void (*dpy_gfx_copy)(DisplayChangeListener *dcl,
                          struct DisplayState *s, int src_x, int src_y,
                          int dst_x, int dst_y, int w, int h);
diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h
index f2752aa..82f8246 100644
--- a/include/ui/spice-display.h
+++ b/include/ui/spice-display.h
@@ -117,7 +117,8 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds);
 
 void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
                                int x, int y, int w, int h);
-void qemu_spice_display_resize(SimpleSpiceDisplay *ssd);
+void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
+                               DisplaySurface *surface);
 void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd);
 void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd);
 
diff --git a/ui/console.c b/ui/console.c
index 54c7bf3..461cda8 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1372,8 +1372,8 @@ void register_displaychangelistener(DisplayState *ds,
     dcl->ds = ds;
     QLIST_INSERT_HEAD(&ds->listeners, dcl, next);
     gui_setup_refresh(ds);
-    if (dcl->ops->dpy_gfx_resize) {
-        dcl->ops->dpy_gfx_resize(dcl, ds);
+    if (dcl->ops->dpy_gfx_switch) {
+        dcl->ops->dpy_gfx_switch(dcl, ds, ds->surface);
     }
 }
 
@@ -1413,8 +1413,8 @@ void dpy_gfx_replace_surface(DisplayState *s,
 
     s->surface = surface;
     QLIST_FOREACH(dcl, &s->listeners, next) {
-        if (dcl->ops->dpy_gfx_resize) {
-            dcl->ops->dpy_gfx_resize(dcl, s);
+        if (dcl->ops->dpy_gfx_switch) {
+            dcl->ops->dpy_gfx_switch(dcl, s, surface);
         }
     }
     qemu_free_displaysurface(old_surface);
diff --git a/ui/gtk.c b/ui/gtk.c
index fe58494..abef1ca 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -266,8 +266,9 @@ static void gd_refresh(DisplayChangeListener *dcl,
     vga_hw_update();
 }
 
-static void gd_resize(DisplayChangeListener *dcl,
-                      DisplayState *ds)
+static void gd_switch(DisplayChangeListener *dcl,
+                      DisplayState *ds,
+                      DisplaySurface *surface)
 {
     GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
     cairo_format_t kind;
@@ -738,7 +739,7 @@ static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
     s->scale_x += .25;
     s->scale_y += .25;
 
-    gd_resize(&s->dcl, s->ds);
+    gd_switch(&s->dcl, s->ds, s->ds->surface);
 }
 
 static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
@@ -754,7 +755,7 @@ static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
     s->scale_x = MAX(s->scale_x, .25);
     s->scale_y = MAX(s->scale_y, .25);
 
-    gd_resize(&s->dcl, s->ds);
+    gd_switch(&s->dcl, s->ds, s->ds->surface);
 }
 
 static void gd_menu_zoom_fixed(GtkMenuItem *item, void *opaque)
@@ -764,7 +765,7 @@ static void gd_menu_zoom_fixed(GtkMenuItem *item, void *opaque)
     s->scale_x = 1.0;
     s->scale_y = 1.0;
 
-    gd_resize(&s->dcl, s->ds);
+    gd_switch(&s->dcl, s->ds, s->ds->surface);
 }
 
 static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque)
@@ -778,7 +779,7 @@ static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque)
         s->free_scale = FALSE;
     }
 
-    gd_resize(&s->dcl, s->ds);
+    gd_switch(&s->dcl, s->ds, s->ds->surface);
 
     gdk_drawable_get_size(gtk_widget_get_window(s->drawing_area), &ww, &wh);
     gtk_widget_queue_draw_area(s->drawing_area, 0, 0, ww, wh);
@@ -1287,7 +1288,7 @@ static void gd_create_menus(GtkDisplayState *s)
 static const DisplayChangeListenerOps dcl_ops = {
     .dpy_name          = "gtk",
     .dpy_gfx_update    = gd_update,
-    .dpy_gfx_resize    = gd_resize,
+    .dpy_gfx_switch    = gd_switch,
     .dpy_refresh       = gd_refresh,
 };
 
diff --git a/ui/sdl.c b/ui/sdl.c
index fc4dc1b..85eefdf 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -117,8 +117,9 @@ static void do_sdl_resize(int width, int height, int bpp)
     }
 }
 
-static void sdl_resize(DisplayChangeListener *dcl,
-                       DisplayState *ds)
+static void sdl_switch(DisplayChangeListener *dcl,
+                       DisplayState *ds,
+                       DisplaySurface *surface)
 {
     if (!scaling_active) {
         do_sdl_resize(ds_get_width(ds), ds_get_height(ds), 0);
@@ -513,7 +514,7 @@ static void handle_keydown(DisplayState *ds, SDL_Event *ev)
         case 0x16: /* 'u' key on US keyboard */
             if (scaling_active) {
                 scaling_active = 0;
-                sdl_resize(dcl, ds);
+                sdl_switch(dcl, ds, ds->surface);
                 vga_hw_invalidate();
                 vga_hw_update();
             }
@@ -856,9 +857,8 @@ static void sdl_cleanup(void)
 static const DisplayChangeListenerOps dcl_ops = {
     .dpy_name          = "sdl",
     .dpy_gfx_update    = sdl_update,
-    .dpy_gfx_resize    = sdl_resize,
+    .dpy_gfx_switch    = sdl_switch,
     .dpy_refresh       = sdl_refresh,
-    .dpy_gfx_setdata   = sdl_setdata,
     .dpy_mouse_set     = sdl_mouse_warp,
     .dpy_cursor_define = sdl_mouse_define,
 };
diff --git a/ui/spice-display.c b/ui/spice-display.c
index b2bda23..cc2a78e 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -367,7 +367,8 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
     qemu_spice_rect_union(&ssd->dirty, &update_area);
 }
 
-void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
+void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
+                               DisplaySurface *surface)
 {
     SimpleSpiceUpdate *update;
 
@@ -589,11 +590,12 @@ static void display_update(DisplayChangeListener *dcl,
     qemu_spice_display_update(ssd, x, y, w, h);
 }
 
-static void display_resize(DisplayChangeListener *dcl,
-                           struct DisplayState *ds)
+static void display_switch(DisplayChangeListener *dcl,
+                           struct DisplayState *ds,
+                           struct DisplaySurface *surface)
 {
     SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
-    qemu_spice_display_resize(ssd);
+    qemu_spice_display_switch(ssd, surface);
 }
 
 static void display_refresh(DisplayChangeListener *dcl,
@@ -606,7 +608,7 @@ static void display_refresh(DisplayChangeListener *dcl,
 static const DisplayChangeListenerOps display_listener_ops = {
     .dpy_name        = "spice",
     .dpy_gfx_update  = display_update,
-    .dpy_gfx_resize  = display_resize,
+    .dpy_gfx_switch  = display_switch,
     .dpy_refresh     = display_refresh,
 };
 
diff --git a/ui/vnc.c b/ui/vnc.c
index a6111d6..f8398c3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -574,8 +574,9 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
     return ptr;
 }
 
-static void vnc_dpy_resize(DisplayChangeListener *dcl,
-                           DisplayState *ds)
+static void vnc_dpy_switch(DisplayChangeListener *dcl,
+                           DisplayState *ds,
+                           DisplaySurface *surface)
 {
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
     VncState *vs;
@@ -1981,17 +1982,6 @@ static void pixel_format_message (VncState *vs) {
     vs->write_pixels = vnc_write_pixels_copy;
 }
 
-static void vnc_dpy_setdata(DisplayChangeListener *dcl,
-                            DisplayState *ds)
-{
-    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
-
-    qemu_pixman_image_unref(vd->guest.fb);
-    vd->guest.fb = pixman_image_ref(ds->surface->image);
-    vd->guest.format = ds->surface->format;
-    vnc_dpy_update(dcl, ds, 0, 0, ds_get_width(ds), ds_get_height(ds));
-}
-
 static void vnc_colordepth(VncState *vs)
 {
     if (vnc_has_feature(vs, VNC_FEATURE_WMVI)) {
@@ -2696,7 +2686,7 @@ static void vnc_init_timer(VncDisplay *vd)
     vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
     if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) {
         vd->timer = qemu_new_timer_ms(rt_clock, vnc_refresh, vd);
-        vnc_dpy_resize(&vd->dcl, vd->ds);
+        vnc_dpy_switch(&vd->dcl, vd->ds, vd->ds->surface);
         vnc_refresh(vd);
     }
 }
@@ -2836,8 +2826,7 @@ static const DisplayChangeListenerOps dcl_ops = {
     .dpy_name          = "vnc",
     .dpy_gfx_copy      = vnc_dpy_copy,
     .dpy_gfx_update    = vnc_dpy_update,
-    .dpy_gfx_resize    = vnc_dpy_resize,
-    .dpy_gfx_setdata   = vnc_dpy_setdata,
+    .dpy_gfx_switch    = vnc_dpy_switch,
     .dpy_mouse_set     = vnc_mouse_set,
     .dpy_cursor_define = vnc_dpy_cursor_define,
 };
-- 
1.7.9.7

  parent reply	other threads:[~2013-03-01  9:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-01  9:00 [Qemu-devel] [RfC PATCH 00/12] console/display: cleanup & untangle data structures Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 01/12] console: fix displaychangelisteners interface Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 02/12] console: kill DisplayState->opaque Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 03/12] spice: zap sdpy global Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 04/12] qxl: zap qxl0 global Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 05/12] qxl: better vga init in enter_vga_mode Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 06/12] sdl: drop dead code Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 07/12] console: rework DisplaySurface handling [vga emu side] Gerd Hoffmann
2013-03-01  9:00 ` Gerd Hoffmann [this message]
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 09/12] console: add surface_*() getters Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 10/12] gtk: stop using DisplayState Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 11/12] vnc: " Gerd Hoffmann
2013-03-01  9:00 ` [Qemu-devel] [RfC PATCH 12/12] sdl: " Gerd Hoffmann

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=1362128443-15687-9-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@us.ibm.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).