From 0a4a008e0eb6f9ba8c6a6191ef0140a4467cdb6f Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Fri, 24 Jun 2011 15:52:24 +0200 Subject: [PATCH] clip: Fix boxes extents computation in intersect_with_boxes The extents of the boxes were not being computed by taking into account just the first box instead of all of them. --- src/cairo-clip.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cairo-clip.c b/src/cairo-clip.c index b03e27c..ce5225d 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -1399,19 +1399,20 @@ intersect_with_boxes (cairo_composite_rectangles_t *extents, cairo_rectangle_int_t rect; cairo_box_t box; + 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); -- 1.7.1