summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2011-06-24 15:52:24 +0200
committerAndrea Canciani <ranma42@gmail.com>2011-06-25 10:19:36 +0200
commita447e949799000760835beeafd2d45c76580fb9e (patch)
tree84e66cd64739576e97af5ae6d9a0a1cedb9ff56e
parent1a4e9f1e9189e9dcb69afff009a10d6eb3bd2bd4 (diff)
clip: Fix boxes extents computation in intersect_with_boxes
The extents of the boxes were being computed by taking into account just the first box instead of all of them. Based on a patch by James Cloos. Fixes clip-disjoint, clip-stroke-unbounded, clip-fill-nz-unbounded, clip-fill-eo-unbounded, clip-fill, clip-stroke, trap-clip. See https://bugs.freedesktop.org/show_bug.cgi?id=38641 Reviewed-by: James Cloos <cloos@jhcloos.com> Tested-by: James Cloos <cloos@jhcloos.com>
-rw-r--r--src/cairo-clip.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index b03e27c9..9527c599 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -1398,20 +1398,22 @@ intersect_with_boxes (cairo_composite_rectangles_t *extents,
{
cairo_rectangle_int_t rect;
cairo_box_t box;
+ int i;
+
+ assert (num_boxes > 0);
/* Find the extents over all the clip boxes */
- box.p1.x = box.p1.y = INT_MAX;
- box.p2.x = box.p2.y = INT_MIN;
- while (num_boxes--) {
- if (boxes->p1.x < box.p1.x)
- box.p1.x = boxes->p1.x;
- if (boxes->p1.y < box.p1.y)
- box.p1.y = boxes->p1.y;
-
- if (boxes->p2.x > box.p2.x)
- box.p2.x = boxes->p2.x;
- if (boxes->p2.y > box.p2.y)
- box.p2.y = boxes->p2.y;
+ box = boxes[0];
+ for (i = 1; i < num_boxes; i++) {
+ if (boxes[i].p1.x < box.p1.x)
+ box.p1.x = boxes[i].p1.x;
+ if (boxes[i].p1.y < box.p1.y)
+ box.p1.y = boxes[i].p1.y;
+
+ if (boxes[i].p2.x > box.p2.x)
+ box.p2.x = boxes[i].p2.x;
+ if (boxes[i].p2.y > box.p2.y)
+ box.p2.y = boxes[i].p2.y;
}
_cairo_box_round_to_rectangle (&box, &rect);