Blame SOURCES/kvm-ui-remove-redundant-indentation-in-vnc_client_update.patch

9bac43
From aefded16955d95827bab7b8145388b6de872da38 Mon Sep 17 00:00:00 2001
9bac43
From: "Daniel P. Berrange" <berrange@redhat.com>
9bac43
Date: Mon, 5 Feb 2018 11:10:00 +0100
9bac43
Subject: [PATCH 06/20] ui: remove redundant indentation in vnc_client_update
9bac43
MIME-Version: 1.0
9bac43
Content-Type: text/plain; charset=UTF-8
9bac43
Content-Transfer-Encoding: 8bit
9bac43
9bac43
RH-Author: Daniel P. Berrange <berrange@redhat.com>
9bac43
Message-id: <20180205111012.6210-6-berrange@redhat.com>
9bac43
Patchwork-id: 78876
9bac43
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 05/17] ui: remove redundant indentation in vnc_client_update
9bac43
Bugzilla: 1527404
9bac43
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9bac43
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9bac43
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9bac43
9bac43
From: "Daniel P. Berrange" <berrange@redhat.com>
9bac43
9bac43
Now that previous dead / unreachable code has been removed, we can simplify
9bac43
the indentation in the vnc_client_update method.
9bac43
9bac43
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9bac43
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
9bac43
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9bac43
Message-id: 20171218191228.31018-4-berrange@redhat.com
9bac43
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9bac43
(cherry picked from commit b939eb89b6f320544a9328fa908d881d0024c1ee)
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 ui/vnc.c | 112 ++++++++++++++++++++++++++++++++-------------------------------
9bac43
 1 file changed, 57 insertions(+), 55 deletions(-)
