diff options
author | Andrea Canciani <ranma42@gmail.com> | 2011-06-24 15:52:24 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2011-06-25 10:19:36 +0200 |
commit | a447e949799000760835beeafd2d45c76580fb9e (patch) | |
tree | 84e66cd64739576e97af5ae6d9a0a1cedb9ff56e /src/cairo-clip.c | |
parent | 1a4e9f1e9189e9dcb69afff009a10d6eb3bd2bd4 (diff) | |
download | cairo-a447e949799000760835beeafd2d45c76580fb9e.tar.gz |
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>
Diffstat (limited to 'src/cairo-clip.c')
-rw-r--r-- | src/cairo-clip.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c index b03e27c9d..9527c599c 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); |