summaryrefslogtreecommitdiff
path: root/src/cairo-region.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-07-23 19:45:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-07-23 20:02:35 +0100
commit1578530557481346f98f449d0f2885a7c985a222 (patch)
treea8928677510682a03e7e2b4ee20c4f1616d5f0a8 /src/cairo-region.c
parent69e52c670739f23ceb344a780dbc04f3cacebf56 (diff)
downloadcairo-1578530557481346f98f449d0f2885a7c985a222.tar.gz
region: Directly handle single rectangle creation in create_rectangles()
In order to avoid the copy and transformation of the single rectangle, we can simply pass it to pixman and create the region from it. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-region.c')
-rw-r--r--src/cairo-region.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 5e29bfe17..f3ccb898a 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -236,6 +236,17 @@ cairo_region_create_rectangles (const cairo_rectangle_int_t *rects,
if (unlikely (region == NULL))
return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
+ CAIRO_REFERENCE_COUNT_INIT (&region->ref_count, 1);
+ region->status = CAIRO_STATUS_SUCCESS;
+
+ if (count == 1) {
+ pixman_region32_init_rect (&region->rgn,
+ rects->x, rects->y,
+ rects->width, rects->height);
+
+ return region;
+ }
+
if (count > ARRAY_LENGTH (stack_pboxes)) {
pboxes = _cairo_malloc_ab (count, sizeof (pixman_box32_t));
if (unlikely (pboxes == NULL)) {
@@ -261,8 +272,6 @@ cairo_region_create_rectangles (const cairo_rectangle_int_t *rects,
return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
- CAIRO_REFERENCE_COUNT_INIT (&region->ref_count, 1);
- region->status = CAIRO_STATUS_SUCCESS;
return region;
}
slim_hidden_def (cairo_region_create_rectangles);