[gimp] plugins: add compatibility wrappers to motion-blur
- From: Téo Mazars <teom src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plugins: add compatibility wrappers to motion-blur
- Date: Fri, 5 Jul 2013 18:12:57 +0000 (UTC)
commit ec6720c897a2fe0646da4d18c040d226717ff150
Author: Téo Mazars <teo mazars ensimag fr>
Date: Thu Jul 4 23:02:55 2013 +0200
plugins: add compatibility wrappers to motion-blur
and remove the old plugin.
app/pdb/internal-procs.c | 2 +-
app/pdb/plug-in-compat-cmds.c | 290 +++++++++
plug-ins/common/.gitignore | 2 -
plug-ins/common/Makefile.am | 19 -
plug-ins/common/blur-motion.c | 1160 -----------------------------------
plug-ins/common/gimprc.common | 1 -
plug-ins/common/plugin-defs.pl | 1 -
po-plug-ins/POTFILES.in | 1 -
tools/pdbgen/pdb/plug_in_compat.pdb | 175 ++++++
9 files changed, 466 insertions(+), 1185 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 3ae9b07..96a9e83 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 690 procedures registered total */
+/* 692 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index 051c6aa..c49c8bd 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -260,6 +260,164 @@ plug_in_cubism_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
+plug_in_mblur_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpDrawable *drawable;
+ gint32 type;
+ gdouble length;
+ gdouble angle;
+ gdouble center_x;
+ gdouble center_y;
+
+ drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+ type = g_value_get_int (gimp_value_array_index (args, 3));
+ length = g_value_get_double (gimp_value_array_index (args, 4));
+ angle = g_value_get_double (gimp_value_array_index (args, 5));
+ center_x = g_value_get_double (gimp_value_array_index (args, 6));
+ center_y = g_value_get_double (gimp_value_array_index (args, 7));
+
+ if (success)
+ {
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+ GIMP_PDB_ITEM_CONTENT, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+ {
+ GeglNode *node = NULL;
+
+ if (type == 0)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-linear",
+ "length", length,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 1)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-circular",
+ "center-x", center_x,
+ "center-y", center_y,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 2)
+ {
+ gdouble factor = CLAMP (length / 256.0, 0.0, 1.0);
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-zoom",
+ "center-x", center_x,
+ "center-y", center_y,
+ "factor", factor,
+ NULL);
+ }
+
+ if (node != NULL)
+ {
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Motion Blur"),
+ node);
+
+ g_object_unref (node);
+ }
+ else
+ success = FALSE;
+
+ }
+ else
+ success = FALSE;
+ }
+
+ return gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+}
+
+static GimpValueArray *
+plug_in_mblur_inward_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpDrawable *drawable;
+ gint32 type;
+ gdouble length;
+ gdouble angle;
+ gdouble center_x;
+ gdouble center_y;
+
+ drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+ type = g_value_get_int (gimp_value_array_index (args, 3));
+ length = g_value_get_double (gimp_value_array_index (args, 4));
+ angle = g_value_get_double (gimp_value_array_index (args, 5));
+ center_x = g_value_get_double (gimp_value_array_index (args, 6));
+ center_y = g_value_get_double (gimp_value_array_index (args, 7));
+
+ if (success)
+ {
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+ GIMP_PDB_ITEM_CONTENT, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+ {
+ GeglNode *node = NULL;
+
+ if (type == 0)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-linear",
+ "length", length,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 1)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-circular",
+ "center-x", center_x,
+ "center-y", center_y,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 2)
+ {
+ gdouble factor = CLAMP (-length / (256.0 - length), -10.0, 0.0);
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-zoom",
+ "center-x", center_x,
+ "center-y", center_y,
+ "factor", factor,
+ NULL);
+ }
+
+ if (node != NULL)
+ {
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Motion Blur"),
+ node);
+
+ g_object_unref (node);
+ }
+ else
+ success = FALSE;
+
+ }
+ else
+ success = FALSE;
+ }
+
+ return gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+}
+
+static GimpValueArray *
plug_in_pixelize_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
@@ -1101,6 +1259,138 @@ register_plug_in_compat_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
+ * gimp-plug-in-mblur
+ */
+ procedure = gimp_procedure_new (plug_in_mblur_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "plug-in-mblur");
+ gimp_procedure_set_static_strings (procedure,
+ "plug-in-mblur",
+ "Simulate movement using directional blur",
+ "This plug-in simulates the effect seen when photographing a moving
object at a slow shutter speed. Done by adding multiple displaced copies.",
+ "Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom,
-cirular' for credits.",
+ "Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom,
-cirular' for credits.",
+ "2013",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_enum ("run-mode",
+ "run mode",
+ "The run mode",
+ GIMP_TYPE_RUN_MODE,
+ GIMP_RUN_INTERACTIVE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_image_id ("image",
+ "image",
+ "Input image (unused)",
+ pdb->gimp, FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_drawable_id ("drawable",
+ "drawable",
+ "Input drawable",
+ pdb->gimp, FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_int32 ("type",
+ "type",
+ "Type of motion blur { LINEAR (0), RADIAL (1), ZOOM
(2) }",
+ 0, 2, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("length",
+ "length",
+ "Length",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("angle",
+ "angle",
+ "Angle",
+ 0, 360, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("center-x",
+ "center x",
+ "Center X",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("center-y",
+ "center y",
+ "Center Y",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
+ * gimp-plug-in-mblur-inward
+ */
+ procedure = gimp_procedure_new (plug_in_mblur_inward_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "plug-in-mblur-inward");
+ gimp_procedure_set_static_strings (procedure,
+ "plug-in-mblur-inward",
+ "Simulate movement using directional blur",
+ "This procedure is equivalent to plug-in-mblur but performs the zoom
blur inward instead of outward.",
+ "Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom,
-cirular' for credits.",
+ "Compatibility procedure. Please see 'gegl:motion-blur-linear, -zoom,
-cirular' for credits.",
+ "2013",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_enum ("run-mode",
+ "run mode",
+ "The run mode",
+ GIMP_TYPE_RUN_MODE,
+ GIMP_RUN_INTERACTIVE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_image_id ("image",
+ "image",
+ "Input image (unused)",
+ pdb->gimp, FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_drawable_id ("drawable",
+ "drawable",
+ "Input drawable",
+ pdb->gimp, FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_int32 ("type",
+ "type",
+ "Type of motion blur { LINEAR (0), RADIAL (1), ZOOM
(2) }",
+ 0, 2, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("length",
+ "length",
+ "Length",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("angle",
+ "angle",
+ "Angle",
+ 0, 360, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("center-x",
+ "center x",
+ "Center X",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("center-y",
+ "center y",
+ "Center Y",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
* gimp-plug-in-pixelize
*/
procedure = gimp_procedure_new (plug_in_pixelize_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index c240c46..d6db89a 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -22,8 +22,6 @@
/blur-gauss.exe
/blur-gauss-selective
/blur-gauss-selective.exe
-/blur-motion
-/blur-motion.exe
/border-average
/border-average.exe
/bump-map
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index c983dff..85aeb99 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -54,7 +54,6 @@ libexec_PROGRAMS = \
blur \
blur-gauss \
blur-gauss-selective \
- blur-motion \
border-average \
bump-map \
cartoon \
@@ -377,23 +376,6 @@ blur_gauss_selective_LDADD = \
$(INTLLIBS) \
$(blur_gauss_selective_RC)
-blur_motion_SOURCES = \
- blur-motion.c
-
-blur_motion_LDADD = \
- $(libgimpui) \
- $(libgimpwidgets) \
- $(libgimpmodule) \
- $(libgimp) \
- $(libgimpmath) \
- $(libgimpconfig) \
- $(libgimpcolor) \
- $(libgimpbase) \
- $(GTK_LIBS) \
- $(RT_LIBS) \
- $(INTLLIBS) \
- $(blur_motion_RC)
-
border_average_SOURCES = \
border-average.c
@@ -722,7 +704,6 @@ decompose_LDADD = \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
- $(GEGL_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(decompose_RC)
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index e980100..cad8335 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -8,7 +8,6 @@ blinds_RC = blinds.rc.o
blur_RC = blur.rc.o
blur_gauss_RC = blur-gauss.rc.o
blur_gauss_selective_RC = blur-gauss-selective.rc.o
-blur_motion_RC = blur-motion.rc.o
border_average_RC = border-average.rc.o
bump_map_RC = bump-map.rc.o
cartoon_RC = cartoon.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 9f76a78..14e30ed 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -9,7 +9,6 @@
'blur' => {},
'blur-gauss' => { ui => 1 },
'blur-gauss-selective' => { ui => 1, cflags => 'MMX_EXTRA_CFLAGS' },
- 'blur-motion' => { ui => 1 },
'border-average' => { ui => 1 },
'bump-map' => { ui => 1 },
'cartoon' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index b6afce8..d25bb0c 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -16,7 +16,6 @@ plug-ins/common/blinds.c
plug-ins/common/blur.c
plug-ins/common/blur-gauss.c
plug-ins/common/blur-gauss-selective.c
-plug-ins/common/blur-motion.c
plug-ins/common/border-average.c
plug-ins/common/bump-map.c
plug-ins/common/cartoon.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index c5ae609..7ecfd19 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -245,6 +245,179 @@ CODE
);
}
+sub plug_in_mblur {
+ $blurb = 'Simulate movement using directional blur';
+
+ $help = <<'HELP';
+This plug-in simulates the effect seen when
+photographing a moving object at a slow shutter
+speed. Done by adding multiple displaced copies.
+HELP
+
+ &std_pdb_compat('gegl:motion-blur-linear, -zoom, -cirular');
+ $date = '2013';
+
+ @inargs = (
+ { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+ desc => 'The run mode' },
+ { name => 'image', type => 'image', dead => 1,
+ desc => 'Input image (unused)' },
+ { name => 'drawable', type => 'drawable',
+ desc => 'Input drawable' },
+ { name => 'type', type => '0 <= int32 <= 2',
+ desc => 'Type of motion blur { LINEAR (0), RADIAL (1), ZOOM (2) }' },
+ { name => 'length', type => 'float',
+ desc => 'Length' },
+ { name => 'angle', type => '0 <= float <= 360',
+ desc => 'Angle' },
+ { name => 'center_x', type => 'float',
+ desc => 'Center X' },
+ { name => 'center_y', type => 'float',
+ desc => 'Center Y' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+ GIMP_PDB_ITEM_CONTENT, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+ {
+ GeglNode *node = NULL;
+
+ if (type == 0)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-linear",
+ "length", length,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 1)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-circular",
+ "center-x", center_x,
+ "center-y", center_y,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 2)
+ {
+ gdouble factor = CLAMP (length / 256.0, 0.0, 1.0);
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-zoom",
+ "center-x", center_x,
+ "center-y", center_y,
+ "factor", factor,
+ NULL);
+ }
+
+ if (node != NULL)
+ {
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Motion Blur"),
+ node);
+
+ g_object_unref (node);
+ }
+ else
+ success = FALSE;
+
+ }
+ else
+ success = FALSE;
+}
+CODE
+ );
+}
+
+sub plug_in_mblur_inward {
+ $blurb = 'Simulate movement using directional blur';
+
+ $help = <<'HELP';
+This procedure is equivalent to plug-in-mblur but
+performs the zoom blur inward instead of outward.
+HELP
+
+ &std_pdb_compat('gegl:motion-blur-linear, -zoom, -cirular');
+ $date = '2013';
+
+ @inargs = (
+ { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+ desc => 'The run mode' },
+ { name => 'image', type => 'image', dead => 1,
+ desc => 'Input image (unused)' },
+ { name => 'drawable', type => 'drawable',
+ desc => 'Input drawable' },
+ { name => 'type', type => '0 <= int32 <= 2',
+ desc => 'Type of motion blur { LINEAR (0), RADIAL (1), ZOOM (2) }' },
+ { name => 'length', type => 'float',
+ desc => 'Length' },
+ { name => 'angle', type => '0 <= float <= 360',
+ desc => 'Angle' },
+ { name => 'center_x', type => 'float',
+ desc => 'Center X' },
+ { name => 'center_y', type => 'float',
+ desc => 'Center Y' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+ GIMP_PDB_ITEM_CONTENT, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+ {
+ GeglNode *node = NULL;
+
+ if (type == 0)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-linear",
+ "length", length,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 1)
+ {
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-circular",
+ "center-x", center_x,
+ "center-y", center_y,
+ "angle", angle,
+ NULL);
+ }
+ else if (type == 2)
+ {
+ gdouble factor = CLAMP (-length / (256.0 - length), -10.0, 0.0);
+ node = gegl_node_new_child (NULL,
+ "operation", "gegl:motion-blur-zoom",
+ "center-x", center_x,
+ "center-y", center_y,
+ "factor", factor,
+ NULL);
+ }
+
+ if (node != NULL)
+ {
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Motion Blur"),
+ node);
+
+ g_object_unref (node);
+ }
+ else
+ success = FALSE;
+
+ }
+ else
+ success = FALSE;
+}
+CODE
+ );
+}
+
sub plug_in_pixelize {
$blurb = 'Simplify image into an array of solid-colored squares';
@@ -1040,6 +1213,8 @@ CODE
plug_in_autocrop_layer
plug_in_colortoalpha
plug_in_cubism
+ plug_in_mblur
+ plug_in_mblur_inward
plug_in_pixelize
plug_in_pixelize2
plug_in_polar_coords
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]