diff options
author | Eric Anholt <anholt@freebsd.org> | 2006-01-04 00:05:16 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2006-01-04 00:05:16 +0000 |
commit | b6b88d2f62d8c596171f487dd25fbdbc85d0c5a8 (patch) | |
tree | 84b50817d12964da66e166c5eba3e45f94cf3913 /render | |
parent | b9c0ae867e1b52186c26841a77745f7f5a0a76dd (diff) |
Correct rounding in divide-by-255 code. Obtained from xserver.
Diffstat (limited to 'render')
-rw-r--r-- | render/picture.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/render/picture.c b/render/picture.c index 3ce191345..70b049b0b 100644 --- a/render/picture.c +++ b/render/picture.c @@ -863,12 +863,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; |