diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2013-10-04 16:45:21 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2013-10-05 20:33:56 -0400 |
commit | 44adc03b76fa942988862d3ed98168899e5190ab (patch) | |
tree | d101156d4cbb9bd8e51be4ec1bb857b679babe7d | |
parent | a69b970ef13b81ac1f8728f9e546440f88ad2d03 (diff) |
pixman-combine32.c: Make Color Burn routine follow the math more closelycombine-formatting
For superluminescent destinations, the old code could underflow in
uint32_t r = (ad - d) * as / s;
when (ad - d) was negative. The new code avoids this problem (and
therefore causes changes in the checksums of thread-test and
blitters-test), but it is likely still buggy due to the use of
unsigned variables and other issues in the blend mode code.
-rw-r--r-- | pixman/pixman-combine32.c | 15 | ||||
-rw-r--r-- | test/blitters-test.c | 2 | ||||
-rw-r--r-- | test/thread-test.c | 2 |
3 files changed, 9 insertions, 10 deletions
diff --git a/pixman/pixman-combine32.c b/pixman/pixman-combine32.c index af059eb0..54946cc6 100644 --- a/pixman/pixman-combine32.c +++ b/pixman/pixman-combine32.c @@ -777,15 +777,14 @@ PDF_SEPARABLE_BLEND_MODE (color_dodge) static inline uint32_t blend_color_burn (uint32_t d, uint32_t ad, uint32_t s, uint32_t as) { - if (s == 0) - { - return d < ad ? 0 : DIV_ONE_UN8 (as * ad); - } + if (d >= ad) + return DIV_ONE_UN8 (ad * as); + else if (as * ad - as * d >= ad * s) + return 0; + else if (s == 0) + return 0; else - { - uint32_t r = (ad - d) * as / s; - return DIV_ONE_UN8 (as * (MAX (r, ad) - r)); - } + return DIV_ONE_UN8 (ad * as - (as * as * (ad - d)) / s); } PDF_SEPARABLE_BLEND_MODE (color_burn) diff --git a/test/blitters-test.c b/test/blitters-test.c index 396b5b54..ea03f475 100644 --- a/test/blitters-test.c +++ b/test/blitters-test.c @@ -394,6 +394,6 @@ main (int argc, const char *argv[]) } return fuzzer_test_main("blitters", 2000000, - 0x6A783AD5, + 0xE0A07495, test_composite, argc, argv); } diff --git a/test/thread-test.c b/test/thread-test.c index a0c78197..71b84f02 100644 --- a/test/thread-test.c +++ b/test/thread-test.c @@ -181,7 +181,7 @@ main (void) crc32 = compute_crc32 (0, crc32s, sizeof crc32s); -#define EXPECTED 0x12F4B484 +#define EXPECTED 0xE299B18E if (crc32 != EXPECTED) { |