Split fill implementations out in the implementations
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Wed, 13 May 2009 15:24:28 +0000 (11:24 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 23 May 2009 16:05:02 +0000 (12:05 -0400)
pixman/pixman-fast-path.c
pixman/pixman-general.c
pixman/pixman-implementation.c
pixman/pixman-mmx.c
pixman/pixman-pict.c
pixman/pixman-private.h
pixman/pixman-sse2.c
pixman/pixman-utils.c

index 8025233..c24258e 100644 (file)
@@ -1223,6 +1223,112 @@ fast_path_composite (pixman_implementation_t *imp,
                                      width, height);
 }
 
+static void
+pixman_fill8 (uint32_t  *bits,
+             int       stride,
+             int       x,
+             int       y,
+             int       width,
+             int       height,
+             uint32_t  xor)
+{
+    int byte_stride = stride * (int) sizeof (uint32_t);
+    uint8_t *dst = (uint8_t *) bits;
+    uint8_t v = xor & 0xff;
+    int i;
+
+    dst = dst + y * byte_stride + x;
+
+    while (height--)
+    {
+       for (i = 0; i < width; ++i)
+           dst[i] = v;
+
+       dst += byte_stride;
+    }
+}
+
+static void
+pixman_fill16 (uint32_t *bits,
+              int       stride,
+              int       x,
+              int       y,
+              int       width,
+              int       height,
+              uint32_t  xor)
+{
+    int short_stride = (stride * (int) sizeof (uint32_t)) / (int) sizeof (uint16_t);
+    uint16_t *dst = (uint16_t *)bits;
+    uint16_t v = xor & 0xffff;
+    int i;
+
+    dst = dst + y * short_stride + x;
+
+    while (height--)
+    {
+       for (i = 0; i < width; ++i)
+           dst[i] = v;
+
+       dst += short_stride;
+    }
+}
+
+static void
+pixman_fill32 (uint32_t *bits,
+              int       stride,
+              int       x,
+              int       y,
+              int       width,
+              int       height,
+              uint32_t  xor)
+{
+    int i;
+
+    bits = bits + y * stride + x;
+
+    while (height--)
+    {
+       for (i = 0; i < width; ++i)
+           bits[i] = xor;
+
+       bits += stride;
+    }
+}
+
+static pixman_bool_t
+fast_path_fill (pixman_implementation_t *imp,
+               uint32_t *bits,
+               int stride,
+               int bpp,
+               int x,
+               int y,
+               int width,
+               int height,
+               uint32_t xor)
+{
+    switch (bpp)
+    {
+    case 8:
+       pixman_fill8 (bits, stride, x, y, width, height, xor);
+       break;
+       
+    case 16:
+       pixman_fill16 (bits, stride, x, y, width, height, xor);
+       break;
+       
+    case 32:
+       pixman_fill32 (bits, stride, x, y, width, height, xor);
+       break;
+       
+    default:
+       return _pixman_implementation_fill (
+           imp->delegate, bits, stride, bpp, x, y, width, height, xor);
+       break;
+    }
+    
+    return TRUE;
+}
+
 pixman_implementation_t *
 _pixman_implementation_create_fast_path (pixman_implementation_t *toplevel)
 {
@@ -1230,6 +1336,7 @@ _pixman_implementation_create_fast_path (pixman_implementation_t *toplevel)
     pixman_implementation_t *imp = _pixman_implementation_create (toplevel, general);
 
     imp->composite = fast_path_composite;
+    imp->fill = fast_path_fill;
     
     return imp;
 }
index e8a0b75..4693823 100644 (file)
@@ -454,6 +454,20 @@ general_blt (pixman_implementation_t *imp,
     return FALSE;
 }
 
+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 (pixman_implementation_t *toplevel)
 {
@@ -469,6 +483,7 @@ _pixman_implementation_create_general (pixman_implementation_t *toplevel)
     }
     imp->composite = general_composite;
     imp->blt = general_blt;
-
+    imp->fill = general_fill;
+    
     return imp;
 }
index ca4cbdc..5fa16e8 100644 (file)
@@ -117,6 +117,20 @@ delegate_blt (pixman_implementation_t *    imp,
                                       width, height);
 }
 
+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);
+}
+
 pixman_implementation_t *
 _pixman_implementation_create (pixman_implementation_t *toplevel,
                               pixman_implementation_t *delegate)
@@ -141,6 +155,7 @@ _pixman_implementation_create (pixman_implementation_t *toplevel,
      */
     imp->composite = delegate_composite;
     imp->blt = delegate_blt;
+    imp->fill = delegate_fill;
     
     for (i = 0; i < PIXMAN_OP_LAST; ++i)
     {
@@ -237,3 +252,17 @@ _pixman_implementation_blt (pixman_implementation_t *      imp,
                         src_bpp, dst_bpp, src_x, src_y, dst_x, dst_y,
                         width, height);
 }
+
+pixman_bool_t
+_pixman_implementation_fill (pixman_implementation_t *imp,
+                            uint32_t *bits,
+                            int stride,
+                            int bpp,
+                            int x,
+                            int y,
+                            int width,
+                            int height,
+                            uint32_t xor)
+{
+    return (* imp->fill) (imp->delegate, bits, stride, bpp, x, y, width, height, xor);
+}
index 1fe8aa7..c12ba53 100644 (file)
@@ -3194,6 +3194,26 @@ mmx_blt (pixman_implementation_t *imp,
     return TRUE;
 }
 
+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 *toplevel)
 {
@@ -3226,6 +3246,7 @@ _pixman_implementation_create_mmx (pixman_implementation_t *toplevel)
 
     imp->composite = mmx_composite;
     imp->blt = mmx_blt;
+    imp->fill = mmx_fill;
     
     return imp;
 }
index 658ac70..17bd566 100644 (file)
@@ -136,3 +136,40 @@ pixman_image_composite (pixman_op_t      op,
                                      dest_x, dest_y,
                                      width, height);
 }
+
+PIXMAN_EXPORT pixman_bool_t
+pixman_blt (uint32_t *src_bits,
+           uint32_t *dst_bits,
+           int src_stride,
+           int dst_stride,
+           int src_bpp,
+           int dst_bpp,
+           int src_x, int src_y,
+           int dst_x, int dst_y,
+           int width, int height)
+{
+    if (!imp)
+       imp = _pixman_choose_implementation();
+    
+    return _pixman_implementation_blt (imp, src_bits, dst_bits, src_stride, dst_stride,
+                                      src_bpp, dst_bpp,
+                                      src_x, src_y,
+                                      dst_x, dst_y,
+                                      width, height);
+}
+
+PIXMAN_EXPORT pixman_bool_t
+pixman_fill (uint32_t *bits,
+            int stride,
+            int bpp,
+            int x,
+            int y,
+            int width,
+            int height,
+            uint32_t xor)
+{
+    if (!imp)
+       imp = _pixman_choose_implementation();
+
+    return _pixman_implementation_fill (imp, bits, stride, bpp, x, y, width, height, xor);
+}
index ac47dc4..adee672 100644 (file)
@@ -908,6 +908,15 @@ typedef pixman_bool_t (* pixman_blt_func_t) (pixman_implementation_t *     imp,
                                             int                        dst_y,
                                             int                        width,
                                             int                        height);
+typedef pixman_bool_t (* pixman_fill_func_t) (pixman_implementation_t *imp,
+                                             uint32_t *bits,
+                                             int stride,
+                                             int bpp,
+                                             int x,
+                                             int y,
+                                             int width,
+                                             int height,
+                                             uint32_t xor);
 
 void
 _pixman_walk_composite_region (pixman_implementation_t *imp,
@@ -956,6 +965,7 @@ struct pixman_implementation_t
 
     pixman_composite_func_t    composite;
     pixman_blt_func_t          blt;
+    pixman_fill_func_t         fill;
     
     pixman_combine_32_func_t   combine_32[PIXMAN_OP_LAST];
     pixman_combine_32_func_t   combine_32_ca[PIXMAN_OP_LAST];
@@ -1024,7 +1034,17 @@ _pixman_implementation_blt (pixman_implementation_t *    imp,
                            int                         dst_y,
                            int                         width,
                            int                         height);
-
+pixman_bool_t
+_pixman_implementation_fill (pixman_implementation_t *   imp,
+                            uint32_t *bits,
+                            int stride,
+                            int bpp,
+                            int x,
+                            int y,
+                            int width,
+                            int height,
+                            uint32_t xor);
+    
 /* Specific implementations */
 pixman_implementation_t *
 _pixman_implementation_create_general (pixman_implementation_t *toplevel);
index f6e1055..a2a5bb0 100644 (file)
@@ -5016,6 +5016,27 @@ sse2_blt (pixman_implementation_t *imp,
     return TRUE;
 }
 
+__attribute__((__force_align_arg_pointer__))
+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 (!pixmanFillsse2 (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_sse2 (pixman_implementation_t *toplevel)
 {
@@ -5080,6 +5101,7 @@ _pixman_implementation_create_sse2 (pixman_implementation_t *toplevel)
     
     imp->composite = sse2_composite;
     imp->blt = sse2_blt;
+    imp->fill = sse2_fill;
     
     return imp;
 }
index a9e00a6..5c43e64 100644 (file)
 #include "pixman-mmx.h"
 #include "pixman-sse2.h"
 
-static void
-pixman_fill8 (uint32_t  *bits,
-             int       stride,
-             int       x,
-             int       y,
-             int       width,
-             int       height,
-             uint32_t  xor)
-{
-    int byte_stride = stride * (int) sizeof (uint32_t);
-    uint8_t *dst = (uint8_t *) bits;
-    uint8_t v = xor & 0xff;
-    int i;
-
-    dst = dst + y * byte_stride + x;
-
-    while (height--)
-    {
-       for (i = 0; i < width; ++i)
-           dst[i] = v;
-
-       dst += byte_stride;
-    }
-}
-
-static void
-pixman_fill16 (uint32_t *bits,
-              int       stride,
-              int       x,
-              int       y,
-              int       width,
-              int       height,
-              uint32_t  xor)
-{
-    int short_stride = (stride * (int) sizeof (uint32_t)) / (int) sizeof (uint16_t);
-    uint16_t *dst = (uint16_t *)bits;
-    uint16_t v = xor & 0xffff;
-    int i;
-
-    dst = dst + y * short_stride + x;
-
-    while (height--)
-    {
-       for (i = 0; i < width; ++i)
-           dst[i] = v;
-
-       dst += short_stride;
-    }
-}
-
-static void
-pixman_fill32 (uint32_t *bits,
-              int       stride,
-              int       x,
-              int       y,
-              int       width,
-              int       height,
-              uint32_t  xor)
-{
-    int i;
-
-    bits = bits + y * stride + x;
-
-    while (height--)
-    {
-       for (i = 0; i < width; ++i)
-           bits[i] = xor;
-
-       bits += stride;
-    }
-}
-
-#if defined(USE_SSE2) && defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
-__attribute__((__force_align_arg_pointer__))
-#endif
-PIXMAN_EXPORT pixman_bool_t
-pixman_fill (uint32_t *bits,
-            int stride,
-            int bpp,
-            int x,
-            int y,
-            int width,
-            int height,
-            uint32_t xor)
-{
-#if 0
-    printf ("filling: %d %d %d %d (stride: %d, bpp: %d)   pixel: %x\n",
-           x, y, width, height, stride, bpp, xor);
-#endif
-
-#ifdef USE_SSE2
-    if (pixman_have_sse2() && pixmanFillsse2 (bits, stride, bpp, x, y, width, height, xor))
-       return TRUE;
-#endif
-
-#ifdef USE_MMX
-    if (pixman_have_mmx() && pixman_fill_mmx (bits, stride, bpp, x, y, width, height, xor))
-       return TRUE;
-#endif
-    
-    switch (bpp)
-    {
-    case 8:
-       pixman_fill8 (bits, stride, x, y, width, height, xor);
-       break;
-       
-    case 16:
-       pixman_fill16 (bits, stride, x, y, width, height, xor);
-       break;
-       
-    case 32:
-       pixman_fill32 (bits, stride, x, y, width, height, xor);
-       break;
-       
-    default:
-       return FALSE;
-       break;
-    }
-
-    return TRUE;
-}
-
-
 /*
  * Compute the smallest value no less than y which is on a
  * grid row