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



commit d72e10831b040b59fff594f1ce3769e3d7c7c9fd
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Tue Sep 10 11:34:09 2013 -0700

    buffer: clean up cow-copy check

 gegl/buffer/gegl-buffer-access.c  |   45 ++++++++++++------------------------
 gegl/buffer/gegl-buffer-private.h |    8 +-----
 2 files changed, 17 insertions(+), 36 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 752b063..ec4efb9 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1741,14 +1741,11 @@ gegl_buffer_copy (GeglBuffer          *src,
     }
 
 
-  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 &&
+  if (src_rect->width  >= src->tile_width    &&
+      src_rect->height >= src->tile_height   &&
+      gegl_buffer_tile_compatible (src, dst) &&
       !g_object_get_data (G_OBJECT (dst), "is-linear") &&
-      gegl_buffer_scan_compatible (src, src_rect->x, src_rect->y,
-                                   dst, dst_rect->x, dst_rect->y))
+      !g_object_get_data (G_OBJECT (src), "is-linear"))
     {
       GeglRectangle dest_rect_r = *dst_rect;
 
@@ -2118,29 +2115,17 @@ gegl_buffer_dup (GeglBuffer *buffer)
   return new_buffer;
 }
 
-/*
- *  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)
+
+/* Returns true if tiles can be shared between buffer src & dst */
+gboolean gegl_buffer_tile_compatible (GeglBuffer *src,
+                                      GeglBuffer *dst)
 {
-  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;
+  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);
 }
 
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 546f4b0..e0f7d3c 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -186,12 +186,8 @@ struct _GeglTile
 
 void _gegl_buffer_drop_hot_tile (GeglBuffer *buffer);
 
-gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
-                                      gint        xA,
-                                      gint        yA,
-                                      GeglBuffer *bufferB,
-                                      gint        xB,
-                                      gint        yB);
+gboolean gegl_buffer_tile_compatible (GeglBuffer *src,
+                                      GeglBuffer *dst);
 
 
 #ifndef __GEGL_TILE_C


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