From: Pekka Paalanen Date: Wed, 8 Feb 2012 13:38:37 +0000 (+0200) Subject: compositor: use floats in computing bounding box X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=219b982ed076d3f0bb9a6199509fb260b8fe8b26;p=profile%2Fivi%2Fweston-ivi-shell.git compositor: use floats in computing bounding box In surface_compute_bbox(), call surface_to_global_float() instead of weston_surface_to_global(). This avoids the recursion: weston_surface_update_transform() weston_surface_update_transform_enable() surface_compute_bbox() weston_surface_to_global() weston_surface_update_transform() which might be non-obvious when reading the code. Computing the min and max coordinates in floats, we can have a tight rounding margin by using floor() and ceil(). Signed-off-by: Pekka Paalanen --- diff --git a/src/compositor.c b/src/compositor.c index f631e23..0c62fb0 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -277,18 +277,20 @@ surface_compute_bbox(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height, pixman_region32_t *bbox) { - int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; + GLfloat min_x = HUGE_VALF, min_y = HUGE_VALF; + GLfloat max_x = -HUGE_VALF, max_y = -HUGE_VALF; int32_t s[4][2] = { { sx, sy }, { sx, sy + height }, { sx + width, sy }, { sx + width, sy + height } }; + GLfloat int_x, int_y; int i; for (i = 0; i < 4; ++i) { - int32_t x, y; - weston_surface_to_global(surface, s[i][0], s[i][1], &x, &y); + GLfloat x, y; + surface_to_global_float(surface, s[i][0], s[i][1], &x, &y); if (x < min_x) min_x = x; if (x > max_x) @@ -299,11 +301,10 @@ surface_compute_bbox(struct weston_surface *surface, int32_t sx, int32_t sy, max_y = y; } - /* weston_surface_to_global rounds with floor(), add the - * minimum required safety margin. - */ - pixman_region32_init_rect(bbox, min_x, min_y, - max_x - min_x + 1, max_y - min_y + 1); + int_x = floorf(min_x); + int_y = floorf(min_y); + pixman_region32_init_rect(bbox, int_x, int_y, + ceilf(max_x) - int_x, ceilf(max_y) - int_y); } static void