[Pixman] [PATCH 02/18] Move initialization of iterators for bits images to pixman-bits-image.c

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


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

pixman_iter_t is now defined in pixman-private.h, and iterators for
bits images are being.

The function next_line_regular() is needed in both pixman-general.c
and pixman-bits-image.c, so rename it to
_pixman_iter_next_line_regular() and move it to pixman-utils.
---
 pixman/pixman-bits-image.c |   59 ++++++++++++++++++++++++++++++++++++++++++++
 pixman/pixman-general.c    |   51 +++-----------------------------------
 pixman/pixman-private.h    |   26 +++++++++++++++++++
 pixman/pixman-utils.c      |    6 ++++
 4 files changed, 95 insertions(+), 47 deletions(-)

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index ff2dde3..33b908a 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -1349,6 +1349,65 @@ bits_image_property_changed (pixman_image_t *image)
 }
 
 static uint32_t *
+get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
+{
+    iter->image->common.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)
+{
+    iter->image->common.get_scanline_64 (
+	iter->image, iter->x, iter->y, iter->width, iter->buffer, mask);
+
+    return iter->buffer;
+}
+
+static void
+next_line_write_narrow (pixman_iter_t *iter)
+{
+    _pixman_image_store_scanline_32 (
+	&iter->image->bits, iter->x, iter->y++, iter->width, iter->buffer);
+}
+
+static void
+next_line_write_wide (pixman_iter_t *iter)
+{
+    _pixman_image_store_scanline_64 (
+	&iter->image->bits, iter->x, iter->y++, iter->width, iter->buffer);
+}
+
+void
+_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)
+{
+    if ((flags & (ITER_NARROW | ITER_WRITE)) == (ITER_NARROW | ITER_WRITE))
+    {
+	iter->get_scanline = get_scanline_narrow;
+	iter->next_line = next_line_write_narrow;
+    }
+    else if (flags & ITER_WRITE)
+    {
+	iter->get_scanline = get_scanline_wide;
+	iter->next_line = next_line_write_wide;
+    }
+    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;
+    }
+}
+
+static uint32_t *
 create_bits (pixman_format_code_t format,
              int                  width,
              int                  height,
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 05d97cc..a66298a 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -39,24 +39,6 @@
 #include "pixman-combine32.h"
 #include "pixman-private.h"
 
-typedef struct pixman_iter_t pixman_iter_t;
-typedef enum
-{
-    ITER_NARROW	= (1 << 0),
-    ITER_WRITE =  (1 << 1)
-} iter_flags_t;
-
-struct pixman_iter_t
-{
-    uint32_t *(* get_scanline) (pixman_iter_t *iter, const uint32_t *mask);
-    void      (* next_line)    (pixman_iter_t *iter);
-
-    pixman_image_t *    image;
-    uint32_t *          buffer;
-    int                 x, y;
-    int                 width;
-};
-
 static uint32_t *
 get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
 {
@@ -82,26 +64,6 @@ get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
 }
 
 static void
-next_line_write_narrow (pixman_iter_t *iter)
-{
-    _pixman_image_store_scanline_32 (
-	&iter->image->bits, iter->x, iter->y++, iter->width, iter->buffer);
-}
-
-static void
-next_line_write_wide (pixman_iter_t *iter)
-{
-    _pixman_image_store_scanline_64 (
-	&iter->image->bits, iter->x, iter->y++, iter->width, iter->buffer);
-}
-
-static void
-next_line_regular (pixman_iter_t *iter)
-{
-    iter->y++;
-}
-
-static void
 next_line_noop (pixman_iter_t *iter)
 {
 }
@@ -124,15 +86,10 @@ iter_init (pixman_implementation_t *imp,
 	iter->get_scanline = get_scanline_null;
 	iter->next_line = next_line_noop;
     }
-    else if ((flags & (ITER_NARROW | ITER_WRITE)) == (ITER_NARROW | ITER_WRITE))
-    {
-	iter->get_scanline = get_scanline_narrow;
-	iter->next_line = next_line_write_narrow;
-    }
-    else if (flags & ITER_WRITE)
+    else if (image->type == BITS)
     {
-	iter->get_scanline = get_scanline_wide;
-	iter->next_line = next_line_write_wide;
+	_pixman_bits_image_iter_init (
+	    image, iter, x, y, width, height, buffer, flags);
     }
     else
     {
@@ -141,7 +98,7 @@ iter_init (pixman_implementation_t *imp,
 	else
 	    iter->get_scanline = get_scanline_wide;
 
-	iter->next_line = next_line_regular;
+	iter->next_line = _pixman_iter_next_line_regular;
     }
 }
 
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 383748a..5e441fe 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -193,10 +193,34 @@ union pixman_image
     solid_fill_t       solid;
 };
 
+typedef struct pixman_iter_t pixman_iter_t;
+typedef enum
+{
+    ITER_NARROW	= (1 << 0),
+    ITER_WRITE =  (1 << 1)
+} iter_flags_t;
+
+struct pixman_iter_t
+{
+    uint32_t *(* get_scanline) (pixman_iter_t *iter, const uint32_t *mask);
+    void      (* next_line)    (pixman_iter_t *iter);
+
+    pixman_image_t *    image;
+    uint32_t *          buffer;
+    int                 x, y;
+    int                 width;
+};
+
 void
 _pixman_bits_image_setup_accessors (bits_image_t *image);
 
 void
+_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_image_get_scanline_generic_64  (pixman_image_t *image,
                                         int             x,
                                         int             y,
@@ -526,6 +550,8 @@ _pixman_choose_implementation (void);
 /*
  * Utilities
  */
+void
+_pixman_iter_next_line_regular (pixman_iter_t *iter);
 
 /* These "formats" all have depth 0, so they
  * will never clash with any real ones
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index 3ef88b7..630c870 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -167,6 +167,12 @@ pixman_contract (uint32_t *      dst,
     }
 }
 
+void
+_pixman_iter_next_line_regular (pixman_iter_t *iter)
+{
+    iter->y++;
+}
+
 #define N_TMP_BOXES (16)
 
 pixman_bool_t
-- 
1.6.0.6



More information about the Pixman mailing list