summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-12-11 16:56:53 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-12-11 16:56:53 +0000
commit118ef0781c5064aa0696af59a5dac67091b10046 (patch)
tree10376288aa93b0ffca17d7d9eac21a1d7d3e5011
parent2674ef864c93034d728ee11ee0b7ab96cd4cba57 (diff)
sna/composite: Make the check for a no-op earlier and clearer
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_composite.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c
index 1d66a8d9..3c04d323 100644
--- a/src/sna/sna_composite.c
+++ b/src/sna/sna_composite.c
@@ -49,6 +49,12 @@ region_is_singular(pixman_region16_t *region)
return region->data == NULL;
}
+static inline bool
+region_is_empty(pixman_region16_t *region)
+{
+ return region->data && region->data->numRects == 0;
+}
+
static inline pixman_bool_t
clip_to_dst(pixman_region16_t *region,
pixman_region16_t *clip,
@@ -84,7 +90,7 @@ clip_to_dst(pixman_region16_t *region,
}
return TRUE;
- } else if (!pixman_region_not_empty(clip)) {
+ } else if (region_is_empty(clip)) {
return FALSE;
} else {
if (dx | dy)
@@ -94,7 +100,7 @@ clip_to_dst(pixman_region16_t *region,
if (dx | dy)
pixman_region_translate(region, dx, dy);
- return pixman_region_not_empty(region);
+ return !region_is_empty(region);
}
}
@@ -116,7 +122,7 @@ clip_to_src(RegionPtr region, PicturePtr p, int dx, int dy)
-(p->clipOrigin.x + dx),
-(p->clipOrigin.y + dy));
- return result && pixman_region_not_empty(region);
+ return result && !region_is_empty(region);
}
Bool
@@ -231,7 +237,7 @@ sna_compute_composite_region(RegionPtr region,
region->extents.x2, region->extents.y2));
}
- return pixman_region_not_empty(region);
+ return !region_is_empty(region);
}
static void
@@ -405,6 +411,11 @@ sna_composite(CARD8 op,
dst_x, dst_y, dst->pDrawable->x, dst->pDrawable->y,
width, height));
+ if (region_is_empty(dst->pCompositeClip)) {
+ DBG(("%s: empty clip, skipping\n", __FUNCTION__));
+ return;
+ }
+
if (mask && sna_composite_mask_is_opaque(mask)) {
DBG(("%s: removing opaque %smask\n",
__FUNCTION__,
@@ -594,6 +605,11 @@ sna_composite_rectangles(CARD8 op,
if (!num_rects)
return;
+ if (region_is_empty(dst->pCompositeClip)) {
+ DBG(("%s: empty clip, skipping\n", __FUNCTION__));
+ return;
+ }
+
if (color->alpha <= 0x00ff) {
switch (op) {
case PictOpOver:
@@ -631,11 +647,6 @@ sna_composite_rectangles(CARD8 op,
}
DBG(("%s: converted to op %d\n", __FUNCTION__, op));
- if (!pixman_region_not_empty(dst->pCompositeClip)) {
- DBG(("%s: empty clip, skipping\n", __FUNCTION__));
- return;
- }
-
if (!_pixman_region_init_clipped_rectangles(&region,
num_rects, rects,
dst->pDrawable->x, dst->pDrawable->y,
@@ -652,7 +663,7 @@ sna_composite_rectangles(CARD8 op,
RegionNumRects(&region)));
if (!pixman_region_intersect(&region, &region, dst->pCompositeClip) ||
- !pixman_region_not_empty(&region)) {
+ region_is_empty(&region)) {
DBG(("%s: zero-intersection between rectangles and clip\n",
__FUNCTION__));
pixman_region_fini(&region);