From patchwork Wed Aug 26 13:05:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 32165 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 62542B70AD for ; Thu, 27 Aug 2009 03:25:29 +1000 (EST) Received: from localhost ([127.0.0.1]:42398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgMFQ-000167-Ow for incoming@patchwork.ozlabs.org; Wed, 26 Aug 2009 13:25:24 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgLwf-0002Pb-VF for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:06:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgLwZ-0002Eq-8X for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:05:59 -0400 Received: from [199.232.76.173] (port=45781 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgLwY-0002EU-DU for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:05:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61911) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgLwX-0000Xo-No for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:05:54 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7QH5qwU032220; Wed, 26 Aug 2009 13:05:52 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7QH5kJq009197; Wed, 26 Aug 2009 13:05:52 -0400 From: Glauber Costa To: qemu-devel@nongnu.org Date: Wed, 26 Aug 2009 09:05:41 -0400 Message-Id: <1251291946-25821-8-git-send-email-glommer@redhat.com> In-Reply-To: <1251291946-25821-7-git-send-email-glommer@redhat.com> References: <1251291946-25821-1-git-send-email-glommer@redhat.com> <1251291946-25821-2-git-send-email-glommer@redhat.com> <1251291946-25821-3-git-send-email-glommer@redhat.com> <1251291946-25821-4-git-send-email-glommer@redhat.com> <1251291946-25821-5-git-send-email-glommer@redhat.com> <1251291946-25821-6-git-send-email-glommer@redhat.com> <1251291946-25821-7-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, Gerd Hoffmann Subject: [Qemu-devel] [PATCH 07/12] BACKPORT: 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 From: Gerd Hoffmann 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. [ backport: uses ds_get_data() instead of direct dereference ] Signed-off-by: Anthony Liguori Signed-off-by: Glauber Costa --- vnc.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/vnc.c b/vnc.c index 1d8ebe7..c0700c0 100644 --- a/vnc.c +++ b/vnc.c @@ -633,8 +633,14 @@ 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; + vnc_update_client(vs); + /* 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 */ @@ -642,6 +648,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 = ds_get_data(vs->ds) + pitch * src_y + depth * src_x; + dst_row = ds_get_data(vs->ds) + 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)