From 991d1e7ca8ae3bee59619812e9f08bde8c17ad02 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 12 Mar 2022 16:15:24 -0500 Subject: [PATCH] Add build-time option to help debug X11 rendering. Add #define that can be manually set in config.h to enable additional debug drawing. This is intended purely for development. Currently this causes the system to highlight tiles before they are redrawn, in order to watch things like expose handling and tile movement. --- configure.ac | 2 ++ src/x11.c | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3ef5c67..2378c8e 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,8 @@ AS_IF([test x"$dx_cv_have_motif" = x"yes"], [MOTIF_CFLAGS=$dx_cv_motif_cflags MOTIF_LIBS=$dx_cv_motif_libs], [AC_DEFINE([X_DISPLAY_MISSING])]) AM_CONDITIONAL([HAVE_MOTIF], [test x"$dx_cv_have_motif" = x"yes"]) +AH_TEMPLATE([X11_RENDER_DEBUG], + [Define to 1 to enable visual aids for debugging X11 rendering.]) AC_CONFIG_TESTDIR([.], [t:.]) DX_PROG_AUTOTEST diff --git a/src/x11.c b/src/x11.c index 955b939..0a9bef0 100644 --- a/src/x11.c +++ b/src/x11.c @@ -31,6 +31,11 @@ /* 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 +#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); -- 2.43.2