[gimp] app: Make smooth paint core internal



commit 803df9b58ab5d7b4c90f3ffbd72ada762fe1ffd9
Author: Alexia Death <alexiadeath gmail com>
Date:   Sun Jan 9 22:53:11 2011 +0200

    app: Make smooth paint core internal

 app/paint/gimpbrushcore.c |    6 ------
 app/paint/gimpink.c       |   26 +++++++++++---------------
 app/paint/gimppaintcore.c |   30 +++++++++++++++++-------------
 app/paint/gimppaintcore.h |    4 ----
 4 files changed, 28 insertions(+), 38 deletions(-)
---
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 6cb116c..cc0c3de 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -521,12 +521,6 @@ gimp_brush_core_interpolate (GimpPaintCore    *paint_core,
   gimp_paint_core_get_last_coords (paint_core, &last_coords);
   gimp_paint_core_get_current_coords (paint_core, &current_coords);
 
-  if (paint_core->stroke_buffer)
-    {
-      current_coords = gimp_paint_core_get_smoothed_coords (paint_core,
-                                                            paint_options, &current_coords);
-      gimp_paint_core_set_current_coords (paint_core, &current_coords);
-    }
 
   /*Zero sized brushes are unfit for interpolate,
    * so we just let paint core fail onits own
diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c
index a9ff574..96e72dc 100644
--- a/app/paint/gimpink.c
+++ b/app/paint/gimpink.c
@@ -254,21 +254,17 @@ gimp_ink_motion (GimpPaintCore    *paint_core,
   TempBuf        *area;
   guchar          col[MAX_CHANNELS];
   PixelRegion     blob_maskPR;
-  GimpCoords      modified_coords;
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
-  modified_coords = gimp_paint_core_get_smoothed_coords (paint_core,
-                                                         paint_options, coords);
-
   if (! ink->last_blob)
     {
       ink->last_blob = ink_pen_ellipse (options,
-                                        modified_coords.x,
-                                        modified_coords.y,
-                                        modified_coords.pressure,
-                                        modified_coords.xtilt,
-                                        modified_coords.ytilt,
+                                        coords->x,
+                                        coords->y,
+                                        coords->pressure,
+                                        coords->xtilt,
+                                        coords->ytilt,
                                         100);
 
       if (ink->start_blob)
@@ -281,12 +277,12 @@ gimp_ink_motion (GimpPaintCore    *paint_core,
   else
     {
       GimpBlob *blob = ink_pen_ellipse (options,
-                                        modified_coords.x,
-                                        modified_coords.y,
-                                        modified_coords.pressure,
-                                        modified_coords.xtilt,
-                                        modified_coords.ytilt,
-                                        modified_coords.velocity * 100);
+                                        coords->x,
+                                        coords->y,
+                                        coords->pressure,
+                                        coords->xtilt,
+                                        coords->ytilt,
+                                        coords->velocity * 100);
 
       blob_union = gimp_blob_convex_union (ink->last_blob, blob);
 
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 326cb93..790e710 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -111,6 +111,10 @@ static void      paint_mask_to_canvas_buf            (GimpPaintCore    *core,
                                                       gdouble           paint_opacity);
 static void      canvas_tiles_to_canvas_buf          (GimpPaintCore    *core);
 
+static void      gimp_paint_core_smooth_coords       (GimpPaintCore    *core,
+                                                      GimpPaintOptions *paint_options,
+                                                      GimpCoords       *coords);
+
 
 G_DEFINE_TYPE (GimpPaintCore, gimp_paint_core, GIMP_TYPE_OBJECT)
 
@@ -324,6 +328,9 @@ gimp_paint_core_paint (GimpPaintCore    *core,
           core->last_paint.y = core->cur_coords.y;
         }
 
+      gimp_paint_core_smooth_coords (core,
+                                     paint_options,
+                                     &core->cur_coords);
       core_class->paint (core, drawable,
                          paint_options,
                          &core->cur_coords,
@@ -1251,10 +1258,10 @@ gimp_paint_core_validate_canvas_tiles (GimpPaintCore *core,
     }
 }
 
-GimpCoords
-gimp_paint_core_get_smoothed_coords (GimpPaintCore    *core,
-                                     GimpPaintOptions *paint_options,
-                                     const GimpCoords *original_coords)
+static void
+gimp_paint_core_smooth_coords (GimpPaintCore    *core,
+                               GimpPaintOptions *paint_options,
+                               GimpCoords       *coords)
 {
   GimpSmoothingOptions *smoothing_options = paint_options->smoothing_options;
   GArray               *history           = core->stroke_buffer;
@@ -1265,15 +1272,14 @@ gimp_paint_core_get_smoothed_coords (GimpPaintCore    *core,
       gint       i;
       guint      length;
       gint       min_index;
-      GimpCoords result           = *original_coords;
       gdouble    gaussian_weight  = 0.0;
       gdouble    gaussian_weight2 = SQR (smoothing_options->smoothing_factor);
       gdouble    velocity_sum     = 0.0;
       gdouble    scale_sum        = 0.0;
 
-      result.x = result.y = 0.0;
+      g_array_append_val (history, *coords);
 
-      g_array_append_val (history, *original_coords);
+      coords->x = coords->y = 0.0;
 
       length = MIN (smoothing_options->smoothing_quality, history->len);
 
@@ -1296,18 +1302,16 @@ gimp_paint_core_get_smoothed_coords (GimpPaintCore    *core,
             }
 
           scale_sum += rate;
-          result.x += rate * next_coords->x;
-          result.y += rate * next_coords->y;
+          coords->x += rate * next_coords->x;
+          coords->y += rate * next_coords->y;
         }
 
       if (scale_sum != 0.0)
         {
-          result.x /= scale_sum;
-          result.y /= scale_sum;
+          coords->x /= scale_sum;
+          coords->y /= scale_sum;
         }
 
-      return result;
     }
 
-  return *original_coords;
 }
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index 5eb0f34..c9038b1 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -203,9 +203,5 @@ void      gimp_paint_core_validate_canvas_tiles     (GimpPaintCore    *core,
                                                      gint              w,
                                                      gint              h);
 
-GimpCoords gimp_paint_core_get_smoothed_coords      (GimpPaintCore    *core,
-                                                     GimpPaintOptions *paint_options,
-                                                     const GimpCoords *original_coords);
-
 
 #endif  /*  __GIMP_PAINT_CORE_H__  */



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