All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liran Alon <liran.alon@oracle.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mtosatti@redhat.com, rth@twiddle.net,
	habkost@redhat.com, kraxel@redhat.com,
	Leonid Shatz <leonid.shatz@oracle.com>,
	Liran Alon <liran.alon@oracle.com>
Subject: [Qemu-devel] [PATCH 23/29] vmsvga: Implement initial support for rgb-alpha cursors
Date: Thu,  9 Aug 2018 14:46:36 +0300	[thread overview]
Message-ID: <1533815202-11967-24-git-send-email-liran.alon@oracle.com> (raw)
In-Reply-To: <1533815202-11967-1-git-send-email-liran.alon@oracle.com>

From: Leonid Shatz <leonid.shatz@oracle.com>

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 <leonid.shatz@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
---
 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;
         }
-- 
1.9.1

  parent reply	other threads:[~2018-08-09 11:48 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 11:46 [Qemu-devel] [PATCH 00/29]: vmsvga: Various fixes and enhancements Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 01/29] vmsvga: Stop using redundant fifo pointer variable Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 02/29] vmsvga: Group together commands by their handling Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 03/29] vmsvga: Explictly mark deprecated commands Liran Alon
2018-08-10  9:44   ` Gerd Hoffmann
2018-08-09 11:46 ` [Qemu-devel] [PATCH 04/29] vmsvga: Do not print error message for ignored commands Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 05/29] vmsvga: Show registers and commands on debug output as decimals Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 06/29] vmsvga: Fix parse of SVGA_CMD_UPDATE_VERBOSE to consider additional opaque cookie Liran Alon
2018-08-10 10:00   ` Gerd Hoffmann
2018-08-11  0:04     ` Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 07/29] vmsvga: Handle SVGA_CMD_FRONT_ROP_FILL command Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 08/29] vmsvga: Parse SVGA_CMD_FENCE command to avoid FIFO desync Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 09/29] vmsvga: Account for length of command word when parsing commands Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 10/29] vmsvga: Remove treatment of deprecated commands as Nop Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 11/29] vmsvga: Remove handler of SVGA_CMD_INVALID_CMD Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 12/29] vmsvga: Add definitions of FIFO registers and report their number Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 13/29] vmsvga: Add support for extended FIFO registers Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 14/29] vmsvga: Setup interrupt pin Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 15/29] vmsvga: Add interrupt mask and status registers Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 16/29] vmsvga: Add framework code for SVGA command to raise interrupt Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 17/29] vmsvga: Define interrupt source flags for interrupt status and mask registers Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 18/29] vmsvga: Add support for SVGA_IRQFLAG_FIFO_PROGRESS Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 19/29] vmsvga: Handle SVGA_CMD_FENCE command Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 20/29] vmsvga: Use standard names for params defining hardware cursor image Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 21/29] vmsvga: Use AND mask bpp parameter in SVGA_CMD_DEFINE_CURSOR Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 22/29] vmsvga: Increase size of cursor AND bitmask Liran Alon
2018-08-09 11:46 ` Liran Alon [this message]
2018-08-10  9:51   ` [Qemu-devel] [PATCH 23/29] vmsvga: Implement initial support for rgb-alpha cursors Gerd Hoffmann
2018-08-09 11:46 ` [Qemu-devel] [PATCH 24/29] vmsvga: Add support for SVGA_FIFO_CAP_CURSOR_BYPASS_3 Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 25/29] vmsvga: Add basic support for GMR registers and FIFO commands Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 26/29] vmsvga: Add basic support for display topology Liran Alon
2018-08-10  9:56   ` Gerd Hoffmann
2018-08-11  0:00     ` Liran Alon
2018-08-13 10:39       ` Gerd Hoffmann
2018-08-09 11:46 ` [Qemu-devel] [PATCH 27/29] vmsvga: Add support for pitchlock register (a display line stride) Liran Alon
2018-08-09 11:46 ` [Qemu-devel] [PATCH 28/29] vmsvga: Introduce new function for reporting device capabilities Liran Alon
2018-08-10  9:58   ` Gerd Hoffmann
2018-08-09 11:46 ` [Qemu-devel] [PATCH 29/29] vmsvga: Don't allow setting screen size with zero width or height Liran Alon
2018-08-10 10:14 ` [Qemu-devel] [PATCH 00/29]: vmsvga: Various fixes and enhancements Gerd Hoffmann
2018-08-11  0:04   ` Liran Alon
2018-08-13 10:54     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1533815202-11967-24-git-send-email-liran.alon@oracle.com \
    --to=liran.alon@oracle.com \
    --cc=habkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=leonid.shatz@oracle.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.