app: add gimp_dynamics_is_output_enabled()

and use it to further simplify stuff. Almost no place needs to use a
GimpDynamicsOutput directly now.
This commit is contained in:
Michael Natterer 2015-04-19 21:58:36 +02:00
parent f65bef9c11
commit 7449316898
10 changed files with 87 additions and 110 deletions

View File

@ -549,11 +549,24 @@ gimp_dynamics_get_output (GimpDynamics *dynamics,
break;
default:
return NULL;
g_return_val_if_reached (NULL);
break;
}
}
gboolean
gimp_dynamics_is_output_enabled (GimpDynamics *dynamics,
GimpDynamicsOutputType type)
{
GimpDynamicsOutput *output;
g_return_val_if_fail (GIMP_IS_DYNAMICS (dynamics), FALSE);
output = gimp_dynamics_get_output (dynamics, type);
return gimp_dynamics_output_is_enabled (output);
}
gdouble
gimp_dynamics_get_linear_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,

View File

@ -52,6 +52,9 @@ GimpData * gimp_dynamics_get_standard (GimpContext *context
GimpDynamicsOutput * gimp_dynamics_get_output (GimpDynamics *dynamics,
GimpDynamicsOutputType type);
gboolean gimp_dynamics_is_output_enabled (GimpDynamics *dynamics,
GimpDynamicsOutputType type);
gdouble gimp_dynamics_get_linear_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,
const GimpCoords *coords,

View File

@ -1530,9 +1530,7 @@ gimp_brush_core_eval_transform_dynamics (GimpBrushCore *core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush)
{
GimpDynamicsOutput *output;
gdouble dyn_aspect_ratio = 0.0;
gdouble fade_point = 1.0;
gdouble fade_point = 1.0;
if (drawable)
{
@ -1561,23 +1559,25 @@ gimp_brush_core_eval_transform_dynamics (GimpBrushCore *core,
paint_options,
fade_point);
output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO);
dyn_aspect_ratio = gimp_dynamics_output_get_aspect_value (output,
coords,
paint_options,
fade_point);
/* Zero aspect ratio is special cased to half of all ar range,
* to force dynamics to have any effect. Forcing to full results
* in disapearing stamp if applied to maximum.
*/
if (gimp_dynamics_output_is_enabled (output))
if (gimp_dynamics_is_output_enabled (core->dynamics,
GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO))
{
gdouble dyn_aspect;
dyn_aspect = gimp_dynamics_get_aspect_value (core->dynamics,
GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO,
coords,
paint_options,
fade_point);
/* Zero aspect ratio is special cased to half of all ar range,
* to force dynamics to have any effect. Forcing to full results
* in disapearing stamp if applied to maximum.
*/
if (core->aspect_ratio == 0.0)
core->aspect_ratio = 10.0 * dyn_aspect_ratio;
core->aspect_ratio = 10.0 * dyn_aspect;
else
core->aspect_ratio *= dyn_aspect_ratio;
core->aspect_ratio *= dyn_aspect;
}
}
}

View File

