[Pixman] [PATCH 07/18] Add _pixman_conical_gradient_iter_init() and call it from pixman-general.c

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


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

Also get rid of the remaining iter initialization in
pixman-general.c. By now, all image types have iter initializers of
their own.
---
 pixman/pixman-conical-gradient.c |   34 ++++++++++++++++++++++++++++++++++
 pixman/pixman-general.c          |   30 ++++++------------------------
 pixman/pixman-private.h          |    6 ++++++
 3 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/pixman/pixman-conical-gradient.c b/pixman/pixman-conical-gradient.c
index a3685d1..960ef9d 100644
--- a/pixman/pixman-conical-gradient.c
+++ b/pixman/pixman-conical-gradient.c
@@ -163,6 +163,40 @@ conical_gradient_property_changed (pixman_image_t *image)
     image->common.get_scanline_64 = _pixman_image_get_scanline_generic_64;
 }
 
+static uint32_t *
+conical_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
+{
+    conical_gradient_get_scanline_32 (iter->image, iter->x, iter->y,
+				      iter->width, iter->buffer,
+				      mask);
+
+    return iter->buffer;
+}
+
+static uint32_t *
+conical_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
+{
+    uint32_t *buffer = conical_get_scanline_narrow (iter, NULL);
+
+    pixman_expand ((uint64_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width);
+
+    return buffer;
+}
+
+void
+_pixman_conical_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 = conical_get_scanline_narrow;
+    else
+	iter->get_scanline = conical_get_scanline_wide;
+
+    iter->next_line = _pixman_iter_next_line_regular;
+}
+
 PIXMAN_EXPORT pixman_image_t *
 pixman_image_create_conical_gradient (pixman_point_fixed_t *        center,
                                       pixman_fixed_t                angle,
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 5865143..f75e7b3 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -45,24 +45,6 @@ get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
     return NULL;
 }
 
-static uint32_t *
-get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
-{
-    _pixman_image_get_scanline_32 (
-	iter->image, iter->x, iter->y, iter->width, iter->buffer, mask);
-
-    return iter->buffer;
-}
-
-static uint32_t *
-get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
-{
-    _pixman_image_get_scanline_64 (
-	iter->image, iter->x, iter->y, iter->width, iter->buffer, mask);
-
-    return iter->buffer;
-}
-
 static void
 iter_init (pixman_implementation_t *imp,
 	   pixman_iter_t *iter,
@@ -96,6 +78,11 @@ iter_init (pixman_implementation_t *imp,
 	_pixman_radial_gradient_iter_init (
 	    image, iter, x, y, width, height, buffer, flags);
     }
+    else if (image->type == CONICAL)
+    {
+	_pixman_conical_gradient_iter_init (
+	    image, iter, x, y, width, height, buffer, flags);
+    }
     else if (image->type == BITS)
     {
 	_pixman_bits_image_iter_init (
@@ -103,12 +90,7 @@ iter_init (pixman_implementation_t *imp,
     }
     else
     {
-	if (flags & ITER_NARROW)
-	    iter->get_scanline = get_scanline_narrow;
-	else
-	    iter->get_scanline = get_scanline_wide;
-
-	iter->next_line = _pixman_iter_next_line_regular;
+	_pixman_log_error (FUNC, "Pixman bug: unknown image type\n");
     }
 }
 
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 1c6f041..6f61d32 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -243,6 +243,12 @@ _pixman_radial_gradient_iter_init (pixman_image_t *image,
 				   uint8_t *buffer, iter_flags_t flags);
 
 void
+_pixman_conical_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,
                                         int             x,
                                         int             y,
-- 
1.6.0.6



More information about the Pixman mailing list