Make the first argument to scanline fetchers have type bits_image_t *
authorSøren Sandmann Pedersen <ssp@redhat.com>
Sun, 1 Sep 2013 02:59:53 +0000 (22:59 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 7 Sep 2013 21:12:18 +0000 (17:12 -0400)
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
pixman/pixman-bits-image.c
pixman/pixman-private.h

index b5c8e4017a10aadf911a302ef56cb83f5594a4aa..4f0642d7778563aef43ded06a0fefe0fc170f576 100644 (file)
@@ -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;
index 75a39a11599f1a0f8f25acb8fcf7bff199ebbb47..7b9a9733559050021c75319b1e4b1240766e85aa 100644 (file)
@@ -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;
index 964660508b013709155cec8fc493bc650a2d4442..120196ddf8f7e1c608318e0bdc1e679274cdd9e6 100644 (file)
@@ -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,