@ -30,7 +30,6 @@
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimperror.h"
#include "core/gimpimage.h"
#include "core/gimppattern.h"
@ -152,16 +151,15 @@ gimp_clone_motion (GimpSourceCore *source_core,
gint paint_area_width,
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;
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;
gdouble force;
if (gimp_source_core_use_source (source_core, source_options))
{
@ -199,10 +197,7 @@ gimp_clone_motion (GimpSourceCore *source_core,
fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (gimp_dynamics_output_is_enabled (force_output))
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE,
coords,

View File

@ -30,7 +30,6 @@
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpimage.h"
#include "gimpdodgeburn.h"
@ -121,7 +120,6 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
gint paint_buffer_y;
gdouble fade_point;
gdouble opacity;
GimpDynamicsOutput *force_output;
gdouble force;
fade_point = gimp_paint_options_get_fade (paint_options, image,
@ -154,10 +152,7 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
options->type,
options->mode);
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (gimp_dynamics_output_is_enabled (force_output))
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE,
coords,

View File

@ -27,7 +27,6 @@
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpimage.h"
#include "gimperaser.h"
@ -116,7 +115,6 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
gint paint_buffer_y;
GimpRGB background;
GeglColor *color;
GimpDynamicsOutput *force_output;
gdouble force;
fade_point = gimp_paint_options_get_fade (paint_options, image,
@ -150,10 +148,7 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
else
paint_mode = GIMP_NORMAL_MODE;
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (gimp_dynamics_output_is_enabled (force_output))
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE,
coords,

View File

@ -35,7 +35,6 @@
#include "core/gimpbrush.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimperror.h"
#include "core/gimpimage.h"
#include "core/gimppickable.h"
@ -476,26 +475,22 @@ gimp_heal_motion (GimpSourceCore *source_core,
gint paint_area_width,
gint paint_area_height)
{
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglBuffer *src_copy;
GeglBuffer *mask_buffer;
const GimpTempBuf *mask_buf;
gdouble fade_point;
GimpDynamicsOutput *force_output;
gdouble force;
gint mask_off_x;
gint mask_off_y;
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglBuffer *src_copy;
GeglBuffer *mask_buffer;
const GimpTempBuf *mask_buf;
gdouble fade_point;
gdouble force;
gint mask_off_x;
gint mask_off_y;
fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (gimp_dynamics_output_is_enabled (force_output))
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE,
coords,

View File

@ -33,7 +33,6 @@
#include "core/gimpbrush.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimptempbuf.h"
@ -121,7 +120,6 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
GimpPaintApplicationMode paint_appl_mode;
gdouble fade_point;
gdouble grad_point;
GimpDynamicsOutput *force_output;
gdouble force;
image = gimp_item_get_image (GIMP_ITEM (drawable));
@ -199,10 +197,7 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
g_object_unref (color);
}
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (gimp_dynamics_output_is_enabled (force_output))
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE,
coords,

View File

@ -854,26 +854,21 @@ gimp_paint_options_get_gradient_color (GimpPaintOptions *paint_options,
gdouble pixel_dist,
GimpRGB *color)
{
GimpGradientOptions *gradient_options;
GimpGradient *gradient;
GimpDynamics *dynamics;
GimpDynamicsOutput *color_output;
GimpDynamics *dynamics;
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (color != NULL, FALSE);
gradient_options = paint_options->gradient_options;
gradient = gimp_context_get_gradient (GIMP_CONTEXT (paint_options));
dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
color_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_COLOR);
if (gimp_dynamics_output_is_enabled (color_output))
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_COLOR))
{
GimpGradientOptions *gradient_options = paint_options->gradient_options;
GimpGradient *gradient;
gradient = gimp_context_get_gradient (GIMP_CONTEXT (paint_options));
gimp_gradient_get_color_at (gradient, GIMP_CONTEXT (paint_options),
NULL, grad_point,
gradient_options->gradient_reverse,
@ -888,9 +883,8 @@ gimp_paint_options_get_gradient_color (GimpPaintOptions *paint_options,
GimpBrushApplicationMode
gimp_paint_options_get_brush_mode (GimpPaintOptions *paint_options)
{
GimpDynamics *dynamics;
GimpDynamicsOutput *force_output;
gboolean dynamic_force = FALSE;
GimpDynamics *dynamics;
gboolean dynamic_force = FALSE;
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), GIMP_BRUSH_SOFT);
@ -899,11 +893,8 @@ gimp_paint_options_get_brush_mode (GimpPaintOptions *paint_options)
dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (force_output)
dynamic_force = gimp_dynamics_output_is_enabled (force_output);
dynamic_force = gimp_dynamics_is_output_enabled (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (dynamic_force || (paint_options->brush_force > 0.0))
return GIMP_BRUSH_PRESSURE;

View File

@ -30,7 +30,6 @@
#include "core/gimpbrush.h"
#include "core/gimpdrawable.h"
#include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpimage.h"
#include "core/gimppickable.h"
#include "core/gimptempbuf.h"
@ -234,23 +233,22 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options,
const GimpCoords *coords)
{
GimpSmudge *smudge = GIMP_SMUDGE (paint_core);
GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglBuffer *paint_buffer;
gint paint_buffer_x;
gint paint_buffer_y;
gint paint_buffer_width;
gint paint_buffer_height;
gdouble fade_point;
gdouble opacity;
gdouble rate;
gdouble dynamic_rate;
gint x, y;
GimpDynamicsOutput *force_output;
gdouble force;
GimpSmudge *smudge = GIMP_SMUDGE (paint_core);
GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglBuffer *paint_buffer;
gint paint_buffer_x;
gint paint_buffer_y;
gint paint_buffer_width;
gint paint_buffer_height;
gdouble fade_point;
gdouble opacity;
gdouble rate;
gdouble dynamic_rate;
gint x, y;
gdouble force;
fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
@ -318,10 +316,7 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
paint_buffer,
GEGL_RECTANGLE (0, 0, 0, 0));
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (gimp_dynamics_output_is_enabled (force_output))
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE))
force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE,
coords,