xf86-video-intel: src/sna/sna_gradient.c
Chris Wilson
ickle at kemper.freedesktop.org
Sat Apr 7 01:56:40 PDT 2012
src/sna/sna_gradient.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
New commits:
commit 1ecf17b2507f95e1fefea15833fa9f57ec256a2e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Apr 7 10:01:01 2012 +0100
sna/gradient: Compute the absolute delta between color stops
Otherwise we do not detect gradients that start from white!
Reported-by: Clemens Eisserer <linuxhippy at gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=48407
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/sna_gradient.c b/src/sna/sna_gradient.c
index 943cbf9..32d26c8 100644
--- a/src/sna/sna_gradient.c
+++ b/src/sna/sna_gradient.c
@@ -44,39 +44,48 @@ sna_gradient_sample_width(PictGradient *gradient)
{
int n, width;
- width = 2;
+ width = 0;
for (n = 1; n < gradient->nstops; n++) {
xFixed dx = gradient->stops[n].x - gradient->stops[n-1].x;
- uint16_t delta, max;
- int ramp;
+ int delta, max, ramp;
if (dx == 0)
return 1024;
max = gradient->stops[n].color.red -
gradient->stops[n-1].color.red;
+ if (max < 0)
+ max = -max;
delta = gradient->stops[n].color.green -
gradient->stops[n-1].color.green;
+ if (delta < 0)
+ delta = -delta;
if (delta > max)
max = delta;
delta = gradient->stops[n].color.blue -
gradient->stops[n-1].color.blue;
+ if (delta < 0)
+ delta = -delta;
if (delta > max)
max = delta;
delta = gradient->stops[n].color.alpha -
gradient->stops[n-1].color.alpha;
+ if (delta < 0)
+ delta = -delta;
if (delta > max)
max = delta;
- ramp = 128 * max / dx;
+ ramp = 256 * max / dx;
if (ramp > width)
width = ramp;
}
- width *= gradient->nstops-1;
+ if (width == 0)
+ return 1;
+
width = (width + 7) & -8;
return min(width, 1024);
}
More information about the xorg-commit
mailing list