From 3306bcb1d91265d60c460aa64d3ee4a4acb430a1 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 17 Jun 2010 08:47:48 +0100 Subject: [PATCH] fixed: Refactor code to use more inlines and less duplication of logic. This also has the side-effect of fixing the types in the problematic functions which hid Andrea's true fix for the unsigned FRAC_MASK. --- src/cairo-fixed-private.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cairo-fixed-private.h b/src/cairo-fixed-private.h index 8873056cf..6cecc8dc5 100644 --- a/src/cairo-fixed-private.h +++ b/src/cairo-fixed-private.h @@ -157,12 +157,24 @@ _cairo_fixed_is_integer (cairo_fixed_t f) return (f & CAIRO_FIXED_FRAC_MASK) == 0; } -static inline int +static inline cairo_fixed_t _cairo_fixed_floor (cairo_fixed_t f) { return f & ~CAIRO_FIXED_FRAC_MASK; } +static inline cairo_fixed_t +_cairo_fixed_round (cairo_fixed_t f) +{ + return _cairo_fixed_floor (f + (CAIRO_FIXED_FRAC_MASK+1)/2); +} + +static inline cairo_fixed_t +_cairo_fixed_round_down (cairo_fixed_t f) +{ + return _cairo_fixed_floor (f + CAIRO_FIXED_FRAC_MASK/2); +} + static inline int _cairo_fixed_integer_part (cairo_fixed_t f) { @@ -172,13 +184,13 @@ _cairo_fixed_integer_part (cairo_fixed_t f) static inline int _cairo_fixed_integer_round (cairo_fixed_t f) { - return (f + (CAIRO_FIXED_FRAC_MASK+1)/2) >> CAIRO_FIXED_FRAC_BITS; + return _cairo_fixed_integer_part (f + (CAIRO_FIXED_FRAC_MASK+1)/2); } static inline int _cairo_fixed_integer_round_down (cairo_fixed_t f) { - return (f + CAIRO_FIXED_FRAC_MASK/2) >> CAIRO_FIXED_FRAC_BITS; + return _cairo_fixed_integer_part (f + CAIRO_FIXED_FRAC_MASK/2); } static inline int