summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-10-23 20:00:41 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2013-10-23 20:00:41 +0200
commit54668ff649fda9d1f182e76727a594d348d00627 (patch)
treebe6be78078da0800f3694d63cd062de4bc817af8
parent492da8a82832b47ee0fc3e27549ef77fbb38ba4e (diff)
Add debug render-mode
If debugging is on for rendering, we draw a red rectangle around every cell we draw. It is a nice way to see which cells actually changed. Debugging only! Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r--src/wlt_render.c48
-rw-r--r--src/wlterm.h1
2 files changed, 48 insertions, 1 deletions
diff --git a/src/wlt_render.c b/src/wlt_render.c
index af5f702..b7d83d6 100644
--- a/src/wlt_render.c
+++ b/src/wlt_render.c
@@ -157,6 +157,48 @@ static void wlt_renderer_fill(struct wlt_renderer *rend,
}
}
+/* used for debugging; draws a border on the given rectangle */
+static void wlt_renderer_highlight(struct wlt_renderer *rend,
+ unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height)
+{
+ unsigned int i, j, tmp;
+ uint8_t *dst;
+ uint32_t out;
+
+ /* clip width */
+ tmp = x + width;
+ if (tmp <= x || x >= rend->width)
+ return;
+ if (tmp > rend->width)
+ width = rend->width - x;
+
+ /* clip height */
+ tmp = y + height;
+ if (tmp <= y || y >= rend->height)
+ return;
+ if (tmp > rend->height)
+ height = rend->height - y;
+
+ /* prepare */
+ dst = rend->data;
+ dst = &dst[y * rend->stride + x * 4];
+ out = (0xff << 24) | (0xd0 << 16) | (0x10 << 8) | 0x10;
+
+ /* draw outline into buffer */
+ for (i = 0; i < height; ++i) {
+ ((uint32_t*)dst)[0] = out;
+ ((uint32_t*)dst)[width - 1] = out;
+
+ if (!i || i + 1 == height) {
+ for (j = 0; j < width; ++j)
+ ((uint32_t*)dst)[j] = out;
+ }
+
+ dst += rend->stride;
+ }
+}
+
static void wlt_renderer_blend(struct wlt_renderer *rend,
const struct wlt_glyph *glyph,
unsigned int x, unsigned int y,
@@ -262,7 +304,7 @@ static int wlt_renderer_draw_cell(struct tsm_screen *screen, uint32_t id,
skip = overlap(ctx, x, y, x + ctx->cell_width, y + ctx->cell_height);
skip = skip && age && rend->age && age <= rend->age;
- if (skip)
+ if (skip && !ctx->debug)
return 0;
/* invert colors if requested */
@@ -296,6 +338,10 @@ static int wlt_renderer_draw_cell(struct tsm_screen *screen, uint32_t id,
fr, fg, fb, br, bg, bb);
}
+ if (!skip && ctx->debug)
+ wlt_renderer_highlight(rend, x, y, ctx->cell_width * cwidth,
+ ctx->cell_height);
+
return 0;
}
diff --git a/src/wlterm.h b/src/wlterm.h
index 758ed49..d26090c 100644
--- a/src/wlterm.h
+++ b/src/wlterm.h
@@ -82,6 +82,7 @@ int wlt_face_render(struct wlt_face *face, struct wlt_glyph **out,
/* rendering */
struct wlt_draw_ctx {
+ bool debug;
struct wlt_renderer *rend;
cairo_t *cr;
struct wlt_face *face;