Soft Light: Consistent approach to division by zero
authorSøren Sandmann <ssp@redhat.com>
Mon, 18 Nov 2013 18:26:33 +0000 (13:26 -0500)
committerSøren Sandmann <ssp@redhat.com>
Sat, 4 Jan 2014 21:13:27 +0000 (16:13 -0500)
commit8f3824316300e257a3698daa13db802e32489236
tree9f6acd46d9ae955b6af4f2bc35ffd6e595dc1c7a
parent89662adf77c69c3f71ded9cd8818ac5626b68451
Soft Light: Consistent approach to division by zero

The Soft Light operator has several branches. One them is decided
based on whether 2 * s is less than or equal to 2 * sa. In floating
point implementations, when those two values are very close to each
other, it may not be completely predictable which branch we hit.

This is a problem because in one branch, when destination alpha is
zero, we get the result

      r = d * as

and in the other we get

      r = 0

So when d and as are not 0, this causes two different results to be
returned from essentially identical input values. In other words,
there is a discontinuity in the current implementation.

This patch randomly changes the second branch such that it now returns
d * sa instead. There is no deep meaning behind this, because
essentially this is an attempt to assign meaning to division by zero,
and all that is requires is that that meaning doesn't depend on minute
differences in input values.

This makes the number of failed pixels in pixel-test go down to 347.
pixman/pixman-combine-float.c
pixman/pixman-combine32.c
test/utils.c