Change blend_color_dodge() to follow the math in the comment more
closely.
Note, the new code here is in some sense worse than the old code
because it can now underflow the unsigned variables when the source is
superluminescent and (as - s) is therefore negative. The old code was
careful to clamp to 0.
But for superluminescent variables we really need the ability for the
blend function to become negative, and so the solution the underflow
problem is to just use signed variables. The use of unsigned variables
is a general problem in all of the blend mode code that will have to
be solved later.
The CRC32 values in thread-test and blitters-test are updated to
account for the changes in output.
static inline uint32_t
blend_color_dodge (uint32_t d, uint32_t ad, uint32_t s, uint32_t as)
{
- if (s >= as)
- {
- return d == 0 ? 0 : DIV_ONE_UN8 (as * ad);
- }
+ if (d == 0)
+ return 0;
+ else if (as * d >= ad * (as - s))
+ return DIV_ONE_UN8 (as * ad);
+ else if (as - s == 0)
+ return DIV_ONE_UN8 (as * ad);
else
- {
- uint32_t r = d * as / (as - s);
- return DIV_ONE_UN8 (as * MIN (r, ad));
- }
+ return DIV_ONE_UN8 (as * ((d * as) / ((as - s))));
}
PDF_SEPARABLE_BLEND_MODE (color_dodge)
}
return fuzzer_test_main("blitters", 2000000,
- 0xAC8FDA98,
+ 0x6A783AD5,
test_composite, argc, argv);
}
crc32 = compute_crc32 (0, crc32s, sizeof crc32s);
-#define EXPECTED 0xFD497D8D
+#define EXPECTED 0x12F4B484
if (crc32 != EXPECTED)
{