test: Add a new "pixel_checker_t" object.
authorSøren Sandmann Pedersen <ssp@redhat.com>
Mon, 19 Dec 2011 22:31:06 +0000 (17:31 -0500)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Tue, 10 Jan 2012 14:04:45 +0000 (09:04 -0500)
commitf57034f678b419c3737b888f643e5bdfcaf727f9
treef6e6f819cff91f6815f2f5bd548e22cf99b07aad
parent0053a9f8694c837388b78ae26fe81979d0327d28
test: Add a new "pixel_checker_t" object.

Add a new pixel_checker_t object to test/utils.[ch]. This object
should be initialized with a format and can then be used to check
whether a given "real" pixel in that format is close enough to a
"perfect" pixel given as a double precision ARGB struct.

The acceptable deviation is calcuated as follows. Each channel of the
perfect pixel has 0.004 subtracted from it and is then converted to
the format. The resulting value is the minimum value that will be
accepted. Similarly, to compute the maximum value, the channel has
0.004 added to it and is then converted to the given format. Checking
a pixel is then a matter of splitting it into channels and checking
that each is within the computed bounds.

The value of 0.004 was chosen because it is the minimum one that will
make the existing composite test pass (see next commit). A problem
with this value is that it causes 0xFE to be acceptable when the
correct value is 1.0, and 0x01 to be acceptable when the correct value
is 0. It would be better if, when the result is exactly 0 or exactly
1, an a8r8g8b8 pixel were required to produce exactly 0x00 or 0xff to
preserve full black and full white. A deviation value of 0.003 would
produce this, but currently this would cause tests with operators that
involve divisions to fail.
test/utils.c
test/utils.h