Fix conical gradients to match QConicalGradient from Qt
authorSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 19 Jun 2010 22:57:45 +0000 (18:57 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Sun, 20 Jun 2010 08:45:20 +0000 (04:45 -0400)
commit3074d57b560d5ec9be2a0e1a6846012698f51208
tree3dc2395cd45731d3fd3492cfcc50840b4ee55f1d
parent66365b5ef1bb85863669227ae6e31134d8d57013
Fix conical gradients to match QConicalGradient from Qt

Under the assumption that pixman gradients are supposed to match
QConicalgradient, described here:

        http://doc.trolltech.com/4.4/qconicalgradient.html

this patch fixes two separate bugs in pixman-conical-gradient.c.

The first bug is that the output of atan2() is in the range of [-pi,
pi], which means the parameter into the gradient can be negative. This
is wrong since a QConicalGradient always interpolates around the
center from 0 to 1. The fix for that is to (a) make sure the given
angle is between 0 and 360, and (b) add or subtract 2 * M_PI if the
computed angle ends up outside [0, 2 * pi].

The other bug is that we were interpolating clockwise, whereas
QConicalGradient calls for a counter-clockwise interpolation. This is
easily fixed by subtracting the parameter from 1.

Finally, this patch encapsulates the computation in a new force-inline
function so that it can be reused in both the affine and non-affine
case.
pixman/pixman-conical-gradient.c