[Pixman] [PATCH 07/15] Move get_scanline_32/64 to the bits part of the image struct.

Søren Sandmann sandmann at cs.au.dk
Sat Jan 8 03:21:51 PST 2011


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

At this point these functions are basically a cache that the bits
image uses for its fetchers, so they can be moved to the bits image.

With the scanline getters only being initialized in the bits image,
the _pixman_image_get_scanline_generic_64 can be moved to
pixman-bits-image.c. That gets rid of the final user of
_pixman_image_get_scanline_32/64, so these can be deleted.
---
 pixman/pixman-bits-image.c       |   49 ++++++++++++++++++++++++++----
 pixman/pixman-conical-gradient.c |    2 -
 pixman/pixman-image.c            |   62 --------------------------------------
 pixman/pixman-linear-gradient.c  |    2 -
 pixman/pixman-private.h          |   32 ++-----------------
 pixman/pixman-radial-gradient.c  |    2 -
 pixman/pixman-solid-fill.c       |    2 -
 7 files changed, 46 insertions(+), 105 deletions(-)

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 0c5f4e4..423e48c 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -35,6 +35,43 @@
 #include "pixman-private.h"
 #include "pixman-combine32.h"
 
+/*
+ * By default, just evaluate the image at 32bpp and expand.  Individual image
+ * types can plug in a better scanline getter if they want to. For example
+ * we  could produce smoother gradients by evaluating them at higher color
+ * depth, but that's a project for the future.
+ */
+static void
+_pixman_image_get_scanline_generic_64 (pixman_image_t * image,
+                                       int              x,
+                                       int              y,
+                                       int              width,
+                                       uint32_t *       buffer,
+                                       const uint32_t * mask)
+{
+    uint32_t *mask8 = NULL;
+
+    /* Contract the mask image, if one exists, so that the 32-bit fetch
+     * function can use it.
+     */
+    if (mask)
+    {
+	mask8 = pixman_malloc_ab (width, sizeof(uint32_t));
+	if (!mask8)
+	    return;
+
+	pixman_contract (mask8, (uint64_t *)mask, width);
+    }
+
+    /* Fetch the source image into the first half of buffer. */
+    image->bits.get_scanline_32 (image, x, y, width, (uint32_t*)buffer, mask8);
+
+    /* Expand from 32bpp to 64bpp in place. */
+    pixman_expand ((uint64_t *)buffer, buffer, PIXMAN_a8r8g8b8, width);
+
+    free (mask8);
+}
+
 /* Fetch functions */
 
 static force_inline uint32_t
@@ -1300,8 +1337,8 @@ bits_image_property_changed (pixman_image_t *image)
 	if ((info->format == format || info->format == PIXMAN_any)	&&
 	    (info->flags & flags) == info->flags)
 	{
-	    image->common.get_scanline_32 = info->fetch_32;
-	    image->common.get_scanline_64 = info->fetch_64;
+	    image->bits.get_scanline_32 = info->fetch_32;
+	    image->bits.get_scanline_64 = info->fetch_64;
 	    break;
 	}
 
@@ -1312,7 +1349,7 @@ 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->bits.get_scanline_32 (
 	iter->image, iter->x, iter->y++, iter->width, iter->buffer, mask);
 
     return iter->buffer;
