From patchwork Thu Aug 24 08:13:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9919373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E44B760353 for ; Thu, 24 Aug 2017 08:14:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D506527FB0 for ; Thu, 24 Aug 2017 08:14:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA27A28161; Thu, 24 Aug 2017 08:14:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FD6B280DE for ; Thu, 24 Aug 2017 08:14:26 +0000 (UTC) Received: from localhost ([::1]:47140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dknHV-0004TE-7X for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Aug 2017 04:14:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dknGL-0004Sy-V5 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 04:13:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dknGI-0002iT-P9 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 04:13:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dknGI-0002i4-Ik for qemu-devel@nongnu.org; Thu, 24 Aug 2017 04:13:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37644883BE; Thu, 24 Aug 2017 08:13:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 37644883BE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-82.ams2.redhat.com [10.36.116.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0752779E8; Thu, 24 Aug 2017 08:13:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9FE653FBB9; Thu, 24 Aug 2017 10:13:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 10:13:05 +0200 Message-Id: <20170824081305.8445-3-kraxel@redhat.com> In-Reply-To: <20170824081305.8445-1-kraxel@redhat.com> References: <20170824081305.8445-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 24 Aug 2017 08:13:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] qxl: add support for chunked cursors. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Ren=C3=A9=20Rebe?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gerd Hoffmann --- hw/display/qxl-render.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c index e1b3f05ecb..b2c98f90c0 100644 --- a/hw/display/qxl-render.c +++ b/hw/display/qxl-render.c @@ -204,7 +204,30 @@ void qxl_render_update_area_done(PCIQXLDevice *qxl, QXLCookie *cookie) g_free(cookie); } -static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor) +static void qxl_unpack_chunks(void *dest, size_t size, PCIQXLDevice *qxl, + QXLDataChunk *chunk, uint32_t group_id) +{ + uint32_t max_chunks = 32; + size_t offset = 0; + size_t bytes; + + for (;;) { + bytes = MIN(size - offset, chunk->data_size); + memcpy(dest + offset, chunk->data, bytes); + offset += bytes; + if (offset == size) + return; + chunk = qxl_phys2virt(qxl, chunk->next_chunk, group_id); + if (!chunk) + return; + max_chunks--; + if (max_chunks == 0) + return; + } +} + +static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor, + uint32_t group_id) { QEMUCursor *c; size_t size; @@ -215,7 +238,7 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor) switch (cursor->header.type) { case SPICE_CURSOR_TYPE_ALPHA: size = sizeof(uint32_t) * cursor->header.width * cursor->header.height; - memcpy(c->data, cursor->chunk.data, size); + qxl_unpack_chunks(c->data, size, qxl, &cursor->chunk, group_id); if (qxl->debug > 2) { cursor_print_ascii_art(c, "qxl/alpha"); } @@ -259,11 +282,7 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext) if (!cursor) { return 1; } - if (cursor->chunk.data_size != cursor->data_size) { - fprintf(stderr, "%s: multiple chunks\n", __FUNCTION__); - return 1; - } - c = qxl_cursor(qxl, cursor); + c = qxl_cursor(qxl, cursor, ext->group_id); if (c == NULL) { c = cursor_builtin_left_ptr(); }