diff options
author | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2009-02-16 05:41:31 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2009-03-28 18:01:19 -0400 |
commit | ebd0e685ae2d76c3af96d748a33a7194c70749f3 (patch) | |
tree | 13f7d867f10785815bbbe4f95d3c2e1098041a63 /src | |
parent | c29aeee2d3569cd43e88adc05662bb6306987b8b (diff) |
[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
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-clip.c | 22 | ||||
-rw-r--r-- | src/cairo-directfb-surface.c | 26 | ||||
-rw-r--r-- | src/cairo-paginated-surface.c | 34 | ||||
-rw-r--r-- | src/cairo-region-private.h | 14 | ||||
-rw-r--r-- | src/cairo-region.c | 28 | ||||
-rw-r--r-- | src/cairo-surface-fallback.c | 2 | ||||
-rw-r--r-- | src/cairo-surface.c | 25 | ||||
-rw-r--r-- | src/cairo-traps.c | 31 | ||||
-rw-r--r-- | src/cairo-types-private.h | 6 | ||||
-rw-r--r-- | src/cairo-win32-surface.c | 48 | ||||
-rw-r--r-- | src/cairo-xcb-surface.c | 24 | ||||
-rw-r--r-- | src/cairo-xlib-surface.c | 29 |
12 files changed, 134 insertions, 155 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c index 649fa7aa..4ca3e9aa 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 b902cca1..3873f3e9 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 8c62644a..cc09b59c 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 8852af37..5a93ebd2 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 1d5de7ce..5f53bc92 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 (®ion->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 (®ion->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 d41c645a..876268f5 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 635575ac..42fc6da8 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 3b6dedf7..96db4ba1 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 0a3ec2e4..e8cf4b1f 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 f0c7aa2c..f182642f 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 17a09e3f..ab589e1d 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 e3a1417a..e411977b 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 && |