diff --git a/ChangeLog b/ChangeLog index fb6eac337..7cea906f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-03 Eric Anholt + + * render/picture.c: (premultiply): + Correct rounding in divide-by-255 code. Obtained from xserver. + 2006-01-03 Eric Anholt * hw/xgl/xglpict.c: (xglPictureInit): 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;