diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-11-23 11:37:54 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2011-01-12 22:04:33 +0100 |
commit | 29439bd7724031504e965ffe5b366baaeeae07d8 (patch) | |
tree | f6eeb47138a80985210828e9d07ad3411a51f28a | |
parent | a484a9c49c98dfad0d74af4440039f61bef24d48 (diff) |
Improve handling of tangent circles
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.
-rw-r--r-- | pixman/pixman-radial-gradient.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pixman/pixman-radial-gradient.c b/pixman/pixman-radial-gradient.c index b595ba72..7b92307e 100644 --- a/pixman/pixman-radial-gradient.c +++ b/pixman/pixman-radial-gradient.c @@ -96,8 +96,24 @@ radial_compute_color (double a, if (a == 0) { - return _pixman_gradient_walker_pixel (walker, - pixman_fixed_1 / 2 * c / b); + double t; + + if (b == 0) + return 0; + + t = pixman_fixed_1 / 2 * c / b; + if (repeat == PIXMAN_REPEAT_NONE) + { + if (0 <= t && t <= pixman_fixed_1) + return _pixman_gradient_walker_pixel (walker, t); + } + else + { + if (t * dr > mindr) + return _pixman_gradient_walker_pixel (walker, t); + } + + return 0; } det = fdot (b, a, 0, b, -c, 0); |