From patchwork Tue Feb 28 16:30:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 143513 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 897BDB6FA7 for ; Wed, 29 Feb 2012 04:33:21 +1100 (EST) Received: from localhost ([::1]:45472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2PxR-0006ml-TU for incoming@patchwork.ozlabs.org; Tue, 28 Feb 2012 11:31:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2Pwl-0005Oa-Ur for qemu-devel@nongnu.org; Tue, 28 Feb 2012 11:30:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2PwM-0003hL-5f for qemu-devel@nongnu.org; Tue, 28 Feb 2012 11:30:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2PwL-0003gp-U9 for qemu-devel@nongnu.org; Tue, 28 Feb 2012 11:30:14 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1SGUCYu030033 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Feb 2012 11:30:12 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1SGU8kd023736; Tue, 28 Feb 2012 11:30:09 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 39F584132D; Tue, 28 Feb 2012 17:30:04 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 28 Feb 2012 17:30:02 +0100 Message-Id: <1330446602-10743-12-git-send-email-kraxel@redhat.com> In-Reply-To: <1330446602-10743-1-git-send-email-kraxel@redhat.com> References: <1330446602-10743-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 11/11] 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 --- 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,