[Pixman] [PATCH 2/2] pixman-gradient-walker: Make left_x and right_x 64 bit variables

Søren Sandmann soren.sandmann at gmail.com
Thu May 15 10:31:07 PDT 2014


From: Søren Sandmann Pedersen <ssp at redhat.com>

The variables left_x, and right_x in gradient_walker_reset() are
computed from pos, which is a 64 bit quantity, so to avoid overflows,
these variables must be 64 bit as well.

Similarly, the left_x and right_x that are stored in
pixman_gradient_walker_t need to be 64 bit as well; otherwise,
pixman_gradient_walker_pixel() will call reset too often.

This fixes the radial-invalid test, which was generating 'invalid'
floating point exceptions when the overflows caused color values to be
outside of [0, 255].
---
 pixman/pixman-gradient-walker.c | 2 +-
 pixman/pixman-private.h         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pixman/pixman-gradient-walker.c b/pixman/pixman-gradient-walker.c
index 5944a55..822f8e6 100644
--- a/pixman/pixman-gradient-walker.c
+++ b/pixman/pixman-gradient-walker.c
@@ -54,7 +54,7 @@ static void
 gradient_walker_reset (pixman_gradient_walker_t *walker,
 		       pixman_fixed_48_16_t      pos)
 {
-    int32_t x, left_x, right_x;
+    int64_t x, left_x, right_x;
     pixman_color_t *left_c, *right_c;
     int n, count = walker->num_stops;
     pixman_gradient_stop_t *stops = walker->stops;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 6ca13b2..fdc966a 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -345,8 +345,8 @@ typedef struct
     float		    r_s, r_b;
     float		    g_s, g_b;
     float		    b_s, b_b;
-    pixman_fixed_t	    left_x;
-    pixman_fixed_t          right_x;
+    pixman_fixed_48_16_t    left_x;
+    pixman_fixed_48_16_t    right_x;
 
     pixman_gradient_stop_t *stops;
     int                     num_stops;
-- 
1.8.3.1



More information about the Pixman mailing list