summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pixman/pixman-gradient-walker.c58
-rw-r--r--pixman/pixman-image.c2
-rw-r--r--pixman/pixman-private.h6
3 files changed, 31 insertions, 35 deletions
diff --git a/pixman/pixman-gradient-walker.c b/pixman/pixman-gradient-walker.c
index 6c7afce..d450316 100644
--- a/pixman/pixman-gradient-walker.c
+++ b/pixman/pixman-gradient-walker.c
@@ -28,37 +28,38 @@
#endif
#include "pixman-private.h"
-static int32_t
-_pixman_gradient_repeat_to_mask (pixman_repeat_t repeat)
+void
+_pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
+ gradient_t * gradient,
+ pixman_repeat_t repeat)
{
switch (repeat)
{
+ case PIXMAN_REPEAT_NONE:
+ walker->num_stops = gradient->n_stops + 2;
+ walker->stops = gradient->stops + 1;
+ walker->mask = 0xffffffff;
+ break;
+
case PIXMAN_REPEAT_NORMAL:
- return 0xffff;
+ walker->num_stops = gradient->n_stops;
+ walker->stops = gradient->stops + 2;
+ walker->mask = 0xffff;
+ break;
case PIXMAN_REPEAT_REFLECT:
- return 0x1ffff;
+ walker->num_stops = gradient->n_stops * 2;
+ walker->stops = gradient->stops + 2;
+ walker->mask = 0x1ffff;
+ break;
- case PIXMAN_REPEAT_NONE:
case PIXMAN_REPEAT_PAD:
- return 0xffffffff;
+ walker->num_stops = gradient->n_stops;
+ walker->stops = gradient->stops + 2;
+ walker->mask = 0xffffffff;
+ break;
}
- return 0;
-}
-
-void
-_pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
- gradient_t * gradient,
- pixman_repeat_t repeat)
-{
- walker->num_stops = gradient->n_stops;
- walker->stops = gradient->stops + 2;
- walker->mask = _pixman_gradient_repeat_to_mask(repeat);
-
- if (PIXMAN_REPEAT_REFLECT)
- walker->num_stops *= 2;
-
/* 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. */
@@ -70,18 +71,16 @@ static void
gradient_walker_reset (pixman_gradient_walker_t *walker,
pixman_fixed_48_16_t pos)
{
- int32_t x, left_x, right_x;
+ pixman_fixed_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;
- x = (int32_t)pos & walker->mask;
+ x = pos & walker->mask;
for (n = 0; n < count; n++)
- {
if (x < stops[n].x)
break;
- }
left_x = stops[n - 1].x;
left_c = &stops[n - 1].color;
@@ -89,11 +88,8 @@ gradient_walker_reset (pixman_gradient_walker_t *walker,
right_x = stops[n].x;
right_c = &stops[n].color;
- left_x += (pos - x);
- right_x += (pos - x);
-
- walker->left_x = left_x;
- walker->right_x = right_x;
+ walker->left_x = left_x + (pos - x);
+ walker->right_x = right_x + (pos - x);
walker->left_ag = ((left_c->alpha >> 8) << 16) | (left_c->green >> 8);
walker->left_rb = ((left_c->red & 0xff00) << 8) | (left_c->blue >> 8);
walker->right_ag = ((right_c->alpha >> 8) << 16) | (right_c->green >> 8);
@@ -107,7 +103,7 @@ gradient_walker_reset (pixman_gradient_walker_t *walker,
}
else
{
- int32_t width = right_x - left_x;
+ pixman_fixed_t width = right_x - left_x;
walker->stepper = ((1 << 24) + width / 2) / width;
}
}
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 9da934d..d28c026 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -75,7 +75,7 @@ gradient_property_changed (pixman_image_t *image)
* The valid stop range is now [first - 1, last + 1].
*
* It is possible to use these stops to interpolate in the
- * offset range [INT32_MIN to INT32_MAX).
+ * offset range [INT32_MIN,INT32_MAX).
*/
break;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index cf6767f..1a410c0 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -300,13 +300,13 @@ typedef struct
uint32_t left_rb;
uint32_t right_ag;
uint32_t right_rb;
- 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_fixed_t stepper;
pixman_gradient_stop_t *stops;
int num_stops;
- uint32_t mask;
+ pixman_fixed_t mask;
} pixman_gradient_walker_t;
void