diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-17 08:47:48 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-17 08:55:19 +0100 |
commit | 3306bcb1d91265d60c460aa64d3ee4a4acb430a1 (patch) | |
tree | 28b05967a35e4ef39bb579d8a054bd6e131bae09 /src | |
parent | c0dee7964c4394b7963041f246855fd3b01f4ebb (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-fixed-private.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/cairo-fixed-private.h b/src/cairo-fixed-private.h index 8873056c..6cecc8dc 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 |