GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit e3c0a4e5 authored by Michael Natterer's avatar Michael Natterer 😴

app: move all GimpDynamics members to private

parent c31d675a
......@@ -55,6 +55,29 @@ enum
};
typedef struct _GimpDynamicsPrivate GimpDynamicsPrivate;
struct _GimpDynamicsPrivate
{
GimpDynamicsOutput *opacity_output;
GimpDynamicsOutput *hardness_output;
GimpDynamicsOutput *force_output;
GimpDynamicsOutput *rate_output;
GimpDynamicsOutput *flow_output;
GimpDynamicsOutput *size_output;
GimpDynamicsOutput *aspect_ratio_output;
GimpDynamicsOutput *color_output;
GimpDynamicsOutput *angle_output;
GimpDynamicsOutput *jitter_output;
GimpDynamicsOutput *spacing_output;
};
#define GET_PRIVATE(output) \
G_TYPE_INSTANCE_GET_PRIVATE (output, \
GIMP_TYPE_DYNAMICS, \
GimpDynamicsPrivate)
static void gimp_dynamics_finalize (GObject *object);
static void gimp_dynamics_set_property (GObject *object,
guint property_id,
......@@ -81,7 +104,6 @@ static void gimp_dynamics_output_notify (GObject *output,
GimpDynamics *dynamics);
G_DEFINE_TYPE (GimpDynamics, gimp_dynamics,
GIMP_TYPE_DATA)
......@@ -165,64 +187,87 @@ gimp_dynamics_class_init (GimpDynamicsClass *klass)
"spacing-output", NULL,
GIMP_TYPE_DYNAMICS_OUTPUT,
GIMP_CONFIG_PARAM_AGGREGATE);
g_type_class_add_private (klass, sizeof (GimpDynamicsPrivate));
}
static void
gimp_dynamics_init (GimpDynamics *dynamics)
{
dynamics->opacity_output = gimp_dynamics_create_output (dynamics,
"opacity-output",
GIMP_DYNAMICS_OUTPUT_OPACITY);
dynamics->force_output = gimp_dynamics_create_output (dynamics,
"force-output",
GIMP_DYNAMICS_OUTPUT_FORCE);
dynamics->hardness_output = gimp_dynamics_create_output (dynamics,
"hardness-output",
GIMP_DYNAMICS_OUTPUT_HARDNESS);
dynamics->rate_output = gimp_dynamics_create_output (dynamics,
"rate-output",
GIMP_DYNAMICS_OUTPUT_RATE);
dynamics->flow_output = gimp_dynamics_create_output (dynamics,
"flow-output",
GIMP_DYNAMICS_OUTPUT_RATE);
dynamics->size_output = gimp_dynamics_create_output (dynamics,
"size-output",
GIMP_DYNAMICS_OUTPUT_SIZE);
dynamics->aspect_ratio_output = gimp_dynamics_create_output (dynamics,
"aspect-ratio-output",
GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO);
dynamics->color_output = gimp_dynamics_create_output (dynamics,
"color-output",
GIMP_DYNAMICS_OUTPUT_COLOR);
dynamics->angle_output = gimp_dynamics_create_output (dynamics,
"angle-output",
GIMP_DYNAMICS_OUTPUT_ANGLE);
dynamics->jitter_output = gimp_dynamics_create_output (dynamics,
"jitter-output",
GIMP_DYNAMICS_OUTPUT_JITTER);
dynamics->spacing_output = gimp_dynamics_create_output (dynamics,
"spacing-output",
GIMP_DYNAMICS_OUTPUT_SPACING);
GimpDynamicsPrivate *private = GET_PRIVATE (dynamics);
private->opacity_output =
gimp_dynamics_create_output (dynamics,
"opacity-output",
GIMP_DYNAMICS_OUTPUT_OPACITY);
private->force_output =
gimp_dynamics_create_output (dynamics,
"force-output",
GIMP_DYNAMICS_OUTPUT_FORCE);
private->hardness_output =
gimp_dynamics_create_output (dynamics,
"hardness-output",
GIMP_DYNAMICS_OUTPUT_HARDNESS);
private->rate_output =
gimp_dynamics_create_output (dynamics,
"rate-output",
GIMP_DYNAMICS_OUTPUT_RATE);
private->flow_output =
gimp_dynamics_create_output (dynamics,
"flow-output",
GIMP_DYNAMICS_OUTPUT_RATE);
private->size_output =
gimp_dynamics_create_output (dynamics,
"size-output",
GIMP_DYNAMICS_OUTPUT_SIZE);
private->aspect_ratio_output =
gimp_dynamics_create_output (dynamics,
"aspect-ratio-output",
GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO);
private->color_output =
gimp_dynamics_create_output (dynamics,
"color-output",
GIMP_DYNAMICS_OUTPUT_COLOR);
private->angle_output =
gimp_dynamics_create_output (dynamics,
"angle-output",
GIMP_DYNAMICS_OUTPUT_ANGLE);
private->jitter_output =
gimp_dynamics_create_output (dynamics,
"jitter-output",
GIMP_DYNAMICS_OUTPUT_JITTER);
private->spacing_output =
gimp_dynamics_create_output (dynamics,
"spacing-output",
GIMP_DYNAMICS_OUTPUT_SPACING);
}
static void
gimp_dynamics_finalize (GObject *object)
{
GimpDynamics *dynamics = GIMP_DYNAMICS (object);
g_object_unref (dynamics->opacity_output);
g_object_unref (dynamics->force_output);
g_object_unref (dynamics->hardness_output);
g_object_unref (dynamics->rate_output);
g_object_unref (dynamics->flow_output);
g_object_unref (dynamics->size_output);
g_object_unref (dynamics->aspect_ratio_output);
g_object_unref (dynamics->color_output);
g_object_unref (dynamics->angle_output);
g_object_unref (dynamics->jitter_output);
g_object_unref (dynamics->spacing_output);
GimpDynamicsPrivate *private = GET_PRIVATE (object);
g_object_unref (private->opacity_output);
g_object_unref (private->force_output);
g_object_unref (private->hardness_output);
g_object_unref (private->rate_output);
g_object_unref (private->flow_output);
g_object_unref (private->size_output);
g_object_unref (private->aspect_ratio_output);
g_object_unref (private->color_output);
g_object_unref (private->angle_output);
g_object_unref (private->jitter_output);
g_object_unref (private->spacing_output);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -233,69 +278,69 @@ gimp_dynamics_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpDynamics *dynamics = GIMP_DYNAMICS (object);
GimpDynamicsOutput *src_output = NULL;
GimpDynamicsOutput *dest_output = NULL;
GimpDynamicsPrivate *private = GET_PRIVATE (object);
GimpDynamicsOutput *src_output = NULL;
GimpDynamicsOutput *dest_output = NULL;
switch (property_id)
{
case PROP_NAME:
gimp_object_set_name (GIMP_OBJECT (dynamics), g_value_get_string (value));
gimp_object_set_name (GIMP_OBJECT (object), g_value_get_string (value));
break;
case PROP_OPACITY_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->opacity_output;
dest_output = private->opacity_output;
break;
case PROP_FORCE_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->force_output;
dest_output = private->force_output;
break;
case PROP_HARDNESS_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->hardness_output;
dest_output = private->hardness_output;
break;
case PROP_RATE_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->rate_output;
dest_output = private->rate_output;
break;
case PROP_FLOW_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->flow_output;
dest_output = private->flow_output;
break;
case PROP_SIZE_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->size_output;
dest_output = private->size_output;
break;
case PROP_ASPECT_RATIO_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->aspect_ratio_output;
dest_output = private->aspect_ratio_output;
break;
case PROP_COLOR_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->color_output;
dest_output = private->color_output;
break;
case PROP_ANGLE_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->angle_output;
dest_output = private->angle_output;
break;
case PROP_JITTER_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->jitter_output;
dest_output = private->jitter_output;
break;
case PROP_SPACING_OUTPUT:
src_output = g_value_get_object (value);
dest_output = dynamics->spacing_output;
dest_output = private->spacing_output;
break;
default:
......@@ -317,56 +362,56 @@ gimp_dynamics_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpDynamics *dynamics = GIMP_DYNAMICS (object);
GimpDynamicsPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_NAME:
g_value_set_string (value, gimp_object_get_name (dynamics));
g_value_set_string (value, gimp_object_get_name (object));
break;
case PROP_OPACITY_OUTPUT:
g_value_set_object (value, dynamics->opacity_output);
g_value_set_object (value, private->opacity_output);
break;
case PROP_FORCE_OUTPUT:
g_value_set_object (value, dynamics->force_output);
g_value_set_object (value, private->force_output);
break;
case PROP_HARDNESS_OUTPUT:
g_value_set_object (value, dynamics->hardness_output);
g_value_set_object (value, private->hardness_output);
break;
case PROP_RATE_OUTPUT:
g_value_set_object (value, dynamics->rate_output);
g_value_set_object (value, private->rate_output);
break;
case PROP_FLOW_OUTPUT:
g_value_set_object (value, dynamics->flow_output);
g_value_set_object (value, private->flow_output);
break;
case PROP_SIZE_OUTPUT:
g_value_set_object (value, dynamics->size_output);
g_value_set_object (value, private->size_output);
break;
case PROP_ASPECT_RATIO_OUTPUT:
g_value_set_object (value, dynamics->aspect_ratio_output);
g_value_set_object (value, private->aspect_ratio_output);
break;
case PROP_COLOR_OUTPUT:
g_value_set_object (value, dynamics->color_output);
g_value_set_object (value, private->color_output);
break;
case PROP_ANGLE_OUTPUT:
g_value_set_object (value, dynamics->angle_output);
g_value_set_object (value, private->angle_output);
break;
case PROP_JITTER_OUTPUT:
g_value_set_object (value, dynamics->jitter_output);
g_value_set_object (value, private->jitter_output);
break;
case PROP_SPACING_OUTPUT:
g_value_set_object (value, dynamics->spacing_output);
g_value_set_object (value, private->spacing_output);
break;
default:
......@@ -450,51 +495,56 @@ GimpDynamicsOutput *
gimp_dynamics_get_output (GimpDynamics *dynamics,
GimpDynamicsOutputType type_id)
{
GimpDynamicsPrivate *private;
g_return_val_if_fail (GIMP_IS_DYNAMICS (dynamics), NULL);
private = GET_PRIVATE (dynamics);
switch (type_id)
{
case GIMP_DYNAMICS_OUTPUT_OPACITY:
return dynamics->opacity_output;
return private->opacity_output;
break;
case GIMP_DYNAMICS_OUTPUT_FORCE:
return dynamics->force_output;
return private->force_output;
break;
case GIMP_DYNAMICS_OUTPUT_HARDNESS:
return dynamics->hardness_output;
return private->hardness_output;
break;
case GIMP_DYNAMICS_OUTPUT_RATE:
return dynamics->rate_output;
return private->rate_output;
break;
case GIMP_DYNAMICS_OUTPUT_FLOW:
return dynamics->flow_output;
return private->flow_output;
break;
case GIMP_DYNAMICS_OUTPUT_SIZE:
return dynamics->size_output;
return private->size_output;
break;
case GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO:
return dynamics->aspect_ratio_output;
return private->aspect_ratio_output;
break;
case GIMP_DYNAMICS_OUTPUT_COLOR:
return dynamics->color_output;
return private->color_output;
break;
case GIMP_DYNAMICS_OUTPUT_ANGLE:
return dynamics->angle_output;
return private->angle_output;
break;
case GIMP_DYNAMICS_OUTPUT_JITTER:
return dynamics->jitter_output;
return private->jitter_output;
break;
case GIMP_DYNAMICS_OUTPUT_SPACING:
return dynamics->spacing_output;
return private->spacing_output;
break;
default:
......
......@@ -34,19 +34,7 @@ typedef struct _GimpDynamicsClass GimpDynamicsClass;
struct _GimpDynamics
{
GimpData parent_instance;
GimpDynamicsOutput *opacity_output;
GimpDynamicsOutput *hardness_output;
GimpDynamicsOutput *force_output;
GimpDynamicsOutput *rate_output;
GimpDynamicsOutput *flow_output;
GimpDynamicsOutput *size_output;
GimpDynamicsOutput *aspect_ratio_output;
GimpDynamicsOutput *color_output;
GimpDynamicsOutput *angle_output;
GimpDynamicsOutput *jitter_output;
GimpDynamicsOutput *spacing_output;
GimpData parent_instance;
};
struct _GimpDynamicsClass
......
......@@ -142,10 +142,11 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
if ((options->rate != 0.0) && (!options->motion_only))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gdouble fade_point;
gdouble dynamic_rate;
gint timeout;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *rate_output;
gdouble fade_point;
gdouble dynamic_rate;
gint timeout;
fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
......@@ -153,11 +154,13 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
airbrush->drawable = drawable;
airbrush->paint_options = paint_options;
dynamic_rate =
gimp_dynamics_output_get_linear_value (dynamics->rate_output,
coords,
paint_options,
fade_point);
rate_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_RATE);
dynamic_rate = gimp_dynamics_output_get_linear_value (rate_output,
coords,
paint_options,
fade_point);
timeout = 10000 / (options->rate * dynamic_rate);
......@@ -191,20 +194,23 @@ gimp_airbrush_motion (GimpPaintCore *paint_core,
{
GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (paint_options);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *flow_output;
gdouble opacity;
gdouble fade_point;
flow_output = gimp_dynamics_get_output (GIMP_BRUSH_CORE (paint_core)->dynamics,
GIMP_DYNAMICS_OUTPUT_FLOW);
fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
opacity = options->flow / 100.0;
opacity *= gimp_dynamics_output_get_linear_value(GIMP_BRUSH_CORE(paint_core)->dynamics->flow_output,
coords,
paint_options,
fade_point);
opacity = (options->flow / 100.0 *
gimp_dynamics_output_get_linear_value (flow_output,
coords,
paint_options,
fade_point));
_gimp_paintbrush_motion (paint_core, drawable, paint_options, coords, opacity);
}
static gboolean
......
......@@ -361,13 +361,18 @@ gimp_brush_core_pre_paint (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush)
{
GimpDynamicsOutput *size_output;
size_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_SIZE);
fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
scale = paint_options->brush_size /
MAX (core->main_brush->mask->width,
core->main_brush->mask->height) *
gimp_dynamics_output_get_linear_value (core->dynamics->size_output,
gimp_dynamics_output_get_linear_value (size_output,
&current_coords,
paint_options,
fade_point);
......@@ -489,40 +494,40 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options,
guint32 time)
{
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpCoords last_coords;
GimpCoords current_coords;
GimpVector2 delta_vec;
gdouble delta_pressure;
gdouble delta_xtilt, delta_ytilt;
gdouble delta_wheel;
gdouble delta_velocity;
gdouble temp_direction;
GimpVector2 temp_vec;
gint n, num_points;
gdouble t0, dt, tn;
gdouble st_factor, st_offset;
gdouble initial;
gdouble dist;
gdouble total;
gdouble pixel_dist;
gdouble pixel_initial;
gdouble xd, yd;
gdouble mag;
gdouble dyn_spacing = core->spacing;
gdouble fade_point;
gboolean use_dyn_spacing;
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *spacing_output;
GimpCoords last_coords;
GimpCoords current_coords;
GimpVector2 delta_vec;
gdouble delta_pressure;
gdouble delta_xtilt, delta_ytilt;
gdouble delta_wheel;
gdouble delta_velocity;
gdouble temp_direction;
GimpVector2 temp_vec;
gint n, num_points;
gdouble t0, dt, tn;
gdouble st_factor, st_offset;
gdouble initial;
gdouble dist;
gdouble total;
gdouble pixel_dist;
gdouble pixel_initial;
gdouble xd, yd;
gdouble mag;
gdouble dyn_spacing = core->spacing;
gdouble fade_point;
gboolean use_dyn_spacing;
g_return_if_fail (GIMP_IS_BRUSH (core->brush));
gimp_paint_core_get_last_coords (paint_core, &last_coords);
gimp_paint_core_get_current_coords (paint_core, &current_coords);
/*Zero sized brushes are unfit for interpolate,
* so we just let paint core fail onits own
**/
/* Zero sized brushes are unfit for interpolate, so we just let
* paint core fail onits own
*/
if (core->scale == 0.0)
{
gimp_paint_core_set_last_coords (paint_core, &current_coords);
......@@ -532,19 +537,20 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
return;
}
spacing_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_SPACING);
fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
use_dyn_spacing =
gimp_dynamics_output_is_enabled (core->dynamics->spacing_output);
use_dyn_spacing = gimp_dynamics_output_is_enabled (spacing_output);
if (use_dyn_spacing)
{
dyn_spacing =
gimp_dynamics_output_get_linear_value (core->dynamics->spacing_output,
&current_coords,
paint_options,
fade_point);
dyn_spacing = gimp_dynamics_output_get_linear_value (spacing_output,
&current_coords,
paint_options,
fade_point);
/* Dynamic spacing assumes that the value set in core is the min
* value and the max is full 200% spacing. This approach differs
......@@ -769,16 +775,19 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
if (core->jitter > 0.0)
{
gdouble dyn_jitter;
gdouble jitter_dist;
gint32 jitter_angle;
GimpDynamicsOutput *jitter_output;
gdouble dyn_jitter;
gdouble jitter_dist;
gint32 jitter_angle;
jitter_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_JITTER);
dyn_jitter =
core->jitter *
gimp_dynamics_output_get_linear_value (core->dynamics->jitter_output,
&current_coords,
paint_options,
fade_point);
dyn_jitter = (core->jitter *
gimp_dynamics_output_get_linear_value (jitter_output,
&current_coords,
paint_options,
fade_point));
jitter_dist = g_rand_double_range (core->rand, 0, dyn_jitter);
jitter_angle = g_rand_int_range (core->rand,
......@@ -1707,7 +1716,12 @@ gimp_brush_core_eval_transform_dynamics (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush)
{
gdouble dyn_aspect_ratio = 0.0;
GimpDynamicsOutput *size_output;
GimpDynamicsOutput *angle_output;
GimpDynamicsOutput *hardness_output;
GimpDynamicsOutput *aspect_output;
gdouble dyn_aspect_ratio = 0.0;
if (drawable)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -1716,35 +1730,42 @@ gimp_brush_core_eval_transform_dynamics (GimpPaintCore *paint_core,
paint_core->pixel_dist);
}
core->scale *=
gimp_dynamics_output_get_linear_value (core->dynamics->size_output,
coords,
paint_options,
fade_point);
core->angle +=
gimp_dynamics_output_get_angular_value (core->dynamics->angle_output,
coords,
paint_options,
fade_point);
size_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_SIZE);
angle_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_ANGLE);
hardness_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS);
hardness_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS);
aspect_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO);
core->scale *= gimp_dynamics_output_get_linear_value (size_output,
coords,
paint_options,
fade_point);
core->angle += gimp_dynamics_output_get_angular_value (angle_output,
coords,
paint_options,
fade_point);
core->hardness =
gimp_dynamics_output_get_linear_value (core->dynamics->hardness_output,
coords,
paint_options,
fade_point);
core->hardness = gimp_dynamics_output_get_linear_value (hardness_output,
coords,
paint_options,
fade_point);
dyn_aspect_ratio =
gimp_dynamics_output_get_aspect_value (core->dynamics->aspect_ratio_output,
coords,