[Pixman] Performance of radial gradients

Siarhei Siamashka siarhei.siamashka at gmail.com
Mon Feb 22 09:59:48 PST 2010


On Monday 22 February 2010, M Joonas Pihlaja wrote:
> On Fri, 19 Feb 2010, Siarhei Siamashka wrote:
> > In any case, seems like radial gradients are not covered by any
> > correctness/precision tests at the moment. This looks like the first
> > thing which needs to be implemented :)
>
> If we're looking at radial gradient correctness could we actually
> define clearly what the radial gradient is supposed to compute first?
> Right now there are rather weird discontinuities which occur
> sometimes, such as when the focal point moves outside of the outer
> circle. 

I'm not very familiar with radial gradients, so may be mistaken easily.

XRENDER spec [1] seems to forbid setting focal point outside of the outer
circle:
"The inner circle has to be completely contained inside the outer one or a
Value error is generated."

Also SVG 1.1 [2] seems to say that:
"If the point defined by fx and fy lies outside the circle defined by cx, cy 
and r, then the user agent shall set the focal point to the intersection of 
the line from (cx, cy) to (fx, fy) with the circle defined by cx, cy and r."

> I've also seen some very odd looking vertical banding. 

Because the image is processed as horizontal scanlines, vertical banding could
be a result of insufficient precision.

The plan to improve radial gradients in pixman could be the following:

1. Implement a reference general path variant of radial gradients fetcher with 
the emphasis on precision. It should be verified by looking at the results 
(like making sure that there is no banding or other oddities), also a simple
testcase could include checking some obvious corner cases and expected results
for them.
2. Implement fast path functions which would preferably use SIMD optimizations
for best performance where appropriate. These should check for some parameters
and value ranges to estimate whether precision is going to be sufficient. For 
some cases which would result in a large precision loss, fallback to the
general path should be done automatically.
3. Regression test should be able to compare any fast path implementation with
the general path (but it still needs to be defined what deviation is
acceptable).


1. http://cgit.freedesktop.org/xorg/proto/renderproto/plain/renderproto.txt
2. http://www.w3.org/TR/SVG11/pservers.html

-- 
Best regards,
Siarhei Siamashka


More information about the Pixman mailing list