[Pixman] [PATCH 4/6] Add a noop src iterator

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


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

When the image is a8r8g8b8 and not transformed, and the fetched
rectangle is within the image bounds, scanlines can be fetched by
simply returning a pointer instead of copying the bits.
---
 pixman/pixman-noop.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c
index d753843..5dc528d 100644
--- a/pixman/pixman-noop.c
+++ b/pixman/pixman-noop.c
@@ -54,6 +54,44 @@ dest_write_back_direct (pixman_iter_t *iter)
     iter->buffer += iter->image->bits.rowstride;
 }
 
+static uint32_t *
+noop_get_scanline (pixman_iter_t *iter, const uint32_t *mask)
+{
+    uint32_t *result = iter->buffer;
+
+    iter->buffer += iter->image->bits.rowstride;
+
+    return result;
+}
+
+static void
+noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
+{
+    pixman_image_t *image = iter->image;
+    uint32_t iter_flags = iter->flags;
+    uint32_t image_flags = image->common.flags;
+
+#define FLAGS						\
+    (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM)
+
+    if ((iter_flags & ITER_NARROW)					&&
+	(image_flags & FLAGS) == FLAGS					&&
+	iter->x >= 0 && iter->y >= 0					&&
+	iter->x + iter->width <= image->bits.width			&&
+	iter->y + iter->height <= image->bits.height			&&
+	image->common.extended_format_code == PIXMAN_a8r8g8b8)
+    {
+	iter->buffer =
+	    image->bits.bits + iter->y * image->bits.rowstride + iter->x;
+
+	iter->get_scanline = noop_get_scanline;
+    }
+    else
+    {
+	(* imp->delegate->src_iter_init) (imp->delegate, iter);
+    }
+}
+
 static void
 noop_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
 {
@@ -90,6 +128,7 @@ _pixman_implementation_create_noop (pixman_implementation_t *fallback)
     pixman_implementation_t *imp =
 	_pixman_implementation_create (fallback, noop_fast_paths);
 
+    imp->src_iter_init = noop_src_iter_init;
     imp->dest_iter_init = noop_dest_iter_init;
     
     return imp;
-- 
1.7.4



More information about the Pixman mailing list