[gimp] Speed up the gegl projection by a factor of about 4



commit 9af87c83aa7865a7fb598bb9b7f4562f0310c7b8
Author: Michael Natterer <mitch gimp org>
Date:   Thu Jun 11 22:22:11 2009 +0200

    Speed up the gegl projection by a factor of about 4
    
    (gimp_projection_validate_tile): validate a strip of up to 8 invalid
    tiles at once to reduce whatever overhead inflicted on gegl.

 app/core/gimpprojection.c |   57 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 53 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c
index c6f209f..3b761b8 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -22,6 +22,8 @@
 #include "core-types.h"
 
 #include "base/tile.h"
+#include "base/tile-rowhints.h" /* EEK */
+#include "base/tile-private.h"  /* EEK */
 #include "base/tile-manager.h"
 #include "base/tile-pyramid.h"
 
@@ -746,14 +748,61 @@ gimp_projection_validate_tile (TileManager    *tm,
                                Tile           *tile,
                                GimpProjection *proj)
 {
-  gint x, y;
+  Tile *additional[7];
+  gint  n_additional = 0;
+  gint  x, y;
+  gint  width, height;
+  gint  tile_width, tile_height;
+  gint  col, row;
+  gint  i;
 
   /*  Find the coordinates of this tile  */
   tile_manager_get_tile_coordinates (tm, tile, &x, &y);
 
-  gimp_projection_construct (proj,
-                             x, y,
-                             tile_ewidth (tile), tile_eheight (tile));
+  width  = tile_width  = tile_ewidth (tile);
+  height = tile_height = tile_eheight (tile);
+
+  tile_manager_get_tile_col_row (tm, tile, &col, &row);
+
+  /*  try to validate up to 8 invalid tiles in a row  */
+  while (tile_width == TILE_WIDTH && n_additional < 7)
+    {
+      Tile *t;
+
+      col++;
+
+      /*  get the next tile without any read or write access, so it
+       *  won't be locked (and validated)
+       */
+      t = tile_manager_get_at (tm, col, row, FALSE, FALSE);
+
+      if (t)
+        {
+          if (tile_is_valid (t))
+            break;
+
+          /*  HACK: mark the tile as valid, so locking it with r/w access
+           *  won't validate it
+           */
+          t->valid = TRUE;
+          t = tile_manager_get_at (tm, col, row, TRUE, TRUE);
+
+          /*  add the tile's width to the chunk to validate  */
+          tile_width = tile_ewidth (t);
+          width += tile_width;
+
+          additional[n_additional++] = t;
+        }
+    }
+
+  gimp_projection_construct (proj, x, y, width, height);
+
+  for (i = 0; i < n_additional; i++)
+    {
+      /*  HACK: mark the tile as valid, because we know it is  */
+      additional[i]->valid = TRUE;
+      tile_release (additional[i], TRUE);
+    }
 }
 
 /*  image callbacks  */



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