[Pixman] [PATCH] Improve handling of tangent circles

Andrea Canciani ranma42 at gmail.com
Tue Jan 4 02:12:56 PST 2011

On Tue, Jan 4, 2011 at 10:59 AM, Siarhei Siamashka
<siarhei.siamashka at gmail.com> wrote:
> On Monday 03 January 2011 10:15:09 Andrea Canciani wrote:
>> When b is 0, avoid the division by zero and just return transparent
>> black.
>> When the solution t would have an invalid radius (negative or outside
>> [0,1] for none-extended gradients), return transparent black.
> Thanks for keeping improving radial gradients code.
> I just wonder if it would be difficult to add a test to pixman for this
> particular division by zero case? Or is it somehow triggered by cairo
> tests?

It is triggered by the new radial-gradient tests in cairo:

The refimages have been created with a patched pixman, so the tests
currently fail on cairo-image, but would pass with this change.

> One of the problems with the pixman radial code is that it is slow.
> And this path further slows it down a bit by adding a new branch in the
> inner loop. This is perfectly fine for a reference implementation, but if
> somebody decides to add some performance optimizations, then we need to have
> at least some basic tests which can catch possible errors and regressions.

I plan to rewrite the radial-gradient test to make it only use pixman
so that it can be added to pixman testsuite.

I know that branches are bad, but I believe that this "slow" implementation
should not try to be too clever. I'll rebase and clean up my cairo/wip/gl2
branch, which shows a branch-less radial gradient implementation
(using some tricks to use values as conditions).

Architectures that have a fast floating point SIMD (single precision
should be sufficient for most gradients) with square root (or which
can implement it in a reasonable way using Newton iteration) would
get much better performance by computing the gradient in parallel.


More information about the Pixman mailing list