[Pixman] [PATCH 3/6] Move noop dest fetching to noop implementation

Søren Sandmann Pedersen sandmann at cs.au.dk
Tue May 3 04:42:44 PDT 2011


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

It will at some point become useful to have CPU specific destination
iterators. However, a problem with that is that such iterators should
not be used if we can composite directly in the destination image.

By moving the noop destination iterator to the noop implementation, we
can ensure that it will be chosen before any CPU specific iterator.
---
 pixman/pixman-bits-image.c |   31 +++++--------------------------
 pixman/pixman-noop.c       |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 835ecfb..4e9ed14 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -1462,43 +1462,22 @@ dest_write_back_wide (pixman_iter_t *iter)
     iter->y++;
 }
 
-static void
-dest_write_back_direct (pixman_iter_t *iter)
-{
-    iter->buffer += iter->image->bits.rowstride;
-}
-
 void
 _pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter)
 {
     if (iter->flags & ITER_NARROW)
     {
-	if (((image->common.flags &
-	      (FAST_PATH_NO_ALPHA_MAP | FAST_PATH_NO_ACCESSORS)) ==
-	     (FAST_PATH_NO_ALPHA_MAP | FAST_PATH_NO_ACCESSORS)) &&
-	    (image->bits.format == PIXMAN_a8r8g8b8	||
-	     (image->bits.format == PIXMAN_x8r8g8b8	&&
-	      (iter->flags & ITER_LOCALIZED_ALPHA))))
+	if ((iter->flags & (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) ==
+	    (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA))
 	{
-	    iter->buffer = image->bits.bits + iter->y * image->bits.rowstride + iter->x;
-
 	    iter->get_scanline = _pixman_iter_get_scanline_noop;
-	    iter->write_back = dest_write_back_direct;
 	}
 	else
 	{
-	    if ((iter->flags & (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) ==
-		(ITER_IGNORE_RGB | ITER_IGNORE_ALPHA))
-	    {
-		iter->get_scanline = _pixman_iter_get_scanline_noop;
-	    }
-	    else
-	    {
-		iter->get_scanline = dest_get_scanline_narrow;
-	    }
-
-	    iter->write_back = dest_write_back_narrow;
+	    iter->get_scanline = dest_get_scanline_narrow;
 	}
+	
+	iter->write_back = dest_write_back_narrow;
     }
     else
     {
diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c
index 673a02a..d753843 100644
--- a/pixman/pixman-noop.c
+++ b/pixman/pixman-noop.c
@@ -48,6 +48,36 @@ noop_composite (pixman_implementation_t *imp,
     return;
 }
 
+static void
+dest_write_back_direct (pixman_iter_t *iter)
+{
+    iter->buffer += iter->image->bits.rowstride;
+}
+
+static void
+noop_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
+{
+    pixman_image_t *image = iter->image;
+    uint32_t image_flags = image->common.flags;
+    uint32_t iter_flags = iter->flags;
+	
+    if ((image_flags & FAST_PATH_STD_DEST_FLAGS) == FAST_PATH_STD_DEST_FLAGS	&&
+	(iter_flags & ITER_NARROW) == ITER_NARROW				&&
+	((image->common.extended_format_code == PIXMAN_a8r8g8b8)	||
+	 (image->common.extended_format_code == PIXMAN_x8r8g8b8 &&
+	  (iter_flags & (ITER_LOCALIZED_ALPHA)))))
+    {
+	iter->buffer = image->bits.bits + iter->y * image->bits.rowstride + iter->x;
+	
+	iter->get_scanline = _pixman_iter_get_scanline_noop;
+	iter->write_back = dest_write_back_direct;
+    }
+    else
+    {
+	(* imp->delegate->dest_iter_init) (imp->delegate, iter);
+    }
+}
+
 static const pixman_fast_path_t noop_fast_paths[] =
 {
     { PIXMAN_OP_DST, PIXMAN_any, 0, PIXMAN_any, 0, PIXMAN_any, 0, noop_composite },
@@ -60,5 +90,7 @@ _pixman_implementation_create_noop (pixman_implementation_t *fallback)
     pixman_implementation_t *imp =
 	_pixman_implementation_create (fallback, noop_fast_paths);
 
+    imp->dest_iter_init = noop_dest_iter_init;
+    
     return imp;
 }
-- 
1.7.4



More information about the Pixman mailing list