[gimp/metadata-browser] app: use GeglBufferIterator in gimp_channel_real_is_empty()



commit 9bc30305de528fd61f4062255a1e79382bad8d25
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 17 00:06:04 2012 +0100

    app: use GeglBufferIterator in gimp_channel_real_is_empty()

 app/core/gimpchannel.c |   33 +++++++++++++++------------------
 1 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 44cadb8..0b7f64f 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1195,34 +1195,31 @@ gimp_channel_real_bounds (GimpChannel *channel,
 static gboolean
 gimp_channel_real_is_empty (GimpChannel *channel)
 {
-  PixelRegion  maskPR;
-  guchar      *data;
-  gint         x, y;
-  gpointer     pr;
+  GeglBuffer         *buffer;
+  GeglBufferIterator *iter;
 
   if (channel->bounds_known)
     return channel->empty;
 
-  pixel_region_init (&maskPR,
-                     gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
-                     0, 0,
-                     gimp_item_get_width  (GIMP_ITEM (channel)),
-                     gimp_item_get_height (GIMP_ITEM (channel)), FALSE);
+  buffer = gimp_drawable_get_read_buffer (GIMP_DRAWABLE (channel));
 
-  for (pr = pixel_regions_register (1, &maskPR);
-       pr != NULL;
-       pr = pixel_regions_process (pr))
+  iter = gegl_buffer_iterator_new (buffer, NULL, babl_format ("Y u8"),
+                                   GEGL_BUFFER_READ);
+
+  while (gegl_buffer_iterator_next (iter))
     {
-      /*  check if any pixel in the channel is non-zero  */
-      data = maskPR.data;
+      guchar *data = iter->data[0];
+      gint    i;
 
-      for (y = 0; y < maskPR.h; y++)
-        for (x = 0; x < maskPR.w; x++)
-          if (*data++)
+      for (i = 0; i < iter->length; i++)
+        {
+          if (data[i])
             {
-              pixel_regions_process_stop (pr);
+              gegl_buffer_iterator_stop (iter);
+
               return FALSE;
             }
+        }
     }
 
   /*  The mask is empty, meaning we can set the bounds as known  */



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