[Pixman] [PATCH 1/3] gradient-walker: Remove need_reset field

Andrea Canciani ranma42 at gmail.com
Thu Jan 5 02:42:16 PST 2012


A reset can be forced by making left_x > right_x, because no pos will
satisfy left <= pos < right.
---
 pixman/pixman-gradient-walker.c |   17 ++++++-----------
 pixman/pixman-private.h         |    2 --
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/pixman/pixman-gradient-walker.c b/pixman/pixman-gradient-walker.c
index e7e724f..ae917e6 100644
--- a/pixman/pixman-gradient-walker.c
+++ b/pixman/pixman-gradient-walker.c
@@ -35,16 +35,13 @@ _pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
 {
     walker->num_stops = gradient->n_stops;
     walker->stops     = gradient->stops;
-    walker->left_x    = 0;
-    walker->right_x   = 0x10000;
-    walker->stepper   = 0;
-    walker->left_ag   = 0;
-    walker->left_rb   = 0;
-    walker->right_ag  = 0;
-    walker->right_rb  = 0;
     walker->repeat    = repeat;
 
-    walker->need_reset = TRUE;
+    /* The remaining part of the structure should be initalized by the
+     * reset function. Set left > right to trigger a reset as soon as
+     * the gradient walker is used. */
+    walker->left_x    = 0x10000;
+    walker->right_x   = 0;
 }
 
 static void
@@ -134,8 +131,6 @@ gradient_walker_reset (pixman_gradient_walker_t *walker,
 	int32_t width = right_x - left_x;
 	walker->stepper = ((1 << 24) + width / 2) / width;
     }
-
-    walker->need_reset = FALSE;
 }
 
 uint32_t
@@ -145,7 +140,7 @@ _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
     int dist, idist;
     uint32_t t1, t2, a, color;
 
-    if (walker->need_reset || x < walker->left_x || x >= walker->right_x)
+    if (x < walker->left_x || x >= walker->right_x)
 	gradient_walker_reset (walker, x);
 
     dist  = ((int)(x - walker->left_x) * walker->stepper) >> 16;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 1443bfb..a41d46c 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -306,8 +306,6 @@ typedef struct
     pixman_gradient_stop_t *stops;
     int                     num_stops;
     pixman_repeat_t	    repeat;
-
-    pixman_bool_t           need_reset;
 } pixman_gradient_walker_t;
 
 void
-- 
1.7.5.4



More information about the Pixman mailing list