[Pixman] [PATCH 04/18] Add _pixman_linear_gradient_iter_init().

Søren Sandmann sandmann at cs.au.dk
Wed Jan 5 18:09:42 PST 2011


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

Call it from pixman-general.c to initialize linear gradient iterators.
---
 pixman/pixman-general.c         |    5 ++++
 pixman/pixman-linear-gradient.c |   43 +++++++++++++++++++++++++++++++++++++++
 pixman/pixman-private.h         |    5 ++++
 3 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index a66298a..7ff2dd2 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -86,6 +86,11 @@ iter_init (pixman_implementation_t *imp,
 	iter->get_scanline = get_scanline_null;
 	iter->next_line = next_line_noop;
     }
+    else if (image->type == LINEAR)
+    {
+	_pixman_linear_gradient_iter_init (
+	    image, iter, x, y, width, height, buffer, flags);
+    }
     else if (image->type == BITS)
     {
 	_pixman_bits_image_iter_init (
diff --git a/pixman/pixman-linear-gradient.c b/pixman/pixman-linear-gradient.c
index 1547882..a2de693 100644
--- a/pixman/pixman-linear-gradient.c
+++ b/pixman/pixman-linear-gradient.c
@@ -226,6 +226,49 @@ linear_gradient_property_changed (pixman_image_t *image)
     image->common.get_scanline_64 = _pixman_image_get_scanline_generic_64;
 }
 
+static uint32_t *
+linear_gradient_get_scanline_narrow (pixman_iter_t  *iter,
+				     const uint32_t *mask)
+{
+    pixman_image_t *image  = iter->image;
+    int             x      = iter->x;
+    int             y      = iter->y;
+    int             width  = iter->width;
+    uint32_t *      buffer = iter->buffer;
+
+    linear_gradient_get_scanline_32 (image, x, y, width, buffer, mask);
+
+    return iter->buffer;
+}
+
+static uint32_t *
+linear_gradient_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
+{
+    uint32_t *buffer = linear_gradient_get_scanline_narrow (iter, NULL);
+
+    pixman_expand ((uint64_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width);
+
+    return buffer;
+}
+
+void
+_pixman_linear_gradient_iter_init (pixman_image_t *image,
+				   pixman_iter_t  *iter,
+				   int             x,
+				   int             y,
+				   int             width,
+				   int             height,
+				   uint8_t        *buffer,
+				   iter_flags_t    flags)
+{
+    if (flags & ITER_NARROW)
+	iter->get_scanline = linear_gradient_get_scanline_narrow;
+    else
+	iter->get_scanline = linear_gradient_get_scanline_wide;
+
+    iter->next_line = _pixman_iter_next_line_regular;
+}
+
 PIXMAN_EXPORT pixman_image_t *
 pixman_image_create_linear_gradient (pixman_point_fixed_t *        p1,
                                      pixman_point_fixed_t *        p2,
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 0511ade..0be38ed 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -219,6 +219,11 @@ _pixman_bits_image_iter_init (pixman_image_t *image,
 			      pixman_iter_t *iter,
 			      int x, int y, int width, int height,
 			      uint8_t *buffer, iter_flags_t flags);
+void
+_pixman_linear_gradient_iter_init (pixman_image_t *image,
+				   pixman_iter_t  *iter,
+				   int x, int y, int width, int height,
+				   uint8_t *buffer, iter_flags_t flags);
 
 void
 _pixman_image_get_scanline_generic_64  (pixman_image_t *image,
-- 
1.6.0.6



More information about the Pixman mailing list