[gegl/wip/pippin] buffer: optimizations for column fetching



commit beda596559d4df80a92cc5444ad0ff2c2f578fbb
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Dec 27 09:21:49 2017 +0100

    buffer: optimizations for column fetching

 gegl/buffer/gegl-buffer-access.c |   62 +++++++++++++++++++++++++++++--------
 1 files changed, 48 insertions(+), 14 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index abfcc56..bf37f38 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -638,19 +638,31 @@ gegl_buffer_iterate_read_simple (GeglBuffer          *buffer,
           tile_base = gegl_tile_get_data (tile);
           tp        = ((guchar *) tile_base) + (offsety * tile_width + offsetx) * px_size;
 
+          if (fish)
+          {
           y = bufy;
           for (row = offsety;
                row < tile_height && y < height;
                row++, y++)
             {
-              if (fish)
-                babl_process (fish, tp, bp, pixels);
-              else
-                memcpy (bp, tp, pixels * px_size);
+              babl_process (fish, tp, bp, pixels);
 
               tp += tile_stride;
               bp += buf_stride;
             }
+          }
+          else
+          {
+            y = bufy;
+            for (row = offsety;
+                 row < tile_height && y < height;
+                 row++, y++)
+              {
+                 memcpy (bp, tp, pixels * px_size);
+                 tp += tile_stride;
+                 bp += buf_stride;
+              }
+          }
 
           gegl_tile_unref (tile);
           bufx += (tile_width - offsetx);
@@ -1421,13 +1433,35 @@ _gegl_buffer_get_unlocked (GeglBuffer          *buffer,
 
   if (GEGL_FLOAT_EQUAL (scale, 1.0) &&
       rect &&
-      rect->width == 1 &&
-      rect->height == 1)
-    {
-      gegl_buffer_get_pixel (buffer, rect->x, rect->y, format, dest_buf,
-                             repeat_mode);
-      return;
-    }
+      rect->width == 1)
+  {
+    if (rect->height == 1)
+      {
+        gegl_buffer_get_pixel (buffer, rect->x, rect->y, format, dest_buf,
+                               repeat_mode);
+        return;
+      }
+    else
+      {
+        gint buf_bpp = babl_format_get_bytes_per_pixel (buffer->soft_format);
+
+        if (buffer->format == format)
+        {
+          gegl_buffer_iterate_read_dispatch (buffer, rect, dest_buf,
+                                             rowstride, format, 0, repeat_mode);
+        }
+        else
+        {
+          uint8_t tmp[rect->width * rect->height * buf_bpp];
+          gegl_buffer_iterate_read_dispatch (buffer, rect, &tmp[0],
+                                             rowstride, buffer->soft_format,
+                                             0, repeat_mode);
+          babl_process (babl_fish (buffer->soft_format, format),
+                        &tmp[0], dest_buf, rect->height);
+        }
+        return;
+      }
+  }
 
   if (!rect && GEGL_FLOAT_EQUAL (scale, 1.0))
     {
@@ -1480,7 +1514,7 @@ _gegl_buffer_get_unlocked (GeglBuffer          *buffer,
       sample_rect.width  = factor * (x2 - x1);
       sample_rect.height = factor * (y2 - y1);
 
-      if (scale == 1.0)
+      if (GEGL_FLOAT_EQUAL (scale, 1.0))
         {
           gegl_buffer_iterate_read_dispatch (buffer, &sample_rect,
                                              (guchar*)dest_buf, rowstride,
@@ -1500,7 +1534,7 @@ _gegl_buffer_get_unlocked (GeglBuffer          *buffer,
           buf_height += 2;
           offset = (buf_width + 1) * bpp;
           sample_buf = g_malloc0 (buf_height * buf_width * bpp);
-          
+
           gegl_buffer_iterate_read_dispatch (buffer, &sample_rect,
                                          (guchar*)sample_buf + offset,
                                          buf_width * bpp,
@@ -1524,7 +1558,7 @@ _gegl_buffer_get_unlocked (GeglBuffer          *buffer,
       else if (buf_height && buf_width)
         {
           sample_buf = g_malloc (buf_height * buf_width * bpp);
-          
+
           gegl_buffer_iterate_read_dispatch (buffer, &sample_rect,
                                          (guchar*)sample_buf,
                                          buf_width * bpp,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]