From ae2be7e25bda46551381c19a673b321b4382e1f9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 24 May 2012 16:33:27 +0100 Subject: [PATCH] sna/trapezoids: Correct rounding for downsampling onto sample grid Reported-by: S. Christian Collins Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49446 Signed-off-by: Chris Wilson --- src/sna/sna_trapezoids.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index c0565fa1..e604720d 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -3150,7 +3150,7 @@ composite_unaligned_boxes(struct sna *sna, static inline int pixman_fixed_to_grid (pixman_fixed_t v) { - return (v + FAST_SAMPLES_mask/2) >> (16 - FAST_SAMPLES_shift); + return (v + ((1<<(16-FAST_SAMPLES_shift))-1)/2) >> (16 - FAST_SAMPLES_shift); } static inline bool @@ -3158,6 +3158,12 @@ project_trapezoid_onto_grid(const xTrapezoid *in, int dx, int dy, xTrapezoid *out) { + __DBG(("%s: in: L:(%d, %d), (%d, %d); R:(%d, %d), (%d, %d), [%d, %d]\n", + __FUNCTION__, + in->left.p1.x, in->left.p1.y, in->left.p2.x, in->left.p2.y, + in->right.p1.x, in->right.p1.y, in->right.p2.x, in->right.p2.y, + in->top, in->bottom)); + out->left.p1.x = dx + pixman_fixed_to_grid(in->left.p1.x); out->left.p1.y = dy + pixman_fixed_to_grid(in->left.p1.y); out->left.p2.x = dx + pixman_fixed_to_grid(in->left.p2.x); @@ -3171,6 +3177,12 @@ project_trapezoid_onto_grid(const xTrapezoid *in, out->top = dy + pixman_fixed_to_grid(in->top); out->bottom = dy + pixman_fixed_to_grid(in->bottom); + __DBG(("%s: out: L:(%d, %d), (%d, %d); R:(%d, %d), (%d, %d), [%d, %d]\n", + __FUNCTION__, + out->left.p1.x, out->left.p1.y, out->left.p2.x, out->left.p2.y, + out->right.p1.x, out->right.p1.y, out->right.p2.x, out->right.p2.y, + out->top, out->bottom)); + return xTrapezoidValid(out); }