summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-09-12 12:20:24 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-09-12 12:20:24 +0100
commit03a7fc16f9ef00ca5591655337621ec67bc37cba (patch)
treec9b3ce301a8eea8ecbf5c0783b08b474f2a54b20
parent2540c877d4811b318e1c2cd707745e5b06c9fa4b (diff)
sna: Avoid the call overhead for the trivial clip case
Profile guided micro-optimisation. /o\ Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_composite.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c
index 9c623fde..bda40c3e 100644
--- a/src/sna/sna_composite.c
+++ b/src/sna/sna_composite.c
@@ -61,6 +61,12 @@ static void dst_move_area_to_cpu(PicturePtr picture,
#define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
+static inline bool
+region_is_singular(pixman_region16_t *region)
+{
+ return region->data == NULL;
+}
+
static inline pixman_bool_t
clip_to_dst(pixman_region16_t *region,
pixman_region16_t *clip,
@@ -76,10 +82,9 @@ clip_to_dst(pixman_region16_t *region,
clip->extents.x1, clip->extents.y1,
clip->extents.x2, clip->extents.y2));
- if (pixman_region_n_rects(region) == 1 &&
- pixman_region_n_rects(clip) == 1) {
- pixman_box16_t *r = pixman_region_rectangles(region, NULL);
- pixman_box16_t *c = pixman_region_rectangles(clip, NULL);
+ if (region_is_singular(region) && region_is_singular(clip)) {
+ pixman_box16_t *r = &region->extents;
+ pixman_box16_t *c = &clip->extents;
int v;
if (r->x1 < (v = c->x1 + dx))
@@ -91,8 +96,12 @@ clip_to_dst(pixman_region16_t *region,
if (r->y2 > (v = c->y2 + dy))
r->y2 = BOUND(v);
- if (r->x1 >= r->x2 || r->y1 >= r->y2)
+ if (r->x1 >= r->x2 || r->y1 >= r->y2) {
pixman_region_init(region);
+ return FALSE;
+ }
+
+ return TRUE;
} else if (!pixman_region_not_empty(clip)) {
return FALSE;
} else {
@@ -102,8 +111,9 @@ clip_to_dst(pixman_region16_t *region,
return FALSE;
if (dx | dy)
pixman_region_translate(region, dx, dy);
+
+ return pixman_region_not_empty(region);
}
- return pixman_region_not_empty(region);
}
static inline Bool