[Pixman] [PATCH 11/11] Consolidate all the iter_init_bits_stride functions

Søren Sandmann Pedersen soren.sandmann at gmail.com
Wed May 22 06:45:20 PDT 2013


The SSE2, MMX, and fast implementations all have a copy of the
function iter_init_bits_stride that computes an image buffer and
stride.

Move that function to pixman-utils.c and share it among all the
implementations.
---
 pixman/pixman-fast-path.c | 19 +++++--------------
 pixman/pixman-mmx.c       | 17 +++--------------
 pixman/pixman-private.h   |  3 +++
 pixman/pixman-sse2.c      | 17 +++--------------
 pixman/pixman-utils.c     | 11 +++++++++++
 5 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index 9af26af..3982dce 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -2261,17 +2261,6 @@ fast_write_back_r5g6b5 (pixman_iter_t *iter)
     }
 }
 
-static void
-iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info)
-{
-    pixman_image_t *image = iter->image;
-    uint8_t *b = (uint8_t *)image->bits.bits;
-    int s = image->bits.rowstride * 4;
-
-    iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (info->format) / 8;
-    iter->stride = s;
-}
-
 #define IMAGE_FLAGS							\
     (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM |		\
      FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST)
@@ -2279,15 +2268,17 @@ iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info)
 static const pixman_iter_info_t fast_iters[] = 
 {
     { PIXMAN_r5g6b5, IMAGE_FLAGS, ITER_NARROW | ITER_SRC,
-      iter_init_bits_stride, fast_fetch_r5g6b5, NULL },
+      _pixman_iter_init_bits_stride, fast_fetch_r5g6b5, NULL },
 
     { PIXMAN_r5g6b5, FAST_PATH_STD_DEST_FLAGS,
       ITER_NARROW | ITER_DEST,
-      iter_init_bits_stride, fast_fetch_r5g6b5, fast_write_back_r5g6b5 },
+      _pixman_iter_init_bits_stride,
+      fast_fetch_r5g6b5, fast_write_back_r5g6b5 },
     
     { PIXMAN_r5g6b5, FAST_PATH_STD_DEST_FLAGS,
       ITER_NARROW | ITER_DEST | ITER_IGNORE_RGB | ITER_IGNORE_ALPHA,
-      iter_init_bits_stride, fast_dest_fetch_noop, fast_write_back_r5g6b5 },
+      _pixman_iter_init_bits_stride,
+      fast_dest_fetch_noop, fast_write_back_r5g6b5 },
 
     { PIXMAN_null },
 };
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index 861b856..c94d282 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -3922,17 +3922,6 @@ mmx_fetch_a8 (pixman_iter_t *iter, const uint32_t *mask)
     return iter->buffer;
 }
 
-static void
-iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info)
-{
-    pixman_image_t *image = iter->image;
-    uint8_t *b = (uint8_t *)image->bits.bits;
-    int s = image->bits.rowstride * 4;
-
-    iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (info->format) / 8;
-    iter->stride = s;
-}
-
 #define IMAGE_FLAGS							\
     (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM |		\
      FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST)
@@ -3940,13 +3929,13 @@ iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info)
 static const pixman_iter_info_t mmx_iters[] = 
 {
     { PIXMAN_x8r8g8b8, IMAGE_FLAGS, ITER_NARROW,
-      iter_init_bits_stride, mmx_fetch_x8r8g8b8, NULL
+      _pixman_iter_init_bits_stride, mmx_fetch_x8r8g8b8, NULL
     },
     { PIXMAN_r5g6b5, IMAGE_FLAGS, ITER_NARROW,
-      iter_init_bits_stride, mmx_fetch_r5g6b5, NULL
+      _pixman_iter_init_bits_stride, mmx_fetch_r5g6b5, NULL
     },
     { PIXMAN_a8, IMAGE_FLAGS, ITER_NARROW,
-      iter_init_bits_stride, mmx_fetch_a8, NULL
+      _pixman_iter_init_bits_stride, mmx_fetch_a8, NULL
     },
     { PIXMAN_null },
 };
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index aa0a842..af4a0b6 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -652,6 +652,9 @@ _pixman_compute_composite_region32 (pixman_region32_t * region,
 uint32_t *
 _pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask);
 
+void
+_pixman_iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info);
+
 /* These "formats" all have depth 0, so they
  * will never clash with any real ones
  */
diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index bc834b5..dde9235 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -6340,17 +6340,6 @@ sse2_fetch_a8 (pixman_iter_t *iter, const uint32_t *mask)
     return iter->buffer;
 }
 
-static void
-iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info)
-{
-    pixman_image_t *image = iter->image;
-    uint8_t *b = (uint8_t *)image->bits.bits;
-    int s = image->bits.rowstride * 4;
-
-    iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (info->format) / 8;
-    iter->stride = s;
-}
-
 #define IMAGE_FLAGS							\
     (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM |		\
      FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST)
@@ -6358,13 +6347,13 @@ iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info)
 static const pixman_iter_info_t sse2_iters[] = 
 {
     { PIXMAN_x8r8g8b8, IMAGE_FLAGS, ITER_NARROW,
-      iter_init_bits_stride, sse2_fetch_x8r8g8b8, NULL
+      _pixman_iter_init_bits_stride, sse2_fetch_x8r8g8b8, NULL
     },
     { PIXMAN_r5g6b5, IMAGE_FLAGS, ITER_NARROW,
-      iter_init_bits_stride, sse2_fetch_r5g6b5, NULL
+      _pixman_iter_init_bits_stride, sse2_fetch_r5g6b5, NULL
     },
     { PIXMAN_a8, IMAGE_FLAGS, ITER_NARROW,
-      iter_init_bits_stride, sse2_fetch_a8, NULL
+      _pixman_iter_init_bits_stride, sse2_fetch_a8, NULL
     },
     { PIXMAN_null },
 };
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index f31171f..98723a8 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -214,6 +214,17 @@ _pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask)
     return iter->buffer;
 }
 
+void
+_pixman_iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info)
+{
+    pixman_image_t *image = iter->image;
+    uint8_t *b = (uint8_t *)image->bits.bits;
+    int s = image->bits.rowstride * 4;
+
+    iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (info->format) / 8;
+    iter->stride = s;
+}
+
 #define N_TMP_BOXES (16)
 
 pixman_bool_t
-- 
1.7.11.7



More information about the Pixman mailing list