Add a noop src iterator
authorSøren Sandmann Pedersen <ssp@redhat.com>
Wed, 9 Feb 2011 04:42:36 +0000 (23:42 -0500)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Thu, 19 May 2011 13:46:56 +0000 (13:46 +0000)
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

index e54272b..aaffbde 100644 (file)
@@ -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;