@@ -1321,7 +1358,7 @@ src_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
 static uint32_t *
 src_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
 {
-    iter->image->common.get_scanline_64 (
+    iter->image->bits.get_scanline_64 (
 	iter->image, iter->x, iter->y++, iter->width, iter->buffer, mask);
 
     return iter->buffer;
@@ -1342,7 +1379,7 @@ _pixman_bits_image_src_iter_init (pixman_image_t *image,
 static uint32_t *
 dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
 {
-    iter->image->common.get_scanline_32 (
+    iter->image->bits.get_scanline_32 (
 	iter->image, iter->x, iter->y, iter->width, iter->buffer, mask);
 
     return iter->buffer;
@@ -1351,7 +1388,7 @@ dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
 static uint32_t *
 dest_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
 {
-    iter->image->common.get_scanline_64 (
+    iter->image->bits.get_scanline_64 (
 	iter->image, iter->x, iter->y, iter->width, iter->buffer, mask);
 
     return iter->buffer;
diff --git a/pixman/pixman-conical-gradient.c b/pixman/pixman-conical-gradient.c
index 35913cb..a00170b 100644
--- a/pixman/pixman-conical-gradient.c
+++ b/pixman/pixman-conical-gradient.c
@@ -159,8 +159,6 @@ conical_gradient_get_scanline_32 (pixman_image_t *image,
 static void
 conical_gradient_property_changed (pixman_image_t *image)
 {
-    image->common.get_scanline_32 = conical_gradient_get_scanline_32;
-    image->common.get_scanline_64 = _pixman_image_get_scanline_generic_64;
 }
 
 static uint32_t *
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index b487df0..e059286 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -50,43 +50,6 @@ _pixman_init_gradient (gradient_t *                  gradient,
     return TRUE;
 }
 
-/*
- * By default, just evaluate the image at 32bpp and expand.  Individual image
- * types can plug in a better scanline getter if they want to. For example
- * we  could produce smoother gradients by evaluating them at higher color
- * depth, but that's a project for the future.
- */
-void
-_pixman_image_get_scanline_generic_64 (pixman_image_t * image,
-                                       int              x,
-                                       int              y,
-                                       int              width,
-                                       uint32_t *       buffer,
-                                       const uint32_t * mask)
-{
-    uint32_t *mask8 = NULL;
-
-    /* Contract the mask image, if one exists, so that the 32-bit fetch
-     * function can use it.
-     */
-    if (mask)
-    {
-	mask8 = pixman_malloc_ab (width, sizeof(uint32_t));
-	if (!mask8)
-	    return;
-
-	pixman_contract (mask8, (uint64_t *)mask, width);
-    }
-
-    /* Fetch the source image into the first half of buffer. */
-    _pixman_image_get_scanline_32 (image, x, y, width, (uint32_t*)buffer, mask8);
-
-    /* Expand from 32bpp to 64bpp in place. */
-    pixman_expand ((uint64_t *)buffer, buffer, PIXMAN_a8r8g8b8, width);
-
-    free (mask8);
-}
-
 pixman_image_t *
 _pixman_image_allocate (void)
 {
@@ -132,31 +95,6 @@ _pixman_image_classify (pixman_image_t *image,
 	return SOURCE_IMAGE_CLASS_UNKNOWN;
 }
 
-void
-_pixman_image_get_scanline_32 (pixman_image_t *image,
-                               int             x,
-                               int             y,
-                               int             width,
-                               uint32_t *      buffer,
-                               const uint32_t *mask)
-{
-    image->common.get_scanline_32 (image, x, y, width, buffer, mask);
-}
-
-/* Even thought the type of buffer is uint32_t *, the function actually expects
- * a uint64_t *buffer.
- */
-void
-_pixman_image_get_scanline_64 (pixman_image_t *image,
-                               int             x,
-                               int             y,
-                               int             width,
-                               uint32_t *      buffer,
-                               const uint32_t *unused)
-{
-    image->common.get_scanline_64 (image, x, y, width, buffer, unused);
-}
-
 static void
 image_property_changed (pixman_image_t *image)
 {
diff --git a/pixman/pixman-linear-gradient.c b/pixman/pixman-linear-gradient.c
index 2f032a8..6640610 100644
--- a/pixman/pixman-linear-gradient.c
+++ b/pixman/pixman-linear-gradient.c
@@ -222,8 +222,6 @@ linear_gradient_get_scanline_32 (pixman_image_t *image,
 static void
 linear_gradient_property_changed (pixman_image_t *image)
 {
-    image->common.get_scanline_32 = linear_gradient_get_scanline_32;
-    image->common.get_scanline_64 = _pixman_image_get_scanline_generic_64;
 }
 
 static uint32_t *
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 32e7381..1d33fbf 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -97,8 +97,6 @@ struct image_common
     pixman_bool_t               component_alpha;
     classify_func_t             classify;
     property_changed_func_t     property_changed;
-    fetch_scanline_t            get_scanline_32;
-    fetch_scanline_t            get_scanline_64;
 
     pixman_image_destroy_func_t destroy_func;
     void *                      destroy_data;
@@ -168,6 +166,9 @@ struct bits_image
     uint32_t *                 free_me;
     int                        rowstride;  /* in number of uint32_t's */
 
+    fetch_scanline_t           get_scanline_32;
+    fetch_scanline_t           get_scanline_64;
+
     fetch_scanline_t           fetch_scanline_32;
     fetch_pixel_32_t	       fetch_pixel_32;
     store_scanline_t           store_scanline_32;
@@ -253,14 +254,6 @@ _pixman_conical_gradient_iter_init (pixman_image_t *image,
 				    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,
-                                        int             width,
-                                        uint32_t *      buffer,
-                                        const uint32_t *mask);
-
 source_image_class_t
 _pixman_image_classify (pixman_image_t *image,
                         int             x,
@@ -268,25 +261,6 @@ _pixman_image_classify (pixman_image_t *image,
                         int             width,
                         int             height);
 
-void
-_pixman_image_get_scanline_32 (pixman_image_t *image,
-                               int             x,
-                               int             y,
-                               int             width,
-                               uint32_t *      buffer,
-                               const uint32_t *mask);
-
-/* Even thought the type of buffer is uint32_t *, the function actually expects
- * a uint64_t *buffer.
- */
-void
-_pixman_image_get_scanline_64 (pixman_image_t *image,
-                               int             x,
-                               int             y,
-                               int             width,
-                               uint32_t *      buffer,
-                               const uint32_t *unused);
-
 pixman_image_t *
 _pixman_image_allocate (void);
 
diff --git a/pixman/pixman-radial-gradient.c b/pixman/pixman-radial-gradient.c
index d0eb08c..7d14dd9 100644
--- a/pixman/pixman-radial-gradient.c
+++ b/pixman/pixman-radial-gradient.c
@@ -373,8 +373,6 @@ radial_gradient_get_scanline_32 (pixman_image_t *image,
 static void
 radial_gradient_property_changed (pixman_image_t *image)
 {
-    image->common.get_scanline_32 = radial_gradient_get_scanline_32;
-    image->common.get_scanline_64 = _pixman_image_get_scanline_generic_64;
 }
 
 static uint32_t *
diff --git a/pixman/pixman-solid-fill.c b/pixman/pixman-solid-fill.c
index 0af4df0..f2df3c7 100644
--- a/pixman/pixman-solid-fill.c
+++ b/pixman/pixman-solid-fill.c
@@ -72,8 +72,6 @@ solid_fill_classify (pixman_image_t *image,
 static void
 solid_fill_property_changed (pixman_image_t *image)
 {
-    image->common.get_scanline_32 = solid_fill_get_scanline_32;
-    image->common.get_scanline_64 = solid_fill_get_scanline_64;
 }
 
 void
-- 
1.6.0.6



More information about the Pixman mailing list