From: Søren Sandmann Pedersen <s...@redhat.com>

As in the blt commit, do the delegation in pixman-implementation.c
whenever the implementation fill returns FALSE instead of relying on
each implementation to do it by itself.

With this change there is no longer any reason for the implementations
to have one fill function that delegates and one that actually blits,
so consolidate those in the NEON, DSPr2, SSE2, and MMX
implementations.
---
 pixman/pixman-arm-neon.c       |   35 +++++--------------
 pixman/pixman-fast-path.c      |    4 +--
 pixman/pixman-general.c        |   15 --------
 pixman/pixman-implementation.c |   30 +++++++---------
 pixman/pixman-mips-dspr2.c     |   35 +++++--------------
 pixman/pixman-mmx.c            |   45 +++++++------------------
 pixman/pixman-sse2.c           |   71 ++++++++++++++-------------------------
 7 files changed, 71 insertions(+), 164 deletions(-)

diff --git a/pixman/pixman-arm-neon.c b/pixman/pixman-arm-neon.c
index f4cc0ba..60e9c78 100644
--- a/pixman/pixman-arm-neon.c
+++ b/pixman/pixman-arm-neon.c
@@ -183,14 +183,15 @@ pixman_composite_src_n_8888_asm_neon (int32_t   w,
                                       uint32_t  src);
 
 static pixman_bool_t
-pixman_fill_neon (uint32_t *bits,
-                  int       stride,
-                  int       bpp,
-                  int       x,
-                  int       y,
-                  int       width,
-                  int       height,
-                  uint32_t  _xor)
+arm_neon_fill (pixman_implementation_t *imp,
+               uint32_t *               bits,
+               int                      stride,
+               int                      bpp,
+               int                      x,
+               int                      y,
+               int                      width,
+               int                      height,
+              uint32_t                 _xor)
 {
     /* stride is always multiple of 32bit units in pixman */
     uint32_t byte_stride = stride * sizeof(uint32_t);
@@ -423,24 +424,6 @@ static const pixman_fast_path_t arm_neon_fast_paths[] =
     { PIXMAN_OP_NONE },
 };
 
-static pixman_bool_t
-arm_neon_fill (pixman_implementation_t *imp,
-               uint32_t *               bits,
-               int                      stride,
-               int                      bpp,
-               int                      x,
-               int                      y,
-               int                      width,
-               int                      height,
-               uint32_t xor)
-{
-    if (pixman_fill_neon (bits, stride, bpp, x, y, width, height, xor))
-       return TRUE;
-
-    return _pixman_implementation_fill (
-       imp->delegate, bits, stride, bpp, x, y, width, height, xor);
-}
-
 #define BIND_COMBINE_U(name)                                             \
 void                                                                     \
 pixman_composite_scanline_##name##_mask_asm_neon (int32_t         w,     \
diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index 9778b0c..d26f6e7 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -2192,9 +2192,7 @@ fast_path_fill (pixman_implementation_t *imp,
        break;
 
     default:
-       return _pixman_implementation_fill (
-           imp->delegate, bits, stride, bpp, x, y, width, height, xor);
-       break;
+       return FALSE;
     }
 
     return TRUE;
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index dcf9bfc..6c6bda0 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -200,20 +200,6 @@ static const pixman_fast_path_t general_fast_path[] =
     { PIXMAN_OP_NONE }
 };
 
