[gimp/multi-stroke] app: the multi-stroke operation depends on intended paint size.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/multi-stroke] app: the multi-stroke operation depends on intended paint size.
- Date: Wed, 25 Mar 2015 13:56:56 +0000 (UTC)
commit 09a80f909e2f5f248a9437df0953b5cfc814ff42
Author: Jehan <jehan girinstud io>
Date: Sat Mar 21 17:57:59 2015 +0100
app: the multi-stroke operation depends on intended paint size.
app/paint/gimpbrushcore.c | 13 +++++++++-
app/paint/gimpconvolve.c | 10 ++++++--
app/paint/gimpdodgeburn.c | 10 ++++++--
app/paint/gimperaser.c | 10 ++++++--
app/paint/gimpink.c | 16 +++++++++++--
app/paint/gimpmirror.c | 51 ++++++++++--------------------------------
app/paint/gimpmultistroke.c | 24 ++++++++++----------
app/paint/gimpmultistroke.h | 12 +++++-----
app/paint/gimppaintbrush.c | 11 ++++++--
app/paint/gimppaintcore.c | 16 ++++++++++---
app/paint/gimppaintcore.h | 8 +++++-
app/paint/gimpsmudge.c | 13 +++++++---
app/paint/gimpsourcecore.c | 8 ++++--
app/paint/gimptiling.c | 12 +++++-----
14 files changed, 121 insertions(+), 93 deletions(-)
---
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 25d7509..a017a09 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -84,7 +84,9 @@ static GeglBuffer * gimp_brush_core_get_paint_buffer(GimpPaintCore *paint_cor
GimpPaintOptions *paint_options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y);
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height);
static void gimp_brush_core_real_set_brush (GimpBrushCore *core,
GimpBrush *brush);
@@ -813,7 +815,9 @@ gimp_brush_core_get_paint_buffer (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y)
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height)
{
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
gint x, y;
@@ -833,6 +837,11 @@ gimp_brush_core_get_paint_buffer (GimpPaintCore *paint_core,
core->scale, core->aspect_ratio, core->angle,
&brush_width, &brush_height);
+ if (paint_width)
+ *paint_width = brush_width;
+ if (paint_height)
+ *paint_height = brush_height;
+
/* adjust the x and y coordinates to the upper left corner of the brush */
x = (gint) floor (coords->x) - (brush_width / 2);
y = (gint) floor (coords->y) - (brush_height / 2);
diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c
index f7b4317..00ffdbf 100644
--- a/app/paint/gimpconvolve.c
+++ b/app/paint/gimpconvolve.c
@@ -142,6 +142,7 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
gdouble rate;
const GimpCoords *coords;
GeglNode *op;
+ gint paint_width, paint_height;
gint nstrokes;
gint i;
@@ -164,12 +165,15 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ &paint_width,
+ &paint_height);
if (! paint_buffer)
continue;
- op = gimp_multi_stroke_get_operation (mstroke, paint_core,
- paint_buffer, i);
+ op = gimp_multi_stroke_get_operation (mstroke, i,
+ paint_width,
+ paint_height);
rate = (options->rate *
gimp_dynamics_get_linear_value (dynamics,
diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c
index 17fe8e0..dc1d53c 100644
--- a/app/paint/gimpdodgeburn.c
+++ b/app/paint/gimpdodgeburn.c
@@ -128,6 +128,7 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
GimpDynamicsOutput *dyn_output = NULL;
const GimpCoords *coords;
GeglNode *op;
+ gint paint_width, paint_height;
gint nstrokes;
gint i;
@@ -150,12 +151,15 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ &paint_width,
+ &paint_height);
if (! paint_buffer)
return;
- op = gimp_multi_stroke_get_operation (mstroke, paint_core,
- paint_buffer, i);
+ op = gimp_multi_stroke_get_operation (mstroke, i,
+ paint_width,
+ paint_height);
/* DodgeBurn the region */
gimp_gegl_dodgeburn (gimp_paint_core_get_orig_image (paint_core),
diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c
index aa02ec2..cac2ef9 100644
--- a/app/paint/gimperaser.c
+++ b/app/paint/gimperaser.c
@@ -124,6 +124,7 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
const GimpCoords *coords;
GeglNode *op;
gint nstrokes;
+ gint paint_width, paint_height;
gint i;
fade_point = gimp_paint_options_get_fade (paint_options, image,
@@ -156,12 +157,15 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ &paint_width,
+ &paint_height);
if (! paint_buffer)
continue;
- op = gimp_multi_stroke_get_operation (mstroke, paint_core,
- paint_buffer, i);
+ op = gimp_multi_stroke_get_operation (mstroke, i,
+ paint_width,
+ paint_height);
gegl_buffer_set_color (paint_buffer, NULL, color);
diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c
index 802690d..da036e3 100644
--- a/app/paint/gimpink.c
+++ b/app/paint/gimpink.c
@@ -61,7 +61,9 @@ static GeglBuffer * gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y);
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height);
static GimpUndo * gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
@@ -217,7 +219,9 @@ gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y)
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height)
{
GimpInk *ink = GIMP_INK (paint_core);
gint x, y;
@@ -235,6 +239,11 @@ gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
x2 = CLAMP ((x + width) / SUBSAMPLE + 2, 0, dwidth);
y2 = CLAMP ((y + height) / SUBSAMPLE + 2, 0, dheight);
+ if (*paint_width)
+ *paint_width = width / SUBSAMPLE + 3;
+ if (*paint_height)
+ *paint_height = height / SUBSAMPLE + 3;
+
/* configure the canvas buffer */
if ((x2 - x1) && (y2 - y1))
{
@@ -377,7 +386,8 @@ gimp_ink_motion (GimpPaintCore *paint_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ NULL, NULL);
ink->cur_blob = NULL;
if (! paint_buffer)
diff --git a/app/paint/gimpmirror.c b/app/paint/gimpmirror.c
index 263a8f1..b40a019 100644
--- a/app/paint/gimpmirror.c
+++ b/app/paint/gimpmirror.c
@@ -70,9 +70,9 @@ static void gimp_mirror_update_strokes (GimpMultiStroke *mirror,
GimpDrawable *drawable,
GimpCoords *origin);
static GeglNode * gimp_mirror_get_operation (GimpMultiStroke *mirror,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke);
+ gint stroke,
+ gint paint_width,
+ gint paint_height);
static void gimp_mirror_reset (GimpMirror *mirror);
static void gimp_mirror_guide_removed_cb (GObject *object,
GimpMirror *mirror);
@@ -288,9 +288,9 @@ gimp_mirror_update_strokes (GimpMultiStroke *mstroke,
static GeglNode *
gimp_mirror_get_operation (GimpMultiStroke *mstroke,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke)
+ gint stroke,
+ gint paint_width,
+ gint paint_height)
{
GimpMirror *mirror = GIMP_MIRROR (mstroke);
GeglNode *op;
@@ -298,24 +298,18 @@ gimp_mirror_get_operation (GimpMultiStroke *mstroke,
g_return_val_if_fail (stroke >= 0 &&
stroke < g_list_length (mstroke->strokes), NULL);
- if (mirror->disable_transformation || stroke == 0 || ! paint_buffer)
+ if (mirror->disable_transformation || stroke == 0 ||
+ paint_width == 0 || paint_height == 0)
{
op = NULL;
}
else if (stroke == 1 && mirror->horizontal_mirror)
{
- gint height;
-
- if (GIMP_IS_SOURCE_CORE (core) || ! GIMP_IS_BRUSH_CORE (core))
- height = gegl_buffer_get_height (paint_buffer);
- else
- height = gimp_brush_get_height (GIMP_BRUSH_CORE (core)->brush);
-
op = gegl_node_new_child (NULL,
"operation", "gegl:reflect",
"origin-x", 0.0,
"origin-y",
- (gdouble) height / 2.0,
+ (gdouble) paint_height / 2.0,
"x",
1.0,
"y",
@@ -327,17 +321,10 @@ gimp_mirror_get_operation (GimpMultiStroke *mstroke,
(stroke == 1 && mirror->vertical_mirror &&
! mirror->horizontal_mirror))
{
- gint width;
-
- if (GIMP_IS_SOURCE_CORE (core) || ! GIMP_IS_BRUSH_CORE (core))
- width = gegl_buffer_get_width (paint_buffer);
- else
- width = gimp_brush_get_width (GIMP_BRUSH_CORE (core)->brush);
-
op = gegl_node_new_child (NULL,
"operation", "gegl:reflect",
"origin-x",
- (gdouble) width / 2.0,
+ (gdouble) paint_width / 2.0,
"origin-y", 0.0,
"x",
0.0,
@@ -347,26 +334,12 @@ gimp_mirror_get_operation (GimpMultiStroke *mstroke,
}
else
{
- gint width;
- gint height;
-
- if (GIMP_IS_SOURCE_CORE (core) || ! GIMP_IS_BRUSH_CORE (core))
- {
- width = gegl_buffer_get_width (paint_buffer);
- height = gegl_buffer_get_height (paint_buffer);
- }
- else
- {
- width = gimp_brush_get_width (GIMP_BRUSH_CORE (core)->brush);
- height = gimp_brush_get_height (GIMP_BRUSH_CORE (core)->brush);
- }
-
op = gegl_node_new_child (NULL,
"operation", "gegl:rotate",
"origin-x",
- (gdouble) width / 2.0,
+ (gdouble) paint_width / 2.0,
"origin-y",
- (gdouble) height / 2.0,
+ (gdouble) paint_height / 2.0,
"degrees",
180.0,
NULL);
diff --git a/app/paint/gimpmultistroke.c b/app/paint/gimpmultistroke.c
index 0c21637..b201727 100644
--- a/app/paint/gimpmultistroke.c
+++ b/app/paint/gimpmultistroke.c
@@ -66,9 +66,9 @@ static void
GimpCoords *origin);
static GeglNode *
gimp_multi_stroke_real_get_op (GimpMultiStroke *mstroke,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke);
+ gint stroke,
+ gint paint_width,
+ gint paint_height);
static GParamSpec **
gimp_multi_stroke_real_get_settings (GimpMultiStroke *mstroke,
guint *nproperties);
@@ -205,9 +205,9 @@ gimp_multi_stroke_real_update_strokes (GimpMultiStroke *mstroke,
static GeglNode *
gimp_multi_stroke_real_get_op (GimpMultiStroke *mstroke,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke)
+ gint stroke,
+ gint paint_width,
+ gint paint_height)
{
/* The basic multi-stroke just returns NULL, since no transformation of the
* brush painting happen. */
@@ -320,16 +320,16 @@ gimp_multi_stroke_get_coords (GimpMultiStroke *mstroke,
**/
GeglNode *
gimp_multi_stroke_get_operation (GimpMultiStroke *mstroke,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke)
+ gint stroke,
+ gint paint_width,
+ gint paint_height)
{
g_return_val_if_fail (GIMP_IS_MULTI_STROKE (mstroke), NULL);
return GIMP_MULTI_STROKE_GET_CLASS (mstroke)->get_operation (mstroke,
- core,
- paint_buffer,
- stroke);
+ stroke,
+ paint_width,
+ paint_height);
}
/**
diff --git a/app/paint/gimpmultistroke.h b/app/paint/gimpmultistroke.h
index 7b43151..0ff1d60 100644
--- a/app/paint/gimpmultistroke.h
+++ b/app/paint/gimpmultistroke.h
@@ -58,9 +58,9 @@ struct _GimpMultiStrokeClass
GimpDrawable *drawable,
GimpCoords *origin);
GeglNode * (* get_operation) (GimpMultiStroke *mstroke,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke);
+ gint stroke,
+ gint paint_width,
+ gint paint_height);
GParamSpec **
(* get_settings) (GimpMultiStroke *mstroke,
guint *nproperties);
@@ -81,9 +81,9 @@ gint gimp_multi_stroke_get_size (GimpMultiStroke *mstroke);
GimpCoords * gimp_multi_stroke_get_coords (GimpMultiStroke *mstroke,
gint stroke);
GeglNode * gimp_multi_stroke_get_operation (GimpMultiStroke *mstroke,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke);
+ gint stroke,
+ gint paint_width,
+ gint paint_height);
GParamSpec ** gimp_multi_stroke_get_settings (GimpMultiStroke *mstroke,
guint *nproperties);
GParamSpec **
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index f3e4fba..c05b624 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -140,6 +140,8 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
for (i = 0; i < nstrokes; i++)
{
+ gint paint_width, paint_height;
+
coords = gimp_multi_stroke_get_coords (mstroke, i);
opacity *= gimp_dynamics_get_linear_value (dynamics,
@@ -153,12 +155,15 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ &paint_width,
+ &paint_height);
if (! paint_buffer)
continue;
- op = gimp_multi_stroke_get_operation (mstroke, paint_core,
- paint_buffer, i);
+ op = gimp_multi_stroke_get_operation (mstroke, i,
+ paint_width,
+ paint_height);
paint_appl_mode = paint_options->application_mode;
grad_point = gimp_dynamics_get_linear_value (dynamics,
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 780493d..865f106 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -107,7 +107,9 @@ static GeglBuffer *
GimpPaintOptions *options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y);
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height);
static GimpUndo* gimp_paint_core_real_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
@@ -267,7 +269,9 @@ gimp_paint_core_real_get_paint_buffer (GimpPaintCore *core,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y)
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height)
{
return NULL;
}
@@ -763,7 +767,9 @@ gimp_paint_core_get_paint_buffer (GimpPaintCore *core,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y)
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height)
{
GeglBuffer *paint_buffer;
@@ -780,7 +786,9 @@ gimp_paint_core_get_paint_buffer (GimpPaintCore *core,
paint_options,
coords,
paint_buffer_x,
- paint_buffer_y);
+ paint_buffer_y,
+ paint_width,
+ paint_height);
core->paint_buffer_x = *paint_buffer_x;
core->paint_buffer_y = *paint_buffer_y;
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index 2682c7e..7c4bfd3 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -112,7 +112,9 @@ struct _GimpPaintCoreClass
GimpPaintOptions *paint_options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y);
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height);
GimpUndo * (* push_undo) (GimpPaintCore *core,
GimpImage *image,
@@ -168,7 +170,9 @@ GeglBuffer * gimp_paint_core_get_paint_buffer (GimpPaintCore *core,
GimpPaintOptions *options,
const GimpCoords *coords,
gint *paint_buffer_x,
- gint *paint_buffer_y);
+ gint *paint_buffer_y,
+ gint *paint_width,
+ gint *paint_height);
GeglBuffer * gimp_paint_core_get_orig_image (GimpPaintCore *core);
GeglBuffer * gimp_paint_core_get_orig_proj (GimpPaintCore *core);
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index 6c628d6..848ba44 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -196,7 +196,8 @@ gimp_smudge_start (GimpPaintCore *paint_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ NULL, NULL);
if (! paint_buffer)
return FALSE;
@@ -282,6 +283,7 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
GeglBuffer *accum_buffer;
GimpCoords *coords;
GeglNode *op;
+ gint paint_width, paint_height;
gint nstrokes;
gint i;
@@ -304,12 +306,15 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ &paint_width,
+ &paint_height);
if (! paint_buffer)
return;
- op = gimp_multi_stroke_get_operation (mstroke, paint_core,
- paint_buffer, i);
+ op = gimp_multi_stroke_get_operation (mstroke, i,
+ paint_width,
+ paint_height);
paint_buffer_width = gegl_buffer_get_width (paint_buffer);
paint_buffer_height = gegl_buffer_get_height (paint_buffer);
diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c
index 36d968c..01f7ef3 100644
--- a/app/paint/gimpsourcecore.c
+++ b/app/paint/gimpsourcecore.c
@@ -425,7 +425,8 @@ gimp_source_core_motion (GimpSourceCore *source_core,
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
paint_options, coords,
&paint_buffer_x,
- &paint_buffer_y);
+ &paint_buffer_y,
+ NULL, NULL);
if (! paint_buffer)
continue;
@@ -462,8 +463,9 @@ gimp_source_core_motion (GimpSourceCore *source_core,
/* Set the paint buffer to transparent */
gegl_buffer_clear (paint_buffer, NULL);
- op = gimp_multi_stroke_get_operation (mstroke, paint_core,
- paint_buffer, i);
+ op = gimp_multi_stroke_get_operation (mstroke, i,
+ gegl_buffer_get_width (paint_buffer),
+ gegl_buffer_get_height (paint_buffer));
GIMP_SOURCE_CORE_GET_CLASS (source_core)->motion (source_core,
drawable,
paint_options,
diff --git a/app/paint/gimptiling.c b/app/paint/gimptiling.c
index f71aa93..379868d 100644
--- a/app/paint/gimptiling.c
+++ b/app/paint/gimptiling.c
@@ -69,9 +69,9 @@ static void gimp_tiling_update_strokes (GimpMultiStroke *tiling,
GimpDrawable *drawable,
GimpCoords *origin);
static GeglNode * gimp_tiling_get_operation (GimpMultiStroke *tiling,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke);
+ gint stroke,
+ gint paint_width,
+ gint paint_height);
static GParamSpec ** gimp_tiling_get_settings (GimpMultiStroke *mstroke,
guint *nsettings);
static void
@@ -344,9 +344,9 @@ gimp_tiling_update_strokes (GimpMultiStroke *mstroke,
static GeglNode *
gimp_tiling_get_operation (GimpMultiStroke *mstroke,
- GimpPaintCore *core,
- GeglBuffer *paint_buffer,
- gint stroke)
+ gint stroke,
+ gint paint_width,
+ gint paint_height)
{
/* No buffer transformation happens for tiling. */
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]