mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 09:08:16 +02:00
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:
parent
69e52c6707
commit
1578530557
1 changed files with 11 additions and 2 deletions
|
|
@ -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 (®ion->ref_count, 1);
|
||||
region->status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (count == 1) {
|
||||
pixman_region32_init_rect (®ion->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 (®ion->ref_count, 1);
|
||||
region->status = CAIRO_STATUS_SUCCESS;
|
||||
return region;
|
||||
}
|
||||
slim_hidden_def (cairo_region_create_rectangles);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue