From 614117e487f36c66f2a479c96e1cb4daef625608 Mon Sep 17 00:00:00 2001 From: M Joonas Pihlaja Date: Tue, 5 Dec 2006 21:31:23 +0200 Subject: [PATCH] tessellator bug fix: fill-degenerate-sort-order Fixes the regression fill-degenerate-sort-order, where confusion arises in the event order for collinear edges. Also fixes (or at least hides) the issues with zrusin-another sometimes generating different trapezoids depending on the state of the random number generator in cairo-skiplist.c. --- src/cairo-bentley-ottmann.c | 40 +++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c index 2c0f98c4d..284e247da 100644 --- a/src/cairo-bentley-ottmann.c +++ b/src/cairo-bentley-ottmann.c @@ -393,15 +393,20 @@ cairo_bo_event_compare (cairo_bo_event_t const *a, return - cmp; } - /* As a final discrimination, look at the opposite point. This - * leaves ambiguities only for identical edges. - */ - if (a->type == CAIRO_BO_EVENT_TYPE_START) - return _cairo_bo_point32_compare (&b->e1->bottom, - &a->e1->bottom); - else if (a->type == CAIRO_BO_EVENT_TYPE_STOP) - return _cairo_bo_point32_compare (&a->e1->top, - &b->e1->top); + /* Next look at the opposite point. This leaves ambiguities only + * for identical edges. */ + if (a->type == CAIRO_BO_EVENT_TYPE_START) { + cmp = _cairo_bo_point32_compare (&b->e1->bottom, + &a->e1->bottom); + if (cmp) + return cmp; + } + else if (a->type == CAIRO_BO_EVENT_TYPE_STOP) { + cmp = _cairo_bo_point32_compare (&a->e1->top, + &b->e1->top); + if (cmp) + return cmp; + } else { /* CAIRO_BO_EVENT_TYPE_INTERSECT */ /* For two intersection events at the identical point, we * don't care what order they sort in, but we do care that we @@ -416,8 +421,21 @@ cairo_bo_event_compare (cairo_bo_event_t const *a, cmp = _cairo_bo_point32_compare (&a->e1->top, &b->e1->top); if (cmp) return cmp; - return _cairo_bo_point32_compare (&a->e1->bottom, &b->e1->bottom); - } + cmp = _cairo_bo_point32_compare (&a->e1->bottom, &b->e1->bottom); + if (cmp) + return cmp; + } + + /* Discrimination based on the edge pointers. */ + if (a->e1 < b->e1) + return -1; + if (a->e1 > b->e1) + return +1; + if (a->e2 < b->e2) + return -1; + if (a->e2 > b->e2) + return +1; + return 0; } static inline int