]> git.draconx.ca Git - rrace.git/blobdiff - src/x11.c
Add build-time option to help debug X11 rendering.
[rrace.git] / src / x11.c
index 955b93945e892e7c586deea2fe9b7ed920de2425..0a9bef0a78684ad47ae791c2fd017cc3a1fc0be6 100644 (file)
--- a/src/x11.c
+++ b/src/x11.c
 /* Size of the traditional icon pixmap (multiple of 3) */
 #define ICON_SIZE 48
 
+/* Define to 1 to add highlights and delays for visually debugging redraws */
+#if X11_RENDER_DEBUG
+#  include <unistd.h>
+#endif
+
 enum {
        NUM_TILE_COLOURS = COLOUR_MAX*(TILE_MAX-1),
        COLOUR_UI_GAMEBG = NUM_TILE_COLOURS,
@@ -167,7 +172,7 @@ redraw_goal_tile(struct app_state *state, Display *display, Drawable d,
 void x11_redraw_goal(struct app_state *state, uint_fast32_t mask)
 {
        Display *display = XtDisplay(state->goal);
-       Window window = XtWindow(state->goal);
+       Window goal = XtWindow(state->goal);
        Dimension w, h;
        int i;
 
@@ -176,8 +181,14 @@ void x11_redraw_goal(struct app_state *state, uint_fast32_t mask)
                int x = i%3, y = i/3;
 
                if (mask & 1) {
-                       redraw_goal_tile(state, display, window,
-                                               x, y, w/3, h/3);
+#if X11_RENDER_DEBUG
+                       XRectangle r = { w/3*(i%3), w/3*(i/3), w/3, h/3 };
+                       XSetForeground(display, state->tile_gc, 0xff0000);
+                       XFillRectangles(display, goal, state->tile_gc, &r, 1);
+                       XFlush(display);
+                       usleep(70000);
+#endif
+                       redraw_goal_tile(state, display, goal, x, y, w/3, h/3);
                }
 
                /*
@@ -264,6 +275,13 @@ void x11_redraw_game(struct app_state *state, uint_fast32_t mask)
 
        for (i = 0; i < 25; i++) {
                if (mask & 1) {
+#if X11_RENDER_DEBUG
+                       XRectangle r = { w*(i%5), w*(i/5), w, h };
+                       XSetForeground(display, state->tile_gc, 0xff0000);
+                       XFillRectangles(display, game, state->tile_gc, &r, 1);
+                       XFlush(display);
+                       usleep(70000);
+#endif
                        redraw_tile(state, display, game,
                                    gp[0], gp[1], gp[2],
                                    i%5, i/5, w, h);