Bug 234606

Summary: [Cairo] Add support for premultiplied alpha interpolated color stop gradients in the Cairo backend
Product: WebKit Reporter: Sam Weinig <sam>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: aperez, Hironori.Fujii, rbuis, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   

Description Sam Weinig 2021-12-22 09:40:34 PST
With https://bugs.webkit.org/show_bug.cgi?id=234492, we added support for choosing between premultiplied alpha and unpremultiplied alpha color stop interpolation for Gradient, but only for the CoreGraphics backend.

To support CSS gradients, the Cairo needs to add support for both modes as well (the unpremultiplied case is still needed for SVG and Canvas).
Comment 1 Adrian Perez 2021-12-22 13:47:35 PST
AFAIU, with Cairo we set the colors for the stops un-premultiplied (because
there is no other option, that's what the public API allows), then Cairo
pre-multiplies color values while building its internal state, then internally
always does calculations using premultiplied values, meaning that when painting 
a gradient it will interpolate stop colors which are premultiplied — there
is no way of telling Cairo to calculate interpolaton of gradient stops
un-premultiplied. Meaning: with Cairo the way it paints gradiants the output
is correct for CSS, but not SVG/Canvas.

(Take this with some big grains of salt, I am not a graphics expert, what
I *think* know is from looking sometimes inside Cairo in the last months.)
Comment 2 Fujii Hironori 2021-12-23 13:18:02 PST
(In reply to Adrian Perez from comment #1)
> Meaning: with Cairo the way it paints gradiants the output
> is correct for CSS, but not SVG/Canvas.

Is this right?
fast/gradients/alpha-premultiplied.html is failing for Cairo ports.
This is not a test case for SVG or Canvas.
Comment 3 Radar WebKit Bug Importer 2021-12-29 09:41:16 PST
<rdar://problem/86985929>