[gimp] app: add gimp_dynamics_is_output_enabled()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_dynamics_is_output_enabled()
- Date: Sun, 19 Apr 2015 19:59:37 +0000 (UTC)
commit 74493168984ccfe2060b27332740d9ae60a7013f
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 19 21:58:36 2015 +0200
app: add gimp_dynamics_is_output_enabled()
and use it to further simplify stuff. Almost no place needs to use a
GimpDynamicsOutput directly now.
app/core/gimpdynamics.c | 15 ++++++++++++++-
app/core/gimpdynamics.h | 3 +++
app/paint/gimpbrushcore.c | 34 +++++++++++++++++-----------------
app/paint/gimpclone.c | 25 ++++++++++---------------
app/paint/gimpdodgeburn.c | 7 +------
app/paint/gimperaser.c | 7 +------
app/paint/gimpheal.c | 29 ++++++++++++-----------------
app/paint/gimppaintbrush.c | 7 +------
app/paint/gimppaintoptions.c | 31 +++++++++++--------------------
app/paint/gimpsmudge.c | 39 +++++++++++++++++----------------------
10 files changed, 87 insertions(+), 110 deletions(-)
---
diff --git a/app/core/gimpdynamics.c b/app/core/gimpdynamics.c
index ba61614..2475e4e 100644
--- a/app/core/gimpdynamics.c
+++ b/app/core/gimpdynamics.c
@@ -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,
diff --git a/app/core/gimpdynamics.h b/app/core/gimpdynamics.h
index 9daaddb..811dce3 100644
--- a/app/core/gimpdynamics.h
+++ b/app/core/gimpdynamics.h
@@ -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,
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 40fb32b..9201643 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -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;
}
}
}
diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c
index be9c317..d342de0 100644
--- a/app/paint/gimpclone.c
+++ b/app/paint/gimpclone.c
@@ -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,
diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c
index 25e43be..e87e79a 100644
--- a/app/paint/gimpdodgeburn.c
+++ b/app/paint/gimpdodgeburn.c
@@ -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,
diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c
index 746647d..00ff7e9 100644
--- a/app/paint/gimperaser.c
+++ b/app/paint/gimperaser.c
@@ -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,
diff --git a/app/paint/gimpheal.c b/app/paint/gimpheal.c
index 92dd5f7..6aea8c0 100644
--- a/app/paint/gimpheal.c
+++ b/app/paint/gimpheal.c
@@ -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,
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index ce82224..c86995f 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -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,
diff --git a/app/paint/gimppaintoptions.c b/app/paint/gimppaintoptions.c
index 86a5364..49a249e 100644
--- a/app/paint/gimppaintoptions.c
+++ b/app/paint/gimppaintoptions.c
@@ -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;
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index be54afc..8c84a4d 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]