[Pixman] [PATCH 0/5] Some changes to Color Dodge and Color Burn

Søren Sandmann Pedersen sandmann at cs.au.dk
Sat Oct 5 17:30:43 PDT 2013

The overall goal of the following patches is to make it more obvious
how the blend mode code relates to the specifications. To that end,
the comment for each blend routine is updated with some math that
shows how we go from specification to a formula that can deal with
premultiplied alpha, and the code is updated to follow the math as
much as possible.

The blend routines for Color Dodge and Color Burn are rewritten to
match the derived formulas. In the case of Color Dodge, this in some
sense makes the code less correct because the new code can now
underflow the unsigned variables when the source pixel is
superluminescent, while the old code was careful to clamp to zero. In
the case of Color Burn, I believe the new code is a net improvement
since the old code could underflow whereas the new code can't.

The reason I don't care too much about the code being correct is that
the blend mode code in general has a number of issues that makes it
not work very well, especially when superluminescent pixels are
involved. For one, the use of unsigned variables is wrong; for
another, the macros use a non-saturating sum that can sometimes

I have some plans to fix the blend modes for real, but for now the
only thing I want to accomplish with this patch set, is to make the
connection between code and formulas clear.


More information about the Pixman mailing list