Merge from HEAD: Correct rounding in divide-by-255 code.

This commit is contained in:
Eric Anholt 2006-02-15 19:59:57 +00:00
parent a4ff401902
commit df19d88454
2 changed files with 10 additions and 4 deletions

View file

@ -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:

View file

@ -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;