Skip to content

Commit

Permalink
correct rounding computation
Browse files Browse the repository at this point in the history
cairo_fixed_integer_round[_down] were adding an unsigned mask value
before shifting its result, causing the shift to be computed as
logical (unsigned) right shift, thus producing incorrect values for
negative inputs. Making the mask value signed fixes this issue.

Bug report by cu:
http://lists.cairographics.org/archives/cairo/2010-June/020115.html
  • Loading branch information
Andrea Canciani committed Jun 16, 2010
1 parent 8689d75 commit 3cd0755
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cairo-fixed-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#define CAIRO_FIXED_ONE_DOUBLE ((double)(1 << CAIRO_FIXED_FRAC_BITS))
#define CAIRO_FIXED_EPSILON ((cairo_fixed_t)(1))

#define CAIRO_FIXED_FRAC_MASK (((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS))
#define CAIRO_FIXED_FRAC_MASK ((cairo_fixed_t)(((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS)))
#define CAIRO_FIXED_WHOLE_MASK (~CAIRO_FIXED_FRAC_MASK)

static inline cairo_fixed_t
Expand Down

0 comments on commit 3cd0755

Please sign in to comment.