summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2011-12-20 06:32:26 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-01-09 05:40:34 -0500
commit37572455866114cbb8bb1bf3acfb1c61d200f98c (patch)
tree145ba26bae451e0b124249557b5808f06ba5e7b2
parent2437ae80e5066dec9fe52f56b016bf136d7cea06 (diff)
Fix rounding for DIV_UNc()
We need to compute floor (a/b * 255 + 0.5), not floor (a / b * 255), so add b/2 to the numerator in the DIV_UNc() macro.
-rw-r--r--pixman/pixman-combine.h.template2
-rw-r--r--test/blitters-test.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/pixman/pixman-combine.h.template b/pixman/pixman-combine.h.template
index 53afcd2..20f784b 100644
--- a/pixman/pixman-combine.h.template
+++ b/pixman/pixman-combine.h.template
@@ -28,7 +28,7 @@
((t) = (a) * (comp2_t)(b) + ONE_HALF, ((((t) >> G_SHIFT ) + (t) ) >> G_SHIFT ))
#define DIV_UNc(a, b) \
- (((comp2_t) (a) * MASK) / (b))
+ (((comp2_t) (a) * MASK + ((b) / 2)) / (b))
#define ADD_UNc(x, y, t) \
((t) = (x) + (y), \
diff --git a/test/blitters-test.c b/test/blitters-test.c
index fd62c67..feea308 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -424,6 +424,6 @@ main (int argc, const char *argv[])
}
return fuzzer_test_main("blitters", 2000000,
- 0x3EDA4108,
+ 0xA364B5BF,
test_composite, argc, argv);
}