diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-06 16:15:29 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-07 01:45:45 +0100 |
commit | 1440399625ae0579d0748475fc924cfe74339a21 (patch) | |
tree | 57327ac842fc6767f15868443e436d08610c3cdc /src/cairo-hull.c | |
parent | c6a6bf580fa7036e4c28137f8c038beb5c347244 (diff) |
[hull] Replace open-coding of 64bit arithmetic.
Use primitives from cairo-wideint-private.h - in this case it helps to
make the code more readable as well as reduce dependence on native 64bit
integers.
Diffstat (limited to 'src/cairo-hull.c')
-rw-r--r-- | src/cairo-hull.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/cairo-hull.c b/src/cairo-hull.c index 77ee7908a..008ba7fda 100644 --- a/src/cairo-hull.c +++ b/src/cairo-hull.c @@ -78,6 +78,13 @@ _cairo_hull_init (cairo_hull_t *hull, } } +static inline cairo_int64_t +_slope_length (cairo_slope_t *slope) +{ + return _cairo_int64_add (_cairo_int32x32_64_mul (slope->dx, slope->dx), + _cairo_int32x32_64_mul (slope->dy, slope->dy)); +} + static int _cairo_hull_vertex_compare (const void *av, const void *bv) { @@ -87,21 +94,21 @@ _cairo_hull_vertex_compare (const void *av, const void *bv) ret = _cairo_slope_compare (&a->slope, &b->slope); - /* In the case of two vertices with identical slope from the - extremal point discard the nearer point. */ - + /* + * In the case of two vertices with identical slope from the + * extremal point discard the nearer point. + */ if (ret == 0) { - cairo_fixed_48_16_t a_dist, b_dist; - a_dist = ((cairo_fixed_48_16_t) a->slope.dx * a->slope.dx + - (cairo_fixed_48_16_t) a->slope.dy * a->slope.dy); - b_dist = ((cairo_fixed_48_16_t) b->slope.dx * b->slope.dx + - (cairo_fixed_48_16_t) b->slope.dy * b->slope.dy); + int cmp; + + cmp = _cairo_int64_cmp (_slope_length (&a->slope), + _slope_length (&b->slope)); + /* - * Use the point's ids to ensure a total ordering. - * a well-defined ordering, and avoid setting discard on - * both points. + * Use the points' ids to ensure a well-defined ordering, + * and avoid setting discard on both points. */ - if (a_dist < b_dist || (a_dist == b_dist && a->id < b->id)) { + if (cmp < 0 || (cmp == 0 && a->id < b->id)) { a->discard = 1; ret = -1; } else { |