From ef3d118c9ec502d80a6262085f33dcbceab1e516 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 22 Aug 2016 13:15:38 -0300 Subject: [PATCH] eeshow/gui/diff.c: improve sectioning --- eeshow/gfx/diff.c | 56 ++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/eeshow/gfx/diff.c b/eeshow/gfx/diff.c index 884f8b6..1eb8d35 100644 --- a/eeshow/gfx/diff.c +++ b/eeshow/gfx/diff.c @@ -116,7 +116,7 @@ static unsigned diff_text_width(void *ctx, const char *s, unsigned size) } -/* ----- Initialization and termination ------------------------------------ */ +/* ----- Initialization ---------------------------------------------------- */ static void *diff_init(int argc, char *const *argv) @@ -182,6 +182,9 @@ fail_open: } +/* ----- Area highlighting ------------------------------------------------- */ + + void add_area(struct area **areas, int xa, int ya, int xb, int yb, uint32_t color) { @@ -226,30 +229,6 @@ static void mark_area(struct diff *diff, int x, int y) } -static void differences(struct diff *diff, uint32_t *a, const uint32_t *b) -{ - unsigned skip = diff->w * 4 - diff->stride; - int x, y; - - for (y = 0; y != diff->h; y++) { - for (x = 0; x != diff->w; x++) { - if (!((*a ^ *b) & MASK)) { - *a = ((*a >> FADE_SHIFT) & FADE_MASK) | - FADE_OFFSET; - } else { - mark_area(diff, x, y); - *a = (*a & MASK) == MASK ? ONLY_NEW : - (*b & MASK) == MASK ? ONLY_OLD : BOTH; - } - a++; - b++; - } - a += skip; - b += skip; - } -} - - static void complement_box(struct diff *diff, uint32_t *a, int xa, int ya, int xb, int yb, uint32_t color) { @@ -296,6 +275,33 @@ void free_areas(struct area **areas) } +/* ----- Termination ------------------------------------------------------- */ + + +static void differences(struct diff *diff, uint32_t *a, const uint32_t *b) +{ + unsigned skip = diff->w * 4 - diff->stride; + int x, y; + + for (y = 0; y != diff->h; y++) { + for (x = 0; x != diff->w; x++) { + if (!((*a ^ *b) & MASK)) { + *a = ((*a >> FADE_SHIFT) & FADE_MASK) | + FADE_OFFSET; + } else { + mark_area(diff, x, y); + *a = (*a & MASK) == MASK ? ONLY_NEW : + (*b & MASK) == MASK ? ONLY_OLD : BOTH; + } + a++; + b++; + } + a += skip; + b += skip; + } +} + + static void diff_end(void *ctx) { struct diff *diff = ctx;