From cf4eb827861bf70d4d45a2ffe062d4c05a1564a6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 9 Apr 2014 10:22:49 +0100 Subject: sna: Restore empty region checking commit 8ef81d676c52e42a6d9048fd92b2843470b62945 Author: Chris Wilson Date: Mon Apr 7 07:59:42 2014 +0100 sna: Simplify checking for singular damage overlooked that we were also checking for empty regions as well as singular regions. Signed-off-by: Chris Wilson --- src/sna/sna_damage.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index f80ce229..f98c2827 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -55,11 +55,16 @@ struct sna_damage_box { static struct sna_damage *__freed_damage; -static inline bool region_is_singular(RegionRec *r) +static inline bool region_is_singular(const RegionRec *r) { return r->data == NULL; } +static inline bool region_is_singular_or_empty(const RegionRec *r) +{ + return r->data == NULL || r->data->numRects == 0; +} + #if HAS_DEBUG_FULL static const char *_debug_describe_region(char *buf, int max, const RegionRec *region) @@ -641,7 +646,7 @@ static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, break; } - if (damage->region.data == NULL || + if (region_is_singular_or_empty(&damage->region) || box_contains_region(box, &damage->region)) { _pixman_region_union_box(&damage->region, box); assert(damage->region.extents.x2 > damage->region.extents.x1); @@ -676,10 +681,10 @@ inline static struct sna_damage *__sna_damage_add(struct sna_damage *damage, break; } - if (region->data == NULL) + if (region_is_singular(region)) return __sna_damage_add_box(damage, ®ion->extents); - if (damage->region.data == NULL) { + if (region_is_singular_or_empty(&damage->region)) { pixman_region_union(&damage->region, &damage->region, region); assert(damage->region.extents.x2 > damage->region.extents.x1); assert(damage->region.extents.y2 > damage->region.extents.y1); -- cgit v1.2.3