[gegl/newiter] Revert "buffer: clean up cow-copy check"



commit ad4cf8fa966dc84fcc92c2a493434f0438346bc0
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Tue Sep 10 12:25:25 2013 -0700

    Revert "buffer: clean up cow-copy check"
    
    New logic was not correct.
    
    This reverts commit d72e10831b040b59fff594f1ce3769e3d7c7c9fd.

 gegl/buffer/gegl-buffer-access.c  |   45 ++++++++++++++++++++++++------------
 gegl/buffer/gegl-buffer-private.h |    8 +++++-
 2 files changed, 36 insertions(+), 17 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index ec4efb9..752b063 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1741,11 +1741,14 @@ gegl_buffer_copy (GeglBuffer          *src,
     }
 
 
-  if (src_rect->width  >= src->tile_width    &&
-      src_rect->height >= src->tile_height   &&
-      gegl_buffer_tile_compatible (src, dst) &&
+  if (src->soft_format == dst->soft_format &&
+      src_rect->width >= src->tile_width &&
+      src_rect->height >= src->tile_height &&
+      src->tile_width == dst->tile_width  &&
+      src->tile_height == dst->tile_height &&
       !g_object_get_data (G_OBJECT (dst), "is-linear") &&
-      !g_object_get_data (G_OBJECT (src), "is-linear"))
+      gegl_buffer_scan_compatible (src, src_rect->x, src_rect->y,
+                                   dst, dst_rect->x, dst_rect->y))
     {
       GeglRectangle dest_rect_r = *dst_rect;
 
@@ -2115,17 +2118,29 @@ gegl_buffer_dup (GeglBuffer *buffer)
   return new_buffer;
 }
 
-
-/* Returns true if tiles can be shared between buffer src & dst */
-gboolean gegl_buffer_tile_compatible (GeglBuffer *src,
-                                      GeglBuffer *dst)
+/*
+ *  check whether iterations on two buffers starting from the given coordinates with
+ *  the same width and height would be able to run parallell.
+ */
+gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
+                                      gint        xA,
+                                      gint        yA,
+                                      GeglBuffer *bufferB,
+                                      gint        xB,
+                                      gint        yB)
 {
-  return (src->soft_format == dst->soft_format &&
-          src->tile_width  == dst->tile_width  &&
-          src->tile_height == dst->tile_height &&
-          src->shift_x % src->tile_width  == 0 &&
-          src->shift_y % src->tile_height == 0 &&
-          dst->shift_x % dst->tile_width  == 0 &&
-          dst->shift_y % dst->tile_height == 0);
+  if (bufferA->tile_storage->tile_width !=
+      bufferB->tile_storage->tile_width)
+    return FALSE;
+  if (bufferA->tile_storage->tile_height !=
+      bufferB->tile_storage->tile_height)
+    return FALSE;
+  if ( (abs((bufferA->shift_x+xA) - (bufferB->shift_x+xB))
+        % bufferA->tile_storage->tile_width) != 0)
+    return FALSE;
+  if ( (abs((bufferA->shift_y+yA) - (bufferB->shift_y+yB))
+        % bufferA->tile_storage->tile_height) != 0)
+    return FALSE;
+  return TRUE;
 }
 
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index e0f7d3c..546f4b0 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -186,8 +186,12 @@ struct _GeglTile
 
 void _gegl_buffer_drop_hot_tile (GeglBuffer *buffer);
 
-gboolean gegl_buffer_tile_compatible (GeglBuffer *src,
-                                      GeglBuffer *dst);
+gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
+                                      gint        xA,
+                                      gint        yA,
+                                      GeglBuffer *bufferB,
+                                      gint        xB,
+                                      gint        yB);
 
 
 #ifndef __GEGL_TILE_C


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