From patchwork Mon Aug 3 09:53:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 30488 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 6AFF0B7063 for ; Mon, 3 Aug 2009 19:56:14 +1000 (EST) Received: from localhost ([127.0.0.1]:55646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXuH2-0001bL-DQ for incoming@patchwork.ozlabs.org; Mon, 03 Aug 2009 05:56:08 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXuDt-0000ew-Nf for qemu-devel@nongnu.org; Mon, 03 Aug 2009 05:52:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXuDo-0000dK-Ql for qemu-devel@nongnu.org; Mon, 03 Aug 2009 05:52:53 -0400 Received: from [199.232.76.173] (port=52539 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXuDo-0000d7-6j for qemu-devel@nongnu.org; Mon, 03 Aug 2009 05:52:48 -0400 Received: from smtp.eu.citrix.com ([62.200.22.115]:45757) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXuDn-0002K2-Mz for qemu-devel@nongnu.org; Mon, 03 Aug 2009 05:52:47 -0400 X-IronPort-AV: E=Sophos;i="4.43,313,1246838400"; d="scan'208";a="6466514" Received: from lonpmailmx01.citrite.net ([10.30.224.162]) by LONPIPO01.EU.CITRIX.COM with ESMTP; 03 Aug 2009 09:52:43 +0000 Received: from kaball.uk.xensource.com (10.80.2.59) by smtprelay.citirx.com (10.30.224.162) with Microsoft SMTP Server id 8.1.358.0; Mon, 3 Aug 2009 10:52:43 +0100 Date: Mon, 3 Aug 2009 10:53:47 +0100 From: Stefano Stabellini X-X-Sender: sstabellini@kaball-desktop To: qemu-devel@nongnu.org Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH v3 1 of 4] vnc: fix copyrect screen corruption 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 This is the patch Gerd submitted few days ago to fix CopyRect. When sending a copyrect command to the vnc client, we must also update the local server surface. Otherwise the server's and the client's idea of the screen content run out of sync and screen updates don't work correctly. Gerd didn't add a Signed-off line so neither am I. --- vnc.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/vnc.c b/vnc.c index de0ff87..a50ee0c 100644 --- a/vnc.c +++ b/vnc.c @@ -654,6 +654,11 @@ static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h) static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, int w, int h) { + uint8_t *src_row; + uint8_t *dst_row; + int y,pitch,depth; + + /* send bitblit op to the vnc client */ vnc_write_u8(vs, 0); /* msg id */ vnc_write_u8(vs, 0); vnc_write_u16(vs, 1); /* number of rects */ @@ -661,6 +666,23 @@ static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, i vnc_write_u16(vs, src_x); vnc_write_u16(vs, src_y); vnc_flush(vs); + + /* do bitblit op on the local surface too */ + pitch = ds_get_linesize(vs->ds); + depth = ds_get_bytes_per_pixel(vs->ds); + src_row = vs->server.ds->data + pitch * src_y + depth * src_x; + dst_row = vs->server.ds->data + pitch * dst_y + depth * dst_x; + if (dst_y > src_y) { + /* copy backwards */ + src_row += pitch * (h-1); + dst_row += pitch * (h-1); + pitch = -pitch; + } + for (y = 0; y < h; y++) { + memmove(dst_row, src_row, w * depth); + src_row += pitch; + dst_row += pitch; + } } static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h)