[gimp] Stop accessing GimpPaintCore's coords members directly (no encapsulation yet).
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp] Stop accessing GimpPaintCore's coords members directly (no encapsulation yet).
- Date: Sun, 3 May 2009 06:08:57 -0400 (EDT)
commit 07ba32d6f8458ccfabfcb8debcd5335efe013050
Author: Michael Natterer <mitch gimp org>
Date: Sun May 3 12:08:21 2009 +0200
Stop accessing GimpPaintCore's coords members directly (no encapsulation yet).
* app/paint/gimppaintcore.[ch]: add
gimp_paint_core_{get|set}_{current|last}_coords(), add "const GimpCoords*"
parameter to ::paint() which gets core->cur_coords passed.
* app/paint/gimpsourcecore.[ch]: add "const GimpCoords*" to ::motion().
* app/paint/gimpbrushcore.c: use the new coords getters/setters instead
of accessing GimpPaintCore members directly.
* app/paint/gimpairbrush.c
* app/paint/gimpclone.c
* app/paint/gimpconvolve.c
* app/paint/gimpdodgeburn.c
* app/paint/gimperaser.c
* app/paint/gimpheal.c
* app/paint/gimpink.c
* app/paint/gimppaintbrush.[ch]
* app/paint/gimpperspectiveclone.c
* app/paint/gimpsmudge.c: change implementations of GimpPaintCore::paint()
and GimpSourceCore::motion() accordingly. app/paint/ is now virtually
free of direct access to the paint core's coords members. More to come...
---
app/paint/gimpairbrush.c | 25 ++++--
app/paint/gimpbrushcore.c | 193 +++++++++++++++++++++-----------------
app/paint/gimpclone.c | 8 +-
app/paint/gimpconvolve.c | 41 +++++----
app/paint/gimpdodgeburn.c | 16 ++--
app/paint/gimperaser.c | 16 ++--
app/paint/gimpheal.c | 8 +-
app/paint/gimpink.c | 36 +++++---
app/paint/gimppaintbrush.c | 14 ++--
app/paint/gimppaintbrush.h | 1 +
app/paint/gimppaintcore.c | 43 +++++++++
app/paint/gimppaintcore.h | 11 ++
app/paint/gimpperspectiveclone.c | 16 ++--
app/paint/gimpsmudge.c | 51 ++++++-----
app/paint/gimpsourcecore.c | 24 +++--
app/paint/gimpsourcecore.h | 4 +-
16 files changed, 313 insertions(+), 194 deletions(-)
diff --git a/app/paint/gimpairbrush.c b/app/paint/gimpairbrush.c
index c5c8b27..9d03136 100644
--- a/app/paint/gimpairbrush.c
+++ b/app/paint/gimpairbrush.c
@@ -44,11 +44,13 @@ static void gimp_airbrush_finalize (GObject *object);
static void gimp_airbrush_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static void gimp_airbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
static gboolean gimp_airbrush_timeout (gpointer data);
@@ -104,6 +106,7 @@ static void
gimp_airbrush_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
@@ -121,6 +124,7 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
GIMP_PAINT_CORE_CLASS (parent_class)->paint (paint_core, drawable,
paint_options,
+ coords,
paint_state, time);
break;
@@ -131,7 +135,7 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
airbrush->timeout_id = 0;
}
- gimp_airbrush_motion (paint_core, drawable, paint_options);
+ gimp_airbrush_motion (paint_core, drawable, paint_options, coords);
if (options->rate != 0.0)
{
@@ -142,7 +146,7 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
airbrush->paint_options = paint_options;
dynamic_rate = gimp_paint_options_get_dynamic_rate (paint_options,
- &paint_core->cur_coords);
+ coords);
timeout = 10000 / (options->rate * dynamic_rate);
@@ -161,6 +165,7 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
GIMP_PAINT_CORE_CLASS (parent_class)->paint (paint_core, drawable,
paint_options,
+ coords,
paint_state, time);
break;
}
@@ -169,7 +174,9 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
static void
gimp_airbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options)
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords)
+
{
GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (paint_options);
gdouble opacity;
@@ -182,15 +189,15 @@ gimp_airbrush_motion (GimpPaintCore *paint_core,
saved_velocity = paint_options->velocity_options->hardness;
if (saved_pressure)
- opacity *= GIMP_PAINT_PRESSURE_SCALE * paint_core->cur_coords.pressure;
+ opacity *= GIMP_PAINT_PRESSURE_SCALE * coords->pressure;
if (saved_velocity)
- opacity *= MAX (0.0, 1 - GIMP_PAINT_VELOCITY_SCALE * paint_core->cur_coords.velocity);
+ opacity *= MAX (0.0, 1 - GIMP_PAINT_VELOCITY_SCALE * coords->velocity);
paint_options->pressure_options->hardness = FALSE;
paint_options->velocity_options->hardness = FALSE;
- _gimp_paintbrush_motion (paint_core, drawable, paint_options, opacity);
+ _gimp_paintbrush_motion (paint_core, drawable, paint_options, coords, opacity);
paint_options->pressure_options->hardness = saved_pressure;
paint_options->velocity_options->hardness = saved_velocity;
@@ -200,10 +207,14 @@ static gboolean
gimp_airbrush_timeout (gpointer data)
{
GimpAirbrush *airbrush = GIMP_AIRBRUSH (data);
+ GimpCoords coords;
+
+ gimp_paint_core_get_current_coords (GIMP_PAINT_CORE (airbrush), &coords);
gimp_airbrush_paint (GIMP_PAINT_CORE (airbrush),
airbrush->drawable,
airbrush->paint_options,
+ &coords,
GIMP_PAINT_STATE_MOTION, 0);
gimp_image_flush (gimp_item_get_image (GIMP_ITEM (airbrush->drawable)));
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 0b7f210..9ae24d5 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -302,16 +302,22 @@ gimp_brush_core_pre_paint (GimpPaintCore *paint_core,
if (paint_state == GIMP_PAINT_STATE_MOTION)
{
+ GimpCoords last_coords;
+ GimpCoords current_coords;
+
+ gimp_paint_core_get_last_coords (paint_core, &last_coords);
+ gimp_paint_core_get_current_coords (paint_core, ¤t_coords);
+
/* If we current point == last point, check if the brush
* wants to be painted in that case. (Direction dependent
* pixmap brush pipes don't, as they don't know which
* pixmap to select.)
*/
- if (paint_core->last_coords.x == paint_core->cur_coords.x &&
- paint_core->last_coords.y == paint_core->cur_coords.y &&
+ if (last_coords.x == current_coords.x &&
+ last_coords.y == current_coords.y &&
! gimp_brush_want_null_motion (core->main_brush,
- &paint_core->last_coords,
- &paint_core->cur_coords))
+ &last_coords,
+ ¤t_coords))
{
return FALSE;
}
@@ -319,8 +325,8 @@ gimp_brush_core_pre_paint (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (paint_core)->handles_changing_brush)
{
core->brush = gimp_brush_select_brush (core->main_brush,
- &paint_core->last_coords,
- &paint_core->cur_coords);
+ &last_coords,
+ ¤t_coords);
}
}
@@ -419,6 +425,8 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
guint32 time)
{
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
+ GimpCoords last_coords;
+ GimpCoords current_coords;
GimpVector2 delta_vec;
gdouble delta_pressure;
gdouble delta_xtilt, delta_ytilt;
@@ -439,19 +447,22 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
g_return_if_fail (GIMP_IS_BRUSH (core->brush));
- gimp_avoid_exact_integer (&paint_core->last_coords.x);
- gimp_avoid_exact_integer (&paint_core->last_coords.y);
- gimp_avoid_exact_integer (&paint_core->cur_coords.x);
- gimp_avoid_exact_integer (&paint_core->cur_coords.y);
+ gimp_paint_core_get_last_coords (paint_core, &last_coords);
+ gimp_paint_core_get_current_coords (paint_core, ¤t_coords);
- delta_vec.x = paint_core->cur_coords.x - paint_core->last_coords.x;
- delta_vec.y = paint_core->cur_coords.y - paint_core->last_coords.y;
- delta_pressure = paint_core->cur_coords.pressure - paint_core->last_coords.pressure;
- delta_xtilt = paint_core->cur_coords.xtilt - paint_core->last_coords.xtilt;
- delta_ytilt = paint_core->cur_coords.ytilt - paint_core->last_coords.ytilt;
- delta_wheel = paint_core->cur_coords.wheel - paint_core->last_coords.wheel;
- delta_velocity = paint_core->cur_coords.velocity - paint_core->last_coords.velocity;
- temp_direction = paint_core->cur_coords.direction;
+ gimp_avoid_exact_integer (&last_coords.x);
+ gimp_avoid_exact_integer (&last_coords.y);
+ gimp_avoid_exact_integer (¤t_coords.x);
+ gimp_avoid_exact_integer (¤t_coords.y);
+
+ delta_vec.x = current_coords.x - last_coords.x;
+ delta_vec.y = current_coords.y - last_coords.y;
+ delta_pressure = current_coords.pressure - last_coords.pressure;
+ delta_xtilt = current_coords.xtilt - last_coords.xtilt;
+ delta_ytilt = current_coords.ytilt - last_coords.ytilt;
+ delta_wheel = current_coords.wheel - last_coords.wheel;
+ delta_velocity = current_coords.velocity - last_coords.velocity;
+ temp_direction = current_coords.direction;
/* return if there has been no motion */
if (! delta_vec.x &&
@@ -484,8 +495,8 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
pixel_initial = paint_core->pixel_dist;
/* FIXME: need to adapt the spacing to the size */
- /* lastscale = MIN (paint_core->last_coords.pressure, 1/256); */
- /* curscale = MIN (paint_core->cur_coords.pressure, 1/256); */
+ /* lastscale = MIN (last_coords.pressure, 1/256); */
+ /* curscale = MIN (current_coords.pressure, 1/256); */
/* spacing = core->spacing * sqrt (0.5 * (lastscale + curscale)); */
/* Compute spacing parameters such that a brush position will be
@@ -505,12 +516,12 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
if (delta_vec.x * delta_vec.x > delta_vec.y * delta_vec.y)
{
st_factor = delta_vec.x;
- st_offset = paint_core->last_coords.x - 0.5;
+ st_offset = last_coords.x - 0.5;
}
else
{
st_factor = delta_vec.y;
- st_offset = paint_core->last_coords.y - 0.5;
+ st_offset = last_coords.y - 0.5;
}
if (fabs (st_factor) > dist / core->spacing)
@@ -543,10 +554,13 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
else if (fabs (st_factor) < EPSILON)
{
/* Hm, we've hardly moved at all. Don't draw anything, but reset the
- * old coordinates and hope we've gone longer the next time.
+ * old coordinates and hope we've gone longer the next time...
*/
- paint_core->cur_coords.x = paint_core->last_coords.x;
- paint_core->cur_coords.y = paint_core->last_coords.y;
+ current_coords.x = last_coords.x;
+ current_coords.y = last_coords.y;
+
+ gimp_paint_core_set_current_coords (paint_core, ¤t_coords);
+
/* ... but go along with the current pressure, tilt and wheel */
return;
}
@@ -578,11 +592,11 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
t0 = (s0 - st_offset) / st_factor;
tn = (sn - st_offset) / st_factor;
- x = (gint) floor (paint_core->last_coords.x + t0 * delta_vec.x);
- y = (gint) floor (paint_core->last_coords.y + t0 * delta_vec.y);
+ x = (gint) floor (last_coords.x + t0 * delta_vec.x);
+ y = (gint) floor (last_coords.y + t0 * delta_vec.y);
- if (t0 < 0.0 && !( x == (gint) floor (paint_core->last_coords.x) &&
- y == (gint) floor (paint_core->last_coords.y) ))
+ if (t0 < 0.0 && !( x == (gint) floor (last_coords.x) &&
+ y == (gint) floor (last_coords.y) ))
{
/* Exception A: If the first stripe's brush position is
* EXTRApolated into a different pixel square than the
@@ -600,11 +614,11 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
s0 += direction;
}
- x = (gint) floor (paint_core->last_coords.x + tn * delta_vec.x);
- y = (gint) floor (paint_core->last_coords.y + tn * delta_vec.y);
+ x = (gint) floor (last_coords.x + tn * delta_vec.x);
+ y = (gint) floor (last_coords.y + tn * delta_vec.y);
- if (tn > 1.0 && !( x == (gint) floor (paint_core->cur_coords.x) &&
- y == (gint) floor (paint_core->cur_coords.y)))
+ if (tn > 1.0 && !( x == (gint) floor (current_coords.x) &&
+ y == (gint) floor (current_coords.y)))
{
/* Exception C: If the last stripe's brush position is
* EXTRApolated into a different pixel square than the
@@ -641,21 +655,14 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
gdouble t = t0 + n * dt;
gdouble p = (gdouble) n / num_points;
- paint_core->cur_coords.x = (paint_core->last_coords.x +
- t * delta_vec.x);
- paint_core->cur_coords.y = (paint_core->last_coords.y +
- t * delta_vec.y);
- paint_core->cur_coords.pressure = (paint_core->last_coords.pressure +
- p * delta_pressure);
- paint_core->cur_coords.xtilt = (paint_core->last_coords.xtilt +
- p * delta_xtilt);
- paint_core->cur_coords.ytilt = (paint_core->last_coords.ytilt +
- p * delta_ytilt);
- paint_core->cur_coords.wheel = (paint_core->last_coords.wheel +
- p * delta_wheel);
- paint_core->cur_coords.velocity = (paint_core->last_coords.velocity +
- p * delta_velocity);
- paint_core->cur_coords.direction = temp_direction;
+ current_coords.x = last_coords.x + t * delta_vec.x;
+ current_coords.y = last_coords.y + t * delta_vec.y;
+ current_coords.pressure = last_coords.pressure + p * delta_pressure;
+ current_coords.xtilt = last_coords.xtilt + p * delta_xtilt;
+ current_coords.ytilt = last_coords.ytilt + p * delta_ytilt;
+ current_coords.wheel = last_coords.wheel + p * delta_wheel;
+ current_coords.velocity = last_coords.velocity + p * delta_velocity;
+ current_coords.direction = temp_direction;
if (core->jitter > 0.0)
{
@@ -666,15 +673,17 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
jitter_angle = g_rand_int_range (core->rand,
0, BRUSH_CORE_JITTER_LUTSIZE);
- paint_core->cur_coords.x +=
+ current_coords.x +=
(core->brush->x_axis.x + core->brush->y_axis.x) *
jitter_dist * core->jitter_lut_x[jitter_angle] * core->scale;
- paint_core->cur_coords.y +=
+ current_coords.y +=
(core->brush->y_axis.y + core->brush->x_axis.y) *
jitter_dist * core->jitter_lut_y[jitter_angle] * core->scale;
}
+ gimp_paint_core_set_current_coords (paint_core, ¤t_coords);
+
paint_core->distance = initial + t * dist;
paint_core->pixel_dist = pixel_initial + t * pixel_dist;
@@ -682,18 +691,19 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
GIMP_PAINT_STATE_MOTION, time);
}
- paint_core->cur_coords.x = paint_core->last_coords.x + delta_vec.x;
- paint_core->cur_coords.y = paint_core->last_coords.y + delta_vec.y;
- paint_core->cur_coords.pressure = paint_core->last_coords.pressure + delta_pressure;
- paint_core->cur_coords.xtilt = paint_core->last_coords.xtilt + delta_xtilt;
- paint_core->cur_coords.ytilt = paint_core->last_coords.ytilt + delta_ytilt;
- paint_core->cur_coords.wheel = paint_core->last_coords.wheel + delta_wheel;
- paint_core->cur_coords.velocity = paint_core->last_coords.velocity + delta_velocity;
+ current_coords.x = last_coords.x + delta_vec.x;
+ current_coords.y = last_coords.y + delta_vec.y;
+ current_coords.pressure = last_coords.pressure + delta_pressure;
+ current_coords.xtilt = last_coords.xtilt + delta_xtilt;
+ current_coords.ytilt = last_coords.ytilt + delta_ytilt;
+ current_coords.wheel = last_coords.wheel + delta_wheel;
+ current_coords.velocity = last_coords.velocity + delta_velocity;
+
+ gimp_paint_core_set_current_coords (paint_core, ¤t_coords);
+ gimp_paint_core_set_last_coords (paint_core, ¤t_coords);
paint_core->distance = total;
paint_core->pixel_dist = pixel_initial + pixel_dist;
-
- paint_core->last_coords = paint_core->cur_coords;
}
static TempBuf *
@@ -702,23 +712,26 @@ gimp_brush_core_get_paint_area (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options)
{
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
+ GimpCoords current_coords;
gint x, y;
gint x1, y1, x2, y2;
gint drawable_width, drawable_height;
gint brush_width, brush_height;
+ gimp_paint_core_get_current_coords (paint_core, ¤t_coords);
+
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_transforming_brush)
{
- core->scale = gimp_paint_options_get_dynamic_size (paint_options,
- &paint_core->cur_coords,
- TRUE);
+ core->scale = gimp_paint_options_get_dynamic_size (paint_options,
+ ¤t_coords,
+ TRUE);
- core->angle = gimp_paint_options_get_dynamic_angle (paint_options,
- &paint_core->cur_coords);
+ core->angle = gimp_paint_options_get_dynamic_angle (paint_options,
+ ¤t_coords);
core->aspect_ratio =
- gimp_paint_options_get_dynamic_aspect_ratio (paint_options,
- &paint_core->cur_coords);
+ gimp_paint_options_get_dynamic_aspect_ratio (paint_options,
+ ¤t_coords);
}
core->scale = gimp_brush_core_clamp_brush_scale (core, core->scale);
@@ -726,8 +739,8 @@ gimp_brush_core_get_paint_area (GimpPaintCore *paint_core,
gimp_brush_transform_size (core->brush, core->scale, core->aspect_ratio, core->angle, &brush_width, &brush_height);
/* adjust the x and y coordinates to the upper left corner of the brush */
- x = (gint) floor (paint_core->cur_coords.x) - (brush_width / 2);
- y = (gint) floor (paint_core->cur_coords.y) - (brush_height / 2);
+ x = (gint) floor (current_coords.x) - (brush_width / 2);
+ y = (gint) floor (current_coords.y) - (brush_height / 2);
drawable_width = gimp_item_get_width (GIMP_ITEM (drawable));
drawable_height = gimp_item_get_height (GIMP_ITEM (drawable));
@@ -874,14 +887,17 @@ gimp_brush_core_paste_canvas (GimpBrushCore *core,
if (brush_mask)
{
GimpPaintCore *paint_core = GIMP_PAINT_CORE (core);
+ GimpCoords current_coords;
PixelRegion brush_maskPR;
gint x;
gint y;
gint off_x;
gint off_y;
- x = (gint) floor (paint_core->cur_coords.x) - (brush_mask->width >> 1);
- y = (gint) floor (paint_core->cur_coords.y) - (brush_mask->height >> 1);
+ gimp_paint_core_get_current_coords (paint_core, ¤t_coords);
+
+ x = (gint) floor (current_coords.x) - (brush_mask->width >> 1);
+ y = (gint) floor (current_coords.y) - (brush_mask->height >> 1);
off_x = (x < 0) ? -x : 0;
off_y = (y < 0) ? -y : 0;
@@ -918,14 +934,17 @@ gimp_brush_core_replace_canvas (GimpBrushCore *core,
if (brush_mask)
{
GimpPaintCore *paint_core = GIMP_PAINT_CORE (core);
+ GimpCoords current_coords;
PixelRegion brush_maskPR;
gint x;
gint y;
gint off_x;
gint off_y;
- x = (gint) floor (paint_core->cur_coords.x) - (brush_mask->width >> 1);
- y = (gint) floor (paint_core->cur_coords.y) - (brush_mask->height >> 1);
+ gimp_paint_core_get_current_coords (paint_core, ¤t_coords);
+
+ x = (gint) floor (current_coords.x) - (brush_mask->width >> 1);
+ y = (gint) floor (current_coords.y) - (brush_mask->height >> 1);
off_x = (x < 0) ? -x : 0;
off_y = (y < 0) ? -y : 0;
@@ -1358,7 +1377,7 @@ gimp_brush_core_transform_mask (GimpBrushCore *core,
static TempBuf *
gimp_brush_core_transform_pixmap (GimpBrushCore *core,
- GimpBrush *brush)
+ GimpBrush *brush)
{
gint width;
gint height;
@@ -1406,6 +1425,7 @@ gimp_brush_core_get_brush_mask (GimpBrushCore *core,
gdouble dynamic_hardness)
{
GimpPaintCore *paint_core = GIMP_PAINT_CORE (core);
+ GimpCoords current_coords;
TempBuf *mask;
mask = gimp_brush_core_transform_mask (core, core->brush);
@@ -1413,24 +1433,26 @@ gimp_brush_core_get_brush_mask (GimpBrushCore *core,
if (! mask)
return NULL;
+ gimp_paint_core_get_current_coords (paint_core, ¤t_coords);
+
switch (brush_hardness)
{
case GIMP_BRUSH_SOFT:
mask = gimp_brush_core_subsample_mask (core, mask,
- paint_core->cur_coords.x,
- paint_core->cur_coords.y);
+ current_coords.x,
+ current_coords.y);
break;
case GIMP_BRUSH_HARD:
mask = gimp_brush_core_solidify_mask (core, mask,
- paint_core->cur_coords.x,
- paint_core->cur_coords.y);
+ current_coords.x,
+ current_coords.y);
break;
case GIMP_BRUSH_PRESSURE:
mask = gimp_brush_core_pressurize_mask (core, mask,
- paint_core->cur_coords.x,
- paint_core->cur_coords.y,
+ current_coords.x,
+ current_coords.y,
dynamic_hardness);
break;
@@ -1453,6 +1475,7 @@ gimp_brush_core_color_area_with_pixmap (GimpBrushCore *core,
GimpBrushApplicationMode mode)
{
GimpPaintCore *paint_core = GIMP_PAINT_CORE (core);
+ GimpCoords current_coords;
GimpImage *image;
PixelRegion destPR;
void *pr;
@@ -1464,8 +1487,6 @@ gimp_brush_core_color_area_with_pixmap (GimpBrushCore *core,
gint y;
TempBuf *pixmap_mask;
TempBuf *brush_mask;
- gdouble X = paint_core->cur_coords.x;
- gdouble Y = paint_core->cur_coords.y;
g_return_if_fail (GIMP_IS_BRUSH (core->brush));
g_return_if_fail (core->brush->pixmap != NULL);
@@ -1478,6 +1499,8 @@ gimp_brush_core_color_area_with_pixmap (GimpBrushCore *core,
if (! pixmap_mask)
return;
+ gimp_paint_core_get_current_coords (paint_core, ¤t_coords);
+
if (mode != GIMP_BRUSH_HARD)
brush_mask = gimp_brush_core_transform_mask (core, core->brush);
else
@@ -1491,16 +1514,16 @@ gimp_brush_core_color_area_with_pixmap (GimpBrushCore *core,
/* Calculate upper left corner of brush as in
* gimp_paint_core_get_paint_area. Ugly to have to do this here, too.
*/
- ulx = (gint) floor (X) - (pixmap_mask->width >> 1);
- uly = (gint) floor (Y) - (pixmap_mask->height >> 1);
+ ulx = (gint) floor (current_coords.x) - (pixmap_mask->width >> 1);
+ uly = (gint) floor (current_coords.y) - (pixmap_mask->height >> 1);
/* Not sure why this is necessary, but empirically the code does
* not work without it for even-sided brushes. See bug #166622.
*/
if (pixmap_mask->width %2 == 0)
- ulx += ROUND (X) - floor (X);
+ ulx += ROUND (current_coords.x) - floor (current_coords.x);
if (pixmap_mask->height %2 == 0)
- uly += ROUND (Y) - floor (Y);
+ uly += ROUND (current_coords.y) - floor (current_coords.y);
offsetx = area->x - ulx;
offsety = area->y - uly;
diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c
index aa15b16..1b99d58 100644
--- a/app/paint/gimpclone.c
+++ b/app/paint/gimpclone.c
@@ -53,6 +53,7 @@ static gboolean gimp_clone_start (GimpPaintCore *paint_core,
static void gimp_clone_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
gdouble opacity,
GimpPickable *src_pickable,
PixelRegion *srcPR,
@@ -149,6 +150,7 @@ static void
gimp_clone_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
gdouble opacity,
GimpPickable *src_pickable,
PixelRegion *srcPR,
@@ -236,11 +238,9 @@ gimp_clone_motion (GimpSourceCore *source_core,
}
}
- opacity *= gimp_paint_options_get_dynamic_opacity (paint_options,
- &paint_core->cur_coords);
+ opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
- hardness = gimp_paint_options_get_dynamic_hardness (paint_options,
- &paint_core->cur_coords);
+ hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
MIN (opacity, GIMP_OPACITY_OPAQUE),
diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c
index 8587ecf..46cbe5b 100644
--- a/app/paint/gimpconvolve.c
+++ b/app/paint/gimpconvolve.c
@@ -45,21 +45,23 @@
#define MAX_SHARPEN -64
-static void gimp_convolve_paint (GimpPaintCore *paint_core,
- GimpDrawable *drawable,
- GimpPaintOptions *paint_options,
- GimpPaintState paint_state,
- guint32 time);
-static void gimp_convolve_motion (GimpPaintCore *paint_core,
- GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
-
-static void gimp_convolve_calculate_matrix (GimpConvolve *convolve,
- GimpConvolveType type,
- gint radius_x,
- gint radius_y,
- gdouble rate);
-static gdouble gimp_convolve_sum_matrix (const gfloat *matrix);
+static void gimp_convolve_paint (GimpPaintCore *paint_core,
+ GimpDrawable *drawable,
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
+ GimpPaintState paint_state,
+ guint32 time);
+static void gimp_convolve_motion (GimpPaintCore *paint_core,
+ GimpDrawable *drawable,
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
+
+static void gimp_convolve_calculate_matrix (GimpConvolve *convolve,
+ GimpConvolveType type,
+ gint radius_x,
+ gint radius_y,
+ gdouble rate);
+static gdouble gimp_convolve_sum_matrix (const gfloat *matrix);
G_DEFINE_TYPE (GimpConvolve, gimp_convolve, GIMP_TYPE_BRUSH_CORE)
@@ -100,13 +102,14 @@ static void
gimp_convolve_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
switch (paint_state)
{
case GIMP_PAINT_STATE_MOTION:
- gimp_convolve_motion (paint_core, drawable, paint_options);
+ gimp_convolve_motion (paint_core, drawable, paint_options, coords);
break;
default:
@@ -117,7 +120,8 @@ gimp_convolve_paint (GimpPaintCore *paint_core,
static void
gimp_convolve_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options)
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords)
{
GimpConvolve *convolve = GIMP_CONVOLVE (paint_core);
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core);
@@ -149,8 +153,7 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
rate = options->rate;
- rate *= gimp_paint_options_get_dynamic_rate (paint_options,
- &paint_core->cur_coords);
+ rate *= gimp_paint_options_get_dynamic_rate (paint_options, coords);
gimp_convolve_calculate_matrix (convolve, options->type,
brush_core->brush->mask->width / 2,
diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c
index db6a6da..72c48c9 100644
--- a/app/paint/gimpdodgeburn.c
+++ b/app/paint/gimpdodgeburn.c
@@ -44,11 +44,13 @@ static void gimp_dodge_burn_finalize (GObject *object);
static void gimp_dodge_burn_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static void gimp_dodge_burn_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
static void gimp_dodge_burn_make_luts (GimpDodgeBurn *dodgeburn,
gdouble db_exposure,
@@ -124,6 +126,7 @@ static void
gimp_dodge_burn_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
@@ -143,7 +146,7 @@ gimp_dodge_burn_paint (GimpPaintCore *paint_core,
break;
case GIMP_PAINT_STATE_MOTION:
- gimp_dodge_burn_motion (paint_core, drawable, paint_options);
+ gimp_dodge_burn_motion (paint_core, drawable, paint_options, coords);
break;
case GIMP_PAINT_STATE_FINISH:
@@ -159,7 +162,8 @@ gimp_dodge_burn_paint (GimpPaintCore *paint_core,
static void
gimp_dodge_burn_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options)
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords)
{
GimpDodgeBurn *dodgeburn = GIMP_DODGE_BURN (paint_core);
GimpContext *context = GIMP_CONTEXT (paint_options);
@@ -235,11 +239,9 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
g_free (temp_data);
- opacity *= gimp_paint_options_get_dynamic_opacity (paint_options,
- &paint_core->cur_coords);
+ opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
- hardness = gimp_paint_options_get_dynamic_hardness (paint_options,
- &paint_core->cur_coords);
+ hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
/* Replace the newly dodgedburned area (canvas_buf) to the image */
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c
index 5a66734..85a54d2 100644
--- a/app/paint/gimperaser.c
+++ b/app/paint/gimperaser.c
@@ -40,11 +40,13 @@
static void gimp_eraser_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static void gimp_eraser_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
G_DEFINE_TYPE (GimpEraser, gimp_eraser, GIMP_TYPE_BRUSH_CORE)
@@ -82,13 +84,14 @@ static void
gimp_eraser_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
switch (paint_state)
{
case GIMP_PAINT_STATE_MOTION:
- gimp_eraser_motion (paint_core, drawable, paint_options);
+ gimp_eraser_motion (paint_core, drawable, paint_options, coords);
break;
default:
@@ -99,7 +102,8 @@ gimp_eraser_paint (GimpPaintCore *paint_core,
static void
gimp_eraser_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options)
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords)
{
GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
@@ -130,11 +134,9 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
color_pixels (temp_buf_get_data (area), col,
area->width * area->height, area->bytes);
- opacity *= gimp_paint_options_get_dynamic_opacity (paint_options,
- &paint_core->cur_coords);
+ opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
- hardness = gimp_paint_options_get_dynamic_hardness (paint_options,
- &paint_core->cur_coords);
+ hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
MIN (opacity, GIMP_OPACITY_OPAQUE),
diff --git a/app/paint/gimpheal.c b/app/paint/gimpheal.c
index 61166ac..99ac4eb 100644
--- a/app/paint/gimpheal.c
+++ b/app/paint/gimpheal.c
@@ -87,6 +87,7 @@ static PixelRegion *gimp_heal_region (PixelRegion *tempPR,
static void gimp_heal_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
gdouble opacity,
GimpPickable *src_pickable,
PixelRegion *srcPR,
@@ -415,6 +416,7 @@ static void
gimp_heal_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
gdouble opacity,
GimpPickable *src_pickable,
PixelRegion *srcPR,
@@ -437,8 +439,7 @@ gimp_heal_motion (GimpSourceCore *source_core,
TempBuf *mask_buf;
gdouble hardness;
- hardness = gimp_paint_options_get_dynamic_hardness (paint_options,
- &paint_core->cur_coords);
+ hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
mask_buf = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (source_core),
GIMP_BRUSH_HARD,
@@ -545,8 +546,7 @@ gimp_heal_motion (GimpSourceCore *source_core,
temp_buf_free (temp);
- opacity *= gimp_paint_options_get_dynamic_opacity (paint_options,
- &paint_core->cur_coords);
+ opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
/* replace the canvas with our healed data */
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core),
diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c
index 745b866..8567b00 100644
--- a/app/paint/gimpink.c
+++ b/app/paint/gimpink.c
@@ -52,6 +52,7 @@ static void gimp_ink_finalize (GObject *object);
static void gimp_ink_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static TempBuf * gimp_ink_get_paint_area (GimpPaintCore *paint_core,
@@ -64,6 +65,7 @@ static GimpUndo* gimp_ink_push_undo (GimpPaintCore *core,
static void gimp_ink_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
guint32 time);
static Blob * ink_pen_ellipse (GimpInkOptions *options,
@@ -137,6 +139,7 @@ static void
gimp_ink_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
@@ -144,9 +147,13 @@ gimp_ink_paint (GimpPaintCore *paint_core,
switch (paint_state)
{
+ GimpCoords last_coords;
+
case GIMP_PAINT_STATE_INIT:
- if (paint_core->cur_coords.x == paint_core->last_coords.x &&
- paint_core->cur_coords.y == paint_core->last_coords.y)
+ gimp_paint_core_get_last_coords (paint_core, &last_coords);
+
+ if (coords->x == last_coords.x &&
+ coords->y == last_coords.y)
{
/* start with new blobs if we're not interpolating */
@@ -174,7 +181,7 @@ gimp_ink_paint (GimpPaintCore *paint_core,
break;
case GIMP_PAINT_STATE_MOTION:
- gimp_ink_motion (paint_core, drawable, paint_options, time);
+ gimp_ink_motion (paint_core, drawable, paint_options, coords, time);
break;
case GIMP_PAINT_STATE_FINISH:
@@ -233,6 +240,7 @@ static void
gimp_ink_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
guint32 time)
{
GimpInk *ink = GIMP_INK (paint_core);
@@ -250,11 +258,11 @@ gimp_ink_motion (GimpPaintCore *paint_core,
if (! ink->last_blob)
{
ink->last_blob = ink_pen_ellipse (options,
- paint_core->cur_coords.x,
- paint_core->cur_coords.y,
- paint_core->cur_coords.pressure,
- paint_core->cur_coords.xtilt,
- paint_core->cur_coords.ytilt,
+ coords->x,
+ coords->y,
+ coords->pressure,
+ coords->xtilt,
+ coords->ytilt,
100);
if (ink->start_blob)
@@ -267,12 +275,12 @@ gimp_ink_motion (GimpPaintCore *paint_core,
else
{
Blob *blob = ink_pen_ellipse (options,
- paint_core->cur_coords.x,
- paint_core->cur_coords.y,
- paint_core->cur_coords.pressure,
- paint_core->cur_coords.xtilt,
- paint_core->cur_coords.ytilt,
- paint_core->cur_coords.velocity * 100);
+ coords->x,
+ coords->y,
+ coords->pressure,
+ coords->xtilt,
+ coords->ytilt,
+ coords->velocity * 100);
blob_union = blob_convex_union (ink->last_blob, blob);
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index 34f6701..a1096c2 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -44,6 +44,7 @@
static void gimp_paintbrush_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
@@ -83,13 +84,14 @@ static void
gimp_paintbrush_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
switch (paint_state)
{
case GIMP_PAINT_STATE_MOTION:
- _gimp_paintbrush_motion (paint_core, drawable, paint_options,
+ _gimp_paintbrush_motion (paint_core, drawable, paint_options, coords,
GIMP_OPACITY_OPAQUE);
break;
@@ -102,6 +104,7 @@ void
_gimp_paintbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
gdouble opacity)
{
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core);
@@ -127,8 +130,7 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
paint_appl_mode = paint_options->application_mode;
- grad_point = gimp_paint_options_get_dynamic_color (paint_options,
- &paint_core->cur_coords);
+ grad_point = gimp_paint_options_get_dynamic_color (paint_options, coords);
/* optionally take the color from the current gradient */
if (gimp_paint_options_get_gradient_color (paint_options, image,
@@ -172,11 +174,9 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
area->bytes);
}
- opacity *= gimp_paint_options_get_dynamic_opacity (paint_options,
- &paint_core->cur_coords);
+ opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
- hardness = gimp_paint_options_get_dynamic_hardness (paint_options,
- &paint_core->cur_coords);
+ hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
/* finally, let the brush core paste the colored area on the canvas */
gimp_brush_core_paste_canvas (brush_core, drawable,
diff --git a/app/paint/gimppaintbrush.h b/app/paint/gimppaintbrush.h
index 3fe110d..12756fc 100644
--- a/app/paint/gimppaintbrush.h
+++ b/app/paint/gimppaintbrush.h
@@ -54,6 +54,7 @@ GType gimp_paintbrush_get_type (void) G_GNUC_CONST;
void _gimp_paintbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
gdouble opacity);
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 49732b1..d9c5b03 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -82,6 +82,7 @@ static gboolean gimp_paint_core_real_pre_paint (GimpPaintCore *core,
static void gimp_paint_core_real_paint (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static void gimp_paint_core_real_post_paint (GimpPaintCore *core,
@@ -243,6 +244,7 @@ static void
gimp_paint_core_real_paint (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
@@ -321,6 +323,7 @@ gimp_paint_core_paint (GimpPaintCore *core,
core_class->paint (core, drawable,
paint_options,
+ &core->cur_coords,
paint_state, time);
core_class->post_paint (core, drawable,
@@ -574,6 +577,46 @@ gimp_paint_core_interpolate (GimpPaintCore *core,
paint_options, time);
}
+void
+gimp_paint_core_set_current_coords (GimpPaintCore *core,
+ const GimpCoords *coords)
+{
+ g_return_if_fail (GIMP_IS_PAINT_CORE (core));
+ g_return_if_fail (coords != NULL);
+
+ core->cur_coords = *coords;
+}
+
+void
+gimp_paint_core_get_current_coords (GimpPaintCore *core,
+ GimpCoords *coords)
+{
+ g_return_if_fail (GIMP_IS_PAINT_CORE (core));
+ g_return_if_fail (coords != NULL);
+
+ *coords = core->cur_coords;
+}
+
+void
+gimp_paint_core_set_last_coords (GimpPaintCore *core,
+ const GimpCoords *coords)
+{
+ g_return_if_fail (GIMP_IS_PAINT_CORE (core));
+ g_return_if_fail (coords != NULL);
+
+ core->last_coords = *coords;
+}
+
+void
+gimp_paint_core_get_last_coords (GimpPaintCore *core,
+ GimpCoords *coords)
+{
+ g_return_if_fail (GIMP_IS_PAINT_CORE (core));
+ g_return_if_fail (coords != NULL);
+
+ *coords = core->last_coords;
+}
+
/**
* gimp_paint_core_round_line:
* @core: the #GimpPaintCore
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index 524db7d..b27558c 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -84,6 +84,7 @@ struct _GimpPaintCoreClass
void (* paint) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
void (* post_paint) (GimpPaintCore *core,
@@ -132,6 +133,16 @@ void gimp_paint_core_interpolate (GimpPaintCore *core,
GimpPaintOptions *paint_options,
guint32 time);
+void gimp_paint_core_set_current_coords (GimpPaintCore *core,
+ const GimpCoords *coords);
+void gimp_paint_core_get_current_coords (GimpPaintCore *core,
+ GimpCoords *coords);
+
+void gimp_paint_core_set_last_coords (GimpPaintCore *core,
+ const GimpCoords *coords);
+void gimp_paint_core_get_last_coords (GimpPaintCore *core,
+ GimpCoords *coords);
+
void gimp_paint_core_round_line (GimpPaintCore *core,
GimpPaintOptions *options,
gboolean constrain_15_degrees);
diff --git a/app/paint/gimpperspectiveclone.c b/app/paint/gimpperspectiveclone.c
index cfb4880..3288c21 100644
--- a/app/paint/gimpperspectiveclone.c
+++ b/app/paint/gimpperspectiveclone.c
@@ -60,6 +60,7 @@ static gboolean gimp_perspective_clone_start (GimpPaintCore *paint_core,
static void gimp_perspective_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
@@ -171,6 +172,7 @@ static void
gimp_perspective_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
@@ -185,8 +187,8 @@ gimp_perspective_clone_paint (GimpPaintCore *paint_core,
{
g_object_set (source_core, "src-drawable", drawable, NULL);
- source_core->src_x = paint_core->cur_coords.x;
- source_core->src_y = paint_core->cur_coords.y;
+ source_core->src_x = coords->x;
+ source_core->src_y = coords->y;
/* get source coordinates in front view perspective */
gimp_matrix3_transform_point (&clone->transform_inv,
@@ -211,8 +213,8 @@ gimp_perspective_clone_paint (GimpPaintCore *paint_core,
{
/* If the control key is down, move the src target and return */
- source_core->src_x = paint_core->cur_coords.x;
- source_core->src_y = paint_core->cur_coords.y;
+ source_core->src_x = coords->x;
+ source_core->src_y = coords->y;
/* get source coordinates in front view perspective */
gimp_matrix3_transform_point (&clone->transform_inv,
@@ -230,8 +232,8 @@ gimp_perspective_clone_paint (GimpPaintCore *paint_core,
gint dest_x;
gint dest_y;
- dest_x = paint_core->cur_coords.x;
- dest_y = paint_core->cur_coords.y;
+ dest_x = coords->x;
+ dest_y = coords->y;
if (options->align_mode == GIMP_SOURCE_ALIGN_REGISTERED)
{
@@ -258,7 +260,7 @@ gimp_perspective_clone_paint (GimpPaintCore *paint_core,
source_core->first_stroke = FALSE;
}
- gimp_source_core_motion (source_core, drawable, paint_options);
+ gimp_source_core_motion (source_core, drawable, paint_options, coords);
}
break;
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index 956ba30..cee0c96 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -45,16 +45,20 @@ static void gimp_smudge_finalize (GObject *object);
static void gimp_smudge_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static gboolean gimp_smudge_start (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
static void gimp_smudge_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
static void gimp_smudge_brush_coords (GimpPaintCore *paint_core,
+ const GimpCoords *coords,
gint *x,
gint *y,
gint *w,
@@ -117,6 +121,7 @@ static void
gimp_smudge_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
@@ -128,10 +133,10 @@ gimp_smudge_paint (GimpPaintCore *paint_core,
/* initialization fails if the user starts outside the drawable */
if (! smudge->initialized)
smudge->initialized = gimp_smudge_start (paint_core, drawable,
- paint_options);
+ paint_options, coords);
if (smudge->initialized)
- gimp_smudge_motion (paint_core, drawable, paint_options);
+ gimp_smudge_motion (paint_core, drawable, paint_options, coords);
break;
case GIMP_PAINT_STATE_FINISH:
@@ -151,7 +156,8 @@ gimp_smudge_paint (GimpPaintCore *paint_core,
static gboolean
gimp_smudge_start (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options)
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords)
{
GimpSmudge *smudge = GIMP_SMUDGE (paint_core);
GimpImage *image;
@@ -170,7 +176,7 @@ gimp_smudge_start (GimpPaintCore *paint_core,
return FALSE;
/* adjust the x and y coordinates to the upper left corner of the brush */
- gimp_smudge_brush_coords (paint_core, &x, &y, &w, &h);
+ gimp_smudge_brush_coords (paint_core, coords, &x, &y, &w, &h);
/* Allocate the accumulation buffer */
bytes = gimp_drawable_bytes (drawable);
@@ -184,10 +190,10 @@ gimp_smudge_start (GimpPaintCore *paint_core,
guchar fill[4];
gimp_pickable_get_pixel_at (GIMP_PICKABLE (drawable),
- CLAMP ((gint) paint_core->cur_coords.x,
+ CLAMP ((gint) coords->x,
0,
gimp_item_get_width (GIMP_ITEM (drawable)) - 1),
- CLAMP ((gint) paint_core->cur_coords.y,
+ CLAMP ((gint) coords->y,
0,
gimp_item_get_height (GIMP_ITEM (drawable)) - 1),
fill);
@@ -225,7 +231,8 @@ gimp_smudge_start (GimpPaintCore *paint_core,
static void
gimp_smudge_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options)
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords)
{
GimpSmudge *smudge = GIMP_SMUDGE (paint_core);
GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options);
@@ -255,15 +262,14 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
return;
/* Get the unclipped brush coordinates */
- gimp_smudge_brush_coords (paint_core, &x, &y, &w, &h);
+ gimp_smudge_brush_coords (paint_core, coords, &x, &y, &w, &h);
/* srcPR will be the pixels under the current painthit from the drawable */
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
area->x, area->y, area->width, area->height, FALSE);
/* Enable dynamic rate */
- dynamic_rate = gimp_paint_options_get_dynamic_rate (paint_options,
- &paint_core->cur_coords);
+ dynamic_rate = gimp_paint_options_get_dynamic_rate (paint_options, coords);
rate = (options->rate / 100.0) * dynamic_rate;
/* The tempPR will be the built up buffer (for smudge) */
@@ -303,11 +309,9 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
else
copy_region (&tempPR, &destPR);
- opacity *= gimp_paint_options_get_dynamic_opacity (paint_options,
- &paint_core->cur_coords);
+ opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
- hardness = gimp_paint_options_get_dynamic_hardness (paint_options,
- &paint_core->cur_coords);
+ hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
MIN (opacity, GIMP_OPACITY_OPAQUE),
@@ -318,11 +322,12 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
}
static void
-gimp_smudge_brush_coords (GimpPaintCore *paint_core,
- gint *x,
- gint *y,
- gint *w,
- gint *h)
+gimp_smudge_brush_coords (GimpPaintCore *paint_core,
+ const GimpCoords *coords,
+ gint *x,
+ gint *y,
+ gint *w,
+ gint *h)
{
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core);
gint width;
@@ -335,8 +340,8 @@ gimp_smudge_brush_coords (GimpPaintCore *paint_core,
&width, &height);
/* Note: these are the brush mask size plus a border of 1 pixel */
- *x = (gint) paint_core->cur_coords.x - width / 2 - 1;
- *y = (gint) paint_core->cur_coords.y - height / 2 - 1;
+ *x = (gint) coords->x - width / 2 - 1;
+ *y = (gint) coords->y - height / 2 - 1;
*w = width + 2;
*h = height + 2;
}
diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c
index 4c5d43d..cd33d3c 100644
--- a/app/paint/gimpsourcecore.c
+++ b/app/paint/gimpsourcecore.c
@@ -65,13 +65,15 @@ static gboolean gimp_source_core_start (GimpPaintCore *paint_core,
static void gimp_source_core_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
#if 0
static void gimp_source_core_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
#endif
static gboolean gimp_source_core_real_get_source (GimpSourceCore *source_core,
@@ -244,6 +246,7 @@ static void
gimp_source_core_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
@@ -257,8 +260,8 @@ gimp_source_core_paint (GimpPaintCore *paint_core,
{
gimp_source_core_set_src_drawable (source_core, drawable);
- source_core->src_x = paint_core->cur_coords.x;
- source_core->src_y = paint_core->cur_coords.y;
+ source_core->src_x = coords->x;
+ source_core->src_y = coords->y;
source_core->first_stroke = TRUE;
}
@@ -276,8 +279,8 @@ gimp_source_core_paint (GimpPaintCore *paint_core,
{
/* If the control key is down, move the src target and return */
- source_core->src_x = paint_core->cur_coords.x;
- source_core->src_y = paint_core->cur_coords.y;
+ source_core->src_x = coords->x;
+ source_core->src_y = coords->y;
source_core->first_stroke = TRUE;
}
@@ -288,8 +291,8 @@ gimp_source_core_paint (GimpPaintCore *paint_core,
gint dest_x;
gint dest_y;
- dest_x = paint_core->cur_coords.x;
- dest_y = paint_core->cur_coords.y;
+ dest_x = coords->x;
+ dest_y = coords->y;
if (options->align_mode == GIMP_SOURCE_ALIGN_REGISTERED)
{
@@ -312,7 +315,7 @@ gimp_source_core_paint (GimpPaintCore *paint_core,
source_core->src_x = dest_x + source_core->offset_x;
source_core->src_y = dest_y + source_core->offset_y;
- gimp_source_core_motion (source_core, drawable, paint_options);
+ gimp_source_core_motion (source_core, drawable, paint_options, coords);
}
break;
@@ -336,7 +339,9 @@ gimp_source_core_paint (GimpPaintCore *paint_core,
void
gimp_source_core_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options)
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords)
+
{
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (paint_options);
@@ -414,6 +419,7 @@ gimp_source_core_motion (GimpSourceCore *source_core,
GIMP_SOURCE_CORE_GET_CLASS (source_core)->motion (source_core,
drawable,
paint_options,
+ coords,
opacity,
src_pickable,
&srcPR,
diff --git a/app/paint/gimpsourcecore.h b/app/paint/gimpsourcecore.h
index a4ceffd..8ef9ccf 100644
--- a/app/paint/gimpsourcecore.h
+++ b/app/paint/gimpsourcecore.h
@@ -70,6 +70,7 @@ struct _GimpSourceCoreClass
void (* motion) (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ const GimpCoords *coords,
gdouble opacity,
GimpPickable *src_pickable,
PixelRegion *srcPR,
@@ -88,7 +89,8 @@ GType gimp_source_core_get_type (void) G_GNUC_CONST;
/* TEMP HACK */
void gimp_source_core_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
- GimpPaintOptions *paint_options);
+ GimpPaintOptions *paint_options,
+ const GimpCoords *coords);
#endif /* __GIMP_SOURCE_CORE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]