pixman/pixman-combine32.c: Bug fixes for separable blend modes
authorSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 19 Jan 2013 03:25:36 +0000 (22:25 -0500)
committerSøren Sandmann <ssp@redhat.com>
Sat, 4 Jan 2014 21:13:27 +0000 (16:13 -0500)
commite7a99b3b0f605d3f9937bc79e4385c6b71df7845
tree8851094dfde73aaf7bc46771223efaf41cb182db
parentfe3504d03fafbd8462a34fbe6150254eeb1d0bcd
pixman/pixman-combine32.c: Bug fixes for separable blend modes

This commit fixes four separate bugs:

1. In the computation

      (1 - sa) * d + (1 - da) * s + sa * da * B(s, d)

   we were using regular addition for all four channels, but for
   superluminescent pixels, the addition could overflow causing
   nonsensical results.

2. The variables and return types used for the results of the blend
   mode calculations were unsigned, but for various blend modes (and
   especially with superluminescent pixels), the blend mode
   calculations could be negative, resulting in underflows.

3. The blend mode computations were returned as 8-bit values, which is
   not sufficient precision (especially considering that we need
   signed results).

4. The value before the final division by 255 was not properly clamped
   to [0, 255].

This patch fixes all those bugs. The blend mode computations are now
returned as signed 16 bit values with 1 represented as 255 * 255.

With these fixes, the number of failing pixels in pixel-test goes down
from 431 to 384.
pixman/pixman-combine32.c
test/blitters-test.c
test/thread-test.c