Commit 32487af5 authored by Robert Bragg's avatar Robert Bragg

Adds a CLUTTER_NEARBYINT macro for float rounding

This is a replacement for the nearbyint function which always rounds to
the nearest integer. nearbyint is a C99 function so it might not always
be available but also it seems in glibc it is defined as a function call
so this macro could end up faster anyway. We can't just add 0.5 because
it will break for negative numbers.
Signed-off-by: 's avatarNeil Roberts <neil@linux.intel.com>
Signed-off-by: 's avatarEmmanuele Bassi <ebassi@linux.intel.com>
parent ad234b30
......@@ -84,6 +84,13 @@ typedef struct _ClutterMainContext ClutterMainContext;
#define P_(String) (String)
#endif
/* This is a replacement for the nearbyint function which always rounds to the
* nearest integer. nearbyint is apparently a C99 function so it might not
* always be available but also it seems in glibc it is defined as a function
* call so this macro could end up faster anyway. We can't just add 0.5f
* because it will break for negative numbers. */
#define CLUTTER_NEARBYINT(x) ((int) ((x) < 0.0f ? (x) - 0.5f : (x) + 0.5f))
typedef enum {
CLUTTER_ACTOR_UNUSED_FLAG = 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment