[gimp] app: simplify handling of the force output in paint methods



commit ca070266428b9c7bae169badbbbaab9933f3bf07
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 19 21:27:48 2015 +0200

    app: simplify handling of the force output in paint methods

 app/paint/gimpclone.c      |   23 +++++++++++------------
 app/paint/gimpdodgeburn.c  |   21 +++++++++------------
 app/paint/gimperaser.c     |   21 +++++++++------------
 app/paint/gimpheal.c       |   21 +++++++++------------
 app/paint/gimppaintbrush.c |   21 +++++++++------------
 app/paint/gimpsmudge.c     |   21 +++++++++------------
 6 files changed, 56 insertions(+), 72 deletions(-)
---
diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c
index 472f04f..be9c317 100644
--- a/app/paint/gimpclone.c
+++ b/app/paint/gimpclone.c
@@ -153,14 +153,15 @@ gimp_clone_motion (GimpSourceCore   *source_core,
                    gint              paint_area_height)
 {
   GimpPaintCore      *paint_core     = GIMP_PAINT_CORE (source_core);
+  GimpBrushCore      *brush_core     = GIMP_BRUSH_CORE (source_core);
   GimpCloneOptions   *options        = GIMP_CLONE_OPTIONS (paint_options);
   GimpSourceOptions  *source_options = GIMP_SOURCE_OPTIONS (paint_options);
   GimpContext        *context        = GIMP_CONTEXT (paint_options);
+  GimpDynamics       *dynamics       = brush_core->dynamics;
   GimpImage          *image          = gimp_item_get_image (GIMP_ITEM (drawable));
   gdouble             fade_point;
+  GimpDynamicsOutput *force_output;
   gdouble             force;
-  gdouble             dyn_force;
-  GimpDynamicsOutput *dyn_output = NULL;
 
   if (gimp_source_core_use_source (source_core, source_options))
     {
@@ -198,17 +199,15 @@ gimp_clone_motion (GimpSourceCore   *source_core,
   fade_point = gimp_paint_options_get_fade (paint_options, image,
                                             paint_core->pixel_dist);
 
-  dyn_output = gimp_dynamics_get_output (GIMP_BRUSH_CORE (paint_core)->dynamics,
-                                         GIMP_DYNAMICS_OUTPUT_FORCE);
+  force_output = gimp_dynamics_get_output (dynamics,
+                                           GIMP_DYNAMICS_OUTPUT_FORCE);
 
-  dyn_force = gimp_dynamics_get_linear_value (GIMP_BRUSH_CORE (paint_core)->dynamics,
-                                              GIMP_DYNAMICS_OUTPUT_FORCE,
-                                              coords,
-                                              paint_options,
-                                              fade_point);
-
-  if (gimp_dynamics_output_is_enabled (dyn_output))
-    force = dyn_force;
+  if (gimp_dynamics_output_is_enabled (force_output))
+    force = gimp_dynamics_get_linear_value (dynamics,
+                                            GIMP_DYNAMICS_OUTPUT_FORCE,
+                                            coords,
+                                            paint_options,
+                                            fade_point);
   else
     force = paint_options->brush_force;
 
diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c
index 6295e63..25e43be 100644
--- a/app/paint/gimpdodgeburn.c
+++ b/app/paint/gimpdodgeburn.c
@@ -121,9 +121,8 @@ gimp_dodge_burn_motion (GimpPaintCore    *paint_core,
   gint                  paint_buffer_y;
   gdouble               fade_point;
   gdouble               opacity;
+  GimpDynamicsOutput   *force_output;
   gdouble               force;
-  gdouble               dyn_force;
-  GimpDynamicsOutput   *dyn_output = NULL;
 
   fade_point = gimp_paint_options_get_fade (paint_options, image,
                                             paint_core->pixel_dist);
@@ -155,17 +154,15 @@ gimp_dodge_burn_motion (GimpPaintCore    *paint_core,
                        options->type,
                        options->mode);
 
-  dyn_output = gimp_dynamics_get_output (dynamics,
-                                         GIMP_DYNAMICS_OUTPUT_FORCE);
+  force_output = gimp_dynamics_get_output (dynamics,
+                                           GIMP_DYNAMICS_OUTPUT_FORCE);
 
-  dyn_force = gimp_dynamics_get_linear_value (dynamics,
-                                              GIMP_DYNAMICS_OUTPUT_FORCE,
-                                              coords,
-                                              paint_options,
-                                              fade_point);
-
-  if (gimp_dynamics_output_is_enabled (dyn_output))
-    force = dyn_force;
+  if (gimp_dynamics_output_is_enabled (force_output))
+    force = gimp_dynamics_get_linear_value (dynamics,
+                                            GIMP_DYNAMICS_OUTPUT_FORCE,
+                                            coords,
+                                            paint_options,
+                                            fade_point);
   else
     force = paint_options->brush_force;
 
diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c
index 3d7b367..746647d 100644
--- a/app/paint/gimperaser.c
+++ b/app/paint/gimperaser.c
@@ -116,9 +116,8 @@ gimp_eraser_motion (GimpPaintCore    *paint_core,
   gint                  paint_buffer_y;
   GimpRGB               background;
   GeglColor            *color;
+  GimpDynamicsOutput   *force_output;
   gdouble               force;
-  gdouble               dyn_force;
-  GimpDynamicsOutput   *dyn_output = NULL;
 
   fade_point = gimp_paint_options_get_fade (paint_options, image,
                                             paint_core->pixel_dist);
@@ -151,17 +150,15 @@ gimp_eraser_motion (GimpPaintCore    *paint_core,
   else
     paint_mode = GIMP_NORMAL_MODE;
 
-  dyn_output = gimp_dynamics_get_output (dynamics,
-                                         GIMP_DYNAMICS_OUTPUT_FORCE);
+  force_output = gimp_dynamics_get_output (dynamics,
+                                           GIMP_DYNAMICS_OUTPUT_FORCE);
 
-  dyn_force = gimp_dynamics_get_linear_value (dynamics,
-                                              GIMP_DYNAMICS_OUTPUT_FORCE,
-                                              coords,
-                                              paint_options,
-                                              fade_point);
-
-  if (gimp_dynamics_output_is_enabled (dyn_output))
-    force = dyn_force;
+  if (gimp_dynamics_output_is_enabled (force_output))
+    force = gimp_dynamics_get_linear_value (dynamics,
+                                            GIMP_DYNAMICS_OUTPUT_FORCE,
+                                            coords,
+                                            paint_options,
+                                            fade_point);
   else
     force = paint_options->brush_force;
 
diff --git a/app/paint/gimpheal.c b/app/paint/gimpheal.c
index 472cbae..92dd5f7 100644
--- a/app/paint/gimpheal.c
+++ b/app/paint/gimpheal.c
@@ -484,26 +484,23 @@ gimp_heal_motion (GimpSourceCore   *source_core,
   GeglBuffer         *mask_buffer;
   const GimpTempBuf  *mask_buf;
   gdouble             fade_point;
+  GimpDynamicsOutput *force_output;
   gdouble             force;
   gint                mask_off_x;
   gint                mask_off_y;
-  gdouble             dyn_force;
-  GimpDynamicsOutput *dyn_output = NULL;
 
   fade_point = gimp_paint_options_get_fade (paint_options, image,
                                             paint_core->pixel_dist);
 
-  dyn_output = gimp_dynamics_get_output (dynamics,
-                                         GIMP_DYNAMICS_OUTPUT_FORCE);
+  force_output = gimp_dynamics_get_output (dynamics,
+                                           GIMP_DYNAMICS_OUTPUT_FORCE);
 
-  dyn_force = gimp_dynamics_get_linear_value (dynamics,
-                                              GIMP_DYNAMICS_OUTPUT_FORCE,
-                                              coords,
-                                              paint_options,
-                                              fade_point);
-
-  if (gimp_dynamics_output_is_enabled (dyn_output))
-    force = dyn_force;
+  if (gimp_dynamics_output_is_enabled (force_output))
+    force = gimp_dynamics_get_linear_value (dynamics,
+                                            GIMP_DYNAMICS_OUTPUT_FORCE,
+                                            coords,
+                                            paint_options,
+                                            fade_point);
   else
     force = paint_options->brush_force;
 
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index 3c605e1..ce82224 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -121,9 +121,8 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
   GimpPaintApplicationMode  paint_appl_mode;
   gdouble                   fade_point;
   gdouble                   grad_point;
+  GimpDynamicsOutput       *force_output;
   gdouble                   force;
-  gdouble                   dyn_force;
-  GimpDynamicsOutput       *dyn_output = NULL;
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
@@ -200,17 +199,15 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
       g_object_unref (color);
     }
 
-  dyn_output = gimp_dynamics_get_output (dynamics,
-                                         GIMP_DYNAMICS_OUTPUT_FORCE);
+  force_output = gimp_dynamics_get_output (dynamics,
+                                           GIMP_DYNAMICS_OUTPUT_FORCE);
 
-  dyn_force = gimp_dynamics_get_linear_value (dynamics,
-                                              GIMP_DYNAMICS_OUTPUT_FORCE,
-                                              coords,
-                                              paint_options,
-                                              fade_point);
-
-  if (gimp_dynamics_output_is_enabled (dyn_output))
-    force = dyn_force;
+  if (gimp_dynamics_output_is_enabled (force_output))
+    force = gimp_dynamics_get_linear_value (dynamics,
+                                            GIMP_DYNAMICS_OUTPUT_FORCE,
+                                            coords,
+                                            paint_options,
+                                            fade_point);
   else
     force = paint_options->brush_force;
 
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index 9fbd5b3..be54afc 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -249,9 +249,8 @@ gimp_smudge_motion (GimpPaintCore    *paint_core,
   gdouble             rate;
   gdouble             dynamic_rate;
   gint                x, y;
+  GimpDynamicsOutput *force_output;
   gdouble             force;
-  gdouble             dyn_force;
-  GimpDynamicsOutput *dyn_output = NULL;
 
   fade_point = gimp_paint_options_get_fade (paint_options, image,
                                             paint_core->pixel_dist);
@@ -319,17 +318,15 @@ gimp_smudge_motion (GimpPaintCore    *paint_core,
                     paint_buffer,
                     GEGL_RECTANGLE (0, 0, 0, 0));
 
-  dyn_output = gimp_dynamics_get_output (dynamics,
-                                         GIMP_DYNAMICS_OUTPUT_FORCE);
+  force_output = gimp_dynamics_get_output (dynamics,
+                                           GIMP_DYNAMICS_OUTPUT_FORCE);
 
-  dyn_force = gimp_dynamics_get_linear_value (dynamics,
-                                              GIMP_DYNAMICS_OUTPUT_FORCE,
-                                              coords,
-                                              paint_options,
-                                              fade_point);
-
-  if (gimp_dynamics_output_is_enabled (dyn_output))
-    force = dyn_force;
+  if (gimp_dynamics_output_is_enabled (force_output))
+    force = gimp_dynamics_get_linear_value (dynamics,
+                                            GIMP_DYNAMICS_OUTPUT_FORCE,
+                                            coords,
+                                            paint_options,
+                                            fade_point);
   else
     force = paint_options->brush_force;
 


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