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>
This commit is contained in:
Chris Wilson 2011-07-23 19:45:30 +01:00
parent 69e52c6707
commit 1578530557

View file

@ -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);