[Spice-devel] [PATCH v3 spice-gtk 1/2] cursor-channel.c: add cursor print function for debugging only (ifdefed)

Alon Levy alevy at redhat.com
Sat Oct 19 18:16:45 CEST 2013


---
 gtk/channel-cursor.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index d1d2c34..66e91df 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -246,6 +246,35 @@ static void do_emit_main_context(GObject *object, int signum, gpointer params)
 
 /* ------------------------------------------------------------------ */
 
+#ifdef DEBUG_CURSOR
+static void print_cursor(display_cursor *cursor, const guint8 *data)
+{
+    int x, y, bpl;
+    const guint8 *xor, *and;
+
+    bpl = (cursor->hdr.width + 7) / 8;
+    and = data;
+    xor = and + bpl * cursor->hdr.height;
+
+    printf("data (%d x %d):\n", cursor->hdr.width, cursor->hdr.height);
+    for (y = 0 ; y < cursor->hdr.height; ++y) {
+        for (x = 0 ; x < cursor->hdr.width / 8; x++) {
+            printf("%02X", and[x]);
+        }
+        and += bpl;
+        printf("\n");
+    }
+    printf("xor:\n");
+    for (y = 0 ; y < cursor->hdr.height; ++y) {
+        for (x = 0 ; x < cursor->hdr.width / 8; ++x) {
+            printf("%02X", xor[x]);
+        }
+        xor += bpl;
+        printf("\n");
+    }
+}
+#endif
+
 static void mono_cursor(display_cursor *cursor, const guint8 *data)
 {
     const guint8 *xor, *and;
@@ -256,6 +285,9 @@ static void mono_cursor(display_cursor *cursor, const guint8 *data)
     and = data;
     xor = and + bpl * cursor->hdr.height;
     dest  = (uint8_t *)cursor->data;
+#ifdef DEBUG_CURSOR
+    print_cursor(cursor, data);
+#endif
     for (y = 0; y < cursor->hdr.height; y++) {
         bit = 0x80;
         for (x = 0; x < cursor->hdr.width; x++, dest += 4) {
-- 
1.8.3.1



More information about the Spice-devel mailing list