[gimp] Bug 785535 - Histogram not updating in real when filters are active
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 785535 - Histogram not updating in real when filters are active
- Date: Sat, 5 Aug 2017 15:20:46 +0000 (UTC)
commit c41e8eca86df42bb92905b7be9670334d377709f
Author: Michael Natterer <mitch gimp org>
Date: Sat Aug 5 17:15:31 2017 +0200
Bug 785535 - Histogram not updating in real when filters are active
Add "gboolean with_filters" to gimp_drawable_calculate_histogram(),
which is passed as FALSE in almost all places, except the histogram
dockable where we want to see both the drawable's unmodified histogram
*and* the histogram after filters are applied.
app/core/gimpdrawable-equalize.c | 10 ++--
app/core/gimpdrawable-histogram.c | 70 +++++++++++++++++++++++++++++-----
app/core/gimpdrawable-histogram.h | 3 +-
app/core/gimpdrawable-levels.c | 2 +-
app/pdb/color-cmds.c | 2 +-
app/pdb/drawable-color-cmds.c | 2 +-
app/tools/gimpcurvestool.c | 2 +-
app/tools/gimplevelstool.c | 2 +-
app/tools/gimpthresholdtool.c | 2 +-
app/widgets/gimphistogrameditor.c | 10 +---
tools/pdbgen/pdb/color.pdb | 2 +-
tools/pdbgen/pdb/drawable_color.pdb | 2 +-
12 files changed, 77 insertions(+), 32 deletions(-)
---
diff --git a/app/core/gimpdrawable-equalize.c b/app/core/gimpdrawable-equalize.c
index 96dd937..1c03eb4 100644
--- a/app/core/gimpdrawable-equalize.c
+++ b/app/core/gimpdrawable-equalize.c
@@ -39,7 +39,7 @@ gimp_drawable_equalize (GimpDrawable *drawable,
{
GimpImage *image;
GimpChannel *selection;
- GimpHistogram *hist;
+ GimpHistogram *histogram;
GeglNode *equalize;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
@@ -48,12 +48,12 @@ gimp_drawable_equalize (GimpDrawable *drawable,
image = gimp_item_get_image (GIMP_ITEM (drawable));
selection = gimp_image_get_mask (image);
- hist = gimp_histogram_new (FALSE);
- gimp_drawable_calculate_histogram (drawable, hist);
+ histogram = gimp_histogram_new (FALSE);
+ gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
equalize = gegl_node_new_child (NULL,
"operation", "gimp:equalize",
- "histogram", hist,
+ "histogram", histogram,
NULL);
if (! mask_only)
@@ -67,5 +67,5 @@ gimp_drawable_equalize (GimpDrawable *drawable,
gimp_selection_resume (GIMP_SELECTION (selection));
g_object_unref (equalize);
- g_object_unref (hist);
+ g_object_unref (histogram);
}
diff --git a/app/core/gimpdrawable-histogram.c b/app/core/gimpdrawable-histogram.c
index 6bae432..b7b86b0 100644
--- a/app/core/gimpdrawable-histogram.c
+++ b/app/core/gimpdrawable-histogram.c
@@ -19,14 +19,17 @@
#include "config.h"
+#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "core-types.h"
#include "gegl/gimp-gegl-nodes.h"
+#include "gegl/gimptilehandlervalidate.h"
#include "gimpchannel.h"
+#include "gimpdrawable-filters.h"
#include "gimpdrawable-histogram.h"
#include "gimphistogram.h"
#include "gimpimage.h"
@@ -34,7 +37,8 @@
void
gimp_drawable_calculate_histogram (GimpDrawable *drawable,
- GimpHistogram *histogram)
+ GimpHistogram *histogram,
+ gboolean with_filters)
{
GimpImage *image;
GimpChannel *mask;
@@ -53,14 +57,21 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
if (FALSE)
{
GeglNode *node = gegl_node_new ();
- GeglNode *buffer_source;
+ GeglNode *source;
GeglNode *histogram_sink;
GeglProcessor *processor;
- buffer_source =
- gimp_gegl_add_buffer_source (node,
- gimp_drawable_get_buffer (drawable),
- 0, 0);
+ if (with_filters)
+ {
+ source = gimp_drawable_get_source_node (drawable);
+ }
+ else
+ {
+ source =
+ gimp_gegl_add_buffer_source (node,
+ gimp_drawable_get_buffer (drawable),
+ 0, 0);
+ }
histogram_sink =
gegl_node_new_child (node,
@@ -68,7 +79,7 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
"histogram", histogram,
NULL);
- gegl_node_connect_to (buffer_source, "output",
+ gegl_node_connect_to (source, "output",
histogram_sink, "input");
if (! gimp_channel_is_empty (mask))
@@ -99,14 +110,50 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
}
else
{
+ GeglBuffer *buffer = gimp_drawable_get_buffer (drawable);
+
+ if (with_filters && gimp_drawable_has_filters (drawable))
+ {
+ GimpTileHandlerValidate *validate;
+ GeglNode *node;
+
+ node = gimp_drawable_get_source_node (drawable);
+
+ buffer = gegl_buffer_new (gegl_buffer_get_extent (buffer),
+ gegl_buffer_get_format (buffer));
+
+ validate =
+ GIMP_TILE_HANDLER_VALIDATE (gimp_tile_handler_validate_new (node));
+
+ gimp_tile_handler_validate_assign (validate, buffer);
+
+ g_object_unref (validate);
+
+ gimp_tile_handler_validate_invalidate (validate,
+ gegl_buffer_get_extent (buffer));
+
+#if 0
+ /* this would keep the buffer updated across drawable or
+ * filter changes, but the histogram is created in one go
+ * and doesn't need the signal connection
+ */
+ g_signal_connect_object (node, "invalidated",
+ G_CALLBACK (gimp_tile_handler_validate_invalidate),
+ validate, G_CONNECT_SWAPPED);
+#endif
+ }
+ else
+ {
+ g_object_ref (buffer);
+ }
+
if (! gimp_channel_is_empty (mask))
{
gint off_x, off_y;
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
- gimp_histogram_calculate (histogram,
- gimp_drawable_get_buffer (drawable),
+ gimp_histogram_calculate (histogram, buffer,
GEGL_RECTANGLE (x, y, width, height),
gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)),
GEGL_RECTANGLE (x + off_x, y + off_y,
@@ -114,10 +161,11 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
}
else
{
- gimp_histogram_calculate (histogram,
- gimp_drawable_get_buffer (drawable),
+ gimp_histogram_calculate (histogram, buffer,
GEGL_RECTANGLE (x, y, width, height),
NULL, NULL);
}
+
+ g_object_unref (buffer);
}
}
diff --git a/app/core/gimpdrawable-histogram.h b/app/core/gimpdrawable-histogram.h
index a1f3c9c..49ef52e 100644
--- a/app/core/gimpdrawable-histogram.h
+++ b/app/core/gimpdrawable-histogram.h
@@ -22,7 +22,8 @@
void gimp_drawable_calculate_histogram (GimpDrawable *drawable,
- GimpHistogram *histogram);
+ GimpHistogram *histogram,
+ gboolean with_filters);
#endif /* __GIMP_HISTOGRAM_H__ */
diff --git a/app/core/gimpdrawable-levels.c b/app/core/gimpdrawable-levels.c
index daf85aa..8317f7f 100644
--- a/app/core/gimpdrawable-levels.c
+++ b/app/core/gimpdrawable-levels.c
@@ -54,7 +54,7 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
histogram = gimp_histogram_new (FALSE);
- gimp_drawable_calculate_histogram (drawable, histogram);
+ gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
gimp_levels_config_stretch (config, histogram,
gimp_drawable_is_rgb (drawable));
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index 1506425..2297f4d 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -647,7 +647,7 @@ histogram_invoker (GimpProcedure *procedure,
linear = FALSE;
histogram = gimp_histogram_new (linear);
- gimp_drawable_calculate_histogram (drawable, histogram);
+ gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
n_bins = gimp_histogram_n_bins (histogram);
diff --git a/app/pdb/drawable-color-cmds.c b/app/pdb/drawable-color-cmds.c
index f8b564e..30347b0 100644
--- a/app/pdb/drawable-color-cmds.c
+++ b/app/pdb/drawable-color-cmds.c
@@ -418,7 +418,7 @@ drawable_histogram_invoker (GimpProcedure *procedure,
linear = FALSE;
histogram = gimp_histogram_new (linear);
- gimp_drawable_calculate_histogram (drawable, histogram);
+ gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
n_bins = gimp_histogram_n_bins (histogram);
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 05d6269..60d8c99 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -195,7 +195,7 @@ gimp_curves_tool_initialize (GimpTool *tool,
}
histogram = gimp_histogram_new (FALSE);
- gimp_drawable_calculate_histogram (drawable, histogram);
+ gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph),
histogram);
g_object_unref (histogram);
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 4aa04c7..cb8acca 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -191,7 +191,7 @@ gimp_levels_tool_initialize (GimpTool *tool,
return FALSE;
}
- gimp_drawable_calculate_histogram (drawable, l_tool->histogram);
+ gimp_drawable_calculate_histogram (drawable, l_tool->histogram, FALSE);
gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->histogram_view),
l_tool->histogram);
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index da72df7..630d22a 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -142,7 +142,7 @@ gimp_threshold_tool_initialize (GimpTool *tool,
return FALSE;
}
- gimp_drawable_calculate_histogram (drawable, t_tool->histogram);
+ gimp_drawable_calculate_histogram (drawable, t_tool->histogram, FALSE);
gimp_histogram_view_set_histogram (t_tool->histogram_box->view,
t_tool->histogram);
diff --git a/app/widgets/gimphistogrameditor.c b/app/widgets/gimphistogrameditor.c
index cee2380..99fb255 100644
--- a/app/widgets/gimphistogrameditor.c
+++ b/app/widgets/gimphistogrameditor.c
@@ -133,12 +133,7 @@ gimp_histogram_editor_init (GimpHistogramEditor *editor)
N_("Percentile:")
};
- editor->drawable = NULL;
- editor->histogram = NULL;
- editor->bg_histogram = NULL;
- editor->valid = FALSE;
- editor->idle_id = 0;
- editor->box = gimp_histogram_box_new ();
+ editor->box = gimp_histogram_box_new ();
gimp_editor_set_show_name (GIMP_EDITOR (editor), TRUE);
@@ -481,7 +476,8 @@ gimp_histogram_editor_validate (GimpHistogramEditor *editor)
}
gimp_drawable_calculate_histogram (editor->drawable,
- editor->histogram);
+ editor->histogram,
+ TRUE);
}
else
{
diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb
index 4333187..75c8cfd 100644
--- a/tools/pdbgen/pdb/color.pdb
+++ b/tools/pdbgen/pdb/color.pdb
@@ -606,7 +606,7 @@ HELP
linear = FALSE;
histogram = gimp_histogram_new (linear);
- gimp_drawable_calculate_histogram (drawable, histogram);
+ gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
n_bins = gimp_histogram_n_bins (histogram);
diff --git a/tools/pdbgen/pdb/drawable_color.pdb b/tools/pdbgen/pdb/drawable_color.pdb
index eafecb4..3c86c92 100644
--- a/tools/pdbgen/pdb/drawable_color.pdb
+++ b/tools/pdbgen/pdb/drawable_color.pdb
@@ -464,7 +464,7 @@ HELP
linear = FALSE;
histogram = gimp_histogram_new (linear);
- gimp_drawable_calculate_histogram (drawable, histogram);
+ gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
n_bins = gimp_histogram_n_bins (histogram);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]