[cairo] Radial gradient fixes have landed

Carl Worth cworth at cworth.org
Thu Mar 1 17:21:32 PST 2007

So I finally pushed out the fixes for the radial gradients that I
worked on at FOSDEM and we've been talking about a bit this week.

As is, everything in the test suite passes except for SVG, (though the
PS/PDF passes are rally boring since we haven't turned on native
gradients there yet---that was blocking on actually getting a test
into the suite, which we at least have now).

For SVG, what's missing is support for remapping gradient stops when
there's an inner radius that is non-zero, particularly for extend
modes of REPEAT and REFLECT. It shouldn't be that much work to do,
(though I did botch my first attempt). Just run the radial-gradient
test case if you want to see what needs to be done.

If anyone wants to look at the math involved in the radial gradient
code, it's here:


Many thanks to Vincent Torri <vtorri at univ-evry.fr> who helped me come
up with a simple derivation of this stuff, (the algebra I set up on my
own was really over-complicated). Oh, for those that saw a version of
this code that I posted earlier, the algebra has been corrected since

Finally, I did this implementation with almost no concern for
performance. There's still a heck of a lot of work happening for every
pixel here, (many floating-point operations and a sqrt). But I did do
a quick check with cairo-perf-diff and it seems only faster (1.05x -
1.58x) than the only code, (which also had the same sqrt per pixel of

If someone really cares about radial gradient performance, this might
very well be a great place to drop in an all-integer implementation,
(with an integer square root implementation). That should help
embedded systems quite a bit, (though it might slow down things like
x86---let's check and start using our DISABLE_SOME_FLOATING_POINT
define if necessary).

One more bug[*] to go before 1.4 I think...


[*] This one here:

Cairo 1.3.14 deadlocks in cairo_scaled_font_glyph_extents or _cairo_ft_unscaled_font_lock_face

If you can reproduce this, please let us know---many people can't and
we don't yet know what the magic variables might be.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070301/faeaf22e/attachment.pgp

More information about the cairo mailing list