From patchwork Mon Feb 27 10:10:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 143171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C6D7FB6F9F for ; Mon, 27 Feb 2012 21:10:28 +1100 (EST) Received: from localhost ([::1]:50221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1xXG-00049s-Oo for incoming@patchwork.ozlabs.org; Mon, 27 Feb 2012 05:10:26 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1xX6-00049k-MB for qemu-devel@nongnu.org; Mon, 27 Feb 2012 05:10:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S1xX5-0003ze-Dd for qemu-devel@nongnu.org; Mon, 27 Feb 2012 05:10:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1xX5-0003zZ-4k for qemu-devel@nongnu.org; Mon, 27 Feb 2012 05:10:15 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1RAAEr2017809 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 27 Feb 2012 05:10:14 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1RAACGd026361; Mon, 27 Feb 2012 05:10:13 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 361A040A17; Mon, 27 Feb 2012 11:10:10 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2012 11:10:10 +0100 Message-Id: <1330337410-21905-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: alevy@redhat.com, Gerd Hoffmann Subject: [Qemu-devel] [PATCH] qxl: properly handle upright and non-shared surfaces 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 Although qxl creates a shared displaysurface when the qxl surface is upright and doesn't need to be flipped there is no guarantee that the surface doesn't become unshared for some reason. Rename qxl_flip to qxl_blit and fix it to handle both flip and non-flip cases. Signed-off-by: Gerd Hoffmann Reviewed-by: Alon Levy --- hw/qxl-render.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/qxl-render.c b/hw/qxl-render.c index f323a4d..25857f6 100644 --- a/hw/qxl-render.c +++ b/hw/qxl-render.c @@ -21,25 +21,31 @@ #include "qxl.h" -static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect) +static void qxl_blit(PCIQXLDevice *qxl, QXLRect *rect) { uint8_t *src; uint8_t *dst = qxl->vga.ds->surface->data; int len, i; - if (qxl->guest_primary.qxl_stride > 0) { + if (is_buffer_shared(qxl->vga.ds->surface)) { return; } if (!qxl->guest_primary.data) { dprint(qxl, 1, "%s: initializing guest_primary.data\n", __func__); qxl->guest_primary.data = memory_region_get_ram_ptr(&qxl->vga.vram); } - dprint(qxl, 1, "%s: stride %d, [%d, %d, %d, %d]\n", __func__, + dprint(qxl, 2, "%s: stride %d, [%d, %d, %d, %d]\n", __func__, qxl->guest_primary.qxl_stride, rect->left, rect->right, rect->top, rect->bottom); src = qxl->guest_primary.data; - src += (qxl->guest_primary.surface.height - rect->top - 1) * - qxl->guest_primary.abs_stride; + if (qxl->guest_primary.qxl_stride < 0) { + /* qxl surface is upside down, walk src scanlines + * in reverse order to flip it */ + src += (qxl->guest_primary.surface.height - rect->top - 1) * + qxl->guest_primary.abs_stride; + } else { + src += rect->top * qxl->guest_primary.abs_stride; + } dst += rect->top * qxl->guest_primary.abs_stride; src += rect->left * qxl->guest_primary.bytes_pp; dst += rect->left * qxl->guest_primary.bytes_pp; @@ -48,7 +54,7 @@ static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect) for (i = rect->top; i < rect->bottom; i++) { memcpy(dst, src, len); dst += qxl->guest_primary.abs_stride; - src -= qxl->guest_primary.abs_stride; + src += qxl->guest_primary.qxl_stride; } } @@ -132,7 +138,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) if (qemu_spice_rect_is_empty(qxl->dirty+i)) { break; } - qxl_flip(qxl, qxl->dirty+i); + qxl_blit(qxl, qxl->dirty+i); dpy_update(vga->ds, qxl->dirty[i].left, qxl->dirty[i].top, qxl->dirty[i].right - qxl->dirty[i].left,