9bac43
9bac43
diff --git a/ui/vnc.c b/ui/vnc.c
9bac43
index 1d2b3a8..2a2e47c 100644
9bac43
--- a/ui/vnc.c
9bac43
+++ b/ui/vnc.c
9bac43
@@ -963,74 +963,76 @@ static int find_and_clear_dirty_height(VncState *vs,
9bac43
 
9bac43
 static int vnc_update_client(VncState *vs, int has_dirty)
9bac43
 {
9bac43
+    VncDisplay *vd = vs->vd;
9bac43
+    VncJob *job;
9bac43
+    int y;
9bac43
+    int height, width;
9bac43
+    int n = 0;
9bac43
+
9bac43
     if (vs->disconnecting) {
9bac43
         vnc_disconnect_finish(vs);
9bac43
         return 0;
9bac43
     }
9bac43
 
9bac43
     vs->has_dirty += has_dirty;
9bac43
-    if (vs->need_update) {
9bac43
-        VncDisplay *vd = vs->vd;
9bac43
-        VncJob *job;
9bac43
-        int y;
9bac43
-        int height, width;
9bac43
-        int n = 0;
9bac43
-
9bac43
-        if (vs->output.offset && !vs->audio_cap && !vs->force_update)
9bac43
-            /* kernel send buffers are full -> drop frames to throttle */
9bac43
-            return 0;
9bac43
+    if (!vs->need_update) {
9bac43
+        return 0;
9bac43
+    }
9bac43
 
9bac43
-        if (!vs->has_dirty && !vs->audio_cap && !vs->force_update)
9bac43
-            return 0;
9bac43
+    if (vs->output.offset && !vs->audio_cap && !vs->force_update) {
9bac43
+        /* kernel send buffers are full -> drop frames to throttle */
9bac43
+        return 0;
9bac43
+    }
9bac43
 
9bac43
-        /*
9bac43
-         * Send screen updates to the vnc client using the server
9bac43
-         * surface and server dirty map.  guest surface updates
9bac43
-         * happening in parallel don't disturb us, the next pass will
9bac43
-         * send them to the client.
9bac43
-         */
9bac43
-        job = vnc_job_new(vs);
9bac43
-
9bac43
-        height = pixman_image_get_height(vd->server);
9bac43
-        width = pixman_image_get_width(vd->server);
9bac43
-
9bac43
-        y = 0;
9bac43
-        for (;;) {
9bac43
-            int x, h;
9bac43
-            unsigned long x2;
9bac43
-            unsigned long offset = find_next_bit((unsigned long *) &vs->dirty,
9bac43
-                                                 height * VNC_DIRTY_BPL(vs),
9bac43
-                                                 y * VNC_DIRTY_BPL(vs));
9bac43
-            if (offset == height * VNC_DIRTY_BPL(vs)) {
9bac43
-                /* no more dirty bits */
9bac43
+    if (!vs->has_dirty && !vs->audio_cap && !vs->force_update) {
9bac43
+        return 0;
9bac43
+    }
9bac43
+
9bac43
+    /*
9bac43
+     * Send screen updates to the vnc client using the server
9bac43
+     * surface and server dirty map.  guest surface updates
9bac43
+     * happening in parallel don't disturb us, the next pass will
9bac43
+     * send them to the client.
9bac43
+     */
9bac43
+    job = vnc_job_new(vs);
9bac43
+
9bac43
+    height = pixman_image_get_height(vd->server);
9bac43
+    width = pixman_image_get_width(vd->server);
9bac43
+
9bac43
+    y = 0;
9bac43
+    for (;;) {
9bac43
+        int x, h;
9bac43
+        unsigned long x2;
9bac43
+        unsigned long offset = find_next_bit((unsigned long *) &vs->dirty,
9bac43
+                                             height * VNC_DIRTY_BPL(vs),
9bac43
+                                             y * VNC_DIRTY_BPL(vs));
9bac43
+        if (offset == height * VNC_DIRTY_BPL(vs)) {
9bac43
+            /* no more dirty bits */
9bac43
+            break;
9bac43
+        }
9bac43
+        y = offset / VNC_DIRTY_BPL(vs);
9bac43
+        x = offset % VNC_DIRTY_BPL(vs);
9bac43
+        x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y],
9bac43
+                                VNC_DIRTY_BPL(vs), x);
9bac43
+        bitmap_clear(vs->dirty[y], x, x2 - x);
9bac43
+        h = find_and_clear_dirty_height(vs, y, x, x2, height);
9bac43
+        x2 = MIN(x2, width / VNC_DIRTY_PIXELS_PER_BIT);
9bac43
+        if (x2 > x) {
9bac43
+            n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y,
9bac43
+                                  (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h);
9bac43
+        }
9bac43
+        if (!x && x2 == width / VNC_DIRTY_PIXELS_PER_BIT) {
9bac43
+            y += h;
9bac43
+            if (y == height) {
9bac43
                 break;
9bac43
             }
9bac43
-            y = offset / VNC_DIRTY_BPL(vs);
9bac43
-            x = offset % VNC_DIRTY_BPL(vs);
9bac43
-            x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y],
9bac43
-                                    VNC_DIRTY_BPL(vs), x);
9bac43
-            bitmap_clear(vs->dirty[y], x, x2 - x);
9bac43
-            h = find_and_clear_dirty_height(vs, y, x, x2, height);
9bac43
-            x2 = MIN(x2, width / VNC_DIRTY_PIXELS_PER_BIT);
9bac43
-            if (x2 > x) {
9bac43
-                n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y,
9bac43
-                                      (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h);
9bac43
-            }
9bac43
-            if (!x && x2 == width / VNC_DIRTY_PIXELS_PER_BIT) {
9bac43
-                y += h;
9bac43
-                if (y == height) {
9bac43
-                    break;
9bac43
-                }
9bac43
-            }
9bac43
         }
9bac43
-
9bac43
-        vnc_job_push(job);
9bac43
-        vs->force_update = 0;
9bac43
-        vs->has_dirty = 0;
9bac43
-        return n;
9bac43
     }
9bac43
 
9bac43
-    return 0;
9bac43
+    vnc_job_push(job);
9bac43
+    vs->force_update = 0;
9bac43
+    vs->has_dirty = 0;
9bac43
+    return n;
9bac43
 }
9bac43
 
9bac43
 /* audio */
9bac43
-- 
9bac43
1.8.3.1
9bac43