diff options
author | Eric Anholt <anholt@freebsd.org> | 2006-02-15 19:59:57 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2006-02-15 19:59:57 +0000 |
commit | df19d88454781546f0d27729160a9dbdc4678189 (patch) | |
tree | 66da181b776d91219d2ab99c7b26975fae197ec8 | |
parent | a4ff4019020e6334248a5083ea5ddcef84752a49 (diff) |
Merge from HEAD: Correct rounding in divide-by-255 code.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | render/picture.c | 8 |
2 files changed, 10 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2006-02-15 Eric Anholt <anholt@FreeBSD.org> + + * render/picture.c: (premultiply): + Merge from HEAD: + Correct rounding in divide-by-255 code. + 2006-02-14 Adam Jackson <ajax@freedesktop.org> * include/xorg-config.h.in: diff --git a/render/picture.c b/render/picture.c index 3ed60310e..522eb4fa9 100644 --- a/render/picture.c +++ b/render/picture.c @@ -860,12 +860,12 @@ static CARD32 xRenderColorToCard32(xRenderColor c) static unsigned int premultiply(unsigned int x) { unsigned int a = x >> 24; - unsigned int t = (x & 0xff00ff) * a; - t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + unsigned int t = (x & 0xff00ff) * a + 0x800080; + t = (t + ((t >> 8) & 0xff00ff)) >> 8; t &= 0xff00ff; - x = ((x >> 8) & 0xff) * a; - x = (x + ((x >> 8) & 0xff) + 0x80); + x = ((x >> 8) & 0xff) * a + 0x80; + x = (x + ((x >> 8) & 0xff)); x &= 0xff00; x |= t | (a << 24); return x; |