[cairo] Radial gradient definition for cairo?

Soeren Sandmann sandmann at daimi.au.dk
Tue Mar 2 03:08:41 PST 2010


M Joonas Pihlaja <jpihlaja at cc.helsinki.fi> writes:

> I was looking at bug 5681 today and wondering what exactly the problem 
> there is.  The bug report contains a test program which draws a radial 
> gradient as well as some screen shots of radial gradients rendering 
> differently in cairo 1.0.2 and then-current cvs head. It turns out 
> that the test case in the bug report has the inner circle outside the 
> outer circle, so the focal point is way outside the outer circle too.  
> On the pixman mailing list Siarhei Siamashka noted that neither 
> Xrender nor SVG support radial gradients where the focal point is 
> outside the outer circle:

Gradients were originally added to XRender in 2005. The discussion of
that is here:

   http://archive.netbsd.se/?ml=xorg&a=2005-05&t=2733998

The original Render code did not support the case where the inner
circle was not contained within the outer, but it did not actually
produce BadValue as the spec claims.

This gradient code was imported into cairo, and the 1.0.2 screenshot
in bug 5681 is what happened if the inner circle wasn't contained in
the outer.

This thread from 2007:

   http://marc.info/?t=117102087400002&r=1&w=2

discusses how radial gradients are supposed to be defined, including
what it means when one of the circles are outside the other, and which
of the circles is the 'first' one. Carl then fixed the implementation
accordingly here:

   http://marc.info/?l=cairo&m=117279850711316&w=2

and added the long comment to fbcompose.c that now lives in
pixman-radial-gradient.c. When the X server started using the same
code as cairo, it gained the ability to deal with disjoint circles too.

Half a year ago or so, Chris fixed a bug in the radial gradients in pixman:

   http://bugs.freedesktop.org/show_bug.cgi?id=22908

with this commit

   http://cgit.freedesktop.org/pixman/commit/?id=20d2df03059d6a5941464d80e81e8116ebf4dbfe

that implicitly imposed an interpretation on gradients. I'm not 100%
convinced that interpretation agrees with the outcome of the first
thread. (I'm not sure it doesn't either).

I haven't actually read all the threads above (not recently anyway),
so I don't really have much of an opinion of my own on what radial
gradients should do.



Soren


More information about the cairo mailing list