From patchwork Mon Nov 18 08:17:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 291971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AAC8C2C00B3 for ; Mon, 18 Nov 2013 19:19:10 +1100 (EST) Received: from localhost ([::1]:41835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViK32-0004zm-4u for incoming@patchwork.ozlabs.org; Mon, 18 Nov 2013 03:19:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViK1e-0003YH-C8 for qemu-devel@nongnu.org; Mon, 18 Nov 2013 03:17:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViK1Y-0006U9-9u for qemu-devel@nongnu.org; Mon, 18 Nov 2013 03:17:42 -0500 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:37963 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViK1X-0006Tp-VU for qemu-devel@nongnu.org; Mon, 18 Nov 2013 03:17:36 -0500 Received: (qmail 24612 invoked by uid 89); 18 Nov 2013 08:17:33 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98/18125. hbedv: 8.2.12.144/7.11.114.48. spamassassin: 3.3.1. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.411787 secs); 18 Nov 2013 08:17:33 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 18 Nov 2013 08:17:31 -0000 X-GL_Whitelist: yes Received: from lieven-pc.kamp-intra.net (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id AD62C20688; Mon, 18 Nov 2013 09:17:11 +0100 (CET) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id 3E64D6115E; Mon, 18 Nov 2013 09:17:22 +0100 (CET) From: Peter Lieven To: qemu-devel@nongnu.org Date: Mon, 18 Nov 2013 09:17:19 +0100 Message-Id: <1384762641-18297-2-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1384762641-18297-1-git-send-email-pl@kamp.de> References: <1384762641-18297-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: corentincj@iksaif.net, aliguori@us.ibm.com, Peter Lieven Subject: [Qemu-devel] [PATCH 1/3] ui/vnc: introduce VNC_DIRTY_PIXELS_PER_BIT macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Peter Lieven --- ui/vnc.c | 55 ++++++++++++++++++++++++++++++++++--------------------- ui/vnc.h | 6 +++++- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 5601cc3..67b1f75 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -442,17 +442,19 @@ static void vnc_dpy_update(DisplayChangeListener *dcl, iteration. otherwise, if (x % 16) != 0, the last iteration may span two 16-pixel blocks but we only mark the first as dirty */ - w += (x % 16); - x -= (x % 16); + w += (x % VNC_DIRTY_PIXELS_PER_BIT); + x -= (x % VNC_DIRTY_PIXELS_PER_BIT); x = MIN(x, width); y = MIN(y, height); w = MIN(x + w, width) - x; h = MIN(h, height); - for (; y < h; y++) - for (i = 0; i < w; i += 16) - set_bit((x + i) / 16, s->dirty[y]); + for (; y < h; y++) { + for (i = 0; i < w; i += VNC_DIRTY_PIXELS_PER_BIT) { + set_bit((x + i) / VNC_DIRTY_PIXELS_PER_BIT, s->dirty[y]); + } + } } void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h, @@ -769,11 +771,11 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl, y = dst_y + h - 1; inc = -1; } - w_lim = w - (16 - (dst_x % 16)); + w_lim = w - (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % VNC_DIRTY_PIXELS_PER_BIT)); if (w_lim < 0) w_lim = w; else - w_lim = w - (w_lim % 16); + w_lim = w - (w_lim % VNC_DIRTY_PIXELS_PER_BIT); for (i = 0; i < h; i++) { for (x = 0; x <= w_lim; x += s, src_row += cmp_bytes, dst_row += cmp_bytes) { @@ -781,10 +783,10 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl, if ((s = w - w_lim) == 0) break; } else if (!x) { - s = (16 - (dst_x % 16)); + s = (16 - (dst_x % VNC_DIRTY_PIXELS_PER_BIT)); s = MIN(s, w_lim); } else { - s = 16; + s = VNC_DIRTY_PIXELS_PER_BIT; } cmp_bytes = s * VNC_SERVER_FB_BYTES; if (memcmp(src_row, dst_row, cmp_bytes) == 0) @@ -911,7 +913,7 @@ static int vnc_update_client(VncState *vs, int has_dirty) for (y = 0; y < height; y++) { int x; int last_x = -1; - for (x = 0; x < width / 16; x++) { + for (x = 0; x < width / VNC_DIRTY_PIXELS_PER_BIT; x++) { if (test_and_clear_bit(x, vs->dirty[y])) { if (last_x == -1) { last_x = x; @@ -921,16 +923,21 @@ static int vnc_update_client(VncState *vs, int has_dirty) int h = find_and_clear_dirty_height(vs, y, last_x, x, height); - n += vnc_job_add_rect(job, last_x * 16, y, - (x - last_x) * 16, h); + n += vnc_job_add_rect(job, + last_x * VNC_DIRTY_PIXELS_PER_BIT, + y, + (x - last_x) * VNC_DIRTY_PIXELS_PER_BIT, + h); } last_x = -1; } } if (last_x != -1) { int h = find_and_clear_dirty_height(vs, y, last_x, x, height); - n += vnc_job_add_rect(job, last_x * 16, y, - (x - last_x) * 16, h); + n += vnc_job_add_rect(job, last_x * VNC_DIRTY_PIXELS_PER_BIT, + y, + (x - last_x) * VNC_DIRTY_PIXELS_PER_BIT, + h); } } @@ -1861,7 +1868,7 @@ static void framebuffer_update_request(VncState *vs, int incremental, int w, int h) { int i; - const size_t width = surface_width(vs->vd->ds) / 16; + const size_t width = surface_width(vs->vd->ds) / VNC_DIRTY_PIXELS_PER_BIT; const size_t height = surface_height(vs->vd->ds); if (y_position > height) { @@ -2563,7 +2570,9 @@ static int vnc_refresh_lossy_rect(VncDisplay *vd, int x, int y) vs->lossy_rect[sty][stx] = 0; for (j = 0; j < VNC_STAT_RECT; ++j) { - bitmap_set(vs->dirty[y + j], x / 16, VNC_STAT_RECT / 16); + bitmap_set(vs->dirty[y + j], + x / VNC_DIRTY_PIXELS_PER_BIT, + VNC_STAT_RECT / VNC_DIRTY_PIXELS_PER_BIT); } has_dirty++; } @@ -2710,17 +2719,21 @@ static int vnc_refresh_server_surface(VncDisplay *vd) } server_ptr = server_row; - for (x = 0; x + 15 < width; - x += 16, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) { - if (!test_and_clear_bit((x / 16), vd->guest.dirty[y])) + for (x = 0; x + VNC_DIRTY_PIXELS_PER_BIT - 1 < width; + x += VNC_DIRTY_PIXELS_PER_BIT, guest_ptr += cmp_bytes, + server_ptr += cmp_bytes) { + if (!test_and_clear_bit((x / VNC_DIRTY_PIXELS_PER_BIT), + vd->guest.dirty[y])) { continue; - if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0) + } + if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0) { continue; + } memcpy(server_ptr, guest_ptr, cmp_bytes); if (!vd->non_adaptive) vnc_rect_updated(vd, x, y, &tv); QTAILQ_FOREACH(vs, &vd->clients, next) { - set_bit((x / 16), vs->dirty[y]); + set_bit((x / VNC_DIRTY_PIXELS_PER_BIT), vs->dirty[y]); } has_dirty++; } diff --git a/ui/vnc.h b/ui/vnc.h index 6e99213..4a8f33c 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -81,8 +81,12 @@ typedef void VncSendHextileTile(VncState *vs, #define VNC_MAX_WIDTH 2560 #define VNC_MAX_HEIGHT 2048 +/* VNC_DIRTY_PIXELS_PER_BIT is the number of dirty pixels represented + * by one bit in the dirty bitmap */ +#define VNC_DIRTY_PIXELS_PER_BIT 16 + /* VNC_DIRTY_BITS is the number of bits in the dirty bitmap. */ -#define VNC_DIRTY_BITS (VNC_MAX_WIDTH / 16) +#define VNC_DIRTY_BITS (VNC_MAX_WIDTH / VNC_DIRTY_PIXELS_PER_BIT) #define VNC_STAT_RECT 64 #define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT)