4ec855
From 1b209dbf4eba1f7cdd456a809a2a8576e66a1464 Mon Sep 17 00:00:00 2001
4ec855
From: Gerd Hoffmann <kraxel@redhat.com>
4ec855
Date: Tue, 13 Aug 2019 11:20:45 +0100
4ec855
Subject: [PATCH 01/10] vnc: detect and optimize pageflips
4ec855
MIME-Version: 1.0
4ec855
Content-Type: text/plain; charset=UTF-8
4ec855
Content-Transfer-Encoding: 8bit
4ec855
4ec855
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
4ec855
Message-id: <20190813112045.3887-2-kraxel@redhat.com>
4ec855
Patchwork-id: 89956
4ec855
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/1] vnc: detect and optimize pageflips
4ec855
Bugzilla: 1727033
4ec855
RH-Acked-by: John Snow <jsnow@redhat.com>
4ec855
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4ec855
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4ec855
4ec855
When size and format of the display surface stays the same we can just
4ec855
tag the guest display as dirty and be done with it.
4ec855
4ec855
There is no need need to resize the vnc server display or to touch the
4ec855
vnc client dirty bits.  On the next refresh cycle
4ec855
vnc_refresh_server_surface() will check for actual display content
4ec855
changes and update the client dirty bits as needed.
4ec855
4ec855
The desktop resize and framebuffer format notifications to the vnc
4ec855
client will be skipped too.
4ec855
4ec855
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4ec855
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4ec855
Message-id: 20190116101049.8929-1-kraxel@redhat.com
4ec855
(cherry picked from commit 61e77a5f0c788495566aecb437bcf6b2cf9cda97)
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 ui/vnc.c | 25 ++++++++++++++++++++++---
4ec855
 1 file changed, 22 insertions(+), 3 deletions(-)
4ec855
4ec855
diff --git a/ui/vnc.c b/ui/vnc.c
4ec855
index 86c6762..0bd44f1 100644
4ec855
--- a/ui/vnc.c
4ec855
+++ b/ui/vnc.c
4ec855
@@ -743,6 +743,17 @@ static void vnc_update_server_surface(VncDisplay *vd)
4ec855
                        width, height);
4ec855
 }
4ec855
 
4ec855
+static bool vnc_check_pageflip(DisplaySurface *s1,
4ec855
+                               DisplaySurface *s2)
4ec855
+{
4ec855
+    return (s1 != NULL &&
4ec855
+            s2 != NULL &&
4ec855
+            surface_width(s1) == surface_width(s2) &&
4ec855
+            surface_height(s1) == surface_height(s2) &&
4ec855
+            surface_format(s1) == surface_format(s2));
4ec855
+
4ec855
+}
4ec855
+
4ec855
 static void vnc_dpy_switch(DisplayChangeListener *dcl,
4ec855
                            DisplaySurface *surface)
4ec855
 {
4ec855
@@ -750,6 +761,7 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
4ec855
         "Display output is not active.";
4ec855
     static DisplaySurface *placeholder;
4ec855
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
4ec855
+    bool pageflip = vnc_check_pageflip(vd->ds, surface);
4ec855
     VncState *vs;
4ec855
 
4ec855
     if (surface == NULL) {
4ec855
@@ -762,14 +774,21 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
4ec855
     vnc_abort_display_jobs(vd);
4ec855
     vd->ds = surface;
4ec855
 
4ec855
-    /* server surface */
4ec855
-    vnc_update_server_surface(vd);
4ec855
-
4ec855
     /* guest surface */
4ec855
     qemu_pixman_image_unref(vd->guest.fb);
4ec855
     vd->guest.fb = pixman_image_ref(surface->image);
4ec855
     vd->guest.format = surface->format;
4ec855
 
4ec855
+    if (pageflip) {
4ec855
+        vnc_set_area_dirty(vd->guest.dirty, vd, 0, 0,
4ec855
+                           surface_width(surface),
4ec855
+                           surface_height(surface));
4ec855
+        return;
4ec855
+    }
4ec855
+
4ec855
+    /* server surface */
4ec855
+    vnc_update_server_surface(vd);
4ec855
+
4ec855
     QTAILQ_FOREACH(vs, &vd->clients, next) {
4ec855
         vnc_colordepth(vs);
4ec855
         vnc_desktop_resize(vs);
4ec855
-- 
4ec855
1.8.3.1
4ec855