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 <kra...@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


Reply via email to