From b8d5c7bc17fcb037c23d323d4f8fbdbab9894d9d Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Tue, 3 Jan 2023 23:19:10 -0500 Subject: [PATCH] x11: Avoid unneeded border clears. In commit 1ad1b0dcce2a ("motif: simplify border_clear implementation.") we went slightly too far and actually removed all checks of the tile mask value, so the border clear calls are done on every draw (only during the blank border win state). This kind of defeats the point of the expose handler excluding the blank border tiles when calculating the mask that is passed in, and means the rationale that the code being removed did literally nothing was not quite accurate. So, we still don't need the fancy computations, but we should check that the provided mask says to redraw any part of the border before doing it. --- src/x11.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/x11.c b/src/x11.c index 0326db9..c8ef335 100644 --- a/src/x11.c +++ b/src/x11.c @@ -290,9 +290,11 @@ void x11_redraw_game(struct app_state *state, uint_fast32_t mask) } /* Optimize the game end case where the outer frame is cleared */ - if (((gp[0] | gp[1] | gp[2]) & ~GOAL_MASK) == 0) { - clear_border(display, game, sz); - mask &= GOAL_MASK; + if (mask & GAME_MASK & ~GOAL_MASK) { + if (((gp[0] | gp[1] | gp[2]) & ~GOAL_MASK) == 0) { + clear_border(display, game, sz); + mask &= GOAL_MASK; + } } for (i = 0; i < 25; i++) { -- 2.43.2