gegl r1880 - in trunk: . gegl/process



Author: neo
Date: Mon Jan 21 12:12:58 2008
New Revision: 1880
URL: http://svn.gnome.org/viewvc/gegl?rev=1880&view=rev

Log:
2008-01-21  Sven Neumann  <sven gimp org>

	* gegl/process/gegl-processor.c: redid the change that introduces
	the use of GSlice for GeglRectangle; this time without the bug.


Modified:
   trunk/ChangeLog
   trunk/gegl/process/gegl-processor.c

Modified: trunk/gegl/process/gegl-processor.c
==============================================================================
--- trunk/gegl/process/gegl-processor.c	(original)
+++ trunk/gegl/process/gegl-processor.c	Mon Jan 21 12:12:58 2008
@@ -218,24 +218,21 @@
 gegl_processor_set_rectangle (GeglProcessor       *processor,
                               const GeglRectangle *rectangle)
 {
-  GeglRectangle bounds;
+  GSList        *iter;
+  GeglRectangle  bounds;
 
   if (gegl_rectangle_equal (&processor->rectangle, rectangle))
-    {
-      return;
-    }
+    return;
 
   bounds               = gegl_node_get_bounding_box (processor->input);
   processor->rectangle = *rectangle;
   gegl_rectangle_intersect (&processor->rectangle, &processor->rectangle, &bounds);
 
   /* remove already queued dirty rectangles */
-  while (processor->dirty_rectangles)
-    {
-      GeglRectangle *rect = processor->dirty_rectangles->data;
-      processor->dirty_rectangles = g_slist_remove (processor->dirty_rectangles, rect);
-      g_free (rect);
-    }
+  for (iter = processor->dirty_rectangles; iter; iter = g_slist_next (iter))
+    g_slice_free (GeglRectangle, iter->data);
+  g_slist_free (processor->dirty_rectangles);
+  processor->dirty_rectangles = NULL;
 }
 
 GeglProcessor *
@@ -325,8 +322,7 @@
               if (band_size < 1)
                 band_size = 1;
 
-              fragment = g_malloc (sizeof (GeglRectangle));
-              *fragment = *dr;
+              fragment = g_slice_dup (GeglRectangle, dr);
 
               fragment->height = band_size;
               dr->height      -= band_size;
@@ -344,8 +340,7 @@
               if (band_size < 1)
                 band_size = 1;
 
-              fragment = g_malloc (sizeof (GeglRectangle));
-              *fragment = *dr;
+              fragment = g_slice_dup (GeglRectangle, dr);
 
               fragment->width = band_size;
               dr->width      -= band_size;
@@ -360,7 +355,7 @@
 
       if (!dr->width || !dr->height)
         {
-          g_free (dr);
+          g_slice_free (GeglRectangle, dr);
           return TRUE;
         }
 
@@ -380,7 +375,8 @@
 
           g_free (buf);
         }
-      g_free (dr);
+
+      g_slice_free (GeglRectangle, dr);
     }
 
   return processor->dirty_rectangles != NULL;
@@ -408,8 +404,7 @@
               if (band_size < 1)
                 band_size = 1;
 
-              fragment = g_malloc (sizeof (GeglRectangle));
-              *fragment = *dr;
+              fragment = g_slice_dup (GeglRectangle, dr);
 
               fragment->height = band_size;
               dr->height      -= band_size;
@@ -427,8 +422,7 @@
               if (band_size < 1)
                 band_size = 1;
 
-              fragment = g_malloc (sizeof (GeglRectangle));
-              *fragment = *dr;
+              fragment = g_slice_dup (GeglRectangle, dr);
 
               fragment->width = band_size;
               dr->width      -= band_size;
@@ -442,13 +436,13 @@
 
       if (!dr->width || !dr->height)
         {
-          g_free (dr);
+          g_slice_free (GeglRectangle, dr);
           return TRUE;
         }
 
       gegl_node_blit (processor->node, 1.0, dr, NULL, NULL, GEGL_AUTO_ROWSTRIDE, GEGL_BLIT_DEFAULT);
       gegl_region_union_with_rect (processor->valid_region, dr);
-      g_free (dr);
+      g_slice_free (GeglRectangle, dr);
     }
 
   return processor->dirty_rectangles != NULL;
@@ -486,6 +480,7 @@
       sum += rect_area (&rectangles[i]);
     }
   g_free (rectangles);
+
   return sum;
 }
 
@@ -600,14 +595,12 @@
       for (i = 0; i < n_rectangles && i < 1; i++)
         {
           GeglRectangle  roi = rectangles[i];
-          GeglRectangle *dr;
-          GeglRegion    *tr = gegl_region_rectangle(&roi);
+          GeglRegion    *tr = gegl_region_rectangle (&roi);
           gegl_region_subtract (processor->queued_region, tr);
           gegl_region_destroy (tr);
 
-          dr                          = g_malloc (sizeof (GeglRectangle));
-          *dr                         = roi;
-          processor->dirty_rectangles = g_slist_prepend (processor->dirty_rectangles, dr);
+          processor->dirty_rectangles = g_slist_prepend (processor->dirty_rectangles,
+                                                         g_slice_dup (GeglRectangle, &roi));
         }
       g_free (rectangles);
 
@@ -634,14 +627,12 @@
       for (i = 0; i < n_rectangles && i < 1; i++)
         {
           GeglRectangle  roi = rectangles[i];
-          GeglRectangle *dr;
           GeglRegion    *tr = gegl_region_rectangle (&roi);
           gegl_region_subtract (processor->queued_region, tr);
           gegl_region_destroy (tr);
 
-          dr                          = g_malloc (sizeof (GeglRectangle));
-          *dr                         = roi;
-          processor->dirty_rectangles = g_slist_prepend (processor->dirty_rectangles, dr);
+          processor->dirty_rectangles = g_slist_prepend (processor->dirty_rectangles,
+                                                         g_slice_dup (GeglRectangle, &roi));
         }
       g_free (rectangles);
     }



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