9ae3a8
From 9730b328cc524281334344466a01fb861b271b82 Mon Sep 17 00:00:00 2001
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Date: Wed, 22 Feb 2017 12:36:22 +0100
9ae3a8
Subject: [PATCH 04/24] ui/vnc: optimize setting in vnc_dpy_update()
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Message-id: <1487766986-6329-5-git-send-email-kraxel@redhat.com>
9ae3a8
Patchwork-id: 73974
9ae3a8
O-Subject: [RHEL-7.4 qemu-kvm PATCH 4/8] ui/vnc: optimize setting in vnc_dpy_update()
9ae3a8
Bugzilla: 1377977
9ae3a8
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9ae3a8
RH-Acked-by: Marc-André Lureau <mlureau@redhat.com>
9ae3a8
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
9ae3a8
9ae3a8
From: Peter Lieven <pl@kamp.de>
9ae3a8
9ae3a8
Signed-off-by: Peter Lieven <pl@kamp.de>
9ae3a8
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
(cherry picked from commit 919372251cbfa9e43b0264fec475dd1eca23784f)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 ui/vnc.c | 16 +++++-----------
9ae3a8
 1 file changed, 5 insertions(+), 11 deletions(-)
9ae3a8
9ae3a8
diff --git a/ui/vnc.c b/ui/vnc.c
9ae3a8
index 54530a2..2540261 100644
9ae3a8
--- a/ui/vnc.c
9ae3a8
+++ b/ui/vnc.c
9ae3a8
@@ -430,30 +430,24 @@ static int vnc_refresh_server_surface(VncDisplay *vd);
9ae3a8
 static void vnc_dpy_update(DisplayChangeListener *dcl,
9ae3a8
                            int x, int y, int w, int h)
9ae3a8
 {
9ae3a8
-    int i;
9ae3a8
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
9ae3a8
     struct VncSurface *s = &vd->guest;
9ae3a8
     int width = surface_width(vd->ds);
9ae3a8
     int height = surface_height(vd->ds);
9ae3a8
 
9ae3a8
-    h += y;
9ae3a8
-
9ae3a8
-    /* round x down to ensure the loop only spans one 16-pixel block per,
9ae3a8
-       iteration.  otherwise, if (x % 16) != 0, the last iteration may span
9ae3a8
-       two 16-pixel blocks but we only mark the first as dirty
9ae3a8
-    */
9ae3a8
+    /* this is needed this to ensure we updated all affected
9ae3a8
+     * blocks if x % VNC_DIRTY_PIXELS_PER_BIT != 0 */
9ae3a8
     w += (x % VNC_DIRTY_PIXELS_PER_BIT);
9ae3a8
     x -= (x % VNC_DIRTY_PIXELS_PER_BIT);
9ae3a8
 
9ae3a8
     x = MIN(x, width);
9ae3a8
     y = MIN(y, height);
9ae3a8
     w = MIN(x + w, width) - x;
9ae3a8
-    h = MIN(h, height);
9ae3a8
+    h = MIN(y + h, height);
9ae3a8
 
9ae3a8
     for (; y < h; y++) {
9ae3a8
-        for (i = 0; i < w; i += VNC_DIRTY_PIXELS_PER_BIT) {
9ae3a8
-            set_bit((x + i) / VNC_DIRTY_PIXELS_PER_BIT, s->dirty[y]);
9ae3a8
-        }
9ae3a8
+        bitmap_set(s->dirty[y], x / VNC_DIRTY_PIXELS_PER_BIT,
9ae3a8
+                   DIV_ROUND_UP(w, VNC_DIRTY_PIXELS_PER_BIT));
9ae3a8
     }
9ae3a8
 }
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8