[cairo-commit] 2 commits - src/cairo-font-face-twin.c src/cairoint.h

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Tue Feb 10 14:57:47 PST 2009


 src/cairo-font-face-twin.c |    6 ++----
 src/cairoint.h             |    9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit b9f0c4b25223830ce73f7e3adef85a0e97a31c0e
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Tue Feb 10 17:57:00 2009 -0500

    Use _cairo_round() instead of round()
    
    MSVC doesn't have round() and the code probably wants
    to round in the same direction regardless of whether
    the values are negative or positive.

diff --git a/src/cairo-font-face-twin.c b/src/cairo-font-face-twin.c
index b834322..3ced9b0 100644
--- a/src/cairo-font-face-twin.c
+++ b/src/cairo-font-face-twin.c
@@ -34,8 +34,6 @@
  *      Behdad Esfahbod <behdad at behdad.org>
  */
 
-#define _ISOC99_SOURCE /* for round() */
-
 #include "cairoint.h"
 
 #include <math.h>
@@ -255,8 +253,8 @@ compute_hinting_scales (cairo_t *cr,
     compute_hinting_scale (cr, x, y, y_scale, y_scale_inv);
 }
 
-#define SNAPXI(p)	(round ((p) * x_scale) * x_scale_inv)
-#define SNAPYI(p)	(round ((p) * y_scale) * y_scale_inv)
+#define SNAPXI(p)	(_cairo_round ((p) * x_scale) * x_scale_inv)
+#define SNAPYI(p)	(_cairo_round ((p) * y_scale) * y_scale_inv)
 
 /* This controls the global font size */
 #define F(g)		((g) / 72.)
commit dffdbd85157395bceb27d30d6426aa47173f6a18
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Tue Feb 10 17:53:39 2009 -0500

    Add _cairo_round()
    
    _cairo_round() has the same behaviour as _cairo_lround() except
    it returns a double instead of an integer.

diff --git a/src/cairoint.h b/src/cairoint.h
index 8115c81..99185b6 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1024,6 +1024,15 @@ typedef struct _cairo_stroke_face {
 cairo_private void
 _cairo_restrict_value (double *value, double min, double max);
 
+/* C99 round() rounds to the nearest integral value with halfway cases rounded
+ * away from 0. _cairo_round rounds halfway cases toward negative infinity.
+ * This matches the rounding behaviour of _cairo_lround. */
+static inline double
+_cairo_round (double r)
+{
+    return floor (r + .5);
+}
+
 cairo_private int
 _cairo_lround (double d);
 


More information about the cairo-commit mailing list