[Pixman] [PATCH 08/18] Virtualize iterator initialization

Søren Sandmann sandmann at cs.au.dk
Wed Jan 5 18:09:46 PST 2011


From: Søren Sandmann Pedersen <ssp at redhat.com>

Make iter_init() a virtual method in the implementation struct. This
allows individual implementations to plug in their own CPU specific
scanline fetchers.
---
 pixman/pixman-general.c        |   42 ++++++++++++++----------------------
 pixman/pixman-implementation.c |   46 +++++++++++++++++++++++++++++++++++++++-
 pixman/pixman-private.h        |   21 ++++++++++++++++++
 3 files changed, 82 insertions(+), 27 deletions(-)

diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index f75e7b3..4f73331 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 *
-get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
-{
-    return NULL;
-}
-
 static void
-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_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,12 +52,7 @@ iter_init (pixman_implementation_t *imp,
     iter->width = width;
     iter->buffer = (uint32_t *)buffer;
 
-    if (!image)
-    {
-	iter->get_scanline = get_scanline_null;
-	iter->next_line = _pixman_iter_next_line_noop;
-    }
-    else if (image->type == SOLID)
+    if (image->type == SOLID)
     {
 	_pixman_solid_fill_iter_init (
 	    image, iter, x, y, width, height, buffer, flags);
@@ -146,17 +135,17 @@ general_composite_rect  (pixman_implementation_t *imp,
     mask_buffer = src_buffer + width * Bpp;
     dest_buffer = mask_buffer + width * Bpp;
 
-    iter_init (imp->toplevel, &src_iter, src,
-	       src_x, src_y, width, height,
-	       src_buffer, narrow);
+    _pixman_implementation_iter_init (imp->toplevel, &src_iter, src,
+				      src_x, src_y, width, height,
+				      src_buffer, narrow);
 
-    iter_init (imp->toplevel, &mask_iter, mask,
-	       mask_x, mask_y, width, height,
-	       mask_buffer, narrow);
+    _pixman_implementation_iter_init (imp->toplevel, &mask_iter, mask,
+				      mask_x, mask_y, width, height,
+				      mask_buffer, narrow);
 
-    iter_init (imp->toplevel, &dest_iter, dest,
-	       dest_x, dest_y, width, height,
-	       dest_buffer, narrow | ITER_WRITE);
+    _pixman_implementation_iter_init (imp->toplevel, &dest_iter, dest,
+				      dest_x, dest_y, width, height,
+				      dest_buffer, narrow | ITER_WRITE);
 
     component_alpha =
         mask                            &&
@@ -251,6 +240,7 @@ _pixman_implementation_create_general (void)
 
     imp->blt = general_blt;
     imp->fill = general_fill;
+    imp->iter_init = general_iter_init;
 
     return imp;
 }
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index bc3749e..1aa28d1 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -111,6 +111,21 @@ delegate_fill (pixman_implementation_t *imp,
 	imp->delegate, bits, stride, bpp, x, y, width, height, xor);
 }
 
+static void
+delegate_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_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 +148,7 @@ _pixman_implementation_create (pixman_implementation_t *delegate,
      */
     imp->blt = delegate_blt;
     imp->fill = delegate_fill;
+    imp->iter_init = delegate_iter_init;
 
     for (i = 0; i < PIXMAN_N_OPERATORS; ++i)
     {
@@ -143,7 +159,7 @@ _pixman_implementation_create (pixman_implementation_t *delegate,
     }
 
     imp->fast_paths = fast_paths;
-    
+
     return imp;
 }
 
@@ -225,3 +241,31 @@ _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_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;
+	iter->next_line = _pixman_iter_next_line_noop;
+    }
+    else
+    {
+	(*imp->iter_init) (
+	    imp, iter, image, x, y, width, height, buffer, flags);
+    }
+}
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 6f61d32..c4194fe 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -431,6 +431,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);
@@ -455,6 +464,7 @@ struct pixman_implementation_t
     
     pixman_blt_func_t		blt;
     pixman_fill_func_t		fill;
+    pixman_iter_init_func_t     iter_init;
 
     pixman_combine_32_func_t	combine_32[PIXMAN_N_OPERATORS];
     pixman_combine_32_func_t	combine_32_ca[PIXMAN_N_OPERATORS];
@@ -521,6 +531,17 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
                              int                      height,
                              uint32_t                 xor);
 
+void
+_pixman_implementation_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



More information about the Pixman mailing list