ref: 29eaa8f55c7b9cc960afa4327a7ce977e6637e9c
parent: 58511aa009c672cc2ade783d537a5830806fd02c
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sun Jul 30 13:16:36 EDT 2023
Flood: don't draw zero-width tile separators Flood's draw_tile() extravagantly uses up to eight rectangles to draw separators around each tile. This could be substantially improved, but a particularly low-hanging optimisation is not do draw them when the separator width is zero. This at least means that Flood completes its initial drawing on my test KaiOS device.
--- a/flood.c
+++ b/flood.c
@@ -1101,31 +1101,33 @@
colour += COL_1;
draw_rect(dr, tx, ty, TILESIZE, TILESIZE, colour);
- if (tile & BORDER_L)
- draw_rect(dr, tx, ty,
- SEP_WIDTH, TILESIZE, COL_SEPARATOR);
- if (tile & BORDER_R)
- draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty,
- SEP_WIDTH, TILESIZE, COL_SEPARATOR);
- if (tile & BORDER_U)
- draw_rect(dr, tx, ty,
- TILESIZE, SEP_WIDTH, COL_SEPARATOR);
- if (tile & BORDER_D)
- draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH,
- TILESIZE, SEP_WIDTH, COL_SEPARATOR);
+ if (SEP_WIDTH > 0) {
+ if (tile & BORDER_L)
+ draw_rect(dr, tx, ty,
+ SEP_WIDTH, TILESIZE, COL_SEPARATOR);
+ if (tile & BORDER_R)
+ draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty,
+ SEP_WIDTH, TILESIZE, COL_SEPARATOR);
+ if (tile & BORDER_U)
+ draw_rect(dr, tx, ty,
+ TILESIZE, SEP_WIDTH, COL_SEPARATOR);
+ if (tile & BORDER_D)
+ draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH,
+ TILESIZE, SEP_WIDTH, COL_SEPARATOR);
- if (tile & CORNER_UL)
- draw_rect(dr, tx, ty,
- SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
- if (tile & CORNER_UR)
- draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty,
- SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
- if (tile & CORNER_DL)
- draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH,
- SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
- if (tile & CORNER_DR)
- draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty + TILESIZE - SEP_WIDTH,
- SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
+ if (tile & CORNER_UL)
+ draw_rect(dr, tx, ty,
+ SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
+ if (tile & CORNER_UR)
+ draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty,
+ SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
+ if (tile & CORNER_DL)
+ draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH,
+ SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
+ if (tile & CORNER_DR)
+ draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty + TILESIZE - SEP_WIDTH,
+ SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR);
+ }
if (tile & CURSOR)
draw_rect_outline(dr, tx + CURSOR_INSET, ty + CURSOR_INSET,