summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-20 15:54:32 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-20 15:54:32 -0300
commit81d1c2e7d5ef25fdf117c2aa00cd1b5fad831d73 (patch)
treead8ffe5d8f069b8821e28b6aef32058a862e3fd9 /gfx
parent39fe8984c452f304b2946bf3125512499aa714dc (diff)
downloadeeshow-81d1c2e7d5ef25fdf117c2aa00cd1b5fad831d73.tar.gz
eeshow-81d1c2e7d5ef25fdf117c2aa00cd1b5fad831d73.tar.bz2
eeshow-81d1c2e7d5ef25fdf117c2aa00cd1b5fad831d73.zip
eeshow/gfx/diff.c (complement_box): determine limits outside the loops
Diffstat (limited to 'gfx')
-rw-r--r--gfx/diff.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/gfx/diff.c b/gfx/diff.c
index 14a9f68..884f8b6 100644
--- a/gfx/diff.c
+++ b/gfx/diff.c
@@ -253,15 +253,22 @@ static void differences(struct diff *diff, uint32_t *a, const uint32_t *b)
static void complement_box(struct diff *diff, uint32_t *a,
int xa, int ya, int xb, int yb, uint32_t color)
{
+ int sx, sy, ex, ey;
uint32_t *p;
int x, y;
- for (y = ya; y != yb; y++) {
- if (y < 0 || y >= diff->h)
- continue;
+ sx = xa > 0 ? xa : 0;
+ ex = xb < diff->w ? xb : diff->w;
+ sy = ya > 0 ? ya : 0;
+ ey = yb < diff->h ? yb : diff->h;
+
+ if (sx >= ex || sy >= ey)
+ return;
+
+ for (y = sy; y != ey; y++) {
p = a + y * (diff->stride >> 2);
- for (x = xa; x != xb; x++)
- if (x >= 0 && x < diff->w && (p[x] & MASK) == MASK)
+ for (x = sx; x != ex; x++)
+ if ((p[x] & MASK) == MASK)
p[x] = color;
}
}