From patchwork Wed May 19 07:24:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 52958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8AAD8B7D66 for ; Wed, 19 May 2010 17:34:17 +1000 (EST) Received: from localhost ([127.0.0.1]:46230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEdmU-00029j-Mc for incoming@patchwork.ozlabs.org; Wed, 19 May 2010 03:33:30 -0400 Received: from [140.186.70.92] (port=54698 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEdaJ-0004DB-JS for qemu-devel@nongnu.org; Wed, 19 May 2010 03:21:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OEdZw-0008OE-LQ for qemu-devel@nongnu.org; Wed, 19 May 2010 03:20:55 -0400 Received: from iksaif.net ([88.191.73.63]:39155) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OEdZu-0008NF-N8 for qemu-devel@nongnu.org; Wed, 19 May 2010 03:20:32 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) (Authenticated sender: corentincj@iksaif.net) by iksaif.net (Postfix) with ESMTPA id 277B3C9003E; Wed, 19 May 2010 09:24:14 +0200 (CEST) From: Corentin Chary To: qemu-devel@nongnu.org Date: Wed, 19 May 2010 09:24:09 +0200 Message-Id: <1274253852-16068-10-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.0.2 In-Reply-To: <1274253852-16068-1-git-send-email-corentincj@iksaif.net> References: <1274253852-16068-1-git-send-email-corentincj@iksaif.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Corentin Chary , Anthony Liguori , Alexander Graf , Adam Litke Subject: [Qemu-devel] [PATCH v3 09/12] vnc: return the number of rectangles X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Some encodings like tight supports tiling (spliting in multiple sub-rectangles). So we needed a way to tell vnc_update_client() how much rectangles are in the buffer. zlib, raw and hextile always send a full rectangle. Signed-off-by: Corentin Chary --- vnc-encoding-hextile.c | 5 +++-- vnc-encoding-zlib.c | 6 ++++-- vnc.c | 25 ++++++++++++++++--------- vnc.h | 6 +++--- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/vnc-encoding-hextile.c b/vnc-encoding-hextile.c index a01c5e2..728f25e 100644 --- a/vnc-encoding-hextile.c +++ b/vnc-encoding-hextile.c @@ -62,8 +62,8 @@ static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h) #undef BPP #undef GENERIC -void vnc_hextile_send_framebuffer_update(VncState *vs, int x, - int y, int w, int h) +int vnc_hextile_send_framebuffer_update(VncState *vs, int x, + int y, int w, int h) { int i, j; int has_fg, has_bg; @@ -83,6 +83,7 @@ void vnc_hextile_send_framebuffer_update(VncState *vs, int x, free(last_fg); free(last_bg); + return 1; } void vnc_hextile_set_pixel_conversion(VncState *vs, int generic) diff --git a/vnc-encoding-zlib.c b/vnc-encoding-zlib.c index 1d4dd1a..88ac863 100644 --- a/vnc-encoding-zlib.c +++ b/vnc-encoding-zlib.c @@ -116,7 +116,7 @@ static int vnc_zlib_stop(VncState *vs) return zstream->total_out - previous_out; } -void vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) +int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { int old_offset, new_offset, bytes_written; @@ -132,13 +132,15 @@ void vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) bytes_written = vnc_zlib_stop(vs); if (bytes_written == -1) - return; + return 0; // hack in the size new_offset = vs->output.offset; vs->output.offset = old_offset; vnc_write_u32(vs, bytes_written); vs->output.offset = new_offset; + + return 1; } void vnc_zlib_clear(VncState *vs) diff --git a/vnc.c b/vnc.c index d622a5a..34da9a2 100644 --- a/vnc.c +++ b/vnc.c @@ -646,7 +646,7 @@ static void vnc_write_pixels_generic(VncState *vs, void *pixels1, int size) } } -void vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) +int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { int i; uint8_t *row; @@ -657,23 +657,27 @@ void vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) vs->write_pixels(vs, row, w * ds_get_bytes_per_pixel(vs->ds)); row += ds_get_linesize(vs->ds); } + return 1; } -static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h) +static int send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { + int n = 0; + switch(vs->vnc_encoding) { case VNC_ENCODING_ZLIB: - vnc_zlib_send_framebuffer_update(vs, x, y, w, h); + n = vnc_zlib_send_framebuffer_update(vs, x, y, w, h); break; case VNC_ENCODING_HEXTILE: vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_HEXTILE); - vnc_hextile_send_framebuffer_update(vs, x, y, w, h); + n = vnc_hextile_send_framebuffer_update(vs, x, y, w, h); break; default: vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_RAW); - vnc_raw_send_framebuffer_update(vs, x, y, w, h); + n = vnc_raw_send_framebuffer_update(vs, x, y, w, h); break; } + return n; } static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, int w, int h) @@ -784,6 +788,7 @@ static int vnc_update_client(VncState *vs, int has_dirty) int y; int n_rectangles; int saved_offset; + int n; if (vs->output.offset && !vs->audio_cap && !vs->force_update) /* kernel send buffers are full -> drop frames to throttle */ @@ -816,16 +821,18 @@ static int vnc_update_client(VncState *vs, int has_dirty) } else { if (last_x != -1) { int h = find_and_clear_dirty_height(vs, y, last_x, x); - send_framebuffer_update(vs, last_x * 16, y, (x - last_x) * 16, h); - n_rectangles++; + n = send_framebuffer_update(vs, last_x * 16, y, + (x - last_x) * 16, h); + n_rectangles += n; } last_x = -1; } } if (last_x != -1) { int h = find_and_clear_dirty_height(vs, y, last_x, x); - send_framebuffer_update(vs, last_x * 16, y, (x - last_x) * 16, h); - n_rectangles++; + n = send_framebuffer_update(vs, last_x * 16, y, + (x - last_x) * 16, h); + n_rectangles += n; } } vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF; diff --git a/vnc.h b/vnc.h index ffcbc52..c3b2173 100644 --- a/vnc.h +++ b/vnc.h @@ -392,13 +392,13 @@ void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h, void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v); /* Encodings */ -void vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); +int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); -void vnc_hextile_send_framebuffer_update(VncState *vs, int x, +int vnc_hextile_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); void vnc_hextile_set_pixel_conversion(VncState *vs, int generic); -void vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); +int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); void vnc_zlib_clear(VncState *vs); #endif /* __QEMU_VNC_H */