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

Søren Sandmann sandmann at cs.au.dk
Sat Jan 8 03:21:46 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 initialized in pixman-bits-image.c
---
 pixman/pixman-bits-image.c |   80 ++++++++++++++++++++++++++++++++++++++++++++
 pixman/pixman-general.c    |   69 ++++++++-----------------------------
 pixman/pixman-private.h    |   28 +++++++++++++++
 3 files changed, 123 insertions(+), 54 deletions(-)

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index ff2dde3..e0a6645 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -1349,6 +1349,86 @@ bits_image_property_changed (pixman_image_t *image)
 }
 
 static uint32_t *
+src_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 *
+src_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;
+}
+
+void
+_pixman_bits_image_src_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 = src_get_scanline_narrow;
+    else
+	iter->get_scanline = src_get_scanline_wide;
+}
+
+static uint32_t *
+dest_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 *
+dest_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
+dest_write_back_narrow (pixman_iter_t *iter)
+{
+    _pixman_image_store_scanline_32 (
+	&iter->image->bits, iter->x, iter->y++, iter->width, iter->buffer);
+}
+
+static void
+dest_write_back_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_dest_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 = dest_get_scanline_narrow;
+	iter->write_back = dest_write_back_narrow;
+    }
+    else
+    {
+	iter->get_scanline = dest_get_scanline_wide;
+	iter->write_back = dest_write_back_wide;
+    }
+}
+
+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 ea27e80..3b7b59d 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -39,23 +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_flags_t;
-
-struct pixman_iter_t
-{
-    uint32_t *(* get_scanline) (pixman_iter_t *iter, const uint32_t *mask);
-    void      (* write_back)   (pixman_iter_t *iter);
-
-    pixman_image_t *    image;
-    uint32_t *          buffer;
-    int                 x, y;
-    int                 width;
-};
-
 static uint32_t *
 src_get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
 {
@@ -94,43 +77,22 @@ src_iter_init (pixman_implementation_t *imp,
     iter->buffer = (uint32_t *)buffer;
 
     if (!image)
+    {
 	iter->get_scanline = src_get_scanline_null;
+    }
+    else if (image->type == BITS)
+    {
+	_pixman_bits_image_src_iter_init (
+	    image, iter, x, y, width, height, buffer, flags);
+    }
     else if (flags & ITER_NARROW)
+    {
 	iter->get_scanline = src_get_scanline_narrow;
+    }
     else
+    {
 	iter->get_scanline = src_get_scanline_wide;
-}
-
-static uint32_t *
-dest_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 *
-dest_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
-write_back_narrow (pixman_iter_t *iter)
-{
-    _pixman_image_store_scanline_32 (
-	&iter->image->bits, iter->x, iter->y++, iter->width, iter->buffer);
-}
-
-static void
-write_back_wide (pixman_iter_t *iter)
-{
-    _pixman_image_store_scanline_64 (
-	&iter->image->bits, iter->x, iter->y++, iter->width, iter->buffer);
+    }
 }
 
 static void
@@ -146,15 +108,14 @@ dest_iter_init (pixman_implementation_t *imp,
     iter->width = width;
     iter->buffer = (uint32_t *)buffer;
 
-    if (flags & ITER_NARROW)
+    if (image->type == BITS)
     {
-	iter->get_scanline = dest_get_scanline_narrow;
-	iter->write_back = write_back_narrow;
+	_pixman_bits_image_dest_iter_init (
+	    image, iter, x, y, width, height, buffer, flags);
     }
     else
     {
-	iter->get_scanline = dest_get_scanline_wide;
-	iter->write_back = write_back_wide;
+	_pixman_log_error (FUNC, "Trying to write to a non-writable image");
     }
 }
 
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 383748a..853fb5a 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -193,10 +193,38 @@ union pixman_image
     solid_fill_t       solid;
 };
 
+typedef struct pixman_iter_t pixman_iter_t;
+typedef enum
+{
+    ITER_NARROW	= (1 << 0),
+} iter_flags_t;
+
+struct pixman_iter_t
+{
+    uint32_t *(* get_scanline) (pixman_iter_t *iter, const uint32_t *mask);
+    void      (* write_back)   (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_src_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_bits_image_dest_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