-static pixman_bool_t
-general_fill (pixman_implementation_t *imp,
-              uint32_t *               bits,
-              int                      stride,
-              int                      bpp,
-              int                      x,
-              int                      y,
-              int                      width,
-              int                      height,
-              uint32_t xor)
-{
-    return FALSE;
-}
-
 pixman_implementation_t *
 _pixman_implementation_create_general (void)
 {
@@ -222,7 +208,6 @@ _pixman_implementation_create_general (void)
     _pixman_setup_combiner_functions_32 (imp);
     _pixman_setup_combiner_functions_64 (imp);
 
-    imp->fill = general_fill;
     imp->src_iter_init = general_src_iter_init;
     imp->dest_iter_init = general_dest_iter_init;
 
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index 8b07848..5607f9d 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -27,21 +27,6 @@
 #include <stdlib.h>
 #include "pixman-private.h"
 
-static pixman_bool_t
-delegate_fill (pixman_implementation_t *imp,
-               uint32_t *               bits,
-               int                      stride,
-               int                      bpp,
-               int                      x,
-               int                      y,
-               int                      width,
-               int                      height,
-               uint32_t                 xor)
-{
-    return _pixman_implementation_fill (
-       imp->delegate, bits, stride, bpp, x, y, width, height, xor);
-}
-
 static void
 delegate_src_iter_init (pixman_implementation_t *imp,
                        pixman_iter_t *          iter)
@@ -77,7 +62,7 @@ _pixman_implementation_create (pixman_implementation_t 
*delegate,
     /* Fill out function pointers with ones that just delegate
      */
     imp->blt = NULL;
-    imp->fill = delegate_fill;
+    imp->fill = NULL;
     imp->src_iter_init = delegate_src_iter_init;
     imp->dest_iter_init = delegate_dest_iter_init;
 
@@ -174,7 +159,18 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
                              int                      height,
                              uint32_t                 xor)
 {
-    return (*imp->fill) (imp, bits, stride, bpp, x, y, width, height, xor);
+    while (imp)
+    {
+       if (imp->fill &&
+           ((*imp->fill) (imp, bits, stride, bpp, x, y, width, height, xor)))
+       {
+           return TRUE;
+       }
+
+       imp = imp->delegate;
+    }
+
+    return FALSE;
 }
 
 void
diff --git a/pixman/pixman-mips-dspr2.c b/pixman/pixman-mips-dspr2.c
index 7c4ac60..1a9e610 100644
--- a/pixman/pixman-mips-dspr2.c
+++ b/pixman/pixman-mips-dspr2.c
@@ -85,14 +85,15 @@ PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_A8_DST (SKIP_ZERO_SRC, 
8888_8_8888, ADD,
                                              uint32_t, uint32_t)
 
 static pixman_bool_t
-pixman_fill_mips (uint32_t *bits,
-                  int       stride,
-                  int       bpp,
-                  int       x,
-                  int       y,
-                  int       width,
-                  int       height,
-                  uint32_t  _xor)
+mips_dspr2_fill (pixman_implementation_t *imp,
+                 uint32_t *               bits,
+                 int                      stride,
+                 int                      bpp,
+                 int                      x,
+                 int                      y,
+                 int                      width,
+                 int                      height,
+                 uint32_t                 _xor)
 {
     uint8_t *byte_line;
     uint32_t byte_width;
@@ -267,24 +268,6 @@ static const pixman_fast_path_t mips_dspr2_fast_paths[] =
     { PIXMAN_OP_NONE },
 };
 
-static pixman_bool_t
-mips_dspr2_fill (pixman_implementation_t *imp,
-                 uint32_t *               bits,
-                 int                      stride,
-                 int                      bpp,
-                 int                      x,
-                 int                      y,
-                 int                      width,
-                 int                      height,
-                 uint32_t xor)
-{
-    if (pixman_fill_mips (bits, stride, bpp, x, y, width, height, xor))
-        return TRUE;
-
-    return _pixman_implementation_fill (
-        imp->delegate, bits, stride, bpp, x, y, width, height, xor);
-}
-
 pixman_implementation_t *
 _pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback)
 {
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index 0379462..5deb9a4 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -2054,15 +2054,16 @@ mmx_composite_over_n_8_8888 (pixman_implementation_t 
*imp,
     _mm_empty ();
 }
 
-pixman_bool_t
-pixman_fill_mmx (uint32_t *bits,
-                 int       stride,
-                 int       bpp,
-                 int       x,
-                 int       y,
-                 int       width,
-                 int       height,
-                 uint32_t xor)
+static pixman_bool_t
+mmx_fill (pixman_implementation_t *imp,
+          uint32_t *               bits,
+          int                      stride,
+          int                      bpp,
+          int                      x,
+          int                      y,
+          int                      width,
+          int                      height,
+          uint32_t                xor)
 {
     uint64_t fill;
     __m64 vfill;
@@ -2280,9 +2281,9 @@ mmx_composite_src_n_8_8888 (pixman_implementation_t *imp,
     srca = src >> 24;
     if (src == 0)
     {
-       pixman_fill_mmx (dest_image->bits.bits, dest_image->bits.rowstride,
-                        PIXMAN_FORMAT_BPP (dest_image->bits.format),
-                        dest_x, dest_y, width, height, 0);
+       mmx_fill (imp, dest_image->bits.bits, dest_image->bits.rowstride,
+                 PIXMAN_FORMAT_BPP (dest_image->bits.format),
+                 dest_x, dest_y, width, height, 0);
        return;
     }
 
@@ -4042,26 +4043,6 @@ static const pixman_fast_path_t mmx_fast_paths[] =
     { PIXMAN_OP_NONE },
 };
 
-static pixman_bool_t
-mmx_fill (pixman_implementation_t *imp,
-          uint32_t *               bits,
-          int                      stride,
-          int                      bpp,
-          int                      x,
-          int                      y,
-          int                      width,
-          int                      height,
-          uint32_t xor)
-{
-    if (!pixman_fill_mmx (bits, stride, bpp, x, y, width, height, xor))
-    {
-       return _pixman_implementation_fill (
-           imp->delegate, bits, stride, bpp, x, y, width, height, xor);
-    }
-
-    return TRUE;
-}
-
 pixman_implementation_t *
 _pixman_implementation_create_mmx (pixman_implementation_t *fallback)
 {
diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index 42c0e99..428db73 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -3309,18 +3309,22 @@ sse2_composite_over_n_8_8888 (pixman_implementation_t 
*imp,
 
 }
 
+#if defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
+__attribute__((__force_align_arg_pointer__))
+#endif
 static pixman_bool_t
-pixman_fill_sse2 (uint32_t *bits,
-                  int       stride,
-                  int       bpp,
-                  int       x,
-                  int       y,
-                  int       width,
-                  int       height,
-                  uint32_t  data)
+sse2_fill (pixman_implementation_t *imp,
+           uint32_t *               bits,
+           int                      stride,
+           int                      bpp,
+           int                      x,
+           int                      y,
+           int                      width,
+           int                      height,
+           uint32_t                xor)
 {
     uint32_t byte_width;
-    uint8_t         *byte_line;
+    uint8_t *byte_line;
 
     __m128i xmm_def;
 
@@ -3334,9 +3338,9 @@ pixman_fill_sse2 (uint32_t *bits,
        byte_width = width;
        stride *= 1;
 
-       b = data & 0xff;
+       b = xor & 0xff;
        w = (b << 8) | b;
-       data = (w << 16) | w;
+       xor = (w << 16) | w;
     }
     else if (bpp == 16)
     {
@@ -3345,7 +3349,7 @@ pixman_fill_sse2 (uint32_t *bits,
        byte_width = 2 * width;
        stride *= 2;
 
-        data = (data & 0xffff) * 0x00010001;
+        xor = (xor & 0xffff) * 0x00010001;
     }
     else if (bpp == 32)
     {
@@ -3359,7 +3363,7 @@ pixman_fill_sse2 (uint32_t *bits,
        return FALSE;
     }
 
-    xmm_def = create_mask_2x32_128 (data, data);
+    xmm_def = create_mask_2x32_128 (xor, xor);
 
     while (height--)
     {
@@ -3370,21 +3374,21 @@ pixman_fill_sse2 (uint32_t *bits,
 
        if (w >= 1 && ((unsigned long)d & 1))
        {
-           *(uint8_t *)d = data;
+           *(uint8_t *)d = xor;
            w -= 1;
            d += 1;
        }
 
        while (w >= 2 && ((unsigned long)d & 3))
        {
-           *(uint16_t *)d = data;
+           *(uint16_t *)d = xor;
            w -= 2;
            d += 2;
        }
 
        while (w >= 4 && ((unsigned long)d & 15))
        {
-           *(uint32_t *)d = data;
+           *(uint32_t *)d = xor;
 
            w -= 4;
            d += 4;
@@ -3435,7 +3439,7 @@ pixman_fill_sse2 (uint32_t *bits,
 
        while (w >= 4)
        {
-           *(uint32_t *)d = data;
+           *(uint32_t *)d = xor;
 
            w -= 4;
            d += 4;
@@ -3443,14 +3447,14 @@ pixman_fill_sse2 (uint32_t *bits,
 
        if (w >= 2)
        {
-           *(uint16_t *)d = data;
+           *(uint16_t *)d = xor;
            w -= 2;
            d += 2;
        }
 
        if (w >= 1)
        {
-           *(uint8_t *)d = data;
+           *(uint8_t *)d = xor;
            w -= 1;
            d += 1;
        }
@@ -3479,9 +3483,9 @@ sse2_composite_src_n_8_8888 (pixman_implementation_t *imp,
     srca = src >> 24;
     if (src == 0)
     {
-       pixman_fill_sse2 (dest_image->bits.bits, dest_image->bits.rowstride,
-                         PIXMAN_FORMAT_BPP (dest_image->bits.format),
-                         dest_x, dest_y, width, height, 0);
+       sse2_fill (imp, dest_image->bits.bits, dest_image->bits.rowstride,
+                  PIXMAN_FORMAT_BPP (dest_image->bits.format),
+                  dest_x, dest_y, width, height, 0);
        return;
     }
 
@@ -5878,29 +5882,6 @@ static const pixman_fast_path_t sse2_fast_paths[] =
     { PIXMAN_OP_NONE },
 };
 
-#if defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
-__attribute__((__force_align_arg_pointer__))
-#endif
-static pixman_bool_t
-sse2_fill (pixman_implementation_t *imp,
-           uint32_t *               bits,
-           int                      stride,
-           int                      bpp,
-           int                      x,
-           int                      y,
-           int                      width,
-           int                      height,
-           uint32_t xor)
-{
-    if (!pixman_fill_sse2 (bits, stride, bpp, x, y, width, height, xor))
-    {
-       return _pixman_implementation_fill (
-           imp->delegate, bits, stride, bpp, x, y, width, height, xor);
-    }
-
-    return TRUE;
-}
-
 static uint32_t *
 sse2_fetch_x8r8g8b8 (pixman_iter_t *iter, const uint32_t *mask)
 {
-- 
1.7.4

_______________________________________________
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman

Reply via email to