Skip to content

Commit

Permalink
fixed: Refactor code to use more inlines and less duplication of logic.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Chris Wilson committed Jun 17, 2010
1 parent c0dee79 commit 3306bcb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/cairo-fixed-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down

0 comments on commit 3306bcb

Please sign in to comment.