qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC 6/6] ui: add ability to dump the raw cursor bytes


From: Daniel P . Berrangé
Subject: [RFC 6/6] ui: add ability to dump the raw cursor bytes
Date: Thu, 23 Jan 2025 19:15:36 +0000

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 hw/display/virtio-gpu.c |  1 +
 include/ui/console.h    |  1 +
 ui/cursor.c             | 21 +++++++++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 9952658df2..84836f52c4 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -102,6 +102,7 @@ static void update_cursor(VirtIOGPU *g, struct 
virtio_gpu_update_cursor *cursor)
 
         if (cursor->resource_id > 0) {
             vgc->update_cursor_data(g, s, cursor->resource_id);
+            cursor_dump_hex(s->current_cursor, "", 24, 24);
             cursor_unmultiply_alpha(s->current_cursor);
             cursor_swap_rgb(s->current_cursor);
         }
diff --git a/include/ui/console.h b/include/ui/console.h
index e5eb903feb..95b57b0e45 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -169,6 +169,7 @@ void cursor_unref(QEMUCursor *c);
 QEMUCursor *cursor_builtin_hidden(void);
 QEMUCursor *cursor_builtin_left_ptr(void);
 void cursor_print_ascii_art(QEMUCursor *c, const char *prefix);
+void cursor_dump_hex(QEMUCursor *c, const char *prefix, int maxw, int maxh);
 int cursor_get_mono_bpl(QEMUCursor *c);
 void cursor_set_mono(QEMUCursor *c,
                      uint32_t foreground, uint32_t background, uint8_t *image,
diff --git a/ui/cursor.c b/ui/cursor.c
index 536e022548..bc96307f3f 100644
--- a/ui/cursor.c
+++ b/ui/cursor.c
@@ -80,6 +80,27 @@ void cursor_print_ascii_art(QEMUCursor *c, const char 
*prefix)
     }
 }
 
+void cursor_dump_hex(QEMUCursor *c, const char *prefix, int maxw, int maxh)
+{
+    uint8_t *data = (uint8_t *) c->data;
+    int x,y,v;
+
+    maxw = MIN(maxw, c->width);
+    maxh = MIN(maxh, c->height);
+
+    for (y = 0; y < maxh; y++) {
+        fprintf(stderr, "%s: %2d: |", prefix, y);
+        for (x = 0; x < maxw; x++) {
+            for (v = 0; v < 4 ; v++, data++) {
+                fprintf(stderr, "%02x", *data);
+            }
+            fprintf(stderr, " ");
+        }
+        data += (c->width - maxw) * 4;
+        fprintf(stderr, "|\n");
+    }
+}
+
 QEMUCursor *cursor_builtin_hidden(void)
 {
     return cursor_parse_xpm(cursor_hidden_xpm);
-- 
2.47.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]