misc: Only use custom lround() under DISABLE_SOME_FLOATING_POINT

On my Core2, the library version of lround() is faster than our
hand-rolled non-floating point implementation. So only enable our code
if we are trying to minimise the number of floating point operations --
even then, it would worth investigating the library performance first.

[Just a reminder that optimisation choices will change over time as our
hardware and software evolves.]
This commit is contained in:
Chris Wilson 2010-01-22 21:35:23 +00:00
parent 1236c41072
commit c0008242b0
3 changed files with 9 additions and 2 deletions

View file

@ -463,6 +463,7 @@ _cairo_operator_bounded_by_either (cairo_operator_t op)
}
#if DISABLE_SOME_FLOATING_POINT
/* This function is identical to the C99 function lround(), except that it
* performs arithmetic rounding (floor(d + .5) instead of away-from-zero rounding) and
* has a valid input range of (INT_MIN, INT_MAX] instead of
@ -673,6 +674,7 @@ _cairo_lround (double d)
#undef MSW
#undef LSW
}
#endif
/* Convert a 32-bit IEEE single precision floating point number to a
* 'half' representation (s10.5)

View file

@ -880,8 +880,8 @@ _cairo_ps_surface_get_page_media (cairo_ps_surface_t *surface)
page->name = strdup (page_name);
} else {
snprintf (buf, sizeof (buf), "%dx%dmm",
_cairo_lround (surface->width * 25.4/72),
_cairo_lround (surface->height * 25.4/72));
(int) _cairo_lround (surface->width * 25.4/72),
(int) _cairo_lround (surface->height * 25.4/72));
page->name = strdup (buf);
}

View file

@ -947,8 +947,13 @@ _cairo_round (double r)
return floor (r + .5);
}
#if DISABLE_SOME_FLOATING_POINT
cairo_private int
_cairo_lround (double d) cairo_const;
#else
#define _cairo_lround lround
#endif
cairo_private uint16_t
_cairo_half_from_float (float f) cairo_const;