[Pixman] [PATCH] Make the first argument to scanline fetchers have type bits_image_t *

Søren Sandmann sandmann at cs.au.dk
Sat Aug 31 20:04:14 PDT 2013


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

Scanline fetchers haven't been used for images other than bits for a
long time, so by making the type reflect this fact, a bit of casting
can be saved in various places.
---
 pixman/pixman-access.c     |   50 ++++++++++++++++++++++----------------------
 pixman/pixman-bits-image.c |   18 +++++++--------
 pixman/pixman-private.h    |    2 +-
 3 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index b5c8e40..4f0642d 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -294,14 +294,14 @@ convert_pixel (pixman_format_code_t from, pixman_format_code_t to, uint32_t pixe
 }
 
 static force_inline uint32_t
-convert_pixel_to_a8r8g8b8 (pixman_image_t *image,
+convert_pixel_to_a8r8g8b8 (bits_image_t *image,
 			   pixman_format_code_t format,
 			   uint32_t pixel)
 {
     if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY		||
 	PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR)
     {
-	return image->bits.indexed->rgba[pixel];
+	return image->indexed->rgba[pixel];
     }
     else
     {
@@ -332,7 +332,7 @@ convert_pixel_from_a8r8g8b8 (pixman_image_t *image,
 }
 
 static force_inline uint32_t
-fetch_and_convert_pixel (pixman_image_t	*	image,
+fetch_and_convert_pixel (bits_image_t *		image,
 			 const uint8_t *	bits,
 			 int			offset,
 			 pixman_format_code_t	format)
@@ -417,7 +417,7 @@ convert_and_store_pixel (bits_image_t *		image,
 
 #define MAKE_ACCESSORS(format)						\
     static void								\
-    fetch_scanline_ ## format (pixman_image_t *image,			\
+    fetch_scanline_ ## format (bits_image_t *image,			\
 			       int	       x,			\
 			       int             y,			\
 			       int             width,			\
@@ -425,7 +425,7 @@ convert_and_store_pixel (bits_image_t *		image,
 			       const uint32_t *mask)			\
     {									\
 	uint8_t *bits =							\
-	    (uint8_t *)(image->bits.bits + y * image->bits.rowstride);	\
+	    (uint8_t *)(image->bits + y * image->rowstride);		\
 	int i;								\
 									\
 	for (i = 0; i < width; ++i)					\
@@ -461,8 +461,8 @@ convert_and_store_pixel (bits_image_t *		image,
 	uint8_t *bits =							\
 	    (uint8_t *)(image->bits + line * image->rowstride);		\
 									\
-	return fetch_and_convert_pixel ((pixman_image_t *)image,	\
-					bits, offset, PIXMAN_ ## format); \
+	return fetch_and_convert_pixel (				\
+	    image, bits, offset, PIXMAN_ ## format);			\
     }									\
 									\
     static const void *const __dummy__ ## format
@@ -583,14 +583,14 @@ to_srgb (float f)
 }
 
 static void
-fetch_scanline_a8r8g8b8_sRGB_float (pixman_image_t *image,
+fetch_scanline_a8r8g8b8_sRGB_float (bits_image_t *  image,
 				    int             x,
 				    int             y,
 				    int             width,
 				    uint32_t *      b,
 				    const uint32_t *mask)
 {
-    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+    const uint32_t *bits = image->bits + y * image->rowstride;
     const uint32_t *pixel = bits + x;
     const uint32_t *end = pixel + width;
     argb_t *buffer = (argb_t *)b;
@@ -612,14 +612,14 @@ fetch_scanline_a8r8g8b8_sRGB_float (pixman_image_t *image,
 
 /* Expects a float buffer */
 static void
-fetch_scanline_a2r10g10b10_float (pixman_image_t *image,
+fetch_scanline_a2r10g10b10_float (bits_image_t *  image,
 				  int             x,
 				  int             y,
 				  int             width,
 				  uint32_t *      b,
 				  const uint32_t *mask)
 {
-    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+    const uint32_t *bits = image->bits + y * image->rowstride;
     const uint32_t *pixel = bits + x;
     const uint32_t *end = pixel + width;
     argb_t *buffer = (argb_t *)b;
@@ -643,14 +643,14 @@ fetch_scanline_a2r10g10b10_float (pixman_image_t *image,
 
 /* Expects a float buffer */
 static void
-fetch_scanline_x2r10g10b10_float (pixman_image_t *image,
+fetch_scanline_x2r10g10b10_float (bits_image_t   *image,
 				  int             x,
 				  int             y,
 				  int             width,
 				  uint32_t *      b,
 				  const uint32_t *mask)
 {
-    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+    const uint32_t *bits = image->bits + y * image->rowstride;
     const uint32_t *pixel = (uint32_t *)bits + x;
     const uint32_t *end = pixel + width;
     argb_t *buffer = (argb_t *)b;
@@ -673,14 +673,14 @@ fetch_scanline_x2r10g10b10_float (pixman_image_t *image,
 
 /* Expects a float buffer */
 static void
-fetch_scanline_a2b10g10r10_float (pixman_image_t *image,
+fetch_scanline_a2b10g10r10_float (bits_image_t   *image,
 				  int             x,
 				  int             y,
 				  int             width,
 				  uint32_t *      b,
 				  const uint32_t *mask)
 {
-    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+    const uint32_t *bits = image->bits + y * image->rowstride;
     const uint32_t *pixel = bits + x;
     const uint32_t *end = pixel + width;
     argb_t *buffer = (argb_t *)b;
@@ -704,14 +704,14 @@ fetch_scanline_a2b10g10r10_float (pixman_image_t *image,
 
 /* Expects a float buffer */
 static void
-fetch_scanline_x2b10g10r10_float (pixman_image_t *image,
+fetch_scanline_x2b10g10r10_float (bits_image_t   *image,
 				  int             x,
 				  int             y,
 				  int             width,
 				  uint32_t *      b,
 				  const uint32_t *mask)
 {
-    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+    const uint32_t *bits = image->bits + y * image->rowstride;
     const uint32_t *pixel = (uint32_t *)bits + x;
     const uint32_t *end = pixel + width;
     argb_t *buffer = (argb_t *)b;
@@ -733,14 +733,14 @@ fetch_scanline_x2b10g10r10_float (pixman_image_t *image,
 }
 
 static void
-fetch_scanline_yuy2 (pixman_image_t *image,
+fetch_scanline_yuy2 (bits_image_t   *image,
                      int             x,
                      int             line,
                      int             width,
                      uint32_t *      buffer,
                      const uint32_t *mask)
 {
-    const uint32_t *bits = image->bits.bits + image->bits.rowstride * line;
+    const uint32_t *bits = image->bits + image->rowstride * line;
     int i;
     
     for (i = 0; i < width; i++)
@@ -767,7 +767,7 @@ fetch_scanline_yuy2 (pixman_image_t *image,
 }
 
 static void
-fetch_scanline_yv12 (pixman_image_t *image,
+fetch_scanline_yv12 (bits_image_t   *image,
                      int             x,
                      int             line,
                      int             width,
@@ -1121,30 +1121,30 @@ store_scanline_generic_float (bits_image_t *  image,
 }
 
 static void
-fetch_scanline_generic_float (pixman_image_t *image,
+fetch_scanline_generic_float (bits_image_t *  image,
 			      int	      x,
 			      int	      y,
 			      int	      width,
 			      uint32_t *      buffer,
 			      const uint32_t *mask)
 {
-    image->bits.fetch_scanline_32 (image, x, y, width, buffer, NULL);
+    image->fetch_scanline_32 (image, x, y, width, buffer, NULL);
 
-    pixman_expand_to_float ((argb_t *)buffer, buffer, image->bits.format, width);
+    pixman_expand_to_float ((argb_t *)buffer, buffer, image->format, width);
 }
 
 /* The 32_sRGB paths should be deleted after narrow processing
  * is no longer invoked for formats that are considered wide.
  * (Also see fetch_pixel_generic_lossy_32) */
 static void
-fetch_scanline_a8r8g8b8_32_sRGB (pixman_image_t *image,
+fetch_scanline_a8r8g8b8_32_sRGB (bits_image_t   *image,
                                  int             x,
                                  int             y,
                                  int             width,
                                  uint32_t       *buffer,
                                  const uint32_t *mask)
 {
-    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+    const uint32_t *bits = image->bits + y * image->rowstride;
     const uint32_t *pixel = (uint32_t *)bits + x;
     const uint32_t *end = pixel + width;
     uint32_t tmp;
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 75a39a1..7b9a973 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -1253,9 +1253,9 @@ bits_image_fetch_untransformed_repeat_none (bits_image_t *image,
 	w = MIN (width, image->width - x);
 
 	if (wide)
-	    image->fetch_scanline_float ((pixman_image_t *)image, x, y, w, buffer, NULL);
+	    image->fetch_scanline_float (image, x, y, w, buffer, NULL);
 	else
-	    image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL);
+	    image->fetch_scanline_32 (image, x, y, w, buffer, NULL);
 
 	width -= w;
 	buffer += w * (wide? 4 : 1);
@@ -1301,9 +1301,9 @@ bits_image_fetch_untransformed_repeat_normal (bits_image_t *image,
 	w = MIN (width, image->width - x);
 
 	if (wide)
-	    image->fetch_scanline_float ((pixman_image_t *)image, x, y, w, buffer, NULL);
+	    image->fetch_scanline_float (image, x, y, w, buffer, NULL);
 	else
-	    image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL);
+	    image->fetch_scanline_32 (image, x, y, w, buffer, NULL);
 
 	buffer += w * (wide? 4 : 1);
 	x += w;
@@ -1528,7 +1528,7 @@ dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
     int             width  = iter->width;
     uint32_t *	    buffer = iter->buffer;
 
-    image->bits.fetch_scanline_32 (image, x, y, width, buffer, mask);
+    image->bits.fetch_scanline_32 (&image->bits, x, y, width, buffer, mask);
     if (image->common.alpha_map)
     {
 	uint32_t *alpha;
@@ -1541,8 +1541,7 @@ dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
 	    y -= image->common.alpha_origin_y;
 
 	    image->common.alpha_map->fetch_scanline_32 (
-		(pixman_image_t *)image->common.alpha_map,
-		x, y, width, alpha, mask);
+		image->common.alpha_map, x, y, width, alpha, mask);
 
 	    for (i = 0; i < width; ++i)
 	    {
@@ -1567,7 +1566,7 @@ dest_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
     argb_t *	    buffer = (argb_t *)iter->buffer;
 
     image->fetch_scanline_float (
-	(pixman_image_t *)image, x, y, width, (uint32_t *)buffer, mask);
+	image, x, y, width, (uint32_t *)buffer, mask);
     if (image->common.alpha_map)
     {
 	argb_t *alpha;
@@ -1580,8 +1579,7 @@ dest_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
 	    y -= image->common.alpha_origin_y;
 
 	    image->common.alpha_map->fetch_scanline_float (
-		(pixman_image_t *)image->common.alpha_map,
-		x, y, width, (uint32_t *)alpha, mask);
+		image->common.alpha_map, x, y, width, (uint32_t *)alpha, mask);
 
 	    for (i = 0; i < width; ++i)
 		buffer[i].a = alpha[i].a;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 0afabad..535117d 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -57,7 +57,7 @@ struct argb_t
     float b;
 };
 
-typedef void (*fetch_scanline_t) (pixman_image_t *image,
+typedef void (*fetch_scanline_t) (bits_image_t   *image,
 				  int             x,
 				  int             y,
 				  int             width,
-- 
1.7.1



More information about the Pixman mailing list