tessellator: Fix boxes tessellator to handle num_boxes <= 1 correctly

We cannot assume that parameter 'out' is empty. So we should make it
empty before returning CAIRO_STATUS_SUCCESS when 'in' contains no boxes.

When 'in' contains a single box, we should copy 'in' to 'out' rather
than just returning CAIRO_STATUS_SUCCESS.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Taekyun Kim 2011-06-08 13:05:54 +09:00 committed by Chris Wilson
parent 27d26bb8b5
commit 6edc5ca55f

View file

@ -731,8 +731,18 @@ _cairo_bentley_ottmann_tessellate_boxes (const cairo_boxes_t *in,
cairo_status_t status;
int i, j;
if (unlikely (in->num_boxes <= 1))
if (unlikely (in->num_boxes == 0)) {
_cairo_boxes_clear (out);
return CAIRO_STATUS_SUCCESS;
}
if (unlikely (in->num_boxes == 1)) {
cairo_box_t box = in->chunks.base[0];
_cairo_boxes_clear (out);
status = _cairo_boxes_add (out, &box);
assert (status == CAIRO_STATUS_SUCCESS);
return CAIRO_STATUS_SUCCESS;
}
rectangles = stack_rectangles;
rectangles_ptrs = stack_rectangles_ptrs;