[cairo-commit] src/cairo-region.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Jul 23 12:17:44 PDT 2011


 src/cairo-region.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 1578530557481346f98f449d0f2885a7c985a222
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 23 19:45:30 2011 +0100

    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 at chris-wilson.co.uk>

diff --git a/src/cairo-region.c b/src/cairo-region.c
index 5e29bfe..f3ccb89 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);


More information about the cairo-commit mailing list