[gegl] operations: add progress to color-enhance and stretch-contrast-hsv
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations: add progress to color-enhance and stretch-contrast-hsv
- Date: Tue, 28 Mar 2017 20:34:08 +0000 (UTC)
commit a0a1fcc6ef336f47872a6258dcca9067d94461b0
Author: Michael Natterer <mitch gimp org>
Date: Tue Mar 28 22:33:01 2017 +0200
operations: add progress to color-enhance and stretch-contrast-hsv
they take way too long to process the entire buffer.
operations/common/color-enhance.c | 48 ++++++++++++++++++++++++++----
operations/common/stretch-contrast-hsv.c | 35 +++++++++++++++++++--
2 files changed, 73 insertions(+), 10 deletions(-)
---
diff --git a/operations/common/color-enhance.c b/operations/common/color-enhance.c
index a2423f1..a148bbd 100644
--- a/operations/common/color-enhance.c
+++ b/operations/common/color-enhance.c
@@ -35,13 +35,19 @@
#include "gegl-op.h"
static void
-buffer_get_min_max (GeglBuffer *buffer,
- gdouble *min,
- gdouble *max)
+buffer_get_min_max (GeglOperation *operation,
+ GeglBuffer *buffer,
+ const GeglRectangle *result,
+ gdouble *min,
+ gdouble *max)
{
GeglBufferIterator *gi;
+ gint done_pixels = 0;
- gi = gegl_buffer_iterator_new (buffer, NULL, 0, babl_format ("CIE LCH(ab) float"),
+ gegl_operation_progress (operation, 0.0, "");
+
+ gi = gegl_buffer_iterator_new (buffer, result, 0,
+ babl_format ("CIE LCH(ab) float"),
GEGL_ACCESS_READ, GEGL_ABYSS_NONE);
*min = G_MAXDOUBLE;
@@ -58,7 +64,16 @@ buffer_get_min_max (GeglBuffer *buffer,
*max = MAX (buf[1], *max);
buf += 3;
}
+
+ done_pixels += gi->length;
+
+ gegl_operation_progress (operation,
+ (gdouble) 0.5 * done_pixels /
+ (gdouble) (result->width * result->height),
+ "");
}
+
+ gegl_operation_progress (operation, 0.5, "");
}
static void prepare (GeglOperation *operation)
@@ -119,11 +134,14 @@ process (GeglOperation *operation,
const Babl *format = gegl_operation_get_format (operation, "output");
gboolean has_alpha = babl_format_has_alpha (format);
GeglBufferIterator *gi;
+ gint done_pixels = 0;
gdouble min;
gdouble max;
gdouble delta;
- buffer_get_min_max (input, &min, &max);
+ buffer_get_min_max (operation, input, result, &min, &max);
+
+ gegl_operation_progress (operation, 0.5, "");
gi = gegl_buffer_iterator_new (input, result, 0, format,
GEGL_ACCESS_READ, GEGL_ABYSS_NONE);
@@ -158,7 +176,15 @@ process (GeglOperation *operation,
in += 4;
out += 4;
}
- }
+
+ done_pixels += gi->length;
+
+ gegl_operation_progress (operation,
+ 0.5 +
+ (gdouble) 0.5 * done_pixels /
+ (gdouble) (result->width * result->height),
+ "");
+ }
}
else
{
@@ -177,9 +203,19 @@ process (GeglOperation *operation,
in += 3;
out += 3;
}
+
+ done_pixels += gi->length;
+
+ gegl_operation_progress (operation,
+ 0.5 +
+ (gdouble) 0.5 * done_pixels /
+ (gdouble) (result->width * result->height),
+ "");
}
}
+ gegl_operation_progress (operation, 1.0, "");
+
return TRUE;
}
diff --git a/operations/common/stretch-contrast-hsv.c b/operations/common/stretch-contrast-hsv.c
index be56647..632b6ad 100644
--- a/operations/common/stretch-contrast-hsv.c
+++ b/operations/common/stretch-contrast-hsv.c
@@ -41,8 +41,10 @@ typedef struct {
} AutostretchData;
static void
-buffer_get_auto_stretch_data (GeglBuffer *buffer,
- AutostretchData *data)
+buffer_get_auto_stretch_data (GeglOperation *operation,
+ GeglBuffer *buffer,
+ const GeglRectangle *result,
+ AutostretchData *data)
{
gfloat smin = G_MAXFLOAT;
gfloat smax = -G_MAXFLOAT;
@@ -50,8 +52,11 @@ buffer_get_auto_stretch_data (GeglBuffer *buffer,
gfloat vmax = -G_MAXFLOAT;
GeglBufferIterator *gi;
+ gint done_pixels = 0;
- gi = gegl_buffer_iterator_new (buffer, NULL, 0, babl_format ("HSVA float"),
+ gegl_operation_progress (operation, 0.0, "");
+
+ gi = gegl_buffer_iterator_new (buffer, result, 0, babl_format ("HSVA float"),
GEGL_ACCESS_READ, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (gi))
@@ -71,6 +76,13 @@ buffer_get_auto_stretch_data (GeglBuffer *buffer,
buf += 4;
}
+
+ done_pixels += gi->length;
+
+ gegl_operation_progress (operation,
+ (gdouble) 0.5 * done_pixels /
+ (gdouble) (result->width * result->height),
+ "");
}
if (data)
@@ -80,6 +92,8 @@ buffer_get_auto_stretch_data (GeglBuffer *buffer,
data->vlo = vmin;
data->vdiff = vmax - vmin;
}
+
+ gegl_operation_progress (operation, 0.5, "");
}
static void
@@ -140,10 +154,13 @@ process (GeglOperation *operation,
{
AutostretchData data;
GeglBufferIterator *gi;
+ gint done_pixels = 0;
- buffer_get_auto_stretch_data (input, &data);
+ buffer_get_auto_stretch_data (operation, input, result, &data);
clean_autostretch_data (&data);
+ gegl_operation_progress (operation, 0.5, "");
+
gi = gegl_buffer_iterator_new (input, result, 0, babl_format ("HSVA float"),
GEGL_ACCESS_READ, GEGL_ABYSS_NONE);
@@ -166,8 +183,18 @@ process (GeglOperation *operation,
in += 4;
out += 4;
}
+
+ done_pixels += gi->length;
+
+ gegl_operation_progress (operation,
+ 0.5 +
+ (gdouble) 0.5 * done_pixels /
+ (gdouble) (result->width * result->height),
+ "");
}
+ gegl_operation_progress (operation, 1.0, "");
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]