pixman/test
Søren Sandmann 15aa37adec Use floating point combiners for all operators that involve divisions
Consider a DISJOINT_ATOP operation with the following pixels:

- source:	0xff (8 bits)
- source alpha:	0x01 (8 bits)
- mask alpha:	0x7b (8 bits)
- dest:		0x00 (8 bits)
- dest alpha:	0xff (8 bits)

When (src IN mask) is computed in 8 bits, the resulting alpha channel
is 0 due to rounding:

     floor ((0x01 * 0x7b) / 255.0 + 0.5) = floor (0.9823) = 0

which means that since Render defines any division by zero as
infinity, the Fa and Fb for this operator end up as follows:

     Fa = max (1 - (1 - 1) / 0, 0) = 0

     Fb = min (1, (1 - 0) / 1) = 1

and so since dest is 0x00, the overall result is 0.

However, when computed in full precision, the alpha value no longer
rounds to 0, and so Fa ends up being

     Fa = max (1 - (1 - 1) / 0.0001, 0) = 1

and so the result is now

     s * ma * Fa + d * Fb

   = (1.0 * (0x7b / 255.0) * 1) + d * 0

   = 0x7b / 255.0

   = 0.4823

so the error in this case ends up being 0.48235294, which is clearly
not something that can be considered acceptable.

In order to avoid this problem, we need to do all arithmetic in such a
way that a multiplication of two tiny numbers can never end up being
zero unless one of the input numbers is itself zero.

This patch makes all computations that involve divisions take place in
floating point, which is sufficient to fix the test cases

This brings the number of failures in pixel-test down to 14.
2014-01-04 16:13:27 -05:00
..
a1-trap-test.c a1-trap-test: Add tests for operator_name and format_name() 2013-02-13 02:18:01 -05:00
affine-test.c test: Test negative strides 2013-09-19 21:37:56 -04:00
alpha-loop.c test: Fix build on MSVC 2013-06-25 16:55:24 +02:00
alphamap.c utils.[ch]: Add new format_name() function 2013-01-23 12:24:31 -05:00
blitters-test.c Use floating point combiners for all operators that involve divisions 2014-01-04 16:13:27 -05:00
check-formats.c test/check-formats.c: Add support for separable blend modes 2014-01-04 16:13:27 -05:00
combiner-test.c test: Get rid of the obsolete 'prng_rand_N' and 'prng_rand_u32' 2012-12-06 17:20:38 +02:00
composite-traps-test.c test: Test negative strides 2013-09-19 21:37:56 -04:00
composite.c general: Support component alpha for all image types 2013-11-23 20:30:33 -05:00
fetch-test.c Use the ARRAY_LENGTH() macro when possible 2011-11-09 09:17:00 +01:00
fuzzer-find-diff.pl test: fix bisecting issue in fuzzer-find-diff.pl 2012-06-12 04:21:57 +03:00
glyph-test.c test: Get rid of the obsolete 'prng_rand_N' and 'prng_rand_u32' 2012-12-06 17:20:38 +02:00
gradient-crash-test.c Add combiner test 2012-10-01 12:56:09 -04:00
infinite-loop.c test: Add inifinite-loop test 2012-09-24 18:29:30 -04:00
lowlevel-blt-bench.c test: add "pixbuf" and "rpixbuf" to lowlevel-blt-bench 2013-04-30 15:38:43 -04:00
Makefile.am test: Add new thread-test program 2013-10-01 23:33:57 +03:00
Makefile.sources test/tolerance-test: New test program 2014-01-04 16:13:27 -05:00
Makefile.win32 Fix building of "other" programs on MSVC 2013-10-09 14:23:11 +02:00
matrix-test.c test: fix matrix-test on big endian systems 2013-08-05 01:42:29 +03:00
oob-test.c Use the ARRAY_LENGTH() macro when possible 2011-11-09 09:17:00 +01:00
pdf-op-test.c Add combiner test 2012-10-01 12:56:09 -04:00
pixel-test.c pixel-test.c: Add a number of pixels that have failed at some point 2014-01-04 16:13:27 -05:00
prng-test.c test: larger 0xFF/0x00 filled clusters in random images for blitters-test 2013-04-28 22:14:47 +03:00
radial-perf-test.c test: Add radial-perf-test, a microbenchmark for radial gradients 2013-03-11 22:41:45 -04:00
region-contains-test.c test: Get rid of the obsolete 'prng_rand_N' and 'prng_rand_u32' 2012-12-06 17:20:38 +02:00
region-test.c test: Switch to the new PRNG instead of old LCG 2012-12-06 17:20:35 +02:00
region-translate-test.c test: Cleanup includes 2011-11-09 09:17:00 +01:00
rotate-test.c test: Test negative strides 2013-09-19 21:37:56 -04:00
scaling-bench.c test: safeguard the scaling-bench test against COW 2013-09-07 17:20:09 -04:00
scaling-crash-test.c test: Composite with solid images instead of using pixman_image_fill_* 2012-05-24 15:30:41 -04:00
scaling-helpers-test.c test: Get rid of the obsolete 'prng_rand_N' and 'prng_rand_u32' 2012-12-06 17:20:38 +02:00
scaling-test.c test: Test negative strides 2013-09-19 21:37:56 -04:00
stress-test.c stresstest: Ensure that the rasterizer is only given alpha formats 2013-01-29 20:43:51 -05:00
thread-test.c Use floating point combiners for all operators that involve divisions 2014-01-04 16:13:27 -05:00
tolerance-test.c test/tolerance-test: New test program 2014-01-04 16:13:27 -05:00
trap-crasher.c test/trap-crasher.c: Add trapezoid that demonstrates a crash 2013-11-01 20:24:27 -04:00
utils-prng.c test: larger 0xFF/0x00 filled clusters in random images for blitters-test 2013-04-28 22:14:47 +03:00
utils-prng.h test: larger 0xFF/0x00 filled clusters in random images for blitters-test 2013-04-28 22:14:47 +03:00
utils.c Soft Light: Consistent approach to division by zero 2014-01-04 16:13:27 -05:00
utils.h Fix build of check-formats on MSVC 2013-10-09 14:23:11 +02:00