diff --git a/clutter/cogl/cogl/cogl-clip-stack.c b/clutter/cogl/cogl/cogl-clip-stack.c index 3f64047a0..8e849c723 100644 --- a/clutter/cogl/cogl/cogl-clip-stack.c +++ b/clutter/cogl/cogl/cogl-clip-stack.c @@ -37,6 +37,7 @@ #include "cogl-internal.h" #include "cogl-framebuffer-private.h" #include "cogl-journal-private.h" +#include "cogl-util.h" void _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, floatVec2 nodes_max, @@ -483,7 +484,10 @@ try_pushing_rect_as_window_rect (float x_1, SWAP (y_1, y_2); #undef SWAP - cogl_clip_push_window_rectangle (x_1, y_1, x_2 - x_1, y_2 - y_1); + cogl_clip_push_window_rectangle (COGL_UTIL_NEARBYINT (x_1), + COGL_UTIL_NEARBYINT (y_1), + COGL_UTIL_NEARBYINT (x_2 - x_1), + COGL_UTIL_NEARBYINT (y_2 - y_1)); return TRUE; } diff --git a/clutter/cogl/cogl/cogl-util.h b/clutter/cogl/cogl/cogl-util.h index a6602a5f5..0e0e095d9 100644 --- a/clutter/cogl/cogl/cogl-util.h +++ b/clutter/cogl/cogl/cogl-util.h @@ -52,4 +52,12 @@ cogl_util_float_signbit (float x) } #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 COGL_UTIL_NEARBYINT(x) ((int) ((x) < 0.0f ? (x) - 0.5f : (x) + 0.5f)) + #endif /* __COGL_UTIL_H */