diff mbox

[12/19] vnc: factor out vnc_update_server_surface

Message ID 1446203414-4013-13-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann Oct. 30, 2015, 11:10 a.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

Comments

Daniel P. Berrangé Oct. 30, 2015, 12:22 p.m. UTC | #1
On Fri, Oct 30, 2015 at 12:10:07PM +0100, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  ui/vnc.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

Regards,
Daniel
diff mbox

Patch

diff --git a/ui/vnc.c b/ui/vnc.c
index 283b93c..61a8f2c 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -714,6 +714,17 @@  void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
     return ptr;
 }
 
+static void vnc_update_server_surface(VncDisplay *vd)
+{
+    qemu_pixman_image_unref(vd->server);
+    vd->server = NULL;
+
+    vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,
+                                          vnc_width(vd),
+                                          vnc_height(vd),
+                                          NULL, 0);
+}
+
 static void vnc_dpy_switch(DisplayChangeListener *dcl,
                            DisplaySurface *surface)
 {
@@ -722,19 +733,17 @@  static void vnc_dpy_switch(DisplayChangeListener *dcl,
     int width, height;
 
     vnc_abort_display_jobs(vd);
-
-    /* server surface */
-    qemu_pixman_image_unref(vd->server);
     vd->ds = surface;
-    width = vnc_width(vd);
-    height = vnc_height(vd);
-    vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,
-                                          width, height, NULL, 0);
+
+    /* server surface */
+    vnc_update_server_surface(vd);
 
     /* guest surface */
     qemu_pixman_image_unref(vd->guest.fb);
     vd->guest.fb = pixman_image_ref(surface->image);
     vd->guest.format = surface->format;
+    width = vnc_width(vd);
+    height = vnc_height(vd);
     memset(vd->guest.dirty, 0x00, sizeof(vd->guest.dirty));
     vnc_set_area_dirty(vd->guest.dirty, width, height, 0, 0,
                        width, height);