[webkit-reviews] review requested: [Bug 30333] [Color] (Un)premultiplication code is not optimal and broken in alpha==0 case : [Attachment 41101] 0002-Fix-Color-alpha-un-premultiplication-code.patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Oct 13 06:50:58 PDT 2009


Sebastian Dröge <slomo at circular-chaos.org> has asked  for review:
Bug 30333: [Color] (Un)premultiplication code is not optimal and broken in
alpha==0 case
https://bugs.webkit.org/show_bug.cgi?id=30333

Attachment 41101: 0002-Fix-Color-alpha-un-premultiplication-code.patch
https://bugs.webkit.org/attachment.cgi?id=41101&action=review

------- Additional Comments from Sebastian Dröge <slomo at circular-chaos.org>
Now to the explanation. First of all, for consistency and correctness the
resulting value of (un-)premultiplication with a 0-alpha should result in (0,
0, 0, 0) instead of the input value without changes. This is because:
a) unpremultiplication: if input alpha is 0 all other components *must* be 0
too, otherwise the premultiplication was done incorrectly
b) premultiplication: for non-0 alpha we multiply with alpha, if we do the same
for 0 alpha the output will be (0, 0, 0, 0) as it should

For the non-0 alpha cases it makes more sense to round to the nearest integer
instead of always rounding upwards. Rounding upwards results in an uneven
distribution of color values, i.e. a 0 component is much less likely than every
other component value.


More information about the webkit-reviews mailing list