[gimp/wip/gradient-edit: 41/43] app: don't update blend tool filter upon irrelevant line changes



commit 513920a8d4671391f6acd9306db0189ea8f51ff0
Author: Ell <ell_se yahoo com>
Date:   Sat Aug 12 11:25:22 2017 -0400

    app: don't update blend tool filter upon irrelevant line changes
    
    When one of the line widget's properties changes, only update the
    blend tool filter if the property has an effect on the result.  In
    particular, don't update the filter when only the selection
    changes.

 app/tools/gimpblendtool-editor.c |   10 ++++++----
 app/tools/gimpblendtool-editor.h |    2 +-
 app/tools/gimpblendtool.c        |   37 ++++++++++++++++++++++++++++++-------
 3 files changed, 37 insertions(+), 12 deletions(-)
---
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index 1e6b1a6..355fb4e 100644
--- a/app/tools/gimpblendtool-editor.c
+++ b/app/tools/gimpblendtool-editor.c
@@ -2123,7 +2123,7 @@ gimp_blend_tool_editor_halt (GimpBlendTool *blend_tool)
     }
 }
 
-void
+gboolean
 gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
 {
   GimpBlendOptions           *options       = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
@@ -2136,16 +2136,16 @@ gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
   gboolean                    changed       = FALSE;
 
   if (gimp_blend_tool_editor_are_handlers_blocked (blend_tool))
-    return;
+    return FALSE;
 
   if (! blend_tool->gradient || offset == 1.0)
-    return;
+    return FALSE;
 
   sliders = gimp_tool_line_get_sliders (GIMP_TOOL_LINE (blend_tool->widget),
                                         &n_sliders);
 
   if (n_sliders == 0)
-    return;
+    return FALSE;
 
   /* update the midpoints first, since moving the gradient stops may change the
    * gradient's midpoints w.r.t. the sliders, but not the other way around.
@@ -2227,6 +2227,8 @@ gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
     }
 
   gimp_blend_tool_editor_update_gui (blend_tool);
+
+  return changed;
 }
 
 void
diff --git a/app/tools/gimpblendtool-editor.h b/app/tools/gimpblendtool-editor.h
index b9bbda4..3388371 100644
--- a/app/tools/gimpblendtool-editor.h
+++ b/app/tools/gimpblendtool-editor.h
@@ -26,7 +26,7 @@ void          gimp_blend_tool_editor_options_notify   (GimpBlendTool    *blend_t
 void          gimp_blend_tool_editor_start            (GimpBlendTool    *blend_tool);
 void          gimp_blend_tool_editor_halt             (GimpBlendTool    *blend_tool);
 
-void          gimp_blend_tool_editor_line_changed     (GimpBlendTool    *blend_tool);
+gboolean      gimp_blend_tool_editor_line_changed     (GimpBlendTool    *blend_tool);
 
 void          gimp_blend_tool_editor_fg_bg_changed    (GimpBlendTool    *blend_tool);
 
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 62e046d..72c656a 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -680,17 +680,40 @@ static void
 gimp_blend_tool_line_changed (GimpToolWidget *widget,
                               GimpBlendTool  *blend_tool)
 {
+  gdouble  start_x;
+  gdouble  start_y;
+  gdouble  end_x;
+  gdouble  end_y;
+  gboolean update = FALSE;
+
   g_object_get (widget,
-                "x1", &blend_tool->start_x,
-                "y1", &blend_tool->start_y,
-                "x2", &blend_tool->end_x,
-                "y2", &blend_tool->end_y,
+                "x1", &start_x,
+                "y1", &start_y,
+                "x2", &end_x,
+                "y2", &end_y,
                 NULL);
 
-  gimp_blend_tool_update_graph (blend_tool);
-  gimp_drawable_filter_apply (blend_tool->filter, NULL);
+  if (start_x != blend_tool->start_x ||
+      start_y != blend_tool->start_y ||
+      end_x   != blend_tool->end_x   ||
+      end_y   != blend_tool->end_y)
+    {
+      blend_tool->start_x = start_x;
+      blend_tool->start_y = start_y;
+      blend_tool->end_x   = end_x;
+      blend_tool->end_y   = end_y;
+
+      update = TRUE;
+    }
 
-  gimp_blend_tool_editor_line_changed (blend_tool);
+  if (gimp_blend_tool_editor_line_changed (blend_tool))
+    update = TRUE;
+
+  if (update)
+    {
+      gimp_blend_tool_update_graph (blend_tool);
+      gimp_drawable_filter_apply (blend_tool->filter, NULL);
+    }
 }
 
 static void


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