[cairo] rewriting libpixman
David Turner
david at freetype.org
Thu Mar 29 23:49:32 PDT 2007
Hello Guys,
On Thu, 29 Mar 2007 13:33:42 -0400, "Jeff Muizelaar" <jeff at infidigm.net> said:
> >
> > The bit-copying "approximation" is exactly equivalent to multiplying by 255 and dividing by 31. There's no point in implementing both -- stick with the bit copy, since it's more efficient.
>
> (x << 3) | (x >> 2) is not equivalent to (255*x + 15)/31 for x = {3, 7,
> 24, 28}
>
May I remind everyone that what we call "alpha" is a mere *approximation*, and that maybe this kind of
numerical accuracy isn't so important as it may seem ?
another common example is the "fast" implementation of y = x*alpha/255.0
Cairo uses (t = x*alpha+128, y = (t + (t >> 8)) >> 8)
while many other graphics libraries do something like:
alpha2 = alpha + (alpha >> 7) // convert from 0..255 to 0..256 range
y = x*alpha2 >> 8
which turns out to be noticeably faster, especially when you're performing several multiplications
with the same alpha in parallel. And I'm pretty certain that this doesn't amount to any perceptual
difference in an 8-bit/channel world, unless you do a ton of alpha composition work on the same
pixels (in which case things are likely to break *anyway* due to accumulated rounding errors)
Frankly, I'd like to see alternative implementations of the "libpixman2" to compare their
performance; that could be very interesting.
Just my €.02
- David
- David Turner
> -Jeff
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
More information about the cairo
mailing list