From patchwork Thu Aug 9 11:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 10561317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E348D157B for ; Thu, 9 Aug 2018 12:07:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFE492AF5C for ; Thu, 9 Aug 2018 12:07:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3C042AF64; Thu, 9 Aug 2018 12:07:44 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY 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 734312AF5C for ; Thu, 9 Aug 2018 12:07:43 +0000 (UTC) Received: from localhost ([::1]:50120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnjjC-0006CW-6f for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Aug 2018 08:07:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnjQG-0005QR-H1 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 07:48:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnjQE-0007ZP-E3 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 07:48:08 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fnjQE-0007Z3-2t for qemu-devel@nongnu.org; Thu, 09 Aug 2018 07:48:06 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w79Bif4R146062; Thu, 9 Aug 2018 11:48:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=JkbkawNodp12jYC7sFaOIE144B7IJr5XIyEOHv6KxkY=; b=bmkUyrB+NtROuV4vxT1Jcjy85jmtmaUhWkyvxkUCDVE0CXgkd2tSdImrt/nNlHZyJvGT T/DEmh2+oa/D2v5CmdXORLqrdIr23J9CzmKyFXRlTGUggKB3HSBta/9LQDQgFWq2veeE UB1Dd0O3aNw/rfEGarhP3NQUZP9gF7+zLhkMRZFt84dCPxVTjxXVwhhz2jhiKTanhJC/ SGZisUHEuv6wIrsf4bbQha5tdmwah79zpe0lMmA7ED7WMk8bnXbQzrslVEEp1VWxUY/F Wv3yOSzsBEROfgFBDuM8vjPZfDGWeryyr9wkwY5Qcp8d1JQ3HibLbRXzBSpn7P3p2PV3 oA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2kn3jtav7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Aug 2018 11:48:04 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w79Bm45p013443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Aug 2018 11:48:04 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w79Bm3xV001178; Thu, 9 Aug 2018 11:48:03 GMT Received: from liran-pc.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 Aug 2018 04:48:03 -0700 From: Liran Alon To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 14:46:36 +0300 Message-Id: <1533815202-11967-24-git-send-email-liran.alon@oracle.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1533815202-11967-1-git-send-email-liran.alon@oracle.com> References: <1533815202-11967-1-git-send-email-liran.alon@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8979 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=980 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808090123 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH 23/29] vmsvga: Implement initial support for rgb-alpha 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: habkost@redhat.com, mtosatti@redhat.com, Liran Alon , kraxel@redhat.com, pbonzini@redhat.com, rth@twiddle.net, Leonid Shatz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Leonid Shatz This adds missing implementation of cursors having rgb and alpha-blending component. Although more work is required in QEMU framework to fully support alpha-blending functionality for cursors, the suggested fix shows well defined cursor shape instead of crashing video device or no hint of visible mouse cursor. Signed-off-by: Leonid Shatz Reviewed-by: Darren Kenny Signed-off-by: Liran Alon --- hw/display/vmware_vga.c | 85 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 13 deletions(-) diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 46f03fe90ac0..49b46938207e 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -668,6 +668,38 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s, dpy_cursor_define(s->vga.con, qc); cursor_put(qc); } + +static inline void vmsvga_rgba_cursor_define(struct vmsvga_state_s *s, + struct vmsvga_cursor_definition_s *c) +{ + QEMUCursor *qc; + int i, pixels = c->width * c->height; + + qc = cursor_alloc(c->width, c->height); + qc->hot_x = c->hot_x; + qc->hot_y = c->hot_y; + + /* fill alpha channel and rgb values */ + for (i = 0; i < pixels; i++) { + qc->data[i] = c->xor_mask[i]; + /* + * Turn semi-transparent pixels to fully opaque + * (opaque pixels stay opaque), due to lack of + * alpha-blending support in QEMU framework. + * This is a trade-off between cursor completely + * missing and cursors with some minor artifacts + * (such as Windows Aero style cursors). + */ + if (c->and_mask[i]) { + qc->data[i] |= 0xff000000; + } + } +#ifdef DEBUG + cursor_print_ascii_art(qc, "rgba"); +#endif + dpy_cursor_define(s->vga.con, qc); + cursor_put(qc); +} #endif static inline int vmsvga_fifo_length(struct vmsvga_state_s *s) @@ -728,7 +760,7 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s) { uint32_t cmd, colour; int args, len, maxloop = 1024; - int x, y, dx, dy, width, height; + int i, x, y, dx, dy, width, height; struct vmsvga_cursor_definition_s cursor; uint32_t cmd_start; uint32_t fence_arg; @@ -830,6 +862,44 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s) goto badcmd; #endif + case SVGA_CMD_DEFINE_ALPHA_CURSOR: + len -= 6; + if (len < 0) { + goto rewind; + } + + cursor.id = vmsvga_fifo_read(s); + cursor.hot_x = vmsvga_fifo_read(s); + cursor.hot_y = vmsvga_fifo_read(s); + cursor.width = x = vmsvga_fifo_read(s); + cursor.height = y = vmsvga_fifo_read(s); + cursor.and_mask_bpp = 32; + cursor.xor_mask_bpp = 32; + args = x * y; + if ((SVGA_PIXMAP_SIZE(x, y, 32) > ARRAY_SIZE(cursor.and_mask)) + || (SVGA_PIXMAP_SIZE(x, y, 32) > ARRAY_SIZE(cursor.xor_mask))) { + goto badcmd; + } + + len -= args; + if (len < 0) { + goto rewind; + } + + for (i = 0; i < args; i++) { + uint32_t rgba = vmsvga_fifo_read_raw(s); + cursor.xor_mask[i] = rgba & 0x00ffffff; + cursor.and_mask[i] = rgba & 0xff000000; + } + +#ifdef HW_MOUSE_ACCEL + vmsvga_rgba_cursor_define(s, &cursor); + break; +#else + args = 0; + goto badcmd; +#endif + case SVGA_CMD_FRONT_ROP_FILL: len -= 1; if (len < 0) { @@ -903,18 +973,6 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s) } args = 7; goto badcmd; - case SVGA_CMD_DEFINE_ALPHA_CURSOR: - len -= 6; - if (len < 0) { - goto rewind; - } - vmsvga_fifo_read(s); - vmsvga_fifo_read(s); - vmsvga_fifo_read(s); - x = vmsvga_fifo_read(s); - y = vmsvga_fifo_read(s); - args = x * y; - goto badcmd; case SVGA_CMD_DRAW_GLYPH_CLIPPED: /* deprecated */ len -= 4; if (len < 0) { @@ -1085,6 +1143,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) #endif #ifdef HW_MOUSE_ACCEL if (dpy_cursor_define_supported(s->vga.con)) { + caps |= SVGA_CAP_ALPHA_CURSOR; caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | SVGA_CAP_CURSOR_BYPASS; }