[Webkit-unassigned] [Bug 105074] Add Canvas blend modes to Cairo

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 19 14:57:11 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=105074





--- Comment #2 from Rik Cabanier <cabanier at adobe.com>  2012-12-19 14:59:27 PST ---
(In reply to comment #1)
> I tried to add support for blending modes in cairo.
> While most modes work correctly, color-burn, color-dogde, hue, luminosity and saturation mode do not work.
> 
> That's Pixman implementation is based on svg specification; and I think there is a difference between svg specification and the tests added in bug #104176 (and possibly also with pdf specification).
> 
> Pdf specification[1] states that the resulting color for color-burn compositing will be
> 
> Cr = (1 – as / ar) * Cb + as / ar × [( 1 – ab) × Cs + ab × B(Cb, Cs)]
> with B(Cb, Cs) = 1 - min(1, (1 - Cb) / Cs) if Cs > 0, or 0 otherwise
> 
> So if we have a opaque source and backdrops (a = 1) and a color component of 0 for source, and 1 for backdrop, the result should be:
> (1 - 1) * 1 + 1 / 1 * ((1 - 1) * 0 + 1 * 0) => 0
> That is what is assumed in the tests for #104176.
> 
> But svg specification[2] states that result for color-burn compositing:
> 
> if Sca == 0 and Dca == Da
>   Dca' = Sa × Da + Sca × (1 - Da) + Dca × (1 - Sa)
>        = Sa × Da + Dca × (1 - Sa)
> otherwise if Sca == 0
>   Dca' = Sca × (1 - Da) + Dca × (1 - Sa)
>        = Dca × (1 - Sa)
> otherwise if Sca > 0
>   Dca' = Sa × Da - Sa × Da × min(1, (1 - Dca/Da) × Sa/Sca) + Sca × (1 - Da) + Dca × (1 - Sa)
>        = Sa × Da × (1 - min(1, (1 - Dca/Da) × Sa/Sca)) + Sca × (1 - Da) + Dca × (1 - Sa)
> 
> For the same backdrop and sources, we have
> Sca = 0; Sa = 1
> Dca = 1; Da = 1
> So, we are in the first case, and the result should be:
> 1 * 1 + 0 * (1 - 1) + 1 * (1 - 1) => 1
> This is what pixman computes.
> (By the way, I don't really understand why there is this Dca == Da check).
> 
> I have not checked other modes yet, but I suppose there may be a the same problem there.
> 
> So am I correct, is the a difference between pdf specification and svg specification. If so, which one are we supposed to follow now ?

In this case, the formula in the SVG specification is correct for color-burn and color-dodge.
I didn't update the formula in the CSS compositing spec yet, but will do so shortly.

I'm surprised to see that hue, luminosity and saturation mode do not work. Are they very different?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list