From nobody Wed Nov 5 10:05:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1533816496593770.7002276671001; Thu, 9 Aug 2018 05:08:16 -0700 (PDT) Received: from localhost ([::1]:50126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnjjj-0007LA-1m for importer@patchew.org; Thu, 09 Aug 2018 08:08:15 -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 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 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== 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Leonid Shatz This adds missing implementation of cursors having rgb and alpha-blending c= omponent. Although more work is required in QEMU framework to fully support alpha-ble= nding functionality for cursors, the suggested fix shows well defined cursor shap= e 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 =3D c->width * c->height; + + qc =3D cursor_alloc(c->width, c->height); + qc->hot_x =3D c->hot_x; + qc->hot_y =3D c->hot_y; + + /* fill alpha channel and rgb values */ + for (i =3D 0; i < pixels; i++) { + qc->data[i] =3D 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] |=3D 0xff000000; + } + } +#ifdef DEBUG + cursor_print_ascii_art(qc, "rgba"); +#endif + dpy_cursor_define(s->vga.con, qc); + cursor_put(qc); +} #endif =20 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 =3D 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 =20 + case SVGA_CMD_DEFINE_ALPHA_CURSOR: + len -=3D 6; + if (len < 0) { + goto rewind; + } + + cursor.id =3D vmsvga_fifo_read(s); + cursor.hot_x =3D vmsvga_fifo_read(s); + cursor.hot_y =3D vmsvga_fifo_read(s); + cursor.width =3D x =3D vmsvga_fifo_read(s); + cursor.height =3D y =3D vmsvga_fifo_read(s); + cursor.and_mask_bpp =3D 32; + cursor.xor_mask_bpp =3D 32; + args =3D 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 -=3D args; + if (len < 0) { + goto rewind; + } + + for (i =3D 0; i < args; i++) { + uint32_t rgba =3D vmsvga_fifo_read_raw(s); + cursor.xor_mask[i] =3D rgba & 0x00ffffff; + cursor.and_mask[i] =3D rgba & 0xff000000; + } + +#ifdef HW_MOUSE_ACCEL + vmsvga_rgba_cursor_define(s, &cursor); + break; +#else + args =3D 0; + goto badcmd; +#endif + case SVGA_CMD_FRONT_ROP_FILL: len -=3D 1; if (len < 0) { @@ -903,18 +973,6 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s) } args =3D 7; goto badcmd; - case SVGA_CMD_DEFINE_ALPHA_CURSOR: - len -=3D 6; - if (len < 0) { - goto rewind; - } - vmsvga_fifo_read(s); - vmsvga_fifo_read(s); - vmsvga_fifo_read(s); - x =3D vmsvga_fifo_read(s); - y =3D vmsvga_fifo_read(s); - args =3D x * y; - goto badcmd; case SVGA_CMD_DRAW_GLYPH_CLIPPED: /* deprecated */ len -=3D 4; if (len < 0) { @@ -1085,6 +1143,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint3= 2_t address) #endif #ifdef HW_MOUSE_ACCEL if (dpy_cursor_define_supported(s->vga.con)) { + caps |=3D SVGA_CAP_ALPHA_CURSOR; caps |=3D SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | SVGA_CAP_CURSOR_BYPASS; } --=20 1.9.1