[gimp] plug-ins, pdb: remove the bump-map plug-in and add 2 PDB compat procs



commit 82223783a3a31eb760cef1bb72a4188e828c538e
Author: Thomas Manni <thomas manni free fr>
Date:   Tue Jun 30 11:03:31 2015 +0200

    plug-ins, pdb: remove the bump-map plug-in and add 2 PDB compat procs

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  377 +++++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 -
 plug-ins/common/bump-map.c          | 1448 -----------------------------------
 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 |  195 +++++
 9 files changed, 573 insertions(+), 1472 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index cffe5a8..06970ed 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 764 procedures registered total */
+/* 766 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 77a5649..ec60f17 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -187,6 +187,63 @@ create_buffer_source_node (GeglNode     *parent,
 }
 
 static gboolean
+bump_map (GimpDrawable *drawable,
+          GimpDrawable *bump_map,
+          gdouble       azimuth,
+          gdouble       elevation,
+          gint          depth,
+          gint          offset_x,
+          gint          offset_y,
+          gdouble       waterlevel,
+          gdouble       ambient,
+          gboolean      compensate,
+          gboolean      invert,
+          gint          type,
+          gboolean      tiled,
+          GimpProgress  *progress,
+          GError       **error)
+{
+  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 *gegl;
+      GeglNode *node;
+      GeglNode *src_node;
+
+      gegl = gegl_node_new ();
+
+      node = gegl_node_new_child (gegl,
+                                  "operation", "gegl:bump-map",
+                                  "tiled",      tiled,
+                                  "type",       type,
+                                  "compensate", compensate,
+                                  "invert",     invert,
+                                  "azimuth",    azimuth,
+                                  "elevation",  elevation,
+                                  "depth",      depth,
+                                  "offset_x",   offset_x,
+                                  "offset_y",   offset_y,
+                                  "waterlevel", waterlevel,
+                                  "ambient",    ambient,
+                                  NULL);
+
+      src_node = create_buffer_source_node (gegl, bump_map);
+
+      gegl_node_connect_to (src_node, "output", node, "aux");
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Bump Map"),
+                                     node);
+      g_object_unref (gegl);
+
+      return TRUE;
+    }
+    else
+      return FALSE;
+}
+
+static gboolean
 displace (GimpDrawable  *drawable,
           gdouble        amount_x,
           gdouble        amount_y,
@@ -649,6 +706,122 @@ plug_in_autostretch_hsv_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_bump_map_invoker (GimpProcedure         *procedure,
+                          Gimp                  *gimp,
+                          GimpContext           *context,
+                          GimpProgress          *progress,
+                          const GimpValueArray  *args,
+                          GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  GimpDrawable *bumpmap;
+  gdouble azimuth;
+  gdouble elevation;
+  gint32 depth;
+  gint32 xofs;
+  gint32 yofs;
+  gdouble waterlevel;
+  gdouble ambient;
+  gboolean compensate;
+  gboolean invert;
+  gint32 type;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  bumpmap = gimp_value_get_drawable (gimp_value_array_index (args, 3), gimp);
+  azimuth = g_value_get_double (gimp_value_array_index (args, 4));
+  elevation = g_value_get_double (gimp_value_array_index (args, 5));
+  depth = g_value_get_int (gimp_value_array_index (args, 6));
+  xofs = g_value_get_int (gimp_value_array_index (args, 7));
+  yofs = g_value_get_int (gimp_value_array_index (args, 8));
+  waterlevel = g_value_get_double (gimp_value_array_index (args, 9));
+  ambient = g_value_get_double (gimp_value_array_index (args, 10));
+  compensate = g_value_get_boolean (gimp_value_array_index (args, 11));
+  invert = g_value_get_boolean (gimp_value_array_index (args, 12));
+  type = g_value_get_int (gimp_value_array_index (args, 13));
+
+  if (success)
+    {
+      success = bump_map (drawable,
+                          bumpmap,
+                          azimuth,
+                          elevation,
+                          depth,
+                          xofs,
+                          yofs,
+                          waterlevel,
+                          ambient,
+                          compensate,
+                          invert,
+                          type,
+                          FALSE,
+                          progress,
+                          error);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
+plug_in_bump_map_tiled_invoker (GimpProcedure         *procedure,
+                                Gimp                  *gimp,
+                                GimpContext           *context,
+                                GimpProgress          *progress,
+                                const GimpValueArray  *args,
+                                GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  GimpDrawable *bumpmap;
+  gdouble azimuth;
+  gdouble elevation;
+  gint32 depth;
+  gint32 xofs;
+  gint32 yofs;
+  gdouble waterlevel;
+  gdouble ambient;
+  gboolean compensate;
+  gboolean invert;
+  gint32 type;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  bumpmap = gimp_value_get_drawable (gimp_value_array_index (args, 3), gimp);
+  azimuth = g_value_get_double (gimp_value_array_index (args, 4));
+  elevation = g_value_get_double (gimp_value_array_index (args, 5));
+  depth = g_value_get_int (gimp_value_array_index (args, 6));
+  xofs = g_value_get_int (gimp_value_array_index (args, 7));
+  yofs = g_value_get_int (gimp_value_array_index (args, 8));
+  waterlevel = g_value_get_double (gimp_value_array_index (args, 9));
+  ambient = g_value_get_double (gimp_value_array_index (args, 10));
+  compensate = g_value_get_boolean (gimp_value_array_index (args, 11));
+  invert = g_value_get_boolean (gimp_value_array_index (args, 12));
+  type = g_value_get_int (gimp_value_array_index (args, 13));
+
+  if (success)
+    {
+      success = bump_map (drawable,
+                          bumpmap,
+                          azimuth,
+                          elevation,
+                          depth,
+                          xofs,
+                          yofs,
+                          waterlevel,
+                          ambient,
+                          compensate,
+                          invert,
+                          type,
+                          TRUE,
+                          progress,
+                          error);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_c_astretch_invoker (GimpProcedure         *procedure,
                             Gimp                  *gimp,
                             GimpContext           *context,
@@ -4163,6 +4336,210 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-bump-map
+   */
+  procedure = gimp_procedure_new (plug_in_bump_map_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-bump-map");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-bump-map",
+                                     "Create an embossing effect using a bump map",
+                                     "This plug-in uses the algorithm described by John Schlag, \"Fast 
Embossing Effects on Raster Image Data\" in Graphics GEMS IV (ISBN 0-12-336155-9). It takes a drawable to be 
applied as a bump map to another image and produces a nice embossing effect.",
+                                     "Compatibility procedure. Please see 'gegl:bump-map' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:bump-map' for credits.",
+                                     "2015",
+                                     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_drawable_id ("bumpmap",
+                                                            "bumpmap",
+                                                            "Bump map drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("azimuth",
+                                                    "azimuth",
+                                                    "Azimuth",
+                                                    0.0, 360.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("elevation",
+                                                    "elevation",
+                                                    "Elevation",
+                                                    0.5, 90.0, 0.5,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("depth",
+                                                      "depth",
+                                                      "Depth",
+                                                      1, 65, 1,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("xofs",
+                                                      "xofs",
+                                                      "X offset",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("yofs",
+                                                      "yofs",
+                                                      "Y offset",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("waterlevel",
+                                                    "waterlevel",
+                                                    "Level that full transparency should represent",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("ambient",
+                                                    "ambient",
+                                                    "Ambient lighting factor",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("compensate",
+                                                     "compensate",
+                                                     "Compensate for darkening",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("invert",
+                                                     "invert",
+                                                     "Invert bumpmap",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("type",
+                                                      "type",
+                                                      "Type of map { LINEAR (0), SPHERICAL (1), SINUSOIDAL 
(2) }",
+                                                      0, 3, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-plug-in-bump-map-tiled
+   */
+  procedure = gimp_procedure_new (plug_in_bump_map_tiled_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-bump-map-tiled");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-bump-map-tiled",
+                                     "Create an embossing effect using a tiled image as a bump map",
+                                     "This plug-in uses the algorithm described by John Schlag, \"Fast 
Embossing Effects on Raster Image Data\" in Graphics GEMS IV (ISBN 0-12-336155-9). It takes a drawable to be 
tiled and applied as a bump map to another image and produces a nice embossing effect.",
+                                     "Compatibility procedure. Please see 'gegl:bump-map' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:bump-map' for credits.",
+                                     "2015",
+                                     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_drawable_id ("bumpmap",
+                                                            "bumpmap",
+                                                            "Bump map drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("azimuth",
+                                                    "azimuth",
+                                                    "Azimuth",
+                                                    0.0, 360.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("elevation",
+                                                    "elevation",
+                                                    "Elevation",
+                                                    0.5, 90.0, 0.5,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("depth",
+                                                      "depth",
+                                                      "Depth",
+                                                      1, 65, 1,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("xofs",
+                                                      "xofs",
+                                                      "X offset",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("yofs",
+                                                      "yofs",
+                                                      "Y offset",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("waterlevel",
+                                                    "waterlevel",
+                                                    "Level that full transparency should represent",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("ambient",
+                                                    "ambient",
+                                                    "Ambient lighting factor",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("compensate",
+                                                     "compensate",
+                                                     "Compensate for darkening",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("invert",
+                                                     "invert",
+                                                     "Invert bumpmap",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("type",
+                                                      "type",
+                                                      "Type of map { LINEAR (0), SPHERICAL (1), SINUSOIDAL 
(2) }",
+                                                      0, 3, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-c-astretch
    */
   procedure = gimp_procedure_new (plug_in_c_astretch_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 3ca3d2b..b74bac2 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -16,8 +16,6 @@
 /blur-gauss-selective.exe
 /border-average
 /border-average.exe
-/bump-map
-/bump-map.exe
 /cartoon
 /cartoon.exe
 /checkerboard
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index c891646..977d822 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -51,7 +51,6 @@ libexec_PROGRAMS = \
        blur \
        blur-gauss-selective \
        border-average \
-       bump-map \
        cartoon \
        checkerboard \
        cml-explorer \
@@ -293,23 +292,6 @@ border_average_LDADD = \
        $(INTLLIBS)             \
        $(border_average_RC)
 
-bump_map_SOURCES = \
-       bump-map.c
-
-bump_map_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(bump_map_RC)
-
 cartoon_SOURCES = \
        cartoon.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 881a38a..9b60f6b 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -5,7 +5,6 @@ blinds_RC = blinds.rc.o
 blur_RC = blur.rc.o
 blur_gauss_selective_RC = blur-gauss-selective.rc.o
 border_average_RC = border-average.rc.o
-bump_map_RC = bump-map.rc.o
 cartoon_RC = cartoon.rc.o
 checkerboard_RC = checkerboard.rc.o
 cml_explorer_RC = cml-explorer.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index dfbb73d..40a681d 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -6,7 +6,6 @@
     'blur' => {},
     'blur-gauss-selective' => { ui => 1, cflags => 'MMX_EXTRA_CFLAGS' },
     'border-average' => { ui => 1, gegl => 1 },
-    'bump-map' => { ui => 1 },
     'cartoon' => { ui => 1 },
     'checkerboard' => { ui => 1 },
     'cml-explorer' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 57e4448..2d5f47b 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -10,7 +10,6 @@ plug-ins/common/blinds.c
 plug-ins/common/blur.c
 plug-ins/common/blur-gauss-selective.c
 plug-ins/common/border-average.c
-plug-ins/common/bump-map.c
 plug-ins/common/cartoon.c
 plug-ins/common/checkerboard.c
 plug-ins/common/cml-explorer.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index e7120b9..0e73fcb 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -419,6 +419,142 @@ CODE
     );
 }
 
+sub plug_in_bump_map {
+    $blurb = 'Create an embossing effect using a bump map';
+
+    $help = <<'HELP';
+This plug-in uses the algorithm described by John Schlag,
+"Fast Embossing Effects on Raster Image Data" in
+Graphics GEMS IV (ISBN 0-12-336155-9).
+It takes a drawable to be applied as a bump
+map to another image and produces a nice embossing effect.
+HELP
+
+    &std_pdb_compat('gegl:bump-map');
+    $date = '2015';
+
+    @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 => 'bumpmap', type => 'drawable',
+    desc => 'Bump map drawable' },
+  { name => 'azimuth', type => '0.0 <= float <= 360.0',
+    desc => 'Azimuth' },
+  { name => 'elevation', type => '0.5 <= float <= 90.0',
+    desc => 'Elevation' },
+  { name => 'depth', type => '1 <= int32 <= 65',
+    desc => 'Depth' },
+  { name => 'xofs', type => 'int32',
+    desc => 'X offset' },
+  { name => 'yofs', type => 'int32',
+    desc => 'Y offset' },
+  { name => 'waterlevel', type => '0.0 <= float <= 1.0',
+    desc => 'Level that full transparency should represent' },
+  { name => 'ambient', type => '0.0 <= float <= 1.0',
+    desc => 'Ambient lighting factor' },
+  { name => 'compensate', type => 'boolean',
+    desc => 'Compensate for darkening' },
+  { name => 'invert', type => 'boolean',
+    desc => 'Invert bumpmap' },
+  { name => 'type', type => '0 <= int32 <= 3',
+    desc => 'Type of map { LINEAR (0), SPHERICAL (1), SINUSOIDAL (2) }' }
+    );
+
+    %invoke = (
+  code => <<'CODE'
+{
+  success = bump_map (drawable,
+                      bumpmap,
+                      azimuth,
+                      elevation,
+                      depth,
+                      xofs,
+                      yofs,
+                      waterlevel,
+                      ambient,
+                      compensate,
+                      invert,
+                      type,
+                      FALSE,
+                      progress,
+                      error);
+}
+CODE
+    );
+}
+
+sub plug_in_bump_map_tiled {
+    $blurb = 'Create an embossing effect using a tiled image as a bump map';
+
+    $help = <<'HELP';
+This plug-in uses the algorithm described by John Schlag,
+"Fast Embossing Effects on Raster Image Data" in
+Graphics GEMS IV (ISBN 0-12-336155-9).
+It takes a drawable to be tiled and applied as a bump map
+to another image and produces a nice embossing effect.
+HELP
+
+    &std_pdb_compat('gegl:bump-map');
+    $date = '2015';
+
+    @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 => 'bumpmap', type => 'drawable',
+    desc => 'Bump map drawable' },
+  { name => 'azimuth', type => '0.0 <= float <= 360.0',
+    desc => 'Azimuth' },
+  { name => 'elevation', type => '0.5 <= float <= 90.0',
+    desc => 'Elevation' },
+  { name => 'depth', type => '1 <= int32 <= 65',
+    desc => 'Depth' },
+  { name => 'xofs', type => 'int32',
+    desc => 'X offset' },
+  { name => 'yofs', type => 'int32',
+    desc => 'Y offset' },
+  { name => 'waterlevel', type => '0.0 <= float <= 1.0',
+    desc => 'Level that full transparency should represent' },
+  { name => 'ambient', type => '0.0 <= float <= 1.0',
+    desc => 'Ambient lighting factor' },
+  { name => 'compensate', type => 'boolean',
+    desc => 'Compensate for darkening' },
+  { name => 'invert', type => 'boolean',
+    desc => 'Invert bumpmap' },
+  { name => 'type', type => '0 <= int32 <= 3',
+    desc => 'Type of map { LINEAR (0), SPHERICAL (1), SINUSOIDAL (2) }' }
+    );
+
+    %invoke = (
+  code => <<'CODE'
+{
+  success = bump_map (drawable,
+                      bumpmap,
+                      azimuth,
+                      elevation,
+                      depth,
+                      xofs,
+                      yofs,
+                      waterlevel,
+                      ambient,
+                      compensate,
+                      invert,
+                      type,
+                      TRUE,
+                      progress,
+                      error);
+}
+CODE
+    );
+}
+
 sub plug_in_c_astretch {
     $blurb = 'Stretch contrast to cover the maximum possible range';
 
@@ -4149,6 +4285,63 @@ create_buffer_source_node (GeglNode     *parent,
 }
 
 static gboolean
+bump_map (GimpDrawable *drawable,
+          GimpDrawable *bump_map,
+          gdouble       azimuth,
+          gdouble       elevation,
+          gint          depth,
+          gint          offset_x,
+          gint          offset_y,
+          gdouble       waterlevel,
+          gdouble       ambient,
+          gboolean      compensate,
+          gboolean      invert,
+          gint          type,
+          gboolean      tiled,
+          GimpProgress  *progress,
+          GError       **error)
+{
+  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 *gegl;
+      GeglNode *node;
+      GeglNode *src_node;
+
+      gegl = gegl_node_new ();
+
+      node = gegl_node_new_child (gegl,
+                                  "operation", "gegl:bump-map",
+                                  "tiled",      tiled,
+                                  "type",       type,
+                                  "compensate", compensate,
+                                  "invert",     invert,
+                                  "azimuth",    azimuth,
+                                  "elevation",  elevation,
+                                  "depth",      depth,
+                                  "offset_x",   offset_x,
+                                  "offset_y",   offset_y,
+                                  "waterlevel", waterlevel,
+                                  "ambient",    ambient,
+                                  NULL);
+
+      src_node = create_buffer_source_node (gegl, bump_map);
+
+      gegl_node_connect_to (src_node, "output", node, "aux");
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Bump Map"),
+                                     node);
+      g_object_unref (gegl);
+
+      return TRUE;
+    }
+    else
+      return FALSE;
+}
+
+static gboolean
 displace (GimpDrawable  *drawable,
           gdouble        amount_x,
           gdouble        amount_y,
@@ -4277,6 +4470,8 @@ CODE
             plug_in_autocrop
             plug_in_autocrop_layer
             plug_in_autostretch_hsv
+            plug_in_bump_map
+            plug_in_bump_map_tiled
             plug_in_c_astretch
             plug_in_colors_channel_mixer
             plug_in_colortoalpha


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]