[cairo-commit] 18 commits - src/cairo-analysis-surface.c src/cairo-clip.c src/cairo-clip-private.h src/cairo-directfb-surface.c src/cairo.h src/cairo-image-surface.c src/cairoint.h src/cairo-paginated-surface.c src/cairo-region.c src/cairo-region-private.h src/cairo-surface.c src/cairo-surface-fallback.c src/cairo-traps.c src/cairo-types-private.h src/cairo-win32-surface.c src/cairo-xcb-surface.c src/cairo-xlib-surface.c src/Makefile.sources

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Sat Mar 28 17:41:30 PDT 2009


 src/Makefile.sources          |    1 
 src/cairo-analysis-surface.c  |   29 --
 src/cairo-clip-private.h      |    4 
 src/cairo-clip.c              |  134 ++++------
 src/cairo-directfb-surface.c  |   26 +-
 src/cairo-image-surface.c     |    2 
 src/cairo-paginated-surface.c |   34 +-
 src/cairo-region-private.h    |  113 --------
 src/cairo-region.c            |  538 +++++++++++++++++++++++++++++++++++-------
 src/cairo-surface-fallback.c  |   67 ++---
 src/cairo-surface.c           |   55 +---
 src/cairo-traps.c             |   61 ++--
 src/cairo-types-private.h     |   42 ---
 src/cairo-win32-surface.c     |   50 +--
 src/cairo-xcb-surface.c       |   24 -
 src/cairo-xlib-surface.c      |   41 +--
 src/cairo.h                   |   78 ++++++
 src/cairoint.h                |   26 +-
 18 files changed, 789 insertions(+), 536 deletions(-)

New commits:
commit 62d84847c3b857b8fd5aeea3f4b5c0f2f4c91625
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Sat Mar 28 03:58:51 2009 -0400

    [region] Add documentation for all the new region methods.

diff --git a/src/cairo-region.c b/src/cairo-region.c
index aec1bdf..e162321 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -76,6 +76,19 @@ cairo_region_set_error (cairo_region_t *region,
     return _cairo_error (status);
 }
 
+/**
+ * cairo_region_create:
+ *
+ * Allocates a new empty region object.
+ * 
+ * Return value: A newly allocated #cairo_region_t. Free with
+ *   cairo_region_destroy(). This function always returns a
+ *   valid pointer; if memory cannot be allocated, then a special
+ *   error object is returned where all operations on the object do nothing.
+ *   You can check for this with cairo_region_status().
+ * 
+ * Since: 1.10
+ **/
 cairo_region_t *
 cairo_region_create (void)
 {
@@ -91,8 +104,22 @@ cairo_region_create (void)
     return region;
 }
 
+/**
+ * cairo_region_create_rectangle:
+ * @rectangle: a #cairo_rectangle_int_t
+ *
+ * Allocates a new region object containing @rectangle.
+ * 
+ * Return value: A newly allocated #cairo_region_t. Free with
+ *   cairo_region_destroy(). This function always returns a
+ *   valid pointer; if memory cannot be allocated, then a special
+ *   error object is returned where all operations on the object do nothing.
+ *   You can check for this with cairo_region_status().
+ * 
+ * Since: 1.10
+ **/
 cairo_region_t *
-cairo_region_create_rectangle (cairo_rectangle_int_t *rect)
+cairo_region_create_rectangle (cairo_rectangle_int_t *rectangle)
 {
     cairo_region_t *region = _cairo_malloc (sizeof (cairo_region_t));
 
@@ -102,22 +129,26 @@ cairo_region_create_rectangle (cairo_rectangle_int_t *rect)
     region->status = CAIRO_STATUS_SUCCESS;
     
     pixman_region32_init_rect (&region->rgn,
-			       rect->x, rect->y,
-			       rect->width, rect->height);
+			       rectangle->x, rectangle->y,
+			       rectangle->width, rectangle->height);
 
     return region;
 }
 
-void
-cairo_region_destroy (cairo_region_t *region)
-{
-    if (region->status)
-	return;
-    
-    pixman_region32_fini (&region->rgn);
-    free (region);
-}
-
+/**
+ * cairo_region_copy:
+ * @original: a #cairo_region_t
+ * 
+ * Allocates a new region object copying the area from @original.
+ * 
+ * Return value: A newly allocated #cairo_region_t. Free with
+ *   cairo_region_destroy(). This function always returns a
+ *   valid pointer; if memory cannot be allocated, then a special
+ *   error object is returned where all operations on the object do nothing.
+ *   You can check for this with cairo_region_status().
+ * 
+ * Since: 1.10
+ **/
 cairo_region_t *
 cairo_region_copy (cairo_region_t *original)
 {
@@ -139,6 +170,36 @@ cairo_region_copy (cairo_region_t *original)
     return copy;
 }
 
+/**
+ * cairo_region_destroy:
+ * @region: a #cairo_region_t
+ * 
+ * Destroys a #cairo_region_t object created with
+ * cairo_region_create(), cairo_region_copy(), or
+ * or cairo_region_create_rectangle().
+ * 
+ * Since: 1.10
+ **/
+void
+cairo_region_destroy (cairo_region_t *region)
+{
+    if (region->status)
+	return;
+    
+    pixman_region32_fini (&region->rgn);
+    free (region);
+}
+
+/**
+ * cairo_region_num_rectangles:
+ * @region: a #cairo_region_t
+ * 
+ * Returns the number of rectangles contained in @region.
+ * 
+ * Return value: The number of rectangles contained in @region.
+ * 
+ * Since: 1.10
+ **/
 int
 cairo_region_num_rectangles (cairo_region_t *region)
 {
@@ -148,30 +209,42 @@ cairo_region_num_rectangles (cairo_region_t *region)
     return pixman_region32_n_rects (&region->rgn);
 }
 
+/**
+ * cairo_region_get_rectangle:
+ * @region: a #cairo_region_t
+ * @nth: a number indicating which rectangle should be returned
+ * @rectangle: return location for a #cairo_rectangle_int_t
+ * 
+ * Stores the @nth rectangle from the region in @rectangle.
+ * 
+ * Since: 1.10
+ **/
 void
 cairo_region_get_rectangle (cairo_region_t *region,
-			    int nth_box,
-			    cairo_rectangle_int_t *rect)
+			    int nth,
+			    cairo_rectangle_int_t *rectangle)
 {
     pixman_box32_t *pbox;
 
     if (region->status)
 	return;
     
-    pbox = pixman_region32_rectangles (&region->rgn, NULL) + nth_box;
+    pbox = pixman_region32_rectangles (&region->rgn, NULL) + nth;
 
-    rect->x = pbox->x1;
-    rect->y = pbox->y1;
-    rect->width = pbox->x2 - pbox->x1;
-    rect->height = pbox->y2 - pbox->y1;
+    rectangle->x = pbox->x1;
+    rectangle->y = pbox->y1;
+    rectangle->width = pbox->x2 - pbox->x1;
+    rectangle->height = pbox->y2 - pbox->y1;
 }
 
 /**
  * cairo_region_get_extents:
  * @region: a #cairo_region_t
- * @rect: rectangle into which to store the extents
+ * @rectangle: rectangle into which to store the extents
  *
- * Gets the bounding box of a region as a #cairo_rectangle_int_t
+ * Gets the bounding rectangle of @region as a #cairo_rectangle_int_t
+ *
+ * Since: 1.10
  **/
 void
 cairo_region_get_extents (cairo_region_t *region,
@@ -190,12 +263,34 @@ cairo_region_get_extents (cairo_region_t *region,
     extents->height = pextents->y2 - pextents->y1;
 }
 
+/**
+ * cairo_region_status:
+ * @region: a #cairo_region_t
+ * 
+ * Checks whether an error has previous occured for this
+ * region object.
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * 
+ * Since: 1.10
+ **/
 cairo_status_t
 cairo_region_status (cairo_region_t *region)
 {
     return region->status;
 }
 
+/**
+ * cairo_region_subtract:
+ * @dst: a #cairo_region_t 
+ * @other: another #cairo_region_t
+ * 
+ * Subtracts @other from @dst and places the result in @dst
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * 
+ * Since: 1.10
+ **/
 cairo_status_t
 cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
 {
@@ -211,6 +306,17 @@ cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
     return CAIRO_STATUS_SUCCESS;
 }
 
+/**
+ * cairo_region_subtract_rectangle:
+ * @dst: a #cairo_region_t
+ * @rectangle: a #cairo_rectangle_int_t
+ *
+ * Subtracts @rectangle from @dst and places the result in @dst
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * 
+ * Since: 1.10
+ **/
 cairo_status_t
 cairo_region_subtract_rectangle (cairo_region_t *dst,
 				 cairo_rectangle_int_t *rectangle)
@@ -233,6 +339,17 @@ cairo_region_subtract_rectangle (cairo_region_t *dst,
     return status;
 }
 
+/**
+ * cairo_region_intersect:
+ * @dst: a #cairo_region_t
+ * @other: another #cairo_region_t
+ * 
+ * Computes the intersection of @dst with @other and places the result in @dst
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * 
+ * Since: 1.10
+ **/
 cairo_status_t
 cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
 {
@@ -248,9 +365,20 @@ cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
     return CAIRO_STATUS_SUCCESS;
 }
 
+/**
+ * cairo_region_intersect_rectangle:
+ * @dst: a #cairo_region_t
+ * @rectangle: a #cairo_rectangle_int_t
+ * 
+ * Computes the intersection of @dst with @rectangle and places the result in @dst
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * 
+ * Since: 1.10
+ **/
 cairo_status_t
 cairo_region_intersect_rectangle (cairo_region_t *dst,
-				  const cairo_rectangle_int_t *rect)
+				  const cairo_rectangle_int_t *rectangle)
 {
     cairo_status_t status = CAIRO_STATUS_SUCCESS;
     pixman_region32_t region;
@@ -259,7 +387,8 @@ cairo_region_intersect_rectangle (cairo_region_t *dst,
 	return dst->status;
     
     pixman_region32_init_rect (&region,
-			       rect->x, rect->y, rect->width, rect->height);
+			       rectangle->x, rectangle->y,
+			       rectangle->width, rectangle->height);
 
     if (!pixman_region32_intersect (&dst->rgn, &dst->rgn, &region))
 	status = cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
@@ -269,6 +398,17 @@ cairo_region_intersect_rectangle (cairo_region_t *dst,
     return status;
 }
 
+/**
+ * cairo_region_union:
+ * @dst: a #cairo_region_t
+ * @other: another #cairo_region_t
+ * 
+ * Computes the union of @dst with @other and places the result in @dst
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * 
+ * Since: 1.10
+ **/
 cairo_status_t
 cairo_region_union (cairo_region_t *dst,
 		    cairo_region_t *other)
@@ -285,15 +425,27 @@ cairo_region_union (cairo_region_t *dst,
     return CAIRO_STATUS_SUCCESS;
 }
 
+/**
+ * cairo_region_union_rectangle:
+ * @dst: a #cairo_region_t
+ * @rectangle: a #cairo_rectangle_int_t
+ * 
+ * Computes the union of @dst with @rectangle and places the result in @dst.
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * 
+ * Since: 1.10
+ **/
 cairo_status_t
 cairo_region_union_rectangle (cairo_region_t *dst,
-			      const cairo_rectangle_int_t *rect)
+			      const cairo_rectangle_int_t *rectangle)
 {
     cairo_status_t status = CAIRO_STATUS_SUCCESS;
     pixman_region32_t region;
 
     pixman_region32_init_rect (&region,
-			       rect->x, rect->y, rect->width, rect->height);
+			       rectangle->x, rectangle->y,
+			       rectangle->width, rectangle->height);
     
     if (!pixman_region32_union (&dst->rgn, &dst->rgn, &region))
 	status = cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
@@ -303,6 +455,16 @@ cairo_region_union_rectangle (cairo_region_t *dst,
     return status;
 }
 
+/**
+ * cairo_region_empty:
+ * @region: a #cairo_region_t
+ * 
+ * Checks whether @region is empty.
+ * 
+ * Return value: %TRUE if @region is empty, %FALSE if it isn't.
+ * 
+ * Since: 1.10
+ **/
 cairo_bool_t
 cairo_region_empty (cairo_region_t *region)
 {
@@ -312,6 +474,16 @@ cairo_region_empty (cairo_region_t *region)
     return !pixman_region32_not_empty (&region->rgn);
 }
 
+/**
+ * cairo_region_translate:
+ * @region: a #cairo_region_t
+ * @dx: Amount to translate in the x direction
+ * @dy: Amount to translate in the y direction
+ * 
+ * Translates @region by (@dx, @dy).
+ * 
+ * Since: 1.10
+ **/
 void
 cairo_region_translate (cairo_region_t *region,
 			int dx, int dy)
@@ -322,19 +494,33 @@ cairo_region_translate (cairo_region_t *region,
     pixman_region32_translate (&region->rgn, dx, dy);
 }
 
+/**
+ * cairo_region_contains_rectangle:
+ * @region: a #cairo_region_t
+ * @rectangle: a #cairo_rectangle_int_t
+ * 
+ * Checks whether @rectangle is inside, outside or partially contained in @region
+ * 
+ * Return value:
+ *   %CAIRO_REGION_OVERLAP_IN if @rectangle is entirely inside @region,
+ *   %CAIRO_REGION_OVERLAP_OUT if @rectangle is entirely outside @region, or
+ *   %CAIRO_REGION_OVERLAP_PART if @rectangle is partially inside and partially outside @region.
+ * 
+ * Since: 1.10
+ **/
 cairo_region_overlap_t
 cairo_region_contains_rectangle (cairo_region_t *region,
-				 const cairo_rectangle_int_t *rect)
+				 const cairo_rectangle_int_t *rectangle)
 {
     pixman_box32_t pbox;
     pixman_region_overlap_t poverlap;
 
     if (!region->status)
     {
-	pbox.x1 = rect->x;
-	pbox.y1 = rect->y;
-	pbox.x2 = rect->x + rect->width;
-	pbox.y2 = rect->y + rect->height;
+	pbox.x1 = rectangle->x;
+	pbox.y1 = rectangle->y;
+	pbox.x2 = rectangle->x + rectangle->width;
+	pbox.y2 = rectangle->y + rectangle->height;
 	
 	poverlap = pixman_region32_contains_rectangle (&region->rgn, &pbox);
 	
@@ -354,6 +540,18 @@ cairo_region_contains_rectangle (cairo_region_t *region,
     return CAIRO_REGION_OVERLAP_OUT;
 }
 
+/**
+ * cairo_region_contains_point:
+ * @region: a #cairo_region_t
+ * @x: the x coordinate of a point
+ * @y: the y coordinate of a point
+ * 
+ * Checks whether (@x, @y) is contained in @region.
+ * 
+ * Return value: %TRUE if (@x, @y) is contained in @region, %FALSE if it is not.
+ * 
+ * Since: 1.10
+ **/
 cairo_bool_t
 cairo_region_contains_point (cairo_region_t *region,
 			     int x, int y)
diff --git a/src/cairo.h b/src/cairo.h
index c496185..025ca6c 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2368,7 +2368,7 @@ cairo_public cairo_region_t *
 cairo_region_create (void);
 
 cairo_public cairo_region_t *
-cairo_region_create_rectangle (cairo_rectangle_int_t *rect);
+cairo_region_create_rectangle (cairo_rectangle_int_t *rectangle);
 
 cairo_public cairo_region_t *
 cairo_region_copy (cairo_region_t *original);
@@ -2396,7 +2396,7 @@ cairo_region_empty (cairo_region_t *region);
 
 cairo_public cairo_region_overlap_t
 cairo_region_contains_rectangle (cairo_region_t *region,
-				 const cairo_rectangle_int_t *rect);
+				 const cairo_rectangle_int_t *rectangle);
 
 cairo_public cairo_bool_t
 cairo_region_contains_point (cairo_region_t *region, int x, int y);
@@ -2416,7 +2416,7 @@ cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other);
 
 cairo_public cairo_status_t
 cairo_region_intersect_rectangle (cairo_region_t *dst,
-				  const cairo_rectangle_int_t *rect);
+				  const cairo_rectangle_int_t *rectangle);
 
 cairo_public cairo_status_t
 cairo_region_union (cairo_region_t *dst, cairo_region_t *other);
commit 980e9f0dbd4f21c0ccf4cc33b0b0f2f370667290
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Sat Mar 28 03:04:28 2009 -0400

    [region] Fix status propagation for regions
    
    When an operation fails, store the status code in the destination
    region rather than leaving it unchanged.

diff --git a/src/cairo-region.c b/src/cairo-region.c
index 55898d9..aec1bdf 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -42,6 +42,40 @@ const cairo_region_t _cairo_region_nil = {
     CAIRO_STATUS_NO_MEMORY,		/* status */
 };
 
+/**
+ * cairo_region_set_error:
+ * @region: a region
+ * @status: a status value indicating an error
+ *
+ * Atomically sets region->status to @status and calls _cairo_error;
+ * Does nothing if status is %CAIRO_STATUS_SUCCESS or any of the internal
+ * status values.
+ *
+ * All assignments of an error status to region->status should happen
+ * through cairo_region_set_error(). Note that due to the nature of
+ * the atomic operation, it is not safe to call this function on the
+ * nil objects.
+ *
+ * The purpose of this function is to allow the user to set a
+ * breakpoint in _cairo_error() to generate a stack trace for when the
+ * user causes cairo to detect an error.
+ *
+ * Return value: the error status.
+ **/
+static cairo_status_t
+cairo_region_set_error (cairo_region_t *region,
+			cairo_status_t status)
+{
+    if (status == CAIRO_STATUS_SUCCESS || status >= CAIRO_INT_STATUS_UNSUPPORTED)
+	return status;
+
+    /* Don't overwrite an existing error. This preserves the first
+     * error, which is the most significant. */
+    _cairo_status_set_error (&region->status, status);
+
+    return _cairo_error (status);
+}
+
 cairo_region_t *
 cairo_region_create (void)
 {
@@ -172,7 +206,7 @@ cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
 	return other->status;
     
     if (!pixman_region32_subtract (&dst->rgn, &dst->rgn, &other->rgn))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -207,9 +241,9 @@ cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
 
     if (other->status)
 	return other->status;
-    
+
     if (!pixman_region32_intersect (&dst->rgn, &dst->rgn, &other->rgn))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -218,7 +252,7 @@ cairo_status_t
 cairo_region_intersect_rectangle (cairo_region_t *dst,
 				  const cairo_rectangle_int_t *rect)
 {
-    cairo_status_t result = CAIRO_STATUS_SUCCESS;
+    cairo_status_t status = CAIRO_STATUS_SUCCESS;
     pixman_region32_t region;
 
     if (dst->status)
@@ -228,11 +262,11 @@ cairo_region_intersect_rectangle (cairo_region_t *dst,
 			       rect->x, rect->y, rect->width, rect->height);
 
     if (!pixman_region32_intersect (&dst->rgn, &dst->rgn, &region))
-	result = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	status = cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
 
     pixman_region32_fini (&region);
     
-    return result;
+    return status;
 }
 
 cairo_status_t
@@ -246,7 +280,7 @@ cairo_region_union (cairo_region_t *dst,
 	return other->status;
 
     if (!pixman_region32_union (&dst->rgn, &dst->rgn, &other->rgn))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -255,14 +289,18 @@ cairo_status_t
 cairo_region_union_rectangle (cairo_region_t *dst,
 			      const cairo_rectangle_int_t *rect)
 {
-    if (!pixman_region32_union_rect (&dst->rgn, &dst->rgn,
-				     rect->x, rect->y,
-				     rect->width, rect->height))
-    {
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-    }
+    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    pixman_region32_t region;
 
-    return CAIRO_STATUS_SUCCESS;
+    pixman_region32_init_rect (&region,
+			       rect->x, rect->y, rect->width, rect->height);
+    
+    if (!pixman_region32_union (&dst->rgn, &dst->rgn, &region))
+	status = cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
+
+    pixman_region32_fini (&region);
+    
+    return status;
 }
 
 cairo_bool_t
commit 64e490a464472cfe06d779503601d41972ed4518
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Sat Mar 28 01:10:24 2009 -0400

    [region] Use signed ints for width and height in cairo_rectangle_int_t

diff --git a/src/cairo.h b/src/cairo.h
index 269fe4d..c496185 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2355,7 +2355,7 @@ typedef struct _cairo_region cairo_region_t;
 
 typedef struct _cairo_rectangle_int {
     int x, y;
-    unsigned int width, height;
+    int width, height;
 } cairo_rectangle_int_t;
 
 typedef enum _cairo_region_overlap {
commit 26999e5aa8b5d353596e31d4b3823cafe007125c
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Fri Mar 27 08:48:42 2009 -0400

    [region] Add cairo_region_intersect_rectangle() and _subtract_rectangle()
    
    Intersecting with and subtracting rectangles is quite common, and we
    already have cairo_union_rectangle().

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 8ee6a64..cc43c03 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -198,17 +198,8 @@ _cairo_clip_intersect_to_region (cairo_clip_t   *clip,
     if (!clip)
 	return CAIRO_STATUS_SUCCESS;
 
-    if (clip->all_clipped) {
-	cairo_region_t *clip_rect;
-
-	clip_rect = cairo_region_create_rectangle (&clip->surface_rect);
-
-	status = cairo_region_intersect (region, clip_rect);
-
-	cairo_region_destroy (clip_rect);
-
-	return status;
-    }
+    if (clip->all_clipped)
+	return cairo_region_intersect_rectangle (region, &clip->surface_rect);
 
     if (clip->path) {
 	/* Intersect clip path into region. */
@@ -220,18 +211,8 @@ _cairo_clip_intersect_to_region (cairo_clip_t   *clip,
 	    return status;
     }
 
-    if (clip->surface) {
-	cairo_region_t *clip_rect;
-
-	clip_rect = cairo_region_create_rectangle (&clip->surface_rect);
-
-	status = cairo_region_intersect (region, clip_rect);
-
-	cairo_region_destroy (clip_rect);
-
-        if (unlikely (status))
-            return status;
-    }
+    if (clip->surface)
+	return cairo_region_intersect_rectangle (region, &clip->surface_rect);
 
     return CAIRO_STATUS_SUCCESS;
 }
diff --git a/src/cairo-region.c b/src/cairo-region.c
index a2a7a82..55898d9 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -178,6 +178,28 @@ cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
 }
 
 cairo_status_t
+cairo_region_subtract_rectangle (cairo_region_t *dst,
+				 cairo_rectangle_int_t *rectangle)
+{
+    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    pixman_region32_t region;
+
+    if (dst->status)
+	return dst->status;
+    
+    pixman_region32_init_rect (&region,
+			       rectangle->x, rectangle->y,
+			       rectangle->width, rectangle->height);
+
+    if (!pixman_region32_subtract (&dst->rgn, &dst->rgn, &region))
+	status = cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY);
+
+    pixman_region32_fini (&region);
+    
+    return status;
+}
+
+cairo_status_t
 cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
 {
     if (dst->status)
@@ -193,6 +215,27 @@ cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
 }
 
 cairo_status_t
+cairo_region_intersect_rectangle (cairo_region_t *dst,
+				  const cairo_rectangle_int_t *rect)
+{
+    cairo_status_t result = CAIRO_STATUS_SUCCESS;
+    pixman_region32_t region;
+
+    if (dst->status)
+	return dst->status;
+    
+    pixman_region32_init_rect (&region,
+			       rect->x, rect->y, rect->width, rect->height);
+
+    if (!pixman_region32_intersect (&dst->rgn, &dst->rgn, &region))
+	result = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
+    pixman_region32_fini (&region);
+    
+    return result;
+}
+
+cairo_status_t
 cairo_region_union (cairo_region_t *dst,
 		    cairo_region_t *other)
 {
@@ -210,7 +253,7 @@ cairo_region_union (cairo_region_t *dst,
 
 cairo_status_t
 cairo_region_union_rectangle (cairo_region_t *dst,
-			      cairo_rectangle_int_t *rect)
+			      const cairo_rectangle_int_t *rect)
 {
     if (!pixman_region32_union_rect (&dst->rgn, &dst->rgn,
 				     rect->x, rect->y,
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 82cd57e..1c8445f 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2679,8 +2679,6 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
 {
     cairo_rectangle_int_t dst_rectangle;
     cairo_rectangle_int_t drawn_rectangle;
-    cairo_bool_t has_drawn_region = FALSE;
-    cairo_region_t *drawn_region = NULL;
     cairo_region_t *clear_region = NULL;
     cairo_status_t status;
 
@@ -2708,10 +2706,7 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
 
     /* Now compute the area that is in dst_rectangle but not in drawn_rectangle
      */
-    drawn_region = cairo_region_create_rectangle (&drawn_rectangle);
-    has_drawn_region = TRUE;
-
-    status = cairo_region_subtract (clear_region, drawn_region);
+    status = cairo_region_subtract_rectangle (clear_region, &drawn_rectangle);
     if (unlikely (status))
         goto CLEANUP_REGIONS;
 
@@ -2721,8 +2716,6 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
                                          clear_region);
 
   CLEANUP_REGIONS:
-    if (drawn_region)
-        cairo_region_destroy (drawn_region);
     cairo_region_destroy (clear_region);
 
     return _cairo_surface_set_error (dst, status);
diff --git a/src/cairo.h b/src/cairo.h
index 7a5a4d3..269fe4d 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2408,13 +2408,22 @@ cairo_public cairo_status_t
 cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other);
 
 cairo_public cairo_status_t
+cairo_region_subtract_rectangle (cairo_region_t *dst,
+				 cairo_rectangle_int_t *rectangle);
+
+cairo_public cairo_status_t
 cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other);
 
 cairo_public cairo_status_t
+cairo_region_intersect_rectangle (cairo_region_t *dst,
+				  const cairo_rectangle_int_t *rect);
+
+cairo_public cairo_status_t
 cairo_region_union (cairo_region_t *dst, cairo_region_t *other);
 
 cairo_public cairo_status_t
-cairo_region_union_rectangle (cairo_region_t *dst, cairo_rectangle_int_t *rectangle);
+cairo_region_union_rectangle (cairo_region_t *dst,
+			      const cairo_rectangle_int_t *rectangle);
 
 
 /* Functions to be used while debugging (not intended for use in production code) */
diff --git a/src/cairoint.h b/src/cairoint.h
index 1f209a7..6c5fd5a 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2707,7 +2707,9 @@ slim_hidden_proto (cairo_region_contains_rectangle);
 slim_hidden_proto (cairo_region_contains_point);
 slim_hidden_proto (cairo_region_translate);
 slim_hidden_proto (cairo_region_subtract);
+slim_hidden_proto (cairo_region_subtract_rectangle);
 slim_hidden_proto (cairo_region_intersect);
+slim_hidden_proto (cairo_region_intersect_rectangle);
 slim_hidden_proto (cairo_region_union);
 slim_hidden_proto (cairo_region_union_rectangle);
 
commit 4b3245481cfbf96388c140421a071fd1f79ad601
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Sat Feb 21 08:13:25 2009 -0500

    [region] Expand rect to rectangle in a couple of names
    
    Specifically,
    
    	cairo_region_union_rect  ->  cairo_region_union_rectangle
    	cairo_region_create_rect ->  cairo_region_create_rectangle
    
    Also delete cairo_region_clear() which is not that useful.

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index feaa9d3..cd79985 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -234,7 +234,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
 	 * this region will be emitted as native operations.
 	 */
 	surface->has_supported = TRUE;
-	status = cairo_region_union_rect (surface->supported_region, rect);
+	status = cairo_region_union_rectangle (surface->supported_region, rect);
 	return status;
     }
 
@@ -243,7 +243,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
      * emitted.
      */
     surface->has_unsupported = TRUE;
-    status = cairo_region_union_rect (surface->fallback_region, rect);
+    status = cairo_region_union_rectangle (surface->fallback_region, rect);
 
     /* The status CAIRO_INT_STATUS_IMAGE_FALLBACK is used to indicate
      * unsupported operations to the meta surface as using
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 58b6335..8ee6a64 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -201,7 +201,7 @@ _cairo_clip_intersect_to_region (cairo_clip_t   *clip,
     if (clip->all_clipped) {
 	cairo_region_t *clip_rect;
 
-	clip_rect = cairo_region_create_rect (&clip->surface_rect);
+	clip_rect = cairo_region_create_rectangle (&clip->surface_rect);
 
 	status = cairo_region_intersect (region, clip_rect);
 
@@ -223,7 +223,7 @@ _cairo_clip_intersect_to_region (cairo_clip_t   *clip,
     if (clip->surface) {
 	cairo_region_t *clip_rect;
 
-	clip_rect = cairo_region_create_rect (&clip->surface_rect);
+	clip_rect = cairo_region_create_rectangle (&clip->surface_rect);
 
 	status = cairo_region_intersect (region, clip_rect);
 
diff --git a/src/cairo-region.c b/src/cairo-region.c
index bc6598a..a2a7a82 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -58,7 +58,7 @@ cairo_region_create (void)
 }
 
 cairo_region_t *
-cairo_region_create_rect (cairo_rectangle_int_t *rect)
+cairo_region_create_rectangle (cairo_rectangle_int_t *rect)
 {
     cairo_region_t *region = _cairo_malloc (sizeof (cairo_region_t));
 
@@ -162,16 +162,6 @@ cairo_region_status (cairo_region_t *region)
     return region->status;
 }
 
-void
-cairo_region_clear (cairo_region_t *region)
-{
-    if (region->status)
-	return;
-
-    pixman_region32_fini (&region->rgn);
-    pixman_region32_init (&region->rgn);
-}
-
 cairo_status_t
 cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
 {
@@ -219,8 +209,8 @@ cairo_region_union (cairo_region_t *dst,
 }
 
 cairo_status_t
-cairo_region_union_rect (cairo_region_t *dst,
-			 cairo_rectangle_int_t *rect)
+cairo_region_union_rectangle (cairo_region_t *dst,
+			      cairo_rectangle_int_t *rect)
 {
     if (!pixman_region32_union_rect (&dst->rgn, &dst->rgn,
 				     rect->x, rect->y,
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 42d86e7..cbe92b2 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -567,7 +567,7 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
              * _cairo_surface_fill_rectangles() or to drawing with a
              * clip region, then we have an additional region to clear.
              */
-            clear_region = cairo_region_create_rect (&extents);
+            clear_region = cairo_region_create_rectangle (&extents);
 
 	    status = cairo_region_status (clear_region);
 	    if (unlikely (status))
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index e093122..82cd57e 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2692,7 +2692,7 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
     dst_rectangle.width = width;
     dst_rectangle.height = height;
 
-    clear_region = cairo_region_create_rect (&dst_rectangle);
+    clear_region = cairo_region_create_rectangle (&dst_rectangle);
 
     drawn_rectangle = dst_rectangle;
 
@@ -2708,7 +2708,7 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
 
     /* Now compute the area that is in dst_rectangle but not in drawn_rectangle
      */
-    drawn_region = cairo_region_create_rect (&drawn_rectangle);
+    drawn_region = cairo_region_create_rectangle (&drawn_rectangle);
     has_drawn_region = TRUE;
 
     status = cairo_region_subtract (clear_region, drawn_region);
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 2fc2fac..d91e0d8 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -649,7 +649,7 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
 	rect.width = x2 - x1;
 	rect.height = y2 - y1;
 
-	status = cairo_region_union_rect (r, &rect);
+	status = cairo_region_union_rectangle (r, &rect);
 	if (unlikely (status))
 	{
 	    cairo_region_destroy (r);
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index f547f5f..a6820af 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2302,7 +2302,7 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	 * is necessary so we don't wrap around when we convert cairo's
 	 * 32 bit region into 16 bit rectangles.
 	 */
-	bounded = cairo_region_create_rect (&rect);
+	bounded = cairo_region_create_rectangle (&rect);
 	status = cairo_region_intersect (bounded, region);
 	if (unlikely (status)) {
 	    cairo_region_destroy (bounded);
diff --git a/src/cairo.h b/src/cairo.h
index 16b203d..7a5a4d3 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2368,7 +2368,7 @@ cairo_public cairo_region_t *
 cairo_region_create (void);
 
 cairo_public cairo_region_t *
-cairo_region_create_rect (cairo_rectangle_int_t *rect);
+cairo_region_create_rectangle (cairo_rectangle_int_t *rect);
 
 cairo_public cairo_region_t *
 cairo_region_copy (cairo_region_t *original);
@@ -2402,9 +2402,6 @@ cairo_public cairo_bool_t
 cairo_region_contains_point (cairo_region_t *region, int x, int y);
 
 cairo_public void
-cairo_region_clear (cairo_region_t *region);
-
-cairo_public void
 cairo_region_translate (cairo_region_t *region, int dx, int dy);
 
 cairo_public cairo_status_t
@@ -2417,7 +2414,7 @@ cairo_public cairo_status_t
 cairo_region_union (cairo_region_t *dst, cairo_region_t *other);
 
 cairo_public cairo_status_t
-cairo_region_union_rect (cairo_region_t *dst, cairo_rectangle_int_t *rect);
+cairo_region_union_rectangle (cairo_region_t *dst, cairo_rectangle_int_t *rectangle);
 
 
 /* Functions to be used while debugging (not intended for use in production code) */
diff --git a/src/cairoint.h b/src/cairoint.h
index fbf8e35..1f209a7 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2695,7 +2695,7 @@ slim_hidden_proto (cairo_user_to_device);
 slim_hidden_proto (cairo_user_to_device_distance);
 slim_hidden_proto (cairo_version_string);
 slim_hidden_proto (cairo_region_create);
-slim_hidden_proto (cairo_region_create_rect);
+slim_hidden_proto (cairo_region_create_rectangle);
 slim_hidden_proto (cairo_region_copy);
 slim_hidden_proto (cairo_region_destroy);
 slim_hidden_proto (cairo_region_status);
@@ -2705,12 +2705,11 @@ slim_hidden_proto (cairo_region_get_rectangle);
 slim_hidden_proto (cairo_region_empty);
 slim_hidden_proto (cairo_region_contains_rectangle);
 slim_hidden_proto (cairo_region_contains_point);
-slim_hidden_proto (cairo_region_clear);
 slim_hidden_proto (cairo_region_translate);
 slim_hidden_proto (cairo_region_subtract);
 slim_hidden_proto (cairo_region_intersect);
 slim_hidden_proto (cairo_region_union);
-slim_hidden_proto (cairo_region_union_rect);
+slim_hidden_proto (cairo_region_union_rectangle);
 
 #if CAIRO_HAS_PNG_FUNCTIONS
 
commit bf6d9bc1758ac1971485b6565d29934d6b06bef2
Author: Søren Sandmann Pedersen <sandmann at daimi.au.dk>
Date:   Wed Feb 18 08:01:19 2009 -0500

    [region] Delete cairo_region_create_rectangles()
    
    It was only used in _cairo_traps_extract_region() which could be
    simplified significantly by calling cairo_region_union_rect()
    repeatedly instead.

diff --git a/src/cairo-region.c b/src/cairo-region.c
index 5d01d37..bc6598a 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -74,50 +74,6 @@ cairo_region_create_rect (cairo_rectangle_int_t *rect)
     return region;
 }
 
-cairo_region_t *
-cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
-				int count)
-{
-    pixman_box32_t stack_pboxes[CAIRO_STACK_ARRAY_LENGTH (pixman_box32_t)];
-    pixman_box32_t *pboxes = stack_pboxes;
-    cairo_region_t *region;
-    int i;
-
-    region = _cairo_malloc (sizeof (cairo_region_t));
-
-    if (!region)
-	return (cairo_region_t *)&_cairo_region_nil;
-
-    region->status = CAIRO_STATUS_SUCCESS;
-    
-    if (count > ARRAY_LENGTH (stack_pboxes)) {
-	pboxes = _cairo_malloc_ab (count, sizeof (pixman_box32_t));
-
-	if (unlikely (pboxes == NULL)) {
-	    free (region);
-	    return (cairo_region_t *)&_cairo_region_nil;
-	}
-    }
-
-    for (i = 0; i < count; i++) {
-	pboxes[i].x1 = rects[i].x;
-	pboxes[i].y1 = rects[i].y;
-	pboxes[i].x2 = rects[i].x + rects[i].width;
-	pboxes[i].y2 = rects[i].y + rects[i].height;
-    }
-
-    if (! pixman_region32_init_rects (&region->rgn, pboxes, count)) {
-	free (region);
-
-	region = (cairo_region_t *)&_cairo_region_nil;
-    }
-    
-    if (pboxes != stack_pboxes)
-	free (pboxes);
-
-    return region;
-}
-
 void
 cairo_region_destroy (cairo_region_t *region)
 {
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 73bb124..2fc2fac 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -610,17 +610,12 @@ cairo_int_status_t
 _cairo_traps_extract_region (const cairo_traps_t  *traps,
 			     cairo_region_t      **region)
 {
-    cairo_rectangle_int_t stack_rects[CAIRO_STACK_ARRAY_LENGTH (cairo_rectangle_int_t)];
-    cairo_rectangle_int_t *rects = stack_rects;
-    int i, rect_count;
-    cairo_int_status_t status;
-
-    if (traps->num_traps == 0) {
-	*region = cairo_region_create ();
-	return CAIRO_STATUS_SUCCESS;
-    }
+    cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_region_t *r;
+    int i;
 
-    for (i = 0; i < traps->num_traps; i++) {
+    for (i = 0; i < traps->num_traps; i++)
+    {
 	if (traps->traps[i].left.p1.x != traps->traps[i].left.p2.x   ||
 	    traps->traps[i].right.p1.x != traps->traps[i].right.p2.x ||
 	    ! _cairo_fixed_is_integer (traps->traps[i].top)          ||
@@ -632,17 +627,12 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
 	}
     }
 
-    if (traps->num_traps > ARRAY_LENGTH (stack_rects)) {
-	rects = _cairo_malloc_ab (traps->num_traps,
-				  sizeof (cairo_rectangle_int_t));
-
-	if (unlikely (rects == NULL))
-	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-    }
-
-    rect_count = 0;
-
-    for (i = 0; i < traps->num_traps; i++) {
+    r = cairo_region_create ();
+    
+    for (i = 0; i < traps->num_traps; i++)
+    {
+	cairo_rectangle_int_t rect;
+	
 	int x1 = _cairo_fixed_integer_part (traps->traps[i].left.p1.x);
 	int y1 = _cairo_fixed_integer_part (traps->traps[i].top);
 	int x2 = _cairo_fixed_integer_part (traps->traps[i].right.p1.x);
@@ -654,26 +644,22 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
 	if (x1 == x2 || y1 == y2)
 	    continue;
 
-	rects[rect_count].x = x1;
-	rects[rect_count].y = y1;
-	rects[rect_count].width = x2 - x1;
-	rects[rect_count].height = y2 - y1;
+	rect.x = x1;
+	rect.y = y1;
+	rect.width = x2 - x1;
+	rect.height = y2 - y1;
 
-	rect_count++;
+	status = cairo_region_union_rect (r, &rect);
+	if (unlikely (status))
+	{
+	    cairo_region_destroy (r);
+	    r = NULL;
+	    break;
+	}
     }
 
-    *region = cairo_region_create_rectangles (rects, rect_count);
-    status = cairo_region_status (*region);
+    *region = r;
     
-    if (rects != stack_rects)
-	free (rects);
-
-    if (unlikely (status))
-    {
-	cairo_region_destroy (*region);
-	*region = NULL;
-    }
-
     return status;
 }
 
diff --git a/src/cairo.h b/src/cairo.h
index adf34b9..16b203d 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2371,10 +2371,6 @@ cairo_public cairo_region_t *
 cairo_region_create_rect (cairo_rectangle_int_t *rect);
 
 cairo_public cairo_region_t *
-cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
-				int count);
-
-cairo_public cairo_region_t *
 cairo_region_copy (cairo_region_t *original);
 
 cairo_public void
diff --git a/src/cairoint.h b/src/cairoint.h
index 9d02d35..fbf8e35 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2696,7 +2696,6 @@ slim_hidden_proto (cairo_user_to_device_distance);
 slim_hidden_proto (cairo_version_string);
 slim_hidden_proto (cairo_region_create);
 slim_hidden_proto (cairo_region_create_rect);
-slim_hidden_proto (cairo_region_create_rectangles);
 slim_hidden_proto (cairo_region_copy);
 slim_hidden_proto (cairo_region_destroy);
 slim_hidden_proto (cairo_region_status);
commit e6d82afcab01cc91b88185abc8d1bfb9df5c2c19
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Wed Feb 18 00:20:46 2009 -0500

    [region] Add slim_hidden_proto for region functions

diff --git a/src/cairoint.h b/src/cairoint.h
index 071ac15..9d02d35 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2694,6 +2694,24 @@ slim_hidden_proto (cairo_user_font_face_set_unicode_to_glyph_func);
 slim_hidden_proto (cairo_user_to_device);
 slim_hidden_proto (cairo_user_to_device_distance);
 slim_hidden_proto (cairo_version_string);
+slim_hidden_proto (cairo_region_create);
+slim_hidden_proto (cairo_region_create_rect);
+slim_hidden_proto (cairo_region_create_rectangles);
+slim_hidden_proto (cairo_region_copy);
+slim_hidden_proto (cairo_region_destroy);
+slim_hidden_proto (cairo_region_status);
+slim_hidden_proto (cairo_region_get_extents);
+slim_hidden_proto (cairo_region_num_rectangles);
+slim_hidden_proto (cairo_region_get_rectangle);
+slim_hidden_proto (cairo_region_empty);
+slim_hidden_proto (cairo_region_contains_rectangle);
+slim_hidden_proto (cairo_region_contains_point);
+slim_hidden_proto (cairo_region_clear);
+slim_hidden_proto (cairo_region_translate);
+slim_hidden_proto (cairo_region_subtract);
+slim_hidden_proto (cairo_region_intersect);
+slim_hidden_proto (cairo_region_union);
+slim_hidden_proto (cairo_region_union_rect);
 
 #if CAIRO_HAS_PNG_FUNCTIONS
 
commit e29103c08189cab9de34f577951219a69bd7c8e2
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Wed Feb 18 00:11:35 2009 -0500

    [region] Move region function prototypes to cairo.h along with helper types.
    
    Move struct _cairo_region to cairoint.h and delete
    cairo-region-private.h. Delete cairo_private from the function
    definitions that had it.

diff --git a/src/Makefile.sources b/src/Makefile.sources
index 7305995..c1df770 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -78,7 +78,6 @@ cairo_private = \
 	cairo-path-private.h \
 	cairo-private.h \
 	cairo-reference-count-private.h \
-	cairo-region-private.h \
 	cairo-scaled-font-private.h \
 	cairo-skiplist-private.h \
 	cairo-spans-private.h \
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index d7d950a..feaa9d3 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -38,7 +38,6 @@
 
 #include "cairo-analysis-surface-private.h"
 #include "cairo-paginated-private.h"
-#include "cairo-region-private.h"
 #include "cairo-meta-surface-private.h"
 
 typedef struct {
diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index b1a9d1a..4229e4f 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -40,7 +40,6 @@
 #include "cairo-compiler-private.h"
 #include "cairo-path-fixed-private.h"
 #include "cairo-reference-count-private.h"
-#include "cairo-region-private.h"
 
 extern const cairo_private cairo_rectangle_list_t _cairo_rectangles_nil;
 
diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
deleted file mode 100644
index c9b2ae1..0000000
--- a/src/cairo-region-private.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Corporation
- *
- * Contributor(s):
- *	Vladimir Vukicevic <vladimir at pobox.com>
- */
-
-#ifndef CAIRO_REGION_PRIVATE_H
-#define CAIRO_REGION_PRIVATE_H
-
-#include "cairo-compiler-private.h"
-#include "cairo-types-private.h"
-
-#include <pixman.h>
-
-CAIRO_BEGIN_DECLS
-
-/* #cairo_region_t is defined in cairoint.h */
-
-struct _cairo_region {
-    cairo_status_t status;
-    
-    pixman_region32_t rgn;
-};
-
-typedef enum _cairo_region_overlap {
-    CAIRO_REGION_OVERLAP_IN,		/* completely inside region */
-    CAIRO_REGION_OVERLAP_OUT,		/* completely outside region */
-    CAIRO_REGION_OVERLAP_PART,		/* partly inside region */
-} cairo_region_overlap_t;
-
-cairo_private cairo_region_t *
-cairo_region_create (void);
-
-cairo_private cairo_region_t *
-cairo_region_create_rect (cairo_rectangle_int_t *rect);
-
-cairo_private cairo_status_t
-cairo_region_status (cairo_region_t *region);
-
-cairo_private void
-cairo_region_clear (cairo_region_t *region);
-
-cairo_private cairo_region_t *
-cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
-				 int count);
-
-cairo_private void
-cairo_region_destroy (cairo_region_t *region);
-
-cairo_private cairo_region_t *
-cairo_region_copy (cairo_region_t *original);
-
-cairo_private int
-cairo_region_num_rectangles (cairo_region_t *region);
-
-cairo_private void
-cairo_region_get_rectangle (cairo_region_t *region,
-			     int nth_rectangle,
-			     cairo_rectangle_int_t *rectangle);
-
-cairo_private void
-cairo_region_get_extents (cairo_region_t *region,
-			   cairo_rectangle_int_t *extents);
-
-cairo_private cairo_status_t
-cairo_region_subtract (cairo_region_t *dst,
-			cairo_region_t *other);
-
-cairo_private cairo_status_t
-cairo_region_intersect (cairo_region_t *dst,
-			 cairo_region_t *other);
-
-cairo_private cairo_status_t
-cairo_region_union (cairo_region_t *dst,
-		     cairo_region_t *other);
-
-cairo_private cairo_status_t
-cairo_region_union_rect (cairo_region_t *dst,
-			  cairo_rectangle_int_t *rect);
-
-cairo_private cairo_bool_t
-cairo_region_empty (cairo_region_t *region);
-
-cairo_private void
-cairo_region_translate (cairo_region_t *region,
-			 int dx, int dy);
-
-cairo_private cairo_region_overlap_t
-cairo_region_contains_rectangle (cairo_region_t *region,
-				  const cairo_rectangle_int_t *rect);
-
-cairo_private cairo_bool_t
-cairo_region_contains_point (cairo_region_t *region,
-			      int x, int y);
-
-CAIRO_END_DECLS
-
-#endif /* CAIRO_REGION_PRIVATE_H */
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 59ce0bf..5d01d37 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -158,7 +158,7 @@ cairo_region_num_rectangles (cairo_region_t *region)
     return pixman_region32_n_rects (&region->rgn);
 }
 
-cairo_private void
+void
 cairo_region_get_rectangle (cairo_region_t *region,
 			    int nth_box,
 			    cairo_rectangle_int_t *rect)
@@ -246,7 +246,7 @@ cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_private cairo_status_t
+cairo_status_t
 cairo_region_union (cairo_region_t *dst,
 		    cairo_region_t *other)
 {
@@ -327,7 +327,7 @@ cairo_region_contains_rectangle (cairo_region_t *region,
     return CAIRO_REGION_OVERLAP_OUT;
 }
 
-cairo_private cairo_bool_t
+cairo_bool_t
 cairo_region_contains_point (cairo_region_t *region,
 			     int x, int y)
 {
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index f075426..bb62351 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -59,7 +59,6 @@ typedef struct _cairo_output_stream cairo_output_stream_t;
 typedef struct _cairo_paginated_surface_backend cairo_paginated_surface_backend_t;
 typedef struct _cairo_path_fixed cairo_path_fixed_t;
 typedef struct _cairo_rectangle_int16 cairo_glyph_size_t;
-typedef struct _cairo_region cairo_region_t;
 typedef struct _cairo_scaled_font_backend   cairo_scaled_font_backend_t;
 typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t;
 typedef struct _cairo_solid_pattern cairo_solid_pattern_t;
@@ -218,11 +217,6 @@ typedef struct _cairo_trapezoid {
     cairo_line_t left, right;
 } cairo_trapezoid_t;
 
-typedef struct _cairo_rectangle_int {
-    int x, y;
-    unsigned int width, height;
-} cairo_rectangle_int_t;
-
 typedef struct _cairo_point_int {
     int x, y;
 } cairo_point_int_t;
diff --git a/src/cairo.h b/src/cairo.h
index f359d79..adf34b9 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2349,6 +2349,81 @@ cairo_public void
 cairo_matrix_transform_point (const cairo_matrix_t *matrix,
 			      double *x, double *y);
 
+/* Region functions */
+
+typedef struct _cairo_region cairo_region_t;
+
+typedef struct _cairo_rectangle_int {
+    int x, y;
+    unsigned int width, height;
+} cairo_rectangle_int_t;
+
+typedef enum _cairo_region_overlap {
+    CAIRO_REGION_OVERLAP_IN,		/* completely inside region */
+    CAIRO_REGION_OVERLAP_OUT,		/* completely outside region */
+    CAIRO_REGION_OVERLAP_PART,		/* partly inside region */
+} cairo_region_overlap_t;
+
+cairo_public cairo_region_t *
+cairo_region_create (void);
+
+cairo_public cairo_region_t *
+cairo_region_create_rect (cairo_rectangle_int_t *rect);
+
+cairo_public cairo_region_t *
+cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
+				int count);
+
+cairo_public cairo_region_t *
+cairo_region_copy (cairo_region_t *original);
+
+cairo_public void
+cairo_region_destroy (cairo_region_t *region);
+
+cairo_public cairo_status_t
+cairo_region_status (cairo_region_t *region);
+
+cairo_public void
+cairo_region_get_extents (cairo_region_t        *region,
+			  cairo_rectangle_int_t *extents);
+
+cairo_public int
+cairo_region_num_rectangles (cairo_region_t *region);
+
+cairo_public void
+cairo_region_get_rectangle (cairo_region_t        *region,
+			    int                    nth_rectangle,
+			    cairo_rectangle_int_t *rectangle);
+
+cairo_public cairo_bool_t
+cairo_region_empty (cairo_region_t *region);
+
+cairo_public cairo_region_overlap_t
+cairo_region_contains_rectangle (cairo_region_t *region,
+				 const cairo_rectangle_int_t *rect);
+
+cairo_public cairo_bool_t
+cairo_region_contains_point (cairo_region_t *region, int x, int y);
+
+cairo_public void
+cairo_region_clear (cairo_region_t *region);
+
+cairo_public void
+cairo_region_translate (cairo_region_t *region, int dx, int dy);
+
+cairo_public cairo_status_t
+cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other);
+
+cairo_public cairo_status_t
+cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other);
+
+cairo_public cairo_status_t
+cairo_region_union (cairo_region_t *dst, cairo_region_t *other);
+
+cairo_public cairo_status_t
+cairo_region_union_rect (cairo_region_t *dst, cairo_rectangle_int_t *rect);
+
+
 /* Functions to be used while debugging (not intended for use in production code) */
 cairo_public void
 cairo_debug_reset_static_data (void);
diff --git a/src/cairoint.h b/src/cairoint.h
index 30273c2..071ac15 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2528,7 +2528,11 @@ _cairo_pattern_reset_static_data (void);
 
 /* cairo-region.c */
 
-#include "cairo-region-private.h"
+struct _cairo_region {
+    cairo_status_t status;
+    
+    pixman_region32_t rgn;
+};
 
 /* cairo-unicode.c */
 
commit 1cca5a1348d071a3c8e2ba9d3ba0d9670b9564f4
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Tue Feb 17 23:52:18 2009 -0500

    [region] Remove underscores from _cairo_region_*

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index eaa7947..d7d950a 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -215,7 +215,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
      * region there is no benefit in emitting a native operation as
      * the fallback image will be painted on top.
      */
-    if (_cairo_region_contains_rectangle (surface->fallback_region, rect) == CAIRO_REGION_OVERLAP_IN)
+    if (cairo_region_contains_rectangle (surface->fallback_region, rect) == CAIRO_REGION_OVERLAP_IN)
 	return CAIRO_INT_STATUS_IMAGE_FALLBACK;
 
     if (backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) {
@@ -226,7 +226,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
 	 * natively supported and the backend will blend the
 	 * transparency into the white background.
 	 */
-	if (_cairo_region_contains_rectangle (surface->supported_region, rect) == CAIRO_REGION_OVERLAP_OUT)
+	if (cairo_region_contains_rectangle (surface->supported_region, rect) == CAIRO_REGION_OVERLAP_OUT)
 	    backend_status = CAIRO_STATUS_SUCCESS;
     }
 
@@ -235,8 +235,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
 	 * this region will be emitted as native operations.
 	 */
 	surface->has_supported = TRUE;
-	status = _cairo_region_union_rect (surface->supported_region,
-					   rect);
+	status = cairo_region_union_rect (surface->supported_region, rect);
 	return status;
     }
 
@@ -245,8 +244,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
      * emitted.
      */
     surface->has_unsupported = TRUE;
-    status = _cairo_region_union_rect (surface->fallback_region,
-				       rect);
+    status = cairo_region_union_rect (surface->fallback_region, rect);
 
     /* The status CAIRO_INT_STATUS_IMAGE_FALLBACK is used to indicate
      * unsupported operations to the meta surface as using
@@ -265,8 +263,8 @@ _cairo_analysis_surface_finish (void *abstract_surface)
 {
     cairo_analysis_surface_t	*surface = (cairo_analysis_surface_t *) abstract_surface;
 
-    _cairo_region_destroy (surface->supported_region);
-    _cairo_region_destroy (surface->fallback_region);
+    cairo_region_destroy (surface->supported_region);
+    cairo_region_destroy (surface->fallback_region);
 
     cairo_surface_destroy (surface->target);
 
@@ -781,8 +779,8 @@ _cairo_analysis_surface_create (cairo_surface_t		*target,
     surface->page_bbox.p2.x = 0;
     surface->page_bbox.p2.y = 0;
 
-    surface->supported_region = _cairo_region_create ();
-    surface->fallback_region = _cairo_region_create ();
+    surface->supported_region = cairo_region_create ();
+    surface->fallback_region = cairo_region_create ();
 
     if (width == -1 && height == -1) {
 	surface->current_clip.x      = CAIRO_RECT_INT_MIN;
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 4ca3e9a..58b6335 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -84,12 +84,12 @@ _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
     if (other->region) {
 	cairo_status_t status;
 	
-	clip->region = _cairo_region_copy (other->region);
+	clip->region = cairo_region_copy (other->region);
 
-	status = _cairo_region_status (clip->region);
+	status = cairo_region_status (clip->region);
 	if (unlikely (status)) {
 	    cairo_surface_destroy (clip->surface);
-	    _cairo_region_destroy (clip->region);
+	    cairo_region_destroy (clip->region);
 	    clip->region = NULL;
 	    
 	    return status;
@@ -115,7 +115,7 @@ _cairo_clip_reset (cairo_clip_t *clip)
     clip->serial = 0;
 
     if (clip->region) {
-	_cairo_region_destroy (clip->region);
+	cairo_region_destroy (clip->region);
 
 	clip->region = NULL;
     }
@@ -177,7 +177,7 @@ _cairo_clip_intersect_to_rectangle (cairo_clip_t            *clip,
     if (clip->region) {
 	cairo_rectangle_int_t extents;
 
-	_cairo_region_get_extents (clip->region, &extents);
+	cairo_region_get_extents (clip->region, &extents);
 	is_empty = _cairo_rectangle_intersect (rectangle, &extents);
 	if (is_empty)
 	    return CAIRO_STATUS_SUCCESS;
@@ -201,11 +201,11 @@ _cairo_clip_intersect_to_region (cairo_clip_t   *clip,
     if (clip->all_clipped) {
 	cairo_region_t *clip_rect;
 
-	clip_rect = _cairo_region_create_rect (&clip->surface_rect);
+	clip_rect = cairo_region_create_rect (&clip->surface_rect);
 
-	status = _cairo_region_intersect (region, clip_rect);
+	status = cairo_region_intersect (region, clip_rect);
 
-	_cairo_region_destroy (clip_rect);
+	cairo_region_destroy (clip_rect);
 
 	return status;
     }
@@ -215,7 +215,7 @@ _cairo_clip_intersect_to_region (cairo_clip_t   *clip,
     }
 
     if (clip->region) {
-	status = _cairo_region_intersect (region, clip->region);
+	status = cairo_region_intersect (region, clip->region);
 	if (unlikely (status))
 	    return status;
     }
@@ -223,11 +223,11 @@ _cairo_clip_intersect_to_region (cairo_clip_t   *clip,
     if (clip->surface) {
 	cairo_region_t *clip_rect;
 
-	clip_rect = _cairo_region_create_rect (&clip->surface_rect);
+	clip_rect = cairo_region_create_rect (&clip->surface_rect);
 
-	status = _cairo_region_intersect (region, clip_rect);
+	status = cairo_region_intersect (region, clip_rect);
 
-	_cairo_region_destroy (clip_rect);
+	cairo_region_destroy (clip_rect);
 
         if (unlikely (status))
             return status;
@@ -354,20 +354,20 @@ _cairo_clip_intersect_region (cairo_clip_t    *clip,
 	return status;
 
     if (clip->region) {
-	status = _cairo_region_intersect (clip->region, region);
+	status = cairo_region_intersect (clip->region, region);
     } else {
-	clip->region = _cairo_region_copy (region);
+	clip->region = cairo_region_copy (region);
 
 	assert (clip->region != NULL);
 	
-        if ((status = _cairo_region_status (clip->region)))
+        if ((status = cairo_region_status (clip->region)))
 	    clip->region = NULL;
     }
 
     clip->serial = _cairo_surface_allocate_clip_serial (target);
-    _cairo_region_destroy (region);
+    cairo_region_destroy (region);
 
-    if (!clip->region || _cairo_region_empty (clip->region))
+    if (!clip->region || cairo_region_empty (clip->region))
 	_cairo_clip_set_all_clipped (clip, target);
 
     return status;
@@ -725,9 +725,9 @@ _cairo_clip_translate (cairo_clip_t  *clip,
 	return;
 
     if (clip->region) {
-        _cairo_region_translate (clip->region,
-                                 _cairo_fixed_integer_part (tx),
-                                 _cairo_fixed_integer_part (ty));
+        cairo_region_translate (clip->region,
+				_cairo_fixed_integer_part (tx),
+				_cairo_fixed_integer_part (ty));
     }
 
     if (clip->surface) {
@@ -783,8 +783,8 @@ _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
          * whatever the right handling is happen */
     } else {
         if (other->region) {
-	    clip->region = _cairo_region_copy (other->region);
-	    if (unlikely ((status = _cairo_region_status (clip->region))))
+	    clip->region = cairo_region_copy (other->region);
+	    if (unlikely ((status = cairo_region_status (clip->region))))
 		goto BAIL;
         }
 
@@ -818,7 +818,7 @@ _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
 
 BAIL:
     if (clip->region)
-	_cairo_region_destroy (clip->region);
+	cairo_region_destroy (clip->region);
     if (clip->surface)
 	cairo_surface_destroy (clip->surface);
 
@@ -872,7 +872,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
     if (clip->region) {
         int i;
 
-	n_rects = _cairo_region_num_rectangles (clip->region);
+	n_rects = cairo_region_num_rectangles (clip->region);
 
 	if (n_rects) {
 	    rectangles = _cairo_malloc_ab (n_rects, sizeof (cairo_rectangle_t));
@@ -884,7 +884,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 	    for (i = 0; i < n_rects; ++i) {
 		cairo_rectangle_int_t clip_rect;
 
-		_cairo_region_get_rectangle (clip->region, i, &clip_rect);
+		cairo_region_get_rectangle (clip->region, i, &clip_rect);
 		
 		if (!_cairo_clip_int_rect_to_user(gstate, &clip_rect, &rectangles[i])) {
 		    _cairo_error_throw (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE);
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 3873f3e..3eee33c 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1305,7 +1305,7 @@ _cairo_directfb_surface_set_clip_region (void           *abstract_surface,
 
 	surface->has_clip = TRUE;
 
-	n_rects = _cairo_region_num_rectangles (region);
+	n_rects = cairo_region_num_rectangles (region);
 
 	if (n_rects == 0)
 	    return CAIRO_STATUS_SUCCESS;
@@ -1326,7 +1326,7 @@ _cairo_directfb_surface_set_clip_region (void           *abstract_surface,
 	for (i = 0; i < n_rects; i++) {
 	    cairo_rectangle_int_t rect;
 
-	    _cairo_region_get_rectangle (region, i, &rect);
+	    cairo_region_get_rectangle (region, i, &rect);
 	    
 	    surface->clips[i].x1 = rect.x;
 	    surface->clips[i].y1 = rect.y;
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index cc09b59..b84fbff 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -397,11 +397,11 @@ _paint_page (cairo_paginated_surface_t *surface)
 
 	region = _cairo_analysis_surface_get_unsupported (analysis);
 
-	num_rects = _cairo_region_num_rectangles (region);
+	num_rects = cairo_region_num_rectangles (region);
 	for (i = 0; i < num_rects; i++) {
 	    cairo_rectangle_int_t rect;
 
-	    _cairo_region_get_rectangle (region, i, &rect);
+	    cairo_region_get_rectangle (region, i, &rect);
 	    
 	    status = _paint_fallback_image (surface, &rect);
 	    
diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
index 78ba5fc..c9b2ae1 100644
--- a/src/cairo-region-private.h
+++ b/src/cairo-region-private.h
@@ -59,68 +59,68 @@ typedef enum _cairo_region_overlap {
 } cairo_region_overlap_t;
 
 cairo_private cairo_region_t *
-_cairo_region_create (void);
+cairo_region_create (void);
 
 cairo_private cairo_region_t *
-_cairo_region_create_rect (cairo_rectangle_int_t *rect);
+cairo_region_create_rect (cairo_rectangle_int_t *rect);
 
 cairo_private cairo_status_t
-_cairo_region_status (cairo_region_t *region);
+cairo_region_status (cairo_region_t *region);
 
 cairo_private void
-_cairo_region_clear (cairo_region_t *region);
+cairo_region_clear (cairo_region_t *region);
 
 cairo_private cairo_region_t *
-_cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
+cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
 				 int count);
 
 cairo_private void
-_cairo_region_destroy (cairo_region_t *region);
+cairo_region_destroy (cairo_region_t *region);
 
 cairo_private cairo_region_t *
-_cairo_region_copy (cairo_region_t *original);
+cairo_region_copy (cairo_region_t *original);
 
 cairo_private int
-_cairo_region_num_rectangles (cairo_region_t *region);
+cairo_region_num_rectangles (cairo_region_t *region);
 
 cairo_private void
-_cairo_region_get_rectangle (cairo_region_t *region,
+cairo_region_get_rectangle (cairo_region_t *region,
 			     int nth_rectangle,
 			     cairo_rectangle_int_t *rectangle);
 
 cairo_private void
-_cairo_region_get_extents (cairo_region_t *region,
+cairo_region_get_extents (cairo_region_t *region,
 			   cairo_rectangle_int_t *extents);
 
 cairo_private cairo_status_t
-_cairo_region_subtract (cairo_region_t *dst,
+cairo_region_subtract (cairo_region_t *dst,
 			cairo_region_t *other);
 
 cairo_private cairo_status_t
-_cairo_region_intersect (cairo_region_t *dst,
+cairo_region_intersect (cairo_region_t *dst,
 			 cairo_region_t *other);
 
 cairo_private cairo_status_t
-_cairo_region_union (cairo_region_t *dst,
+cairo_region_union (cairo_region_t *dst,
 		     cairo_region_t *other);
 
 cairo_private cairo_status_t
-_cairo_region_union_rect (cairo_region_t *dst,
+cairo_region_union_rect (cairo_region_t *dst,
 			  cairo_rectangle_int_t *rect);
 
 cairo_private cairo_bool_t
-_cairo_region_empty (cairo_region_t *region);
+cairo_region_empty (cairo_region_t *region);
 
 cairo_private void
-_cairo_region_translate (cairo_region_t *region,
+cairo_region_translate (cairo_region_t *region,
 			 int dx, int dy);
 
 cairo_private cairo_region_overlap_t
-_cairo_region_contains_rectangle (cairo_region_t *region,
+cairo_region_contains_rectangle (cairo_region_t *region,
 				  const cairo_rectangle_int_t *rect);
 
 cairo_private cairo_bool_t
-_cairo_region_contains_point (cairo_region_t *region,
+cairo_region_contains_point (cairo_region_t *region,
 			      int x, int y);
 
 CAIRO_END_DECLS
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 04bfbd9..59ce0bf 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -43,7 +43,7 @@ const cairo_region_t _cairo_region_nil = {
 };
 
 cairo_region_t *
-_cairo_region_create (void)
+cairo_region_create (void)
 {
     cairo_region_t *region = _cairo_malloc (sizeof (cairo_region_t));
 
@@ -58,7 +58,7 @@ _cairo_region_create (void)
 }
 
 cairo_region_t *
-_cairo_region_create_rect (cairo_rectangle_int_t *rect)
+cairo_region_create_rect (cairo_rectangle_int_t *rect)
 {
     cairo_region_t *region = _cairo_malloc (sizeof (cairo_region_t));
 
@@ -75,8 +75,8 @@ _cairo_region_create_rect (cairo_rectangle_int_t *rect)
 }
 
 cairo_region_t *
-_cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
-				 int count)
+cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
+				int count)
 {
     pixman_box32_t stack_pboxes[CAIRO_STACK_ARRAY_LENGTH (pixman_box32_t)];
     pixman_box32_t *pboxes = stack_pboxes;
@@ -119,7 +119,7 @@ _cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
 }
 
 void
-_cairo_region_destroy (cairo_region_t *region)
+cairo_region_destroy (cairo_region_t *region)
 {
     if (region->status)
 	return;
@@ -129,19 +129,19 @@ _cairo_region_destroy (cairo_region_t *region)
 }
 
 cairo_region_t *
-_cairo_region_copy (cairo_region_t *original)
+cairo_region_copy (cairo_region_t *original)
 {
     cairo_region_t *copy;
     
     if (original->status)
 	return (cairo_region_t *)&_cairo_region_nil;
 
-    copy = _cairo_region_create ();
+    copy = cairo_region_create ();
     if (!copy)
 	return (cairo_region_t *)&_cairo_region_nil;
 
     if (!pixman_region32_copy (&copy->rgn, &original->rgn)) {
-	_cairo_region_destroy (copy);
+	cairo_region_destroy (copy);
 
 	return (cairo_region_t *)&_cairo_region_nil;
     }
@@ -150,7 +150,7 @@ _cairo_region_copy (cairo_region_t *original)
 }
 
 int
-_cairo_region_num_rectangles (cairo_region_t *region)
+cairo_region_num_rectangles (cairo_region_t *region)
 {
     if (region->status)
 	return 0;
@@ -159,9 +159,9 @@ _cairo_region_num_rectangles (cairo_region_t *region)
 }
 
 cairo_private void
-_cairo_region_get_rectangle (cairo_region_t *region,
-			     int nth_box,
-			     cairo_rectangle_int_t *rect)
+cairo_region_get_rectangle (cairo_region_t *region,
+			    int nth_box,
+			    cairo_rectangle_int_t *rect)
 {
     pixman_box32_t *pbox;
 
@@ -177,15 +177,15 @@ _cairo_region_get_rectangle (cairo_region_t *region,
 }
 
 /**
- * _cairo_region_get_extents:
+ * cairo_region_get_extents:
  * @region: a #cairo_region_t
  * @rect: rectangle into which to store the extents
  *
  * Gets the bounding box of a region as a #cairo_rectangle_int_t
  **/
 void
-_cairo_region_get_extents (cairo_region_t *region,
-			   cairo_rectangle_int_t *extents)
+cairo_region_get_extents (cairo_region_t *region,
+			  cairo_rectangle_int_t *extents)
 {
     pixman_box32_t *pextents;
 
@@ -201,13 +201,13 @@ _cairo_region_get_extents (cairo_region_t *region,
 }
 
 cairo_status_t
-_cairo_region_status (cairo_region_t *region)
+cairo_region_status (cairo_region_t *region)
 {
     return region->status;
 }
 
 void
-_cairo_region_clear (cairo_region_t *region)
+cairo_region_clear (cairo_region_t *region)
 {
     if (region->status)
 	return;
@@ -217,7 +217,7 @@ _cairo_region_clear (cairo_region_t *region)
 }
 
 cairo_status_t
-_cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
+cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
 {
     if (dst->status)
 	return dst->status;
@@ -232,7 +232,7 @@ _cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
 }
 
 cairo_status_t
-_cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
+cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
 {
     if (dst->status)
 	return dst->status;
@@ -247,8 +247,8 @@ _cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
 }
 
 cairo_private cairo_status_t
-_cairo_region_union (cairo_region_t *dst,
-		     cairo_region_t *other)
+cairo_region_union (cairo_region_t *dst,
+		    cairo_region_t *other)
 {
     if (dst->status)
 	return dst->status;
@@ -263,8 +263,8 @@ _cairo_region_union (cairo_region_t *dst,
 }
 
 cairo_status_t
-_cairo_region_union_rect (cairo_region_t *dst,
-			  cairo_rectangle_int_t *rect)
+cairo_region_union_rect (cairo_region_t *dst,
+			 cairo_rectangle_int_t *rect)
 {
     if (!pixman_region32_union_rect (&dst->rgn, &dst->rgn,
 				     rect->x, rect->y,
@@ -277,7 +277,7 @@ _cairo_region_union_rect (cairo_region_t *dst,
 }
 
 cairo_bool_t
-_cairo_region_empty (cairo_region_t *region)
+cairo_region_empty (cairo_region_t *region)
 {
     if (region->status)
 	return TRUE;
@@ -286,8 +286,8 @@ _cairo_region_empty (cairo_region_t *region)
 }
 
 void
-_cairo_region_translate (cairo_region_t *region,
-			 int dx, int dy)
+cairo_region_translate (cairo_region_t *region,
+			int dx, int dy)
 {
     if (region->status)
 	return;
@@ -296,8 +296,8 @@ _cairo_region_translate (cairo_region_t *region,
 }
 
 cairo_region_overlap_t
-_cairo_region_contains_rectangle (cairo_region_t *region,
-				  const cairo_rectangle_int_t *rect)
+cairo_region_contains_rectangle (cairo_region_t *region,
+				 const cairo_rectangle_int_t *rect)
 {
     pixman_box32_t pbox;
     pixman_region_overlap_t poverlap;
@@ -328,9 +328,8 @@ _cairo_region_contains_rectangle (cairo_region_t *region,
 }
 
 cairo_private cairo_bool_t
-_cairo_region_contains_point (cairo_region_t *region,
-			      int x,
-			      int y)
+cairo_region_contains_point (cairo_region_t *region,
+			     int x, int y)
 {
     if (region->status)
 	return FALSE;
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 876268f..42d86e7 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -417,7 +417,7 @@ _composite_trap_region (cairo_clip_t            *clip,
     cairo_status_t status;
     cairo_solid_pattern_t solid_pattern;
     cairo_surface_pattern_t mask;
-    int num_rects = _cairo_region_num_rectangles (trap_region);
+    int num_rects = cairo_region_num_rectangles (trap_region);
     unsigned int clip_serial;
     cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
 
@@ -544,7 +544,7 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
             if (unlikely (status))
                 goto out;
 
-            _cairo_region_get_extents (trap_region, &trap_extents);
+            cairo_region_get_extents (trap_region, &trap_extents);
         } else {
             cairo_box_t trap_box;
             _cairo_traps_extents (traps, &trap_box);
@@ -567,9 +567,9 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
              * _cairo_surface_fill_rectangles() or to drawing with a
              * clip region, then we have an additional region to clear.
              */
-            clear_region = _cairo_region_create_rect (&extents);
+            clear_region = cairo_region_create_rect (&extents);
 
-	    status = _cairo_region_status (clear_region);
+	    status = cairo_region_status (clear_region);
 	    if (unlikely (status))
 		goto out;
 
@@ -577,14 +577,14 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
             if (unlikely (status))
                 goto out;
 
-            _cairo_region_get_extents (clear_region, &extents);
+            cairo_region_get_extents (clear_region, &extents);
 
-            status = _cairo_region_subtract (clear_region, trap_region);
+            status = cairo_region_subtract (clear_region, trap_region);
             if (unlikely (status))
                 goto out;
 
-            if (_cairo_region_empty (clear_region)) {
-                _cairo_region_destroy (clear_region);
+            if (cairo_region_empty (clear_region)) {
+                cairo_region_destroy (clear_region);
 		clear_region = NULL;
             }
         } else {
@@ -659,9 +659,9 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
 
 out:
     if (trap_region)
-        _cairo_region_destroy (trap_region);
+        cairo_region_destroy (trap_region);
     if (clear_region)
-        _cairo_region_destroy (clear_region);
+        cairo_region_destroy (clear_region);
 
     return status;
 }
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 42fc6da..e093122 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1587,7 +1587,7 @@ _cairo_surface_fill_region (cairo_surface_t	   *surface,
 
     assert (! surface->is_snapshot);
 
-    num_rects = _cairo_region_num_rectangles (region);
+    num_rects = cairo_region_num_rectangles (region);
     if (num_rects == 0)
 	return CAIRO_STATUS_SUCCESS;
 
@@ -1601,7 +1601,7 @@ _cairo_surface_fill_region (cairo_surface_t	   *surface,
     }
 
     for (i = 0; i < num_rects; i++)
-	_cairo_region_get_rectangle (region, i, &rects[i]);
+	cairo_region_get_rectangle (region, i, &rects[i]);
 
     status =  _cairo_surface_fill_rectangles (surface, op,
 					      color, rects, num_rects);
@@ -2692,7 +2692,7 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
     dst_rectangle.width = width;
     dst_rectangle.height = height;
 
-    clear_region = _cairo_region_create_rect (&dst_rectangle);
+    clear_region = cairo_region_create_rect (&dst_rectangle);
 
     drawn_rectangle = dst_rectangle;
 
@@ -2708,10 +2708,10 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
 
     /* Now compute the area that is in dst_rectangle but not in drawn_rectangle
      */
-    drawn_region = _cairo_region_create_rect (&drawn_rectangle);
+    drawn_region = cairo_region_create_rect (&drawn_rectangle);
     has_drawn_region = TRUE;
 
-    status = _cairo_region_subtract (clear_region, drawn_region);
+    status = cairo_region_subtract (clear_region, drawn_region);
     if (unlikely (status))
         goto CLEANUP_REGIONS;
 
@@ -2722,8 +2722,8 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
 
   CLEANUP_REGIONS:
     if (drawn_region)
-        _cairo_region_destroy (drawn_region);
-    _cairo_region_destroy (clear_region);
+        cairo_region_destroy (drawn_region);
+    cairo_region_destroy (clear_region);
 
     return _cairo_surface_set_error (dst, status);
 }
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 96db4ba..73bb124 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -600,7 +600,7 @@ _cairo_traps_extents (const cairo_traps_t *traps,
  * Determines if a set of trapezoids are exactly representable as a
  * cairo region.  If so, the passed-in region is initialized to
  * the area representing the given traps.  It should be finalized
- * with _cairo_region_fini().  If not, %CAIRO_INT_STATUS_UNSUPPORTED
+ * with cairo_region_fini().  If not, %CAIRO_INT_STATUS_UNSUPPORTED
  * is returned.
  *
  * Return value: %CAIRO_STATUS_SUCCESS, %CAIRO_INT_STATUS_UNSUPPORTED
@@ -616,7 +616,7 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
     cairo_int_status_t status;
 
     if (traps->num_traps == 0) {
-	*region = _cairo_region_create ();
+	*region = cairo_region_create ();
 	return CAIRO_STATUS_SUCCESS;
     }
 
@@ -662,15 +662,15 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
 	rect_count++;
     }
 
-    *region = _cairo_region_create_rectangles (rects, rect_count);
-    status = _cairo_region_status (*region);
+    *region = cairo_region_create_rectangles (rects, rect_count);
+    status = cairo_region_status (*region);
     
     if (rects != stack_rects)
 	free (rects);
 
     if (unlikely (status))
     {
-	_cairo_region_destroy (*region);
+	cairo_region_destroy (*region);
 	*region = NULL;
     }
 
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index f182642..649a96b 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -1471,11 +1471,11 @@ _cairo_win32_surface_set_clip_region (void           *abstract_surface,
 
 	/* Create a GDI region for the cairo region */
 
-	_cairo_region_get_extents (region, &extents);
-	num_rects = _cairo_region_num_rectangles (region);
+	cairo_region_get_extents (region, &extents);
+	num_rects = cairo_region_num_rectangles (region);
 
 	if (num_rects == 1)
-	    _cairo_region_get_rectangle (region, 0, &rect0);
+	    cairo_region_get_rectangle (region, 0, &rect0);
 	    
 	if (num_rects == 1 &&
 	    rect0.x == 0 &&
@@ -1517,7 +1517,7 @@ _cairo_win32_surface_set_clip_region (void           *abstract_surface,
 	    for (i = 0; i < num_rects; i++) {
 		cairo_rectangle_int_t rect;
 
-	        _cairo_region_get_rectangle (region, i, &rect);
+	        cairo_region_get_rectangle (region, i, &rect);
 		
 		rects[i].left = rect.x;
 		rects[i].top = rect.y;
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index ab589e1..8d0090b 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1559,7 +1559,7 @@ _cairo_xcb_surface_set_clip_region (void           *abstract_surface,
 	xcb_rectangle_t *rects = NULL;
 	int n_rects, i;
 
-	n_rects = _cairo_region_num_rectangles (region);
+	n_rects = cairo_region_num_rectangles (region);
 
 	if (n_rects > 0) {
 	    rects = _cairo_malloc_ab (n_rects, sizeof(xcb_rectangle_t));
@@ -1572,7 +1572,7 @@ _cairo_xcb_surface_set_clip_region (void           *abstract_surface,
 	for (i = 0; i < n_rects; i++) {
 	    cairo_rectangle_int_t rect;
 
-	    _cairo_region_get_rectangle (region, i, &rect);
+	    cairo_region_get_rectangle (region, i, &rect);
 	    
 	    rects[i].x = rect.x;
 	    rects[i].y = rect.y;
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index e411977..f547f5f 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2302,19 +2302,19 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	 * is necessary so we don't wrap around when we convert cairo's
 	 * 32 bit region into 16 bit rectangles.
 	 */
-	bounded = _cairo_region_create_rect (&rect);
-	status = _cairo_region_intersect (bounded, region);
+	bounded = cairo_region_create_rect (&rect);
+	status = cairo_region_intersect (bounded, region);
 	if (unlikely (status)) {
-	    _cairo_region_destroy (bounded);
+	    cairo_region_destroy (bounded);
 	    return status;
 	}
 
-	n_rects = _cairo_region_num_rectangles (bounded);
+	n_rects = cairo_region_num_rectangles (bounded);
 
 	if (n_rects > ARRAY_LENGTH (surface->embedded_clip_rects)) {
 	    rects = _cairo_malloc_ab (n_rects, sizeof (XRectangle));
 	    if (unlikely (rects == NULL)) {
-		_cairo_region_destroy (bounded);
+		cairo_region_destroy (bounded);
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    }
 	} else {
@@ -2324,7 +2324,7 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	for (i = 0; i < n_rects; i++) {
 	    cairo_rectangle_int_t rect;
 	    
-	    _cairo_region_get_rectangle (bounded, i, &rect);
+	    cairo_region_get_rectangle (bounded, i, &rect);
 
 	    rects[i].x = rect.x;
 	    rects[i].y = rect.y;
@@ -2332,7 +2332,7 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	    rects[i].height = rect.height;
 	}
 	
-	_cairo_region_destroy (bounded);
+	cairo_region_destroy (bounded);
 
 	surface->have_clip_rects = TRUE;
 	surface->clip_rects = rects;
commit fcdca966941f4f7cc908bd46df1ec9a6b0f757c1
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Tue Feb 17 22:52:50 2009 -0500

    [region] Always define cairo_rectangle_int_t with ints
    
    Use ints in cairo_rectangle_int_t, no matter the fixed type.

diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index e8cf4b1..f075426 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -218,37 +218,17 @@ typedef struct _cairo_trapezoid {
     cairo_line_t left, right;
 } cairo_trapezoid_t;
 
-struct _cairo_rectangle_int16 {
-    int16_t x, y;
-    uint16_t width, height;
-};
-
-struct _cairo_rectangle_int32 {
-    int32_t x, y;
-    uint32_t width, height;
-};
+typedef struct _cairo_rectangle_int {
+    int x, y;
+    unsigned int width, height;
+} cairo_rectangle_int_t;
 
-struct _cairo_point_int16 {
-    int16_t x, y;
-};
-
-struct _cairo_point_int32 {
-    int32_t x, y;
-};
+typedef struct _cairo_point_int {
+    int x, y;
+} cairo_point_int_t;
 
-#if CAIRO_FIXED_BITS == 32 && CAIRO_FIXED_FRAC_BITS >= 16
-typedef struct _cairo_rectangle_int16 cairo_rectangle_int_t;
-typedef struct _cairo_point_int16 cairo_point_int_t;
-#define CAIRO_RECT_INT_MIN (INT16_MIN >> (CAIRO_FIXED_FRAC_BITS - 16))
-#define CAIRO_RECT_INT_MAX (INT16_MAX >> (CAIRO_FIXED_FRAC_BITS - 16))
-#elif CAIRO_FIXED_BITS == 32
-typedef struct _cairo_rectangle_int32 cairo_rectangle_int_t;
-typedef struct _cairo_point_int32 cairo_point_int_t;
-#define CAIRO_RECT_INT_MIN (INT32_MIN >> CAIRO_FIXED_FRAC_BITS)
-#define CAIRO_RECT_INT_MAX (INT32_MAX >> CAIRO_FIXED_FRAC_BITS)
-#else
-#error Not sure how to pick a cairo_rectangle_int_t and cairo_point_int_t for your CAIRO_FIXED_BITS!
-#endif
+#define CAIRO_RECT_INT_MIN (INT_MIN >> CAIRO_FIXED_FRAC_BITS)
+#define CAIRO_RECT_INT_MAX (INT_MAX >> CAIRO_FIXED_FRAC_BITS)
 
 /* Rectangles that take part in a composite operation.
  *
commit cfa7a384b730289233bef556fe1919f781eac684
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Tue Feb 17 23:40:02 2009 -0500

    [region] Add _cairo_region_contains_point()

diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
index 533b3d6..78ba5fc 100644
--- a/src/cairo-region-private.h
+++ b/src/cairo-region-private.h
@@ -113,12 +113,15 @@ _cairo_region_empty (cairo_region_t *region);
 
 cairo_private void
 _cairo_region_translate (cairo_region_t *region,
-			 int x, int y);
+			 int dx, int dy);
 
 cairo_private cairo_region_overlap_t
 _cairo_region_contains_rectangle (cairo_region_t *region,
 				  const cairo_rectangle_int_t *rect);
 
+cairo_private cairo_bool_t
+_cairo_region_contains_point (cairo_region_t *region,
+			      int x, int y);
 
 CAIRO_END_DECLS
 
diff --git a/src/cairo-region.c b/src/cairo-region.c
index e702d2c..04bfbd9 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -287,12 +287,12 @@ _cairo_region_empty (cairo_region_t *region)
 
 void
 _cairo_region_translate (cairo_region_t *region,
-			 int x, int y)
+			 int dx, int dy)
 {
     if (region->status)
 	return;
     
-    pixman_region32_translate (&region->rgn, x, y);
+    pixman_region32_translate (&region->rgn, dx, dy);
 }
 
 cairo_region_overlap_t
@@ -326,3 +326,14 @@ _cairo_region_contains_rectangle (cairo_region_t *region,
 
     return CAIRO_REGION_OVERLAP_OUT;
 }
+
+cairo_private cairo_bool_t
+_cairo_region_contains_point (cairo_region_t *region,
+			      int x,
+			      int y)
+{
+    if (region->status)
+	return FALSE;
+
+    return pixman_region32_contains_point (&region->rgn, x, y, NULL);
+}
diff --git a/src/cairo.h b/src/cairo.h
index 206861d..f359d79 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2353,6 +2353,7 @@ cairo_matrix_transform_point (const cairo_matrix_t *matrix,
 cairo_public void
 cairo_debug_reset_static_data (void);
 
+
 CAIRO_END_DECLS
 
 #endif /* CAIRO_H */
commit 15564d1949778124e553d792f85cae2b031aad45
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Tue Feb 17 05:58:34 2009 -0500

    [region] Add _cairo_region_union

diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
index 450b086..533b3d6 100644
--- a/src/cairo-region-private.h
+++ b/src/cairo-region-private.h
@@ -101,6 +101,10 @@ _cairo_region_intersect (cairo_region_t *dst,
 			 cairo_region_t *other);
 
 cairo_private cairo_status_t
+_cairo_region_union (cairo_region_t *dst,
+		     cairo_region_t *other);
+
+cairo_private cairo_status_t
 _cairo_region_union_rect (cairo_region_t *dst,
 			  cairo_rectangle_int_t *rect);
 
diff --git a/src/cairo-region.c b/src/cairo-region.c
index b951e63..e702d2c 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -246,6 +246,22 @@ _cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
     return CAIRO_STATUS_SUCCESS;
 }
 
+cairo_private cairo_status_t
+_cairo_region_union (cairo_region_t *dst,
+		     cairo_region_t *other)
+{
+    if (dst->status)
+	return dst->status;
+
+    if (other->status)
+	return other->status;
+
+    if (!pixman_region32_union (&dst->rgn, &dst->rgn, &other->rgn))
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
 cairo_status_t
 _cairo_region_union_rect (cairo_region_t *dst,
 			  cairo_rectangle_int_t *rect)
commit df883aa937d2f3ecf52048b60caff48b1c9edac9
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Tue Feb 17 06:06:40 2009 -0500

    [region] Add a cairo_region_overlap_t type

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 9c97c11..eaa7947 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -215,7 +215,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
      * region there is no benefit in emitting a native operation as
      * the fallback image will be painted on top.
      */
-    if (_cairo_region_contains_rectangle (surface->fallback_region, rect) == PIXMAN_REGION_IN)
+    if (_cairo_region_contains_rectangle (surface->fallback_region, rect) == CAIRO_REGION_OVERLAP_IN)
 	return CAIRO_INT_STATUS_IMAGE_FALLBACK;
 
     if (backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) {
@@ -226,7 +226,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
 	 * natively supported and the backend will blend the
 	 * transparency into the white background.
 	 */
-	if (_cairo_region_contains_rectangle (surface->supported_region, rect) == PIXMAN_REGION_OUT)
+	if (_cairo_region_contains_rectangle (surface->supported_region, rect) == CAIRO_REGION_OVERLAP_OUT)
 	    backend_status = CAIRO_STATUS_SUCCESS;
     }
 
diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
index 5a93ebd..450b086 100644
--- a/src/cairo-region-private.h
+++ b/src/cairo-region-private.h
@@ -52,6 +52,12 @@ struct _cairo_region {
     pixman_region32_t rgn;
 };
 
+typedef enum _cairo_region_overlap {
+    CAIRO_REGION_OVERLAP_IN,		/* completely inside region */
+    CAIRO_REGION_OVERLAP_OUT,		/* completely outside region */
+    CAIRO_REGION_OVERLAP_PART,		/* partly inside region */
+} cairo_region_overlap_t;
+
 cairo_private cairo_region_t *
 _cairo_region_create (void);
 
@@ -105,7 +111,7 @@ cairo_private void
 _cairo_region_translate (cairo_region_t *region,
 			 int x, int y);
 
-cairo_private pixman_region_overlap_t
+cairo_private cairo_region_overlap_t
 _cairo_region_contains_rectangle (cairo_region_t *region,
 				  const cairo_rectangle_int_t *rect);
 
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 5f53bc9..b951e63 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -279,19 +279,34 @@ _cairo_region_translate (cairo_region_t *region,
     pixman_region32_translate (&region->rgn, x, y);
 }
 
-pixman_region_overlap_t
+cairo_region_overlap_t
 _cairo_region_contains_rectangle (cairo_region_t *region,
 				  const cairo_rectangle_int_t *rect)
 {
     pixman_box32_t pbox;
+    pixman_region_overlap_t poverlap;
 
-    if (region->status)
-	return PIXMAN_REGION_OUT;
-    
-    pbox.x1 = rect->x;
-    pbox.y1 = rect->y;
-    pbox.x2 = rect->x + rect->width;
-    pbox.y2 = rect->y + rect->height;
+    if (!region->status)
+    {
+	pbox.x1 = rect->x;
+	pbox.y1 = rect->y;
+	pbox.x2 = rect->x + rect->width;
+	pbox.y2 = rect->y + rect->height;
+	
+	poverlap = pixman_region32_contains_rectangle (&region->rgn, &pbox);
+	
+	switch (poverlap)
+	{
+	case PIXMAN_REGION_OUT:
+	    return CAIRO_REGION_OVERLAP_OUT;
+	    
+	case PIXMAN_REGION_IN:
+	    return CAIRO_REGION_OVERLAP_IN;
+	    
+	case PIXMAN_REGION_PART:
+	    return CAIRO_REGION_OVERLAP_PART;
+	}
+    }
 
-    return pixman_region32_contains_rectangle (&region->rgn, &pbox);
+    return CAIRO_REGION_OVERLAP_OUT;
 }
commit ebd0e685ae2d76c3af96d748a33a7194c70749f3
Author: Søren Sandmann Pedersen <sandmann at daimi.au.dk>
Date:   Mon Feb 16 05:41:31 2009 -0500

    [region] Consistently use rectangles in the API of regions
    
    Usually, rectangles are more useful than boxes, so regions should only
    expose rectangles in their public API.
    
    Specifically,
      _cairo_region_num_boxes becomes _cairo_region_num_rectangles
      _cairo_region_get_box becomes _cairo_region_get_rectangle
    
    Remove the cairo_box_int_t type

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 649fa7a..4ca3e9a 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -859,7 +859,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 {
     cairo_rectangle_list_t *list;
     cairo_rectangle_t *rectangles = NULL;
-    int n_boxes = 0;
+    int n_rects = 0;
 
     if (clip->all_clipped)
 	goto DONE;
@@ -872,25 +872,19 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
     if (clip->region) {
         int i;
 
-	n_boxes = _cairo_region_num_boxes (clip->region);
+	n_rects = _cairo_region_num_rectangles (clip->region);
 
-	if (n_boxes) {
-	    rectangles = _cairo_malloc_ab (n_boxes, sizeof (cairo_rectangle_t));
+	if (n_rects) {
+	    rectangles = _cairo_malloc_ab (n_rects, sizeof (cairo_rectangle_t));
 	    if (unlikely (rectangles == NULL)) {
 		_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 		return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
 	    }
 
-	    for (i = 0; i < n_boxes; ++i) {
-		cairo_box_int_t box;
+	    for (i = 0; i < n_rects; ++i) {
 		cairo_rectangle_int_t clip_rect;
 
-		_cairo_region_get_box (clip->region, i, &box);
-
-		clip_rect.x = box.p1.x;
-		clip_rect.y = box.p1.y;
-		clip_rect.width  = box.p2.x - box.p1.x;
-		clip_rect.height = box.p2.y - box.p1.y;
+		_cairo_region_get_rectangle (clip->region, i, &clip_rect);
 		
 		if (!_cairo_clip_int_rect_to_user(gstate, &clip_rect, &rectangles[i])) {
 		    _cairo_error_throw (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE);
@@ -902,7 +896,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
     } else {
         cairo_rectangle_int_t extents;
 
-	n_boxes = 1;
+	n_rects = 1;
 
 	rectangles = malloc(sizeof (cairo_rectangle_t));
 	if (unlikely (rectangles == NULL)) {
@@ -929,7 +923,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 
     list->status = CAIRO_STATUS_SUCCESS;
     list->rectangles = rectangles;
-    list->num_rectangles = n_boxes;
+    list->num_rectangles = n_rects;
     return list;
 }
 
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index b902cca..3873f3e 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1299,39 +1299,39 @@ _cairo_directfb_surface_set_clip_region (void           *abstract_surface,
 		__FUNCTION__, surface, region);
 
     if (region) {
-	int              n_boxes;
+	int              n_rects;
 	cairo_status_t   status;
 	int              i;
 
 	surface->has_clip = TRUE;
 
-	n_boxes = _cairo_region_num_boxes (region);
+	n_rects = _cairo_region_num_rectangles (region);
 
-	if (n_boxes == 0)
+	if (n_rects == 0)
 	    return CAIRO_STATUS_SUCCESS;
 
-	if (surface->n_clips != n_boxes) {
+	if (surface->n_clips != n_rects) {
 	    if (surface->clips)
 		free (surface->clips);
 
-	    surface->clips = _cairo_malloc_ab (n_boxes, sizeof (DFBRegion));
+	    surface->clips = _cairo_malloc_ab (n_rects, sizeof (DFBRegion));
 	    if (!surface->clips) {
 		surface->n_clips = 0;
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    }
 
-	    surface->n_clips = n_boxes;
+	    surface->n_clips = n_rects;
 	}
 
-	for (i = 0; i < n_boxes; i++) {
-	    cairo_box_int_t box;
+	for (i = 0; i < n_rects; i++) {
+	    cairo_rectangle_int_t rect;
 
-	    _cairo_region_get_box (region, i, &box);
+	    _cairo_region_get_rectangle (region, i, &rect);
 	    
-	    surface->clips[i].x1 = box.p1.x;
-	    surface->clips[i].y1 = box.p1.y;
-	    surface->clips[i].x2 = box.p2.x - 1;
-	    surface->clips[i].y2 = box.p2.y - 1;
+	    surface->clips[i].x1 = rect.x;
+	    surface->clips[i].y1 = rect.y;
+	    surface->clips[i].x2 = rect.x + rect.width - 1;
+	    surface->clips[i].y2 = rect.y + rect.height - 1;
 	}
     } else {
 	surface->has_clip = FALSE;
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 8c62644..cc09b59 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -244,7 +244,7 @@ _cairo_paginated_surface_release_source_image (void	  *abstract_surface,
 
 static cairo_int_status_t
 _paint_fallback_image (cairo_paginated_surface_t *surface,
-		       cairo_box_int_t           *box)
+		       cairo_rectangle_int_t     *rect)
 {
     double x_scale = surface->base.x_fallback_resolution / surface->target->x_resolution;
     double y_scale = surface->base.y_fallback_resolution / surface->target->y_resolution;
@@ -254,10 +254,10 @@ _paint_fallback_image (cairo_paginated_surface_t *surface,
     cairo_surface_t *image;
     cairo_surface_pattern_t pattern;
 
-    x = box->p1.x;
-    y = box->p1.y;
-    width = box->p2.x - x;
-    height = box->p2.y - y;
+    x = rect->x;
+    y = rect->y;
+    width = rect->width;
+    height = rect->height;
     image = _cairo_paginated_surface_create_image_surface (surface,
 							   ceil (width  * x_scale),
 							   ceil (height * y_scale));
@@ -365,23 +365,23 @@ _paint_page (cairo_paginated_surface_t *surface)
     }
 
     if (has_page_fallback) {
-	cairo_box_int_t box;
+	cairo_rectangle_int_t rect;
 
 	surface->backend->set_paginated_mode (surface->target,
 		                              CAIRO_PAGINATED_MODE_FALLBACK);
 
-	box.p1.x = 0;
-	box.p1.y = 0;
-	box.p2.x = surface->width;
-	box.p2.y = surface->height;
-	status = _paint_fallback_image (surface, &box);
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = surface->width;
+	rect.height = surface->height;
+	status = _paint_fallback_image (surface, &rect);
 	if (unlikely (status))
 	    goto FAIL;
     }
 
     if (has_finegrained_fallback) {
         cairo_region_t *region;
-        int num_boxes, i;
+        int num_rects, i;
 
 	surface->backend->set_paginated_mode (surface->target,
 		                              CAIRO_PAGINATED_MODE_FALLBACK);
@@ -397,13 +397,13 @@ _paint_page (cairo_paginated_surface_t *surface)
 
 	region = _cairo_analysis_surface_get_unsupported (analysis);
 
-	num_boxes = _cairo_region_num_boxes (region);
-	for (i = 0; i < num_boxes; i++) {
-	    cairo_box_int_t box;
+	num_rects = _cairo_region_num_rectangles (region);
+	for (i = 0; i < num_rects; i++) {
+	    cairo_rectangle_int_t rect;
 
-	    _cairo_region_get_box (region, i, &box);
+	    _cairo_region_get_rectangle (region, i, &rect);
 	    
-	    status = _paint_fallback_image (surface, &box);
+	    status = _paint_fallback_image (surface, &rect);
 	    
 	    if (unlikely (status))
 		goto FAIL;
diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
index 8852af3..5a93ebd 100644
--- a/src/cairo-region-private.h
+++ b/src/cairo-region-private.h
@@ -65,8 +65,8 @@ cairo_private void
 _cairo_region_clear (cairo_region_t *region);
 
 cairo_private cairo_region_t *
-_cairo_region_create_boxes (cairo_box_int_t *boxes,
-			    int count);
+_cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
+				 int count);
 
 cairo_private void
 _cairo_region_destroy (cairo_region_t *region);
@@ -75,12 +75,12 @@ cairo_private cairo_region_t *
 _cairo_region_copy (cairo_region_t *original);
 
 cairo_private int
-_cairo_region_num_boxes (cairo_region_t *region);
+_cairo_region_num_rectangles (cairo_region_t *region);
 
 cairo_private void
-_cairo_region_get_box (cairo_region_t *region,
-		       int nth_box,
-		       cairo_box_int_t *box);
+_cairo_region_get_rectangle (cairo_region_t *region,
+			     int nth_rectangle,
+			     cairo_rectangle_int_t *rectangle);
 
 cairo_private void
 _cairo_region_get_extents (cairo_region_t *region,
@@ -107,7 +107,7 @@ _cairo_region_translate (cairo_region_t *region,
 
 cairo_private pixman_region_overlap_t
 _cairo_region_contains_rectangle (cairo_region_t *region,
-				  const cairo_rectangle_int_t *box);
+				  const cairo_rectangle_int_t *rect);
 
 
 CAIRO_END_DECLS
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 1d5de7c..5f53bc9 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -75,8 +75,8 @@ _cairo_region_create_rect (cairo_rectangle_int_t *rect)
 }
 
 cairo_region_t *
-_cairo_region_create_boxes (cairo_box_int_t *boxes,
-			    int count)
+_cairo_region_create_rectangles (cairo_rectangle_int_t *rects,
+				 int count)
 {
     pixman_box32_t stack_pboxes[CAIRO_STACK_ARRAY_LENGTH (pixman_box32_t)];
     pixman_box32_t *pboxes = stack_pboxes;
@@ -100,10 +100,10 @@ _cairo_region_create_boxes (cairo_box_int_t *boxes,
     }
 
     for (i = 0; i < count; i++) {
-	pboxes[i].x1 = boxes[i].p1.x;
-	pboxes[i].y1 = boxes[i].p1.y;
-	pboxes[i].x2 = boxes[i].p2.x;
-	pboxes[i].y2 = boxes[i].p2.y;
+	pboxes[i].x1 = rects[i].x;
+	pboxes[i].y1 = rects[i].y;
+	pboxes[i].x2 = rects[i].x + rects[i].width;
+	pboxes[i].y2 = rects[i].y + rects[i].height;
     }
 
     if (! pixman_region32_init_rects (&region->rgn, pboxes, count)) {
@@ -150,7 +150,7 @@ _cairo_region_copy (cairo_region_t *original)
 }
 
 int
-_cairo_region_num_boxes (cairo_region_t *region)
+_cairo_region_num_rectangles (cairo_region_t *region)
 {
     if (region->status)
 	return 0;
@@ -159,9 +159,9 @@ _cairo_region_num_boxes (cairo_region_t *region)
 }
 
 cairo_private void
-_cairo_region_get_box (cairo_region_t *region,
-		       int nth_box,
-		       cairo_box_int_t *box)
+_cairo_region_get_rectangle (cairo_region_t *region,
+			     int nth_box,
+			     cairo_rectangle_int_t *rect)
 {
     pixman_box32_t *pbox;
 
@@ -170,10 +170,10 @@ _cairo_region_get_box (cairo_region_t *region,
     
     pbox = pixman_region32_rectangles (&region->rgn, NULL) + nth_box;
 
-    box->p1.x = pbox->x1;
-    box->p1.y = pbox->y1;
-    box->p2.x = pbox->x2;
-    box->p2.y = pbox->y2;
+    rect->x = pbox->x1;
+    rect->y = pbox->y1;
+    rect->width = pbox->x2 - pbox->x1;
+    rect->height = pbox->y2 - pbox->y1;
 }
 
 /**
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index d41c645..876268f 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -417,7 +417,7 @@ _composite_trap_region (cairo_clip_t            *clip,
     cairo_status_t status;
     cairo_solid_pattern_t solid_pattern;
     cairo_surface_pattern_t mask;
-    int num_rects = _cairo_region_num_boxes (trap_region);
+    int num_rects = _cairo_region_num_rectangles (trap_region);
     unsigned int clip_serial;
     cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
 
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 635575a..42fc6da 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1570,14 +1570,13 @@ _cairo_surface_fill_rectangle (cairo_surface_t	   *surface,
  *
  * Return value: %CAIRO_STATUS_SUCCESS or the error that occurred
  **/
-COMPILE_TIME_ASSERT (sizeof (cairo_box_int_t) <= sizeof (cairo_rectangle_int_t));
 cairo_status_t
 _cairo_surface_fill_region (cairo_surface_t	   *surface,
 			    cairo_operator_t	    op,
 			    const cairo_color_t    *color,
 			    cairo_region_t         *region)
 {
-    int num_boxes;
+    int num_rects;
     cairo_rectangle_int_t stack_rects[CAIRO_STACK_ARRAY_LENGTH (cairo_rectangle_int_t)];
     cairo_rectangle_int_t *rects = stack_rects;
     cairo_status_t status;
@@ -1588,12 +1587,12 @@ _cairo_surface_fill_region (cairo_surface_t	   *surface,
 
     assert (! surface->is_snapshot);
 
-    num_boxes = _cairo_region_num_boxes (region);
-    if (num_boxes == 0)
+    num_rects = _cairo_region_num_rectangles (region);
+    if (num_rects == 0)
 	return CAIRO_STATUS_SUCCESS;
 
-    if (num_boxes > ARRAY_LENGTH (stack_rects)) {
-	rects = _cairo_malloc_ab (num_boxes,
+    if (num_rects > ARRAY_LENGTH (stack_rects)) {
+	rects = _cairo_malloc_ab (num_rects,
 				  sizeof (cairo_rectangle_int_t));
 	if (rects == NULL) {
 	    return _cairo_surface_set_error (surface,
@@ -1601,19 +1600,11 @@ _cairo_surface_fill_region (cairo_surface_t	   *surface,
 	}
     }
 
-    for (i = 0; i < num_boxes; i++) {
-	cairo_box_int_t box;
-
-	_cairo_region_get_box (region, i, &box);
-	
-	rects[i].x = box.p1.x;
-	rects[i].y = box.p1.y;
-	rects[i].width  = box.p2.x - rects[i].x;
-	rects[i].height = box.p2.y - rects[i].y;
-    }
+    for (i = 0; i < num_rects; i++)
+	_cairo_region_get_rectangle (region, i, &rects[i]);
 
     status =  _cairo_surface_fill_rectangles (surface, op,
-					      color, rects, num_boxes);
+					      color, rects, num_rects);
 
     if (rects != stack_rects)
 	free (rects);
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 3b6dedf..96db4ba 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -610,9 +610,9 @@ cairo_int_status_t
 _cairo_traps_extract_region (const cairo_traps_t  *traps,
 			     cairo_region_t      **region)
 {
-    cairo_box_int_t stack_boxes[CAIRO_STACK_ARRAY_LENGTH (cairo_box_int_t)];
-    cairo_box_int_t *boxes = stack_boxes;
-    int i, box_count;
+    cairo_rectangle_int_t stack_rects[CAIRO_STACK_ARRAY_LENGTH (cairo_rectangle_int_t)];
+    cairo_rectangle_int_t *rects = stack_rects;
+    int i, rect_count;
     cairo_int_status_t status;
 
     if (traps->num_traps == 0) {
@@ -632,14 +632,15 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
 	}
     }
 
-    if (traps->num_traps > ARRAY_LENGTH (stack_boxes)) {
-	boxes = _cairo_malloc_ab (traps->num_traps, sizeof (cairo_box_int_t));
+    if (traps->num_traps > ARRAY_LENGTH (stack_rects)) {
+	rects = _cairo_malloc_ab (traps->num_traps,
+				  sizeof (cairo_rectangle_int_t));
 
-	if (unlikely (boxes == NULL))
+	if (unlikely (rects == NULL))
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
-    box_count = 0;
+    rect_count = 0;
 
     for (i = 0; i < traps->num_traps; i++) {
 	int x1 = _cairo_fixed_integer_part (traps->traps[i].left.p1.x);
@@ -653,19 +654,19 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
 	if (x1 == x2 || y1 == y2)
 	    continue;
 
-	boxes[box_count].p1.x = x1;
-	boxes[box_count].p1.y = y1;
-	boxes[box_count].p2.x = x2;
-	boxes[box_count].p2.y = y2;
+	rects[rect_count].x = x1;
+	rects[rect_count].y = y1;
+	rects[rect_count].width = x2 - x1;
+	rects[rect_count].height = y2 - y1;
 
-	box_count++;
+	rect_count++;
     }
 
-    *region = _cairo_region_create_boxes (boxes, box_count);
+    *region = _cairo_region_create_rectangles (rects, rect_count);
     status = _cairo_region_status (*region);
     
-    if (boxes != stack_boxes)
-	free (boxes);
+    if (rects != stack_rects)
+	free (rects);
 
     if (unlikely (status))
     {
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index 0a3ec2e..e8cf4b1 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -250,12 +250,6 @@ typedef struct _cairo_point_int32 cairo_point_int_t;
 #error Not sure how to pick a cairo_rectangle_int_t and cairo_point_int_t for your CAIRO_FIXED_BITS!
 #endif
 
-typedef struct _cairo_box_int {
-    cairo_point_int_t p1;
-    cairo_point_int_t p2;
-} cairo_box_int_t;
-
-
 /* Rectangles that take part in a composite operation.
  *
  * This defines four translations that define which pixels of the
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index f0c7aa2..f182642 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -1461,36 +1461,36 @@ _cairo_win32_surface_set_clip_region (void           *abstract_surface,
     /* Then combine any new region with it */
     if (region) {
 	cairo_rectangle_int_t extents;
-	int num_boxes;
+	int num_rects;
 	RGNDATA *data;
 	size_t data_size;
 	RECT *rects;
 	int i;
 	HRGN gdi_region;
-	cairo_box_int_t box0;
+	cairo_rectangle_int_t rect0;
 
 	/* Create a GDI region for the cairo region */
 
 	_cairo_region_get_extents (region, &extents);
-	num_boxes = _cairo_region_num_boxes (region);
+	num_rects = _cairo_region_num_rectangles (region);
 
-	if (num_boxes == 1)
-	    _cairo_region_get_box (region, 0, &box0);
+	if (num_rects == 1)
+	    _cairo_region_get_rectangle (region, 0, &rect0);
 	    
-	if (num_boxes == 1 &&
-	    box0.p1.x == 0 &&
-	    box0.p1.y == 0 &&
-	    box0.p2.x == surface->extents.width &&
-	    box0.p2.y == surface->extents.height)
+	if (num_rects == 1 &&
+	    rect0.x == 0 &&
+	    rect0.y == 0 &&
+	    rect0.width == surface->extents.width &&
+	    rect0.width == surface->extents.height)
 	{
 	    gdi_region = NULL;
 	    
 	    SelectClipRgn (surface->dc, NULL);
 	    IntersectClipRect (surface->dc,
-			       box0.p1.x,
-			       box0.p1.y,
-			       box0.p2.x,
-			       box0.p2.y);
+			       rect0.x,
+			       rect0.y,
+			       rect0.x + rect0.width,
+			       rect0.y + rect0.height);
 	} else {
 	    /* XXX see notes in _cairo_win32_save_initial_clip --
 	     * this code will interact badly with a HDC which had an initial
@@ -1499,7 +1499,7 @@ _cairo_win32_surface_set_clip_region (void           *abstract_surface,
 	     * logical units (unlike IntersectClipRect).
 	     */
 
-	    data_size = sizeof (RGNDATAHEADER) + num_boxes * sizeof (RECT);
+	    data_size = sizeof (RGNDATAHEADER) + num_rects * sizeof (RECT);
 	    data = malloc (data_size);
 	    if (!data)
 		return _cairo_error(CAIRO_STATUS_NO_MEMORY);
@@ -1507,22 +1507,22 @@ _cairo_win32_surface_set_clip_region (void           *abstract_surface,
 
 	    data->rdh.dwSize = sizeof (RGNDATAHEADER);
 	    data->rdh.iType = RDH_RECTANGLES;
-	    data->rdh.nCount = num_boxes;
-	    data->rdh.nRgnSize = num_boxes * sizeof (RECT);
+	    data->rdh.nCount = num_rects;
+	    data->rdh.nRgnSize = num_rects * sizeof (RECT);
 	    data->rdh.rcBound.left = extents.x;
 	    data->rdh.rcBound.top = extents.y;
 	    data->rdh.rcBound.right = extents.x + extents.width;
 	    data->rdh.rcBound.bottom = extents.y + extents.height;
 
-	    for (i = 0; i < num_boxes; i++) {
-		cairo_box_int_t box;
+	    for (i = 0; i < num_rects; i++) {
+		cairo_rectangle_int_t rect;
 
-		_cairo_region_get_box (region, i, &box);
+	        _cairo_region_get_rectangle (region, i, &rect);
 		
-		rects[i].left = box.p1.x;
-		rects[i].top = box.p1.y;
-		rects[i].right = box.p2.x;
-		rects[i].bottom = box.p2.y;
+		rects[i].left = rect.x;
+		rects[i].top = rect.y;
+		rects[i].right = rect.x + rect.width;
+		rects[i].bottom = rect.y + rect.height;
 	    }
 
 	    gdi_region = ExtCreateRegion (NULL, data_size, data);
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 17a09e3..ab589e1 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1557,32 +1557,32 @@ _cairo_xcb_surface_set_clip_region (void           *abstract_surface,
     } else {
 	cairo_status_t status;
 	xcb_rectangle_t *rects = NULL;
-	int n_boxes, i;
+	int n_rects, i;
 
-	n_boxes = _cairo_region_num_boxes (region);
+	n_rects = _cairo_region_num_rectangles (region);
 
-	if (n_boxes > 0) {
-	    rects = _cairo_malloc_ab (n_boxes, sizeof(xcb_rectangle_t));
+	if (n_rects > 0) {
+	    rects = _cairo_malloc_ab (n_rects, sizeof(xcb_rectangle_t));
 	    if (rects == NULL)
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	} else {
 	    rects = NULL;
 	}
 
-	for (i = 0; i < n_boxes; i++) {
-	    cairo_box_int_t box;
+	for (i = 0; i < n_rects; i++) {
+	    cairo_rectangle_int_t rect;
 
-	    _cairo_region_get_box (region, i, &box);
+	    _cairo_region_get_rectangle (region, i, &rect);
 	    
-	    rects[i].x = box.p1.x;
-	    rects[i].y = box.p1.y;
-	    rects[i].width = box.p2.x - box.p1.x;
-	    rects[i].height = box.p2.y - box.p1.y;
+	    rects[i].x = rect.x;
+	    rects[i].y = rect.y;
+	    rects[i].width = rect.width;
+	    rects[i].height = rect.height;
 	}
  
 	surface->have_clip_rects = TRUE;
 	surface->clip_rects = rects;
-	surface->num_clip_rects = n_boxes;
+	surface->num_clip_rects = n_rects;
 
 	if (surface->gc)
 	    _cairo_xcb_surface_set_gc_clip_rects (surface);
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index e3a1417..e411977 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2269,7 +2269,6 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t	op,
     return status;
 }
 
-COMPILE_TIME_ASSERT (sizeof (XRectangle) <= sizeof (cairo_box_int_t));
 static cairo_int_status_t
 _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 				     cairo_region_t *region)
@@ -2291,7 +2290,7 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
     if (region != NULL) {
 	cairo_status_t status;
 	XRectangle *rects = NULL;
-	int n_boxes, i;
+	int n_rects, i;
 	cairo_rectangle_int_t rect;
 	cairo_region_t *bounded;
 
@@ -2310,10 +2309,10 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	    return status;
 	}
 
-	n_boxes = _cairo_region_num_boxes (bounded);
+	n_rects = _cairo_region_num_rectangles (bounded);
 
-	if (n_boxes > ARRAY_LENGTH (surface->embedded_clip_rects)) {
-	    rects = _cairo_malloc_ab (n_boxes, sizeof (XRectangle));
+	if (n_rects > ARRAY_LENGTH (surface->embedded_clip_rects)) {
+	    rects = _cairo_malloc_ab (n_rects, sizeof (XRectangle));
 	    if (unlikely (rects == NULL)) {
 		_cairo_region_destroy (bounded);
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2322,25 +2321,25 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	    rects = surface->embedded_clip_rects;
 	}
 
-	for (i = 0; i < n_boxes; i++) {
-	    cairo_box_int_t box;
+	for (i = 0; i < n_rects; i++) {
+	    cairo_rectangle_int_t rect;
+	    
+	    _cairo_region_get_rectangle (bounded, i, &rect);
 
-	    _cairo_region_get_box (bounded, i, &box);
-
-	    rects[i].x = box.p1.x;
-	    rects[i].y = box.p1.y;
-	    rects[i].width  = box.p2.x - rects[i].x;
-	    rects[i].height = box.p2.y - rects[i].y;
+	    rects[i].x = rect.x;
+	    rects[i].y = rect.y;
+	    rects[i].width = rect.width;
+	    rects[i].height = rect.height;
 	}
 	
 	_cairo_region_destroy (bounded);
 
 	surface->have_clip_rects = TRUE;
 	surface->clip_rects = rects;
-	surface->num_clip_rects = n_boxes;
+	surface->num_clip_rects = n_rects;
 
 	/* Discard the trivial clip rectangle that covers the entire surface */
-	if (n_boxes == 1 &&
+	if (n_rects == 1 &&
 	    rects[0].x == 0 &&
 	    rects[0].y == 0 &&
 	    rects[0].width  == surface->width &&
commit c29aeee2d3569cd43e88adc05662bb6306987b8b
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Thu Dec 11 18:37:40 2008 -0500

    [region] Change sense of _cairo_region_not_empty() to _cairo_region_empty()
    
    Having "not" in the name causes double negatives.

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 380949c..649fa7a 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -367,7 +367,7 @@ _cairo_clip_intersect_region (cairo_clip_t    *clip,
     clip->serial = _cairo_surface_allocate_clip_serial (target);
     _cairo_region_destroy (region);
 
-    if (!clip->region || ! _cairo_region_not_empty (clip->region))
+    if (!clip->region || _cairo_region_empty (clip->region))
 	_cairo_clip_set_all_clipped (clip, target);
 
     return status;
diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
index f762fea..8852af3 100644
--- a/src/cairo-region-private.h
+++ b/src/cairo-region-private.h
@@ -99,7 +99,7 @@ _cairo_region_union_rect (cairo_region_t *dst,
 			  cairo_rectangle_int_t *rect);
 
 cairo_private cairo_bool_t
-_cairo_region_not_empty (cairo_region_t *region);
+_cairo_region_empty (cairo_region_t *region);
 
 cairo_private void
 _cairo_region_translate (cairo_region_t *region,
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 8224582..1d5de7c 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -261,12 +261,12 @@ _cairo_region_union_rect (cairo_region_t *dst,
 }
 
 cairo_bool_t
-_cairo_region_not_empty (cairo_region_t *region)
+_cairo_region_empty (cairo_region_t *region)
 {
     if (region->status)
-	return FALSE;
+	return TRUE;
     
-    return (cairo_bool_t) pixman_region32_not_empty (&region->rgn);
+    return !pixman_region32_not_empty (&region->rgn);
 }
 
 void
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index da2f943..d41c645 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -583,7 +583,7 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
             if (unlikely (status))
                 goto out;
 
-            if (!_cairo_region_not_empty (clear_region)) {
+            if (_cairo_region_empty (clear_region)) {
                 _cairo_region_destroy (clear_region);
 		clear_region = NULL;
             }
commit c88321d0a2b9d200b2044674d02fa0683feca74c
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Thu Dec 11 16:20:23 2008 -0500

    [region] Miscellaneous bug fixes.
    
    - Initialize region->status in _cairo_region_create_boxes()
    - Make _cairo_region_copy() actually return a region.
    - Fix a bug where a NULL region could be dereferenced
    
    Also add an assertion that the result of cairo_region_copy() is never
    NULL.

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 7534881..380949c 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -357,6 +357,8 @@ _cairo_clip_intersect_region (cairo_clip_t    *clip,
 	status = _cairo_region_intersect (clip->region, region);
     } else {
 	clip->region = _cairo_region_copy (region);
+
+	assert (clip->region != NULL);
 	
         if ((status = _cairo_region_status (clip->region)))
 	    clip->region = NULL;
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index e9e544d..746fca1 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1427,7 +1427,7 @@ _cairo_image_surface_set_clip_region (void *abstract_surface,
 {
     cairo_image_surface_t *surface = (cairo_image_surface_t *) abstract_surface;
 
-    if (! pixman_image_set_clip_region32 (surface->pixman_image, &region->rgn))
+    if (! pixman_image_set_clip_region32 (surface->pixman_image, region? &region->rgn : NULL))
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     surface->has_clip = region != NULL;
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 804c64d..8224582 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -88,6 +88,8 @@ _cairo_region_create_boxes (cairo_box_int_t *boxes,
     if (!region)
 	return (cairo_region_t *)&_cairo_region_nil;
 
+    region->status = CAIRO_STATUS_SUCCESS;
+    
     if (count > ARRAY_LENGTH (stack_pboxes)) {
 	pboxes = _cairo_malloc_ab (count, sizeof (pixman_box32_t));
 
@@ -144,7 +146,7 @@ _cairo_region_copy (cairo_region_t *original)
 	return (cairo_region_t *)&_cairo_region_nil;
     }
 
-    return CAIRO_STATUS_SUCCESS;
+    return copy;
 }
 
 int
commit 93b285dc2c9c9ec486e0096933c3611f73374fcb
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Thu Dec 11 15:50:15 2008 -0500

    [region] Get rid of clip->has_region

diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index 517c28c..b1a9d1a 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -79,7 +79,6 @@ struct _cairo_clip {
      * A clip region that can be placed in the surface
      */
     cairo_region_t *region;
-    cairo_bool_t has_region;
     /*
      * If the surface supports path clipping, we store the list of
      * clipping paths that has been set here as a linked list.
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 095af10..7534881 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -72,34 +72,30 @@ _cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target)
 cairo_status_t
 _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
 {
-    cairo_status_t status;
-
     clip->mode = other->mode;
 
     clip->all_clipped = other->all_clipped;
-
+    
     clip->surface = cairo_surface_reference (other->surface);
     clip->surface_rect = other->surface_rect;
 
     clip->serial = other->serial;
 
-    if (other->has_region) {
-        clip->has_region = TRUE;
+    if (other->region) {
+	cairo_status_t status;
 	
 	clip->region = _cairo_region_copy (other->region);
-    } else {
-        clip->has_region = FALSE;
-	
-	clip->region = _cairo_region_create ();
-    }
 
-    status = _cairo_region_status (clip->region);
-    if (unlikely (status)) {
-	cairo_surface_destroy (clip->surface);
-	_cairo_region_destroy (clip->region);
+	status = _cairo_region_status (clip->region);
+	if (unlikely (status)) {
+	    cairo_surface_destroy (clip->surface);
+	    _cairo_region_destroy (clip->region);
+	    clip->region = NULL;
+	    
+	    return status;
+	}
+    } else {
 	clip->region = NULL;
-	
-	return status;
     }
     
     clip->path = _cairo_clip_path_reference (other->path);
@@ -118,10 +114,10 @@ _cairo_clip_reset (cairo_clip_t *clip)
 
     clip->serial = 0;
 
-    if (clip->has_region) {
-	_cairo_region_clear (clip->region);
+    if (clip->region) {
+	_cairo_region_destroy (clip->region);
 
-        clip->has_region = FALSE;
+	clip->region = NULL;
     }
 
     _cairo_clip_path_destroy (clip->path);
@@ -788,8 +784,6 @@ _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
 	    clip->region = _cairo_region_copy (other->region);
 	    if (unlikely ((status = _cairo_region_status (clip->region))))
 		goto BAIL;
-
-	    clip->has_region = TRUE;
         }
 
         if (other->surface) {
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 22e67f7..635575a 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2389,7 +2389,7 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip)
 						     clip->path,
 						     clip->serial);
 
-	    if (clip->has_region)
+	    if (clip->region)
 		return _cairo_surface_set_clip_region (surface,
 						       clip->region,
 						       clip->serial);
commit e3e1b35eb9eb3cf90d882a7452580f9efe00b89a
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Thu Dec 11 15:29:23 2008 -0500

    [region] Make cairo_region_t a malloced object.

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 1be592e..9c97c11 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -52,8 +52,8 @@ typedef struct {
     cairo_bool_t has_supported;
     cairo_bool_t has_unsupported;
 
-    cairo_region_t supported_region;
-    cairo_region_t fallback_region;
+    cairo_region_t *supported_region;
+    cairo_region_t *fallback_region;
     cairo_rectangle_int_t current_clip;
     cairo_box_t page_bbox;
 
@@ -215,7 +215,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
      * region there is no benefit in emitting a native operation as
      * the fallback image will be painted on top.
      */
-    if (_cairo_region_contains_rectangle (&surface->fallback_region, rect) == PIXMAN_REGION_IN)
+    if (_cairo_region_contains_rectangle (surface->fallback_region, rect) == PIXMAN_REGION_IN)
 	return CAIRO_INT_STATUS_IMAGE_FALLBACK;
 
     if (backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) {
@@ -226,7 +226,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
 	 * natively supported and the backend will blend the
 	 * transparency into the white background.
 	 */
-	if (_cairo_region_contains_rectangle (&surface->supported_region, rect) == PIXMAN_REGION_OUT)
+	if (_cairo_region_contains_rectangle (surface->supported_region, rect) == PIXMAN_REGION_OUT)
 	    backend_status = CAIRO_STATUS_SUCCESS;
     }
 
@@ -235,8 +235,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
 	 * this region will be emitted as native operations.
 	 */
 	surface->has_supported = TRUE;
-	status = _cairo_region_union_rect (&surface->supported_region,
-					   &surface->supported_region,
+	status = _cairo_region_union_rect (surface->supported_region,
 					   rect);
 	return status;
     }
@@ -246,8 +245,7 @@ _add_operation  (cairo_analysis_surface_t *surface,
      * emitted.
      */
     surface->has_unsupported = TRUE;
-    status = _cairo_region_union_rect (&surface->fallback_region,
-				       &surface->fallback_region,
+    status = _cairo_region_union_rect (surface->fallback_region,
 				       rect);
 
     /* The status CAIRO_INT_STATUS_IMAGE_FALLBACK is used to indicate
@@ -267,8 +265,8 @@ _cairo_analysis_surface_finish (void *abstract_surface)
 {
     cairo_analysis_surface_t	*surface = (cairo_analysis_surface_t *) abstract_surface;
 
-    _cairo_region_fini (&surface->supported_region);
-    _cairo_region_fini (&surface->fallback_region);
+    _cairo_region_destroy (surface->supported_region);
+    _cairo_region_destroy (surface->fallback_region);
 
     cairo_surface_destroy (surface->target);
 
@@ -783,8 +781,8 @@ _cairo_analysis_surface_create (cairo_surface_t		*target,
     surface->page_bbox.p2.x = 0;
     surface->page_bbox.p2.y = 0;
 
-    _cairo_region_init (&surface->supported_region);
-    _cairo_region_init (&surface->fallback_region);
+    surface->supported_region = _cairo_region_create ();
+    surface->fallback_region = _cairo_region_create ();
 
     if (width == -1 && height == -1) {
 	surface->current_clip.x      = CAIRO_RECT_INT_MIN;
@@ -831,7 +829,7 @@ _cairo_analysis_surface_get_supported (cairo_surface_t *abstract_surface)
 {
     cairo_analysis_surface_t	*surface = (cairo_analysis_surface_t *) abstract_surface;
 
-    return &surface->supported_region;
+    return surface->supported_region;
 }
 
 cairo_region_t *
@@ -839,7 +837,7 @@ _cairo_analysis_surface_get_unsupported (cairo_surface_t *abstract_surface)
 {
     cairo_analysis_surface_t	*surface = (cairo_analysis_surface_t *) abstract_surface;
 
-    return &surface->fallback_region;
+    return surface->fallback_region;
 }
 
 cairo_bool_t
diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index 36c0fbd..517c28c 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -78,7 +78,7 @@ struct _cairo_clip {
     /*
      * A clip region that can be placed in the surface
      */
-    cairo_region_t region;
+    cairo_region_t *region;
     cairo_bool_t has_region;
     /*
      * If the surface supports path clipping, we store the list of
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 9455c28..095af10 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -64,8 +64,7 @@ _cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target)
 
     clip->serial = 0;
 
-    _cairo_region_init (&clip->region);
-    clip->has_region = FALSE;
+    clip->region = NULL;
 
     clip->path = NULL;
 }
@@ -73,6 +72,8 @@ _cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target)
 cairo_status_t
 _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
 {
+    cairo_status_t status;
+
     clip->mode = other->mode;
 
     clip->all_clipped = other->all_clipped;
@@ -82,22 +83,25 @@ _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
 
     clip->serial = other->serial;
 
-    _cairo_region_init (&clip->region);
-
     if (other->has_region) {
-	cairo_status_t status;
-
-	status = _cairo_region_copy (&clip->region, &other->region);
-	if (unlikely (status)) {
-	    _cairo_region_fini (&clip->region);
-	    cairo_surface_destroy (clip->surface);
-	    return status;
-	}
         clip->has_region = TRUE;
+	
+	clip->region = _cairo_region_copy (other->region);
     } else {
         clip->has_region = FALSE;
+	
+	clip->region = _cairo_region_create ();
     }
 
+    status = _cairo_region_status (clip->region);
+    if (unlikely (status)) {
+	cairo_surface_destroy (clip->surface);
+	_cairo_region_destroy (clip->region);
+	clip->region = NULL;
+	
+	return status;
+    }
+    
     clip->path = _cairo_clip_path_reference (other->path);
 
     return CAIRO_STATUS_SUCCESS;
@@ -115,11 +119,7 @@ _cairo_clip_reset (cairo_clip_t *clip)
     clip->serial = 0;
 
     if (clip->has_region) {
-        /* _cairo_region_fini just releases the resources used but
-         * doesn't bother with leaving the region in a valid state.
-         * So _cairo_region_init has to be called afterwards. */
-	_cairo_region_fini (&clip->region);
-        _cairo_region_init (&clip->region);
+	_cairo_region_clear (clip->region);
 
         clip->has_region = FALSE;
     }
@@ -178,10 +178,10 @@ _cairo_clip_intersect_to_rectangle (cairo_clip_t            *clip,
             return status;
     }
 
-    if (clip->has_region) {
+    if (clip->region) {
 	cairo_rectangle_int_t extents;
 
-	_cairo_region_get_extents (&clip->region, &extents);
+	_cairo_region_get_extents (clip->region, &extents);
 	is_empty = _cairo_rectangle_intersect (rectangle, &extents);
 	if (is_empty)
 	    return CAIRO_STATUS_SUCCESS;
@@ -194,7 +194,7 @@ _cairo_clip_intersect_to_rectangle (cairo_clip_t            *clip,
 }
 
 cairo_status_t
-_cairo_clip_intersect_to_region (cairo_clip_t      *clip,
+_cairo_clip_intersect_to_region (cairo_clip_t   *clip,
 				 cairo_region_t *region)
 {
     cairo_status_t status;
@@ -203,13 +203,13 @@ _cairo_clip_intersect_to_region (cairo_clip_t      *clip,
 	return CAIRO_STATUS_SUCCESS;
 
     if (clip->all_clipped) {
-	cairo_region_t clip_rect;
+	cairo_region_t *clip_rect;
 
-	_cairo_region_init_rect (&clip_rect, &clip->surface_rect);
+	clip_rect = _cairo_region_create_rect (&clip->surface_rect);
 
-	status = _cairo_region_intersect (region, &clip_rect, region);
+	status = _cairo_region_intersect (region, clip_rect);
 
-	_cairo_region_fini (&clip_rect);
+	_cairo_region_destroy (clip_rect);
 
 	return status;
     }
@@ -218,20 +218,20 @@ _cairo_clip_intersect_to_region (cairo_clip_t      *clip,
 	/* Intersect clip path into region. */
     }
 
-    if (clip->has_region) {
-	status = _cairo_region_intersect (region, &clip->region, region);
+    if (clip->region) {
+	status = _cairo_region_intersect (region, clip->region);
 	if (unlikely (status))
 	    return status;
     }
 
     if (clip->surface) {
-	cairo_region_t clip_rect;
+	cairo_region_t *clip_rect;
 
-	_cairo_region_init_rect (&clip_rect, &clip->surface_rect);
+	clip_rect = _cairo_region_create_rect (&clip->surface_rect);
 
-	status = _cairo_region_intersect (region, &clip_rect, region);
+	status = _cairo_region_intersect (region, clip_rect);
 
-	_cairo_region_fini (&clip_rect);
+	_cairo_region_destroy (clip_rect);
 
         if (unlikely (status))
             return status;
@@ -344,7 +344,7 @@ _cairo_clip_intersect_region (cairo_clip_t    *clip,
 			      cairo_traps_t   *traps,
 			      cairo_surface_t *target)
 {
-    cairo_region_t region;
+    cairo_region_t *region;
     cairo_int_status_t status;
 
     if (clip->all_clipped)
@@ -357,20 +357,19 @@ _cairo_clip_intersect_region (cairo_clip_t    *clip,
     if (status)
 	return status;
 
-    if (clip->has_region) {
-	status = _cairo_region_intersect (&clip->region,
-					  &clip->region,
-					  &region);
+    if (clip->region) {
+	status = _cairo_region_intersect (clip->region, region);
     } else {
-        status = _cairo_region_copy (&clip->region, &region);
-	if (status == CAIRO_STATUS_SUCCESS)
-	    clip->has_region = TRUE;
+	clip->region = _cairo_region_copy (region);
+	
+        if ((status = _cairo_region_status (clip->region)))
+	    clip->region = NULL;
     }
 
     clip->serial = _cairo_surface_allocate_clip_serial (target);
-    _cairo_region_fini (&region);
+    _cairo_region_destroy (region);
 
-    if (! _cairo_region_not_empty (&clip->region))
+    if (!clip->region || ! _cairo_region_not_empty (clip->region))
 	_cairo_clip_set_all_clipped (clip, target);
 
     return status;
@@ -727,8 +726,8 @@ _cairo_clip_translate (cairo_clip_t  *clip,
     if (clip->all_clipped)
 	return;
 
-    if (clip->has_region) {
-        _cairo_region_translate (&clip->region,
+    if (clip->region) {
+        _cairo_region_translate (clip->region,
                                  _cairo_fixed_integer_part (tx),
                                  _cairo_fixed_integer_part (ty));
     }
@@ -785,9 +784,9 @@ _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
         /* We should reapply the original clip path in this case, and let
          * whatever the right handling is happen */
     } else {
-        if (other->has_region) {
-            status = _cairo_region_copy (&clip->region, &other->region);
-	    if (unlikely (status))
+        if (other->region) {
+	    clip->region = _cairo_region_copy (other->region);
+	    if (unlikely ((status = _cairo_region_status (clip->region))))
 		goto BAIL;
 
 	    clip->has_region = TRUE;
@@ -822,8 +821,8 @@ _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
     return CAIRO_STATUS_SUCCESS;
 
 BAIL:
-    if (clip->has_region)
-	_cairo_region_fini (&clip->region);
+    if (clip->region)
+	_cairo_region_destroy (clip->region);
     if (clip->surface)
 	cairo_surface_destroy (clip->surface);
 
@@ -874,10 +873,10 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 	return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable;
     }
 
-    if (clip->has_region) {
+    if (clip->region) {
         int i;
 
-	n_boxes = _cairo_region_num_boxes (&clip->region);
+	n_boxes = _cairo_region_num_boxes (clip->region);
 
 	if (n_boxes) {
 	    rectangles = _cairo_malloc_ab (n_boxes, sizeof (cairo_rectangle_t));
@@ -890,7 +889,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 		cairo_box_int_t box;
 		cairo_rectangle_int_t clip_rect;
 
-		_cairo_region_get_box (&clip->region, i, &box);
+		_cairo_region_get_box (clip->region, i, &box);
 
 		clip_rect.x = box.p1.x;
 		clip_rect.y = box.p1.y;
diff --git a/src/cairo-region-private.h b/src/cairo-region-private.h
index d969116..f762fea 100644
--- a/src/cairo-region-private.h
+++ b/src/cairo-region-private.h
@@ -47,27 +47,32 @@ CAIRO_BEGIN_DECLS
 /* #cairo_region_t is defined in cairoint.h */
 
 struct _cairo_region {
+    cairo_status_t status;
+    
     pixman_region32_t rgn;
 };
 
-cairo_private void
-_cairo_region_init (cairo_region_t *region);
+cairo_private cairo_region_t *
+_cairo_region_create (void);
+
+cairo_private cairo_region_t *
+_cairo_region_create_rect (cairo_rectangle_int_t *rect);
+
+cairo_private cairo_status_t
+_cairo_region_status (cairo_region_t *region);
 
 cairo_private void
-_cairo_region_init_rect (cairo_region_t *region,
-			 cairo_rectangle_int_t *rect);
+_cairo_region_clear (cairo_region_t *region);
 
-cairo_private cairo_int_status_t
-_cairo_region_init_boxes (cairo_region_t *region,
-			  cairo_box_int_t *boxes,
-			  int count);
+cairo_private cairo_region_t *
+_cairo_region_create_boxes (cairo_box_int_t *boxes,
+			    int count);
 
 cairo_private void
-_cairo_region_fini (cairo_region_t *region);
+_cairo_region_destroy (cairo_region_t *region);
 
-cairo_private cairo_int_status_t
-_cairo_region_copy (cairo_region_t *dst,
-		    cairo_region_t *src);
+cairo_private cairo_region_t *
+_cairo_region_copy (cairo_region_t *original);
 
 cairo_private int
 _cairo_region_num_boxes (cairo_region_t *region);
@@ -81,19 +86,16 @@ cairo_private void
 _cairo_region_get_extents (cairo_region_t *region,
 			   cairo_rectangle_int_t *extents);
 
-cairo_private cairo_int_status_t
+cairo_private cairo_status_t
 _cairo_region_subtract (cairo_region_t *dst,
-			cairo_region_t *a,
-			cairo_region_t *b);
+			cairo_region_t *other);
 
-cairo_private cairo_int_status_t
+cairo_private cairo_status_t
 _cairo_region_intersect (cairo_region_t *dst,
-			 cairo_region_t *a,
-			 cairo_region_t *b);
+			 cairo_region_t *other);
 
-cairo_private cairo_int_status_t
+cairo_private cairo_status_t
 _cairo_region_union_rect (cairo_region_t *dst,
-			  cairo_region_t *src,
 			  cairo_rectangle_int_t *rect);
 
 cairo_private cairo_bool_t
diff --git a/src/cairo-region.c b/src/cairo-region.c
index d32805e..804c64d 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -33,39 +33,68 @@
  * Contributor(s):
  *	Owen Taylor <otaylor at redhat.com>
  *      Vladimir Vukicevic <vladimir at pobox.com>
+ *      Søren Sandmann <sandmann at daimi.au.dk>
  */
 
 #include "cairoint.h"
 
-void
-_cairo_region_init (cairo_region_t *region)
+const cairo_region_t _cairo_region_nil = {
+    CAIRO_STATUS_NO_MEMORY,		/* status */
+};
+
+cairo_region_t *
+_cairo_region_create (void)
 {
+    cairo_region_t *region = _cairo_malloc (sizeof (cairo_region_t));
+
+    if (!region)
+	return (cairo_region_t *)&_cairo_region_nil;
+
+    region->status = CAIRO_STATUS_SUCCESS;
+
     pixman_region32_init (&region->rgn);
+
+    return region;
 }
 
-void
-_cairo_region_init_rect (cairo_region_t *region,
-			 cairo_rectangle_int_t *rect)
+cairo_region_t *
+_cairo_region_create_rect (cairo_rectangle_int_t *rect)
 {
+    cairo_region_t *region = _cairo_malloc (sizeof (cairo_region_t));
+
+    if (!region)
+	return (cairo_region_t *)&_cairo_region_nil;
+    
+    region->status = CAIRO_STATUS_SUCCESS;
+    
     pixman_region32_init_rect (&region->rgn,
-			     rect->x, rect->y,
-			     rect->width, rect->height);
+			       rect->x, rect->y,
+			       rect->width, rect->height);
+
+    return region;
 }
 
-cairo_int_status_t
-_cairo_region_init_boxes (cairo_region_t *region,
-			  cairo_box_int_t *boxes,
-			  int count)
+cairo_region_t *
+_cairo_region_create_boxes (cairo_box_int_t *boxes,
+			    int count)
 {
     pixman_box32_t stack_pboxes[CAIRO_STACK_ARRAY_LENGTH (pixman_box32_t)];
     pixman_box32_t *pboxes = stack_pboxes;
-    cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_region_t *region;
     int i;
 
+    region = _cairo_malloc (sizeof (cairo_region_t));
+
+    if (!region)
+	return (cairo_region_t *)&_cairo_region_nil;
+
     if (count > ARRAY_LENGTH (stack_pboxes)) {
 	pboxes = _cairo_malloc_ab (count, sizeof (pixman_box32_t));
-	if (unlikely (pboxes == NULL))
-	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
+	if (unlikely (pboxes == NULL)) {
+	    free (region);
+	    return (cairo_region_t *)&_cairo_region_nil;
+	}
     }
 
     for (i = 0; i < count; i++) {
@@ -75,26 +104,45 @@ _cairo_region_init_boxes (cairo_region_t *region,
 	pboxes[i].y2 = boxes[i].p2.y;
     }
 
-    if (! pixman_region32_init_rects (&region->rgn, pboxes, count))
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    if (! pixman_region32_init_rects (&region->rgn, pboxes, count)) {
+	free (region);
 
+	region = (cairo_region_t *)&_cairo_region_nil;
+    }
+    
     if (pboxes != stack_pboxes)
 	free (pboxes);
 
-    return status;
+    return region;
 }
 
 void
-_cairo_region_fini (cairo_region_t *region)
+_cairo_region_destroy (cairo_region_t *region)
 {
+    if (region->status)
+	return;
+    
     pixman_region32_fini (&region->rgn);
+    free (region);
 }
 
-cairo_int_status_t
-_cairo_region_copy (cairo_region_t *dst, cairo_region_t *src)
+cairo_region_t *
+_cairo_region_copy (cairo_region_t *original)
 {
-    if (!pixman_region32_copy (&dst->rgn, &src->rgn))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    cairo_region_t *copy;
+    
+    if (original->status)
+	return (cairo_region_t *)&_cairo_region_nil;
+
+    copy = _cairo_region_create ();
+    if (!copy)
+	return (cairo_region_t *)&_cairo_region_nil;
+
+    if (!pixman_region32_copy (&copy->rgn, &original->rgn)) {
+	_cairo_region_destroy (copy);
+
+	return (cairo_region_t *)&_cairo_region_nil;
+    }
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -102,6 +150,9 @@ _cairo_region_copy (cairo_region_t *dst, cairo_region_t *src)
 int
 _cairo_region_num_boxes (cairo_region_t *region)
 {
+    if (region->status)
+	return 0;
+    
     return pixman_region32_n_rects (&region->rgn);
 }
 
@@ -112,6 +163,9 @@ _cairo_region_get_box (cairo_region_t *region,
 {
     pixman_box32_t *pbox;
 
+    if (region->status)
+	return;
+    
     pbox = pixman_region32_rectangles (&region->rgn, NULL) + nth_box;
 
     box->p1.x = pbox->x1;
@@ -128,9 +182,15 @@ _cairo_region_get_box (cairo_region_t *region,
  * Gets the bounding box of a region as a #cairo_rectangle_int_t
  **/
 void
-_cairo_region_get_extents (cairo_region_t *region, cairo_rectangle_int_t *extents)
+_cairo_region_get_extents (cairo_region_t *region,
+			   cairo_rectangle_int_t *extents)
 {
-    pixman_box32_t *pextents = pixman_region32_extents (&region->rgn);
+    pixman_box32_t *pextents;
+
+    if (region->status || !extents)
+	return;
+
+    pextents = pixman_region32_extents (&region->rgn);
 
     extents->x = pextents->x1;
     extents->y = pextents->y1;
@@ -138,33 +198,62 @@ _cairo_region_get_extents (cairo_region_t *region, cairo_rectangle_int_t *extent
     extents->height = pextents->y2 - pextents->y1;
 }
 
-cairo_int_status_t
-_cairo_region_subtract (cairo_region_t *dst, cairo_region_t *a, cairo_region_t *b)
+cairo_status_t
+_cairo_region_status (cairo_region_t *region)
+{
+    return region->status;
+}
+
+void
+_cairo_region_clear (cairo_region_t *region)
+{
+    if (region->status)
+	return;
+
+    pixman_region32_fini (&region->rgn);
+    pixman_region32_init (&region->rgn);
+}
+
+cairo_status_t
+_cairo_region_subtract (cairo_region_t *dst, cairo_region_t *other)
 {
-    if (!pixman_region32_subtract (&dst->rgn, &a->rgn, &b->rgn))
+    if (dst->status)
+	return dst->status;
+
+    if (other->status)
+	return other->status;
+    
+    if (!pixman_region32_subtract (&dst->rgn, &dst->rgn, &other->rgn))
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_int_status_t
-_cairo_region_intersect (cairo_region_t *dst, cairo_region_t *a, cairo_region_t *b)
+cairo_status_t
+_cairo_region_intersect (cairo_region_t *dst, cairo_region_t *other)
 {
-    if (!pixman_region32_intersect (&dst->rgn, &a->rgn, &b->rgn))
+    if (dst->status)
+	return dst->status;
+
+    if (other->status)
+	return other->status;
+    
+    if (!pixman_region32_intersect (&dst->rgn, &dst->rgn, &other->rgn))
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_int_status_t
+cairo_status_t
 _cairo_region_union_rect (cairo_region_t *dst,
-			  cairo_region_t *src,
 			  cairo_rectangle_int_t *rect)
 {
-    if (!pixman_region32_union_rect (&dst->rgn, &src->rgn,
-				   rect->x, rect->y,
-				   rect->width, rect->height))
+    if (!pixman_region32_union_rect (&dst->rgn, &dst->rgn,
+				     rect->x, rect->y,
+				     rect->width, rect->height))
+    {
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -172,6 +261,9 @@ _cairo_region_union_rect (cairo_region_t *dst,
 cairo_bool_t
 _cairo_region_not_empty (cairo_region_t *region)
 {
+    if (region->status)
+	return FALSE;
+    
     return (cairo_bool_t) pixman_region32_not_empty (&region->rgn);
 }
 
@@ -179,6 +271,9 @@ void
 _cairo_region_translate (cairo_region_t *region,
 			 int x, int y)
 {
+    if (region->status)
+	return;
+    
     pixman_region32_translate (&region->rgn, x, y);
 }
 
@@ -188,6 +283,9 @@ _cairo_region_contains_rectangle (cairo_region_t *region,
 {
     pixman_box32_t pbox;
 
+    if (region->status)
+	return PIXMAN_REGION_OUT;
+    
     pbox.x1 = rect->x;
     pbox.y1 = rect->y;
     pbox.x2 = rect->x + rect->width;
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 7c38cbd..da2f943 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -520,10 +520,8 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
 				cairo_antialias_t antialias)
 {
     cairo_status_t status;
-    cairo_region_t trap_region;
-    cairo_region_t clear_region;
-    cairo_bool_t has_trap_region = FALSE;
-    cairo_bool_t has_clear_region = FALSE;
+    cairo_region_t *trap_region = NULL;
+    cairo_region_t *clear_region = NULL;
     cairo_rectangle_int_t extents;
     cairo_composite_traps_info_t traps_info;
 
@@ -535,23 +533,18 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
         return status;
 
     status = _cairo_traps_extract_region (traps, &trap_region);
-    if (CAIRO_INT_STATUS_UNSUPPORTED == status) {
-        has_trap_region = FALSE;
-    } else if (status) {
-        return status;
-    } else {
-        has_trap_region = TRUE;
-    }
+    if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
+	return status;
 
     if (_cairo_operator_bounded_by_mask (op)) {
         cairo_rectangle_int_t trap_extents;
 
-        if (has_trap_region) {
-            status = _cairo_clip_intersect_to_region (clip, &trap_region);
+        if (trap_region) {
+            status = _cairo_clip_intersect_to_region (clip, trap_region);
             if (unlikely (status))
                 goto out;
 
-            _cairo_region_get_extents (&trap_region, &trap_extents);
+            _cairo_region_get_extents (trap_region, &trap_extents);
         } else {
             cairo_box_t trap_box;
             _cairo_traps_extents (traps, &trap_box);
@@ -569,27 +562,30 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
     } else {
         cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
 
-        if (has_trap_region && !clip_surface) {
+        if (trap_region && !clip_surface) {
             /* If we optimize drawing with an unbounded operator to
              * _cairo_surface_fill_rectangles() or to drawing with a
              * clip region, then we have an additional region to clear.
              */
-            _cairo_region_init_rect (&clear_region, &extents);
+            clear_region = _cairo_region_create_rect (&extents);
+
+	    status = _cairo_region_status (clear_region);
+	    if (unlikely (status))
+		goto out;
 
-            has_clear_region = TRUE;
-            status = _cairo_clip_intersect_to_region (clip, &clear_region);
+            status = _cairo_clip_intersect_to_region (clip, clear_region);
             if (unlikely (status))
                 goto out;
 
-            _cairo_region_get_extents (&clear_region, &extents);
+            _cairo_region_get_extents (clear_region, &extents);
 
-            status = _cairo_region_subtract (&clear_region, &clear_region, &trap_region);
+            status = _cairo_region_subtract (clear_region, trap_region);
             if (unlikely (status))
                 goto out;
 
-            if (!_cairo_region_not_empty (&clear_region)) {
-                _cairo_region_fini (&clear_region);
-                has_clear_region = FALSE;
+            if (!_cairo_region_not_empty (clear_region)) {
+                _cairo_region_destroy (clear_region);
+		clear_region = NULL;
             }
         } else {
             status = _cairo_clip_intersect_to_rectangle (clip, &extents);
@@ -599,7 +595,7 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
     if (unlikely (status))
         goto out;
 
-    if (has_trap_region) {
+    if (trap_region) {
         cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
 
         if ((src->type == CAIRO_PATTERN_TYPE_SOLID ||
@@ -613,12 +609,13 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
             }
 
             /* Solid rectangles special case */
-            status = _cairo_surface_fill_region (dst, op, color, &trap_region);
+            status = _cairo_surface_fill_region (dst, op, color, trap_region);
 
-            if (!status && has_clear_region)
+            if (!status && clear_region) {
                 status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_CLEAR,
                                                      CAIRO_COLOR_TRANSPARENT,
-                                                     &clear_region);
+                                                     clear_region);
+	    }
 
             goto out;
         }
@@ -641,13 +638,13 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
              * regions. In that case, we fall through.
              */
             status = _composite_trap_region (clip, src, op, dst,
-                                             &trap_region, &extents);
+                                             trap_region, &extents);
 
             if (status != CAIRO_INT_STATUS_UNSUPPORTED) {
-                if (!status && has_clear_region)
+                if (!status && clear_region)
                     status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_CLEAR,
                                                          CAIRO_COLOR_TRANSPARENT,
-                                                         &clear_region);
+                                                         clear_region);
                 goto out;
             }
         }
@@ -661,10 +658,10 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
                                   &traps_info, dst, &extents);
 
 out:
-    if (has_trap_region)
-        _cairo_region_fini (&trap_region);
-    if (has_clear_region)
-        _cairo_region_fini (&clear_region);
+    if (trap_region)
+        _cairo_region_destroy (trap_region);
+    if (clear_region)
+        _cairo_region_destroy (clear_region);
 
     return status;
 }
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 456f851..22e67f7 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2201,10 +2201,10 @@ _cairo_surface_reset_clip (cairo_surface_t *surface)
 cairo_status_t
 _cairo_surface_set_clip_region (cairo_surface_t	    *surface,
 				cairo_region_t	    *region,
-				unsigned int	    serial)
+				unsigned int	     serial)
 {
     cairo_status_t status;
-
+    
     if (surface->status)
 	return surface->status;
 
@@ -2381,7 +2381,7 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip)
 
 	    if (surface->backend->set_clip_region != NULL)
 		return _cairo_surface_set_clip_region (surface,
-						       &clip->region,
+						       clip->region,
 						       clip->serial);
 	} else {
 	    if (clip->path)
@@ -2391,7 +2391,7 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip)
 
 	    if (clip->has_region)
 		return _cairo_surface_set_clip_region (surface,
-						       &clip->region,
+						       clip->region,
 						       clip->serial);
 	}
     }
@@ -2689,8 +2689,8 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
     cairo_rectangle_int_t dst_rectangle;
     cairo_rectangle_int_t drawn_rectangle;
     cairo_bool_t has_drawn_region = FALSE;
-    cairo_region_t drawn_region;
-    cairo_region_t clear_region;
+    cairo_region_t *drawn_region = NULL;
+    cairo_region_t *clear_region = NULL;
     cairo_status_t status;
 
     /* The area that was drawn is the area in the destination rectangle but not within
@@ -2700,7 +2700,8 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
     dst_rectangle.y = dst_y;
     dst_rectangle.width = width;
     dst_rectangle.height = height;
-    _cairo_region_init_rect (&clear_region, &dst_rectangle);
+
+    clear_region = _cairo_region_create_rect (&dst_rectangle);
 
     drawn_rectangle = dst_rectangle;
 
@@ -2716,24 +2717,22 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t         *dst,
 
     /* Now compute the area that is in dst_rectangle but not in drawn_rectangle
      */
-    _cairo_region_init_rect (&drawn_region, &drawn_rectangle);
+    drawn_region = _cairo_region_create_rect (&drawn_rectangle);
     has_drawn_region = TRUE;
 
-    status = _cairo_region_subtract (&clear_region,
-				     &clear_region,
-				     &drawn_region);
+    status = _cairo_region_subtract (clear_region, drawn_region);
     if (unlikely (status))
         goto CLEANUP_REGIONS;
 
   EMPTY:
     status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_SOURCE,
                                          CAIRO_COLOR_TRANSPARENT,
-                                         &clear_region);
+                                         clear_region);
 
   CLEANUP_REGIONS:
-    if (has_drawn_region)
-        _cairo_region_fini (&drawn_region);
-    _cairo_region_fini (&clear_region);
+    if (drawn_region)
+        _cairo_region_destroy (drawn_region);
+    _cairo_region_destroy (clear_region);
 
     return _cairo_surface_set_error (dst, status);
 }
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 0afdce2..3b6dedf 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -608,7 +608,7 @@ _cairo_traps_extents (const cairo_traps_t *traps,
  **/
 cairo_int_status_t
 _cairo_traps_extract_region (const cairo_traps_t  *traps,
-			     cairo_region_t       *region)
+			     cairo_region_t      **region)
 {
     cairo_box_int_t stack_boxes[CAIRO_STACK_ARRAY_LENGTH (cairo_box_int_t)];
     cairo_box_int_t *boxes = stack_boxes;
@@ -616,7 +616,7 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
     cairo_int_status_t status;
 
     if (traps->num_traps == 0) {
-	_cairo_region_init (region);
+	*region = _cairo_region_create ();
 	return CAIRO_STATUS_SUCCESS;
     }
 
@@ -661,13 +661,17 @@ _cairo_traps_extract_region (const cairo_traps_t  *traps,
 	box_count++;
     }
 
-    status = _cairo_region_init_boxes (region, boxes, box_count);
-
+    *region = _cairo_region_create_boxes (boxes, box_count);
+    status = _cairo_region_status (*region);
+    
     if (boxes != stack_boxes)
 	free (boxes);
 
     if (unlikely (status))
-	_cairo_region_fini (region);
+    {
+	_cairo_region_destroy (*region);
+	*region = NULL;
+    }
 
     return status;
 }
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index f86a133..e3a1417 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2293,7 +2293,7 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	XRectangle *rects = NULL;
 	int n_boxes, i;
 	cairo_rectangle_int_t rect;
-	cairo_region_t bounded;
+	cairo_region_t *bounded;
 
 	rect.x = rect.y = 0;
 	rect.width = surface->width;
@@ -2303,19 +2303,19 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	 * is necessary so we don't wrap around when we convert cairo's
 	 * 32 bit region into 16 bit rectangles.
 	 */
-	_cairo_region_init_rect (&bounded, &rect);
-	status = _cairo_region_intersect (&bounded, &bounded, region);
+	bounded = _cairo_region_create_rect (&rect);
+	status = _cairo_region_intersect (bounded, region);
 	if (unlikely (status)) {
-	    _cairo_region_fini (&bounded);
+	    _cairo_region_destroy (bounded);
 	    return status;
 	}
 
-	n_boxes = _cairo_region_num_boxes (&bounded);
+	n_boxes = _cairo_region_num_boxes (bounded);
 
 	if (n_boxes > ARRAY_LENGTH (surface->embedded_clip_rects)) {
 	    rects = _cairo_malloc_ab (n_boxes, sizeof (XRectangle));
 	    if (unlikely (rects == NULL)) {
-		_cairo_region_fini (&bounded);
+		_cairo_region_destroy (bounded);
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    }
 	} else {
@@ -2325,7 +2325,7 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	for (i = 0; i < n_boxes; i++) {
 	    cairo_box_int_t box;
 
-	    _cairo_region_get_box (&bounded, i, &box);
+	    _cairo_region_get_box (bounded, i, &box);
 
 	    rects[i].x = box.p1.x;
 	    rects[i].y = box.p1.y;
@@ -2333,7 +2333,7 @@ _cairo_xlib_surface_set_clip_region (void           *abstract_surface,
 	    rects[i].height = box.p2.y - rects[i].y;
 	}
 	
-	_cairo_region_fini (&bounded);
+	_cairo_region_destroy (bounded);
 
 	surface->have_clip_rects = TRUE;
 	surface->clip_rects = rects;
diff --git a/src/cairoint.h b/src/cairoint.h
index 66a9726..30273c2 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2408,7 +2408,7 @@ _cairo_traps_extents (const cairo_traps_t *traps,
 
 cairo_private cairo_int_status_t
 _cairo_traps_extract_region (const cairo_traps_t *tr,
-			     cairo_region_t      *region);
+			     cairo_region_t      **region);
 
 cairo_private cairo_status_t
 _cairo_traps_path (const cairo_traps_t *traps,


More information about the cairo-commit mailing list