app: simplify handling of the force output in paint methods

This commit is contained in:
Michael Natterer 2015-04-19 21:27:48 +02:00
parent 0d7d96d09f
commit ca07026642
6 changed files with 56 additions and 72 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;