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

Make src_iter_init() and dest_iter_init() virtual methods in the
implementation struct. This allows individual implementations to plug
in their own CPU specific scanline fetchers.
---
 pixman/pixman-general.c        |   52 +++++++++++----------------
 pixman/pixman-implementation.c |   76 +++++++++++++++++++++++++++++++++++++++-
 pixman/pixman-private.h        |   35 ++++++++++++++++++-
 3 files changed, 131 insertions(+), 32 deletions(-)

diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 4b837fa..e2f1dc3 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -39,18 +39,12 @@
 #include "pixman-combine32.h"
 #include "pixman-private.h"
 
-static uint32_t *
-src_get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
-{
-    return NULL;
-}
-
 static void
-src_iter_init (pixman_implementation_t *imp,
-              pixman_iter_t *iter,
-              pixman_image_t *image,
-              int x, int y, int width, int height,
-              uint8_t *buffer, iter_flags_t flags)
+general_src_iter_init (pixman_implementation_t *imp,
+                      pixman_iter_t *iter,
+                      pixman_image_t *image,
+                      int x, int y, int width, int height,
+                      uint8_t *buffer, iter_flags_t flags)
 {
     iter->image = image;
     iter->x = x;
@@ -58,11 +52,7 @@ src_iter_init (pixman_implementation_t *imp,
     iter->width = width;
     iter->buffer = (uint32_t *)buffer;
 
-    if (!image)
-    {
-       iter->get_scanline = src_get_scanline_null;
-    }
-    else if (image->type == SOLID)
+    if (image->type == SOLID)
     {
        _pixman_solid_fill_iter_init (
            image, iter, x, y, width, height, buffer, flags);
@@ -94,11 +84,11 @@ src_iter_init (pixman_implementation_t *imp,
 }
 
 static void
-dest_iter_init (pixman_implementation_t *imp,
-               pixman_iter_t *iter,
-               pixman_image_t *image,
-               int x, int y, int width, int height,
-               uint8_t *buffer, iter_flags_t flags)
+general_dest_iter_init (pixman_implementation_t *imp,
+                       pixman_iter_t *iter,
+                       pixman_image_t *image,
+                       int x, int y, int width, int height,
+                       uint8_t *buffer, iter_flags_t flags)
 {
     iter->image = image;
     iter->x = x;
@@ -169,17 +159,17 @@ general_composite_rect  (pixman_implementation_t *imp,
     mask_buffer = src_buffer + width * Bpp;
     dest_buffer = mask_buffer + width * Bpp;
 
-    src_iter_init (imp->toplevel, &src_iter, src,
-                  src_x, src_y, width, height,
-                  src_buffer, narrow);
+    _pixman_implementation_src_iter_init (imp->toplevel, &src_iter, src,
+                                         src_x, src_y, width, height,
+                                         src_buffer, narrow);
 
-    src_iter_init (imp->toplevel, &mask_iter, mask,
-                  mask_x, mask_y, width, height,
-                  mask_buffer, narrow);
+    _pixman_implementation_src_iter_init (imp->toplevel, &mask_iter, mask,
+                                         mask_x, mask_y, width, height,
+                                         mask_buffer, narrow);
 
-    dest_iter_init (imp->toplevel, &dest_iter, dest,
-                   dest_x, dest_y, width, height,
-                   dest_buffer, narrow);
+    _pixman_implementation_dest_iter_init (imp->toplevel, &dest_iter, dest,
+                                          dest_x, dest_y, width, height,
+                                          dest_buffer, narrow);
 
     component_alpha =
         mask                            &&
@@ -272,6 +262,8 @@ _pixman_implementation_create_general (void)
 
     imp->blt = general_blt;
     imp->fill = general_fill;
+    imp->src_iter_init = general_src_iter_init;
+    imp->dest_iter_init = general_dest_iter_init;
 
     return imp;
 }
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index bc3749e..e633432 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -111,6 +111,36 @@ delegate_fill (pixman_implementation_t *imp,
        imp->delegate, bits, stride, bpp, x, y, width, height, xor);
 }
 
+static void
+delegate_src_iter_init (pixman_implementation_t *imp,
+                       pixman_iter_t *          iter,
+                       pixman_image_t *         image,
+                       int                      x,
+                       int                      y,
+                       int                      width,
+                       int                      height,
+                       uint8_t *                buffer,
+                       iter_flags_t             flags)
+{
+    _pixman_implementation_src_iter_init (
+       imp->delegate, iter, image, x, y, width, height, buffer, flags);
+}
+
+static void
+delegate_dest_iter_init (pixman_implementation_t *imp,
+                        pixman_iter_t *          iter,
+                        pixman_image_t *         image,
+                        int                      x,
+                        int                      y,
+                        int                      width,
+                        int                      height,
+                        uint8_t *                buffer,
+                        iter_flags_t             flags)
+{
+    _pixman_implementation_dest_iter_init (
+       imp->delegate, iter, image, x, y, width, height, buffer, flags);
+}
+
 pixman_implementation_t *
 _pixman_implementation_create (pixman_implementation_t *delegate,
                               const pixman_fast_path_t *fast_paths)
@@ -133,6 +163,8 @@ _pixman_implementation_create (pixman_implementation_t 
*delegate,
      */
     imp->blt = delegate_blt;
     imp->fill = delegate_fill;
+    imp->src_iter_init = delegate_src_iter_init;
+    imp->dest_iter_init = delegate_dest_iter_init;
 
     for (i = 0; i < PIXMAN_N_OPERATORS; ++i)
     {
@@ -143,7 +175,7 @@ _pixman_implementation_create (pixman_implementation_t 
*delegate,
     }
 
     imp->fast_paths = fast_paths;
-    
+
     return imp;
 }
 
@@ -225,3 +257,45 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
     return (*imp->fill) (imp, bits, stride, bpp, x, y, width, height, xor);
 }
 
+static uint32_t *
+get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
+{
+    return NULL;
+}
+
+void
+_pixman_implementation_src_iter_init (pixman_implementation_t  *imp,
+                                     pixman_iter_t             *iter,
+                                     pixman_image_t            *image,
+                                     int                        x,
+                                     int                        y,
+                                     int                        width,
+                                     int                        height,
+                                     uint8_t                   *buffer,
+                                     iter_flags_t               flags)
+{
+    if (!image)
+    {
+       iter->get_scanline = get_scanline_null;
+    }
+    else
+    {
+       (*imp->src_iter_init) (
+           imp, iter, image, x, y, width, height, buffer, flags);
+    }
+}
+
+void
+_pixman_implementation_dest_iter_init (pixman_implementation_t *imp,
+                                      pixman_iter_t            *iter,
+                                      pixman_image_t           *image,
+                                      int                       x,
+                                      int                       y,
+                                      int                       width,
+                                      int                       height,
+                                      uint8_t                  *buffer,
+                                      iter_flags_t              flags)
+{
+    (*imp->dest_iter_init) (
+       imp, iter, image, x, y, width, height, buffer, flags);
+}
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 5a32c22..852e0fd 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -436,6 +436,15 @@ typedef pixman_bool_t (*pixman_fill_func_t) 
(pixman_implementation_t *imp,
                                             int                      width,
                                             int                      height,
                                             uint32_t                 xor);
+typedef void (*pixman_iter_init_func_t) (pixman_implementation_t *imp,
+                                         pixman_iter_t           *iter,
+                                         pixman_image_t          *image,
+                                         int                      x,
+                                         int                      y,
+                                         int                      width,
+                                         int                      height,
+                                         uint8_t                 *buffer,
+                                         iter_flags_t             flags);
 
 void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
 void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp);
@@ -457,9 +466,11 @@ struct pixman_implementation_t
     pixman_implementation_t *  toplevel;
     pixman_implementation_t *  delegate;
     const pixman_fast_path_t * fast_paths;
-    
+
     pixman_blt_func_t          blt;
     pixman_fill_func_t         fill;
+    pixman_iter_init_func_t     src_iter_init;
+    pixman_iter_init_func_t     dest_iter_init;
 
     pixman_combine_32_func_t   combine_32[PIXMAN_N_OPERATORS];
     pixman_combine_32_func_t   combine_32_ca[PIXMAN_N_OPERATORS];
@@ -526,6 +537,28 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
                              int                      height,
                              uint32_t                 xor);
 
+void
+_pixman_implementation_src_iter_init (pixman_implementation_t       *imp,
+                                     pixman_iter_t                 *iter,
+                                     pixman_image_t                *image,
+                                     int                            x,
+                                     int                            y,
+                                     int                            width,
+                                     int                            height,
+                                     uint8_t                       *buffer,
+                                     iter_flags_t                   flags);
+
+void
+_pixman_implementation_dest_iter_init (pixman_implementation_t       *imp,
+                                      pixman_iter_t                 *iter,
+                                      pixman_image_t                *image,
+                                      int                            x,
+                                      int                            y,
+                                      int                            width,
+                                      int                            height,
+                                      uint8_t                       *buffer,
+                                      iter_flags_t                   flags);
+
 /* Specific implementations */
 pixman_implementation_t *
 _pixman_implementation_create_general (void);
-- 
1.6.0.6

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

Reply via email to