diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-01 10:00:37 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-01 10:12:59 +0000 |
commit | 2f5b769e7144c7b85010429e6d8aebf9c9fc1628 (patch) | |
tree | e99ced8b0aaa53f9f4b2078ce0a63342e00db147 | |
parent | 24bf59c43fbedd9d85c913ac3c7f0e752c232eb4 (diff) |
sna: Move some checks against programming errors to asserts
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_damage.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 4a2dd802..d720c5cb 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -445,8 +445,7 @@ done: inline static struct sna_damage *__sna_damage_add(struct sna_damage *damage, RegionPtr region) { - if (!RegionNotEmpty(region)) - return damage; + assert(RegionNotEmpty(region)); if (!damage) { damage = _sna_damage_create(); @@ -907,8 +906,13 @@ struct sna_damage *_sna_damage_all(struct sna_damage *damage, struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, int width, int height) { - if (damage->dirty) + if (damage->dirty) { __sna_damage_reduce(damage); + if (!RegionNotEmpty(&damage->region)) { + __sna_damage_destroy(damage); + return NULL; + } + } if (damage->region.data) return damage; @@ -952,17 +956,13 @@ static struct sna_damage *__sna_damage_subtract(struct sna_damage *damage, if (damage == NULL) return NULL; - if (!RegionNotEmpty(&damage->region)) { - __sna_damage_destroy(damage); - return NULL; - } - - if (!RegionNotEmpty(region)) - return damage; + assert(RegionNotEmpty(region)); if (!sna_damage_maybe_contains_box(damage, ®ion->extents)) return damage; + assert(RegionNotEmpty(&damage->region)); + if (region_is_singular(region) && box_contains(®ion->extents, &damage->extents)) { __sna_damage_destroy(damage); @@ -1033,14 +1033,11 @@ inline static struct sna_damage *__sna_damage_subtract_box(struct sna_damage *da if (damage == NULL) return NULL; - if (!RegionNotEmpty(&damage->region)) { - __sna_damage_destroy(damage); - return NULL; - } - if (!sna_damage_maybe_contains_box(damage, box)) return damage; + assert(RegionNotEmpty(&damage->region)); + if (box_contains(box, &damage->extents)) { __sna_damage_destroy(damage); return NULL; |