summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-12-24 12:17:43 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-12-24 12:14:33 +0000
commitcc21d3fa045209861564cf240a9a082e0bdb63f8 (patch)
treebed52fc61395cbb562e6b9ec3aa4faffc3a507f3
parentb86e4f59299f935d5a0ea8375da97e6fc57571f9 (diff)
sna/damage: Fix the is-contained test
It was a non-overlapping test which is almost the reverse of what was intended. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_damage.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c
index b7130288..8b5ca7b1 100644
--- a/src/sna/sna_damage.c
+++ b/src/sna/sna_damage.c
@@ -135,7 +135,7 @@ static const char *_debug_describe_damage(char *buf, int max,
sprintf(damage_str, "%c[ ...]",
damage->mode == DAMAGE_SUBTRACT ? '-' : '+');
} else
- damage_str = "";
+ damage_str[0] = '\0';
snprintf(buf, max, "[[(%d, %d), (%d, %d)]: %s %s]",
damage->extents.x1, damage->extents.y1,
damage->extents.x2, damage->extents.y2,
@@ -922,10 +922,10 @@ struct sna_damage *_sna_damage_is_all(struct sna_damage *damage,
static bool box_contains(const BoxRec *a, const BoxRec *b)
{
- if (b->x2 <= a->x1 || b->x1 >= a->x2)
+ if (b->x1 < a->x1 || b->x2 > a->x2)
return false;
- if (b->y2 <= a->y1 || b->y1 >= a->y2)
+ if (b->y1 < a->y1 || b->y2 > a->y2)
return false;
return true;
@@ -1042,6 +1042,11 @@ inline static struct sna_damage *__sna_damage_subtract_box(struct sna_damage *da
return damage;
if (damage->mode != DAMAGE_SUBTRACT) {
+ if (box_contains(box, &damage->extents)) {
+ __sna_damage_destroy(damage);
+ return NULL;
+ }
+
if (damage->dirty)
__sna_damage_reduce(damage);