summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-05-24 16:33:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-05-24 16:33:27 +0100
commitae2be7e25bda46551381c19a673b321b4382e1f9 (patch)
tree601c795cf6f6503d57bfd7d6fbb091cb5cc67b5f
parent0ab226e27e7920bdb9f7eb62c5174cd097ac7f7f (diff)
sna/trapezoids: Correct rounding for downsampling onto sample grid
Reported-by: S. Christian Collins <s_chriscollins@hotmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49446 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_trapezoids.c14
1 files changed, 13 insertions, 1 deletions
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);
}