[PATCH libXrender] Fix alpha premultiplication in XRenderParseColor.

Emanuele Giaquinta emanuele.giaquinta at gmail.com
Tue Jan 3 05:42:34 PST 2012


On Tue, Jan 03, 2012 at 08:21:32AM -0500, Jeremy Huddleston wrote:
> I believe just the division is unsigned with those changes.  The multiplication will still be signed.

No, the type of XRenderColor fields is unsigned short.

> 
> On Jan 2, 2012, at 2:58 PM, Emanuele Giaquinta wrote:
> 
> > Due to C arithmetic conversion rules we must use an unsigned constant (or a
> > cast) to perform the multiplication using unsigned arithmetic.
> > ---
> > src/Color.c |    6 +++---
> > 1 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/Color.c b/src/Color.c
> > index 9c76e58..23ef800 100644
> > --- a/src/Color.c
> > +++ b/src/Color.c
> > @@ -85,8 +85,8 @@ XRenderParseColor(Display *dpy, char *spec, XRenderColor *def)
> > 	def->blue = coreColor.blue;
> > 	def->alpha = 0xffff;
> >     }
> > -    def->red = (def->red * def->alpha) / 65535;
> > -    def->green = (def->green * def->alpha) / 65535;
> > -    def->blue = (def->blue * def->alpha) / 65535;
> > +    def->red = (def->red * def->alpha) / 0xffffU;
> > +    def->green = (def->green * def->alpha) / 0xffffU;
> > +    def->blue = (def->blue * def->alpha) / 0xffffU;
> >     return 1;
> > }
> > -- 
> > 1.7.7.3
> > _______________________________________________
> > xorg-devel at lists.x.org: X.Org development
> > Archives: http://lists.x.org/archives/xorg-devel
> > Info: http://lists.x.org/mailman/listinfo/xorg-devel
> > 
> 


More information about the xorg-devel mailing list