[gimp] Add GimpCoords* parameter to gimp_paint_core_interpolate()



commit 53c661312b45b9810af35ab302f8931209e45b91
Author: Michael Natterer <mitch gimp org>
Date:   Mon May 25 20:49:34 2009 +0200

    Add GimpCoords* parameter to gimp_paint_core_interpolate()
    
    Pass the current coords to the function instead of setting them
    on the paint core before calling it. Doesn't exactly make the code
    in the paint tool  simpler, but that needs further refactoring anyway.
---
 app/paint/gimppaintcore-stroke.c |   16 +++++++---------
 app/paint/gimppaintcore.c        |    4 ++++
 app/paint/gimppaintcore.h        |    1 +
 app/tools/gimppainttool.c        |   34 ++++++++++++++++++----------------
 4 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/app/paint/gimppaintcore-stroke.c b/app/paint/gimppaintcore-stroke.c
index 151b23a..dabe73e 100644
--- a/app/paint/gimppaintcore-stroke.c
+++ b/app/paint/gimppaintcore-stroke.c
@@ -78,9 +78,8 @@ gimp_paint_core_stroke (GimpPaintCore     *core,
 
       for (i = 1; i < n_strokes; i++)
         {
-          core->cur_coords = strokes[i];
-
-          gimp_paint_core_interpolate (core, drawable, paint_options, 0);
+          gimp_paint_core_interpolate (core, drawable, paint_options,
+                                       &strokes[i], 0);
         }
 
       gimp_paint_core_paint (core, drawable, paint_options,
@@ -194,9 +193,8 @@ gimp_paint_core_stroke_boundary (GimpPaintCore     *core,
 
           for (i = 1; i < n_coords; i++)
             {
-              core->cur_coords = coords[i];
-
-              gimp_paint_core_interpolate (core, drawable, paint_options, 0);
+              gimp_paint_core_interpolate (core, drawable, paint_options,
+                                           &coords[i], 0);
             }
 
           gimp_paint_core_paint (core, drawable, paint_options,
@@ -299,9 +297,9 @@ gimp_paint_core_stroke_vectors (GimpPaintCore     *core,
 
               for (i = 1; i < coords->len; i++)
                 {
-                  core->cur_coords = g_array_index (coords, GimpCoords, i);
-
-                  gimp_paint_core_interpolate (core, drawable, paint_options, 0);
+                  gimp_paint_core_interpolate (core, drawable, paint_options,
+                                               &g_array_index (coords, GimpCoords, i),
+                                               0);
                 }
 
               gimp_paint_core_paint (core, drawable, paint_options,
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 3c07094..8af5647 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -568,12 +568,16 @@ void
 gimp_paint_core_interpolate (GimpPaintCore    *core,
                              GimpDrawable     *drawable,
                              GimpPaintOptions *paint_options,
+                             const GimpCoords *coords,
                              guint32           time)
 {
   g_return_if_fail (GIMP_IS_PAINT_CORE (core));
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
   g_return_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options));
+  g_return_if_fail (coords != NULL);
+
+  core->cur_coords = *coords;
 
   GIMP_PAINT_CORE_GET_CLASS (core)->interpolate (core, drawable,
                                                  paint_options, time);
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index 42af71d..3b19002 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -132,6 +132,7 @@ void      gimp_paint_core_cleanup                   (GimpPaintCore    *core);
 void      gimp_paint_core_interpolate               (GimpPaintCore    *core,
                                                      GimpDrawable     *drawable,
                                                      GimpPaintOptions *paint_options,
+                                                     const GimpCoords *coords,
                                                      guint32           time);
 
 void      gimp_paint_core_set_current_coords        (GimpPaintCore    *core,
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index a556f8b..2cda5f4 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -264,10 +264,10 @@ gimp_paint_tool_button_press (GimpTool         *tool,
       return;
     }
 
-  drawable = gimp_image_get_active_drawable (display->image);
-
   curr_coords = *coords;
 
+  drawable = gimp_image_get_active_drawable (display->image);
+
   gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
 
   curr_coords.x -= off_x;
@@ -332,7 +332,8 @@ gimp_paint_tool_button_press (GimpTool         *tool,
   /*  Paint to the image  */
   if (paint_tool->draw_line)
     {
-      gimp_paint_core_interpolate (core, drawable, paint_options, time);
+      gimp_paint_core_interpolate (core, drawable, paint_options,
+                                   &core->cur_coords, time);
     }
   else
     {
@@ -403,33 +404,34 @@ gimp_paint_tool_motion (GimpTool         *tool,
   GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
   GimpPaintCore    *core          = paint_tool->core;
   GimpDrawable     *drawable;
+  GimpCoords        curr_coords;
   gint              off_x, off_y;
 
+  GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
+
   if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
-    {
-      GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state,
-                                              display);
-      return;
-    }
+    return;
 
-  drawable = gimp_image_get_active_drawable (display->image);
+  curr_coords = *coords;
 
-  core->cur_coords = *coords;
+  drawable = gimp_image_get_active_drawable (display->image);
 
   gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
 
-  core->cur_coords.x -= off_x;
-  core->cur_coords.y -= off_y;
-
-  GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
+  curr_coords.x -= off_x;
+  curr_coords.y -= off_y;
 
   /*  don't paint while the Shift key is pressed for line drawing  */
   if (paint_tool->draw_line)
-    return;
+    {
+      gimp_paint_core_set_current_coords (core, &curr_coords);
+      return;
+    }
 
   gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
 
-  gimp_paint_core_interpolate (core, drawable, paint_options, time);
+  gimp_paint_core_interpolate (core, drawable, paint_options,
+                               &curr_coords, time);
 
   gimp_projection_flush_now (gimp_image_get_projection (display->image));
   gimp_display_flush_now (display);



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