summaryrefslogtreecommitdiff
path: root/src/cairo-hull.c
diff options
context:
space:
mode:
authorBertram Felgenhauer <int-e@gmx.de>2005-09-29 17:26:20 +0000
committerBertram Felgenhauer <int-e@gmx.de>2005-09-29 17:26:20 +0000
commitfa2d0ab5b7744fa929e77ee61e93476c425777e3 (patch)
treec5712983d4a58019baa317d47e1976afeb9bbb9a /src/cairo-hull.c
parentd3e7dad53eb25aff2608af08057bb86d864de145 (diff)
downloadcairo-fa2d0ab5b7744fa929e77ee61e93476c425777e3.tar.gz
Using a pointer comparison as the fallback total order was wrong - these pointers are not stable. So we introduce our own total order instead.
mark 4599 as fixed reviewed by: cworth
Diffstat (limited to 'src/cairo-hull.c')
-rw-r--r--src/cairo-hull.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/cairo-hull.c b/src/cairo-hull.c
index 34e0588af..ca5465b75 100644
--- a/src/cairo-hull.c
+++ b/src/cairo-hull.c
@@ -41,6 +41,7 @@ typedef struct cairo_hull
cairo_point_t point;
cairo_slope_t slope;
int discard;
+ int id;
} cairo_hull_t;
static cairo_hull_t *
@@ -70,10 +71,13 @@ _cairo_hull_create (cairo_pen_vertex_t *vertices, int num_vertices)
_cairo_slope_init (&hull[i].slope, &hull[0].point, &hull[i].point);
/* Discard all points coincident with the extremal point */
- if (i != 0 && hull[i].slope.dx == 0 && hull[i].slope.dy == 0)
+ if (i != 0 && hull[i].slope.dx == 0 && hull[i].slope.dy == 0) {
hull[i].discard = 1;
- else
+ hull[i].id = -i;
+ } else {
hull[i].discard = 0;
+ hull[i].id = i;
+ }
}
return hull;
@@ -98,11 +102,11 @@ _cairo_hull_vertex_compare (const void *av, const void *bv)
b_dist = ((cairo_fixed_48_16_t) b->slope.dx * b->slope.dx +
(cairo_fixed_48_16_t) b->slope.dy * b->slope.dy);
/*
- * Use pointer comparison for coincident points to ensure
+ * Use the point's ids to ensure a total ordering.
* a well-defined ordering, and avoid setting discard on
- * both points.
+ * both points.
*/
- if (a_dist < b_dist || (a_dist == b_dist && a < b)) {
+ if (a_dist < b_dist || (a_dist == b_dist && a->id < b->id)) {
a->discard = 1;
ret = -1;
} else {