[gimp/pippin/linear-is-the-new-black: 10/11] app: add new multiply op



commit 3cfbf8e6fc3131cad4cf6a029e80df3f2ca95cd3
Author: Øyvind Kolås <pippin gimp org>
Date:   Mon Jan 9 02:03:52 2017 +0100

    app: add new multiply op

 app/core/core-enums.c                        |    6 +-
 app/core/core-enums.h                        |    4 +-
 app/gegl/gimp-gegl-nodes.c                   |   15 ++-
 app/operations/Makefile.am                   |    6 +-
 app/operations/gimp-operations.c             |    6 +-
 app/operations/gimplayermodefunctions.c      |    9 ++-
 app/operations/gimpoperationmultiply.c       |  135 +++++++++++++++++++++++++
 app/operations/gimpoperationmultiply.h       |   60 +++++++++++
 app/operations/gimpoperationmultiplylegacy.c |  137 ++++++++++++++++++++++++++
 app/operations/gimpoperationmultiplylegacy.h |   61 ++++++++++++
 app/operations/gimpoperationmultiplymode.c   |  137 --------------------------
 app/operations/gimpoperationmultiplymode.h   |   61 ------------
 app/widgets/gimpwidgets-constructors.c       |    4 +-
 libgimp/gimpenums.h                          |    4 +-
 tools/pdbgen/enums.pl                        |   45 +++++----
 15 files changed, 457 insertions(+), 233 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index 06dccd9..7c74306 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -318,6 +318,8 @@ gimp_layer_mode_get_type (void)
     { GIMP_LAYER_MODE_LCH_COLOR, "GIMP_LAYER_MODE_LCH_COLOR", "lch-color" },
     { GIMP_LAYER_MODE_LCH_LIGHTNESS, "GIMP_LAYER_MODE_LCH_LIGHTNESS", "lch-lightness" },
     { GIMP_LAYER_MODE_NORMAL, "GIMP_LAYER_MODE_NORMAL", "normal" },
+    { GIMP_LAYER_MODE_MULTIPLY, "GIMP_LAYER_MODE_MULTIPLY", "multiply" },
+    { GIMP_LAYER_MODE_MULTIPLY_LINEAR, "GIMP_LAYER_MODE_MULTIPLY_LINEAR", "multiply-linear" },
     { GIMP_LAYER_MODE_ERASE, "GIMP_LAYER_MODE_ERASE", "erase" },
     { GIMP_LAYER_MODE_REPLACE, "GIMP_LAYER_MODE_REPLACE", "replace" },
     { GIMP_LAYER_MODE_ANTI_ERASE, "GIMP_LAYER_MODE_ANTI_ERASE", "anti-erase" },
@@ -329,7 +331,7 @@ gimp_layer_mode_get_type (void)
     { GIMP_LAYER_MODE_NORMAL_NON_LINEAR, NC_("layer-mode", "Normal (non-linear)"), NULL },
     { GIMP_LAYER_MODE_DISSOLVE, NC_("layer-mode", "Dissolve"), NULL },
     { GIMP_LAYER_MODE_BEHIND, NC_("layer-mode", "Behind"), NULL },
-    { GIMP_LAYER_MODE_MULTIPLY_LEGACY, NC_("layer-mode", "Multiply"), NULL },
+    { GIMP_LAYER_MODE_MULTIPLY_LEGACY, NC_("layer-mode", "Multiply (legacy)"), NULL },
     { GIMP_LAYER_MODE_SCREEN_LEGACY, NC_("layer-mode", "Screen"), NULL },
     { GIMP_LAYER_MODE_OVERLAY_LEGACY, NC_("layer-mode", "Old broken Overlay"), NULL },
     { GIMP_LAYER_MODE_DIFFERENCE_LEGACY, NC_("layer-mode", "Difference"), NULL },
@@ -355,6 +357,8 @@ gimp_layer_mode_get_type (void)
     { GIMP_LAYER_MODE_LCH_COLOR, NC_("layer-mode", "Color (LCH)"), NULL },
     { GIMP_LAYER_MODE_LCH_LIGHTNESS, NC_("layer-mode", "Lightness (LCH)"), NULL },
     { GIMP_LAYER_MODE_NORMAL, NC_("layer-mode", "Normal"), NULL },
+    { GIMP_LAYER_MODE_MULTIPLY, NC_("layer-mode", "Multiply"), NULL },
+    { GIMP_LAYER_MODE_MULTIPLY_LINEAR, NC_("layer-mode", "Multiply (linear)"), NULL },
     { GIMP_LAYER_MODE_ERASE, NC_("layer-mode", "Erase"), NULL },
     { GIMP_LAYER_MODE_REPLACE, NC_("layer-mode", "Replace"), NULL },
     { GIMP_LAYER_MODE_ANTI_ERASE, NC_("layer-mode", "Anti erase"), NULL },
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index 2dbda12..c6b8ad2 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -157,7 +157,7 @@ typedef enum
   GIMP_LAYER_MODE_NORMAL_NON_LINEAR,      /*< desc="Normal (non-linear)"  >*/
   GIMP_LAYER_MODE_DISSOLVE,               /*< desc="Dissolve"             >*/
   GIMP_LAYER_MODE_BEHIND,                 /*< desc="Behind"               >*/
-  GIMP_LAYER_MODE_MULTIPLY_LEGACY,        /*< desc="Multiply"             >*/
+  GIMP_LAYER_MODE_MULTIPLY_LEGACY,        /*< desc="Multiply (legacy)"    >*/
   GIMP_LAYER_MODE_SCREEN_LEGACY,          /*< desc="Screen"               >*/
   GIMP_LAYER_MODE_OVERLAY_LEGACY,         /*< desc="Old broken Overlay"   >*/
   GIMP_LAYER_MODE_DIFFERENCE_LEGACY,      /*< desc="Difference"           >*/
@@ -183,6 +183,8 @@ typedef enum
   GIMP_LAYER_MODE_LCH_COLOR,              /*< desc="Color (LCH)"          >*/
   GIMP_LAYER_MODE_LCH_LIGHTNESS,          /*< desc="Lightness (LCH)"      >*/
   GIMP_LAYER_MODE_NORMAL,                 /*< desc="Normal"               >*/
+  GIMP_LAYER_MODE_MULTIPLY,               /*< desc="Multiply"             >*/
+  GIMP_LAYER_MODE_MULTIPLY_LINEAR,        /*< desc="Multiply (linear)"    >*/
 
   /* internal modes, not available to the PDB */
   GIMP_LAYER_MODE_ERASE      = 1000, /*< pdb-skip, desc="Erase"      >*/
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index e28b449..88f94bb 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -166,6 +166,11 @@ gimp_gegl_mode_node_set_mode (GeglNode      *node,
       operation = "gimp:multiply-mode";
       break;
 
+    case GIMP_LAYER_MODE_MULTIPLY:
+    case GIMP_LAYER_MODE_MULTIPLY_LINEAR:
+      operation = "gimp:multiply";
+      break;
+
     case GIMP_LAYER_MODE_SCREEN_LEGACY:
       operation = "gimp:screen-mode";
       break;
@@ -293,17 +298,19 @@ gimp_gegl_mode_node_set_mode (GeglNode      *node,
     {
     case GIMP_LAYER_MODE_NORMAL:
     case GIMP_LAYER_MODE_DISSOLVE:
+    case GIMP_LAYER_MODE_MULTIPLY_LINEAR:
+        gegl_node_set (node,
+           "linear",    TRUE,
+           NULL);
+        break;
     case GIMP_LAYER_MODE_BEHIND:
+    case GIMP_LAYER_MODE_MULTIPLY:
     case GIMP_LAYER_MODE_MULTIPLY_LEGACY:
     case GIMP_LAYER_MODE_SCREEN_LEGACY:
     case GIMP_LAYER_MODE_ADDITION_LEGACY:
     case GIMP_LAYER_MODE_SUBTRACT_LEGACY:
     case GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY:
     case GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY:
-        gegl_node_set (node,
-           "linear",    TRUE,
-           NULL);
-        break;
     case GIMP_LAYER_MODE_NORMAL_NON_LINEAR:
     case GIMP_LAYER_MODE_OVERLAY_LEGACY:
     case GIMP_LAYER_MODE_DIFFERENCE_LEGACY:
diff --git a/app/operations/Makefile.am b/app/operations/Makefile.am
index 75e917e..8b49ee5 100644
--- a/app/operations/Makefile.am
+++ b/app/operations/Makefile.am
@@ -102,8 +102,10 @@ libappoperations_generic_a_sources = \
        gimpoperationdissolvemode.h             \
        gimpoperationbehindmode.c               \
        gimpoperationbehindmode.h               \
-       gimpoperationmultiplymode.c             \
-       gimpoperationmultiplymode.h             \
+       gimpoperationmultiply.c             \
+       gimpoperationmultiply.h             \
+       gimpoperationmultiplylegacy.c           \
+       gimpoperationmultiplylegacy.h           \
        gimpoperationscreenmode.c               \
        gimpoperationscreenmode.h               \
        gimpoperationoverlaymode.c              \
diff --git a/app/operations/gimp-operations.c b/app/operations/gimp-operations.c
index c38920e..d31e109 100644
--- a/app/operations/gimp-operations.c
+++ b/app/operations/gimp-operations.c
@@ -69,7 +69,8 @@
 #include "gimpoperationnormalmode.h"
 #include "gimpoperationdissolvemode.h"
 #include "gimpoperationbehindmode.h"
-#include "gimpoperationmultiplymode.h"
+#include "gimpoperationmultiply.h"
+#include "gimpoperationmultiplylegacy.h"
 #include "gimpoperationscreenmode.h"
 #include "gimpoperationoverlaymode.h"
 #include "gimpoperationdifferencemode.h"
@@ -133,7 +134,8 @@ gimp_operations_init (void)
   g_type_class_ref (GIMP_TYPE_OPERATION_NORMAL_MODE);
   g_type_class_ref (GIMP_TYPE_OPERATION_DISSOLVE_MODE);
   g_type_class_ref (GIMP_TYPE_OPERATION_BEHIND_MODE);
-  g_type_class_ref (GIMP_TYPE_OPERATION_MULTIPLY_MODE);
+  g_type_class_ref (GIMP_TYPE_OPERATION_MULTIPLY);
+  g_type_class_ref (GIMP_TYPE_OPERATION_MULTIPLY_LEGACY);
   g_type_class_ref (GIMP_TYPE_OPERATION_SCREEN_MODE);
   g_type_class_ref (GIMP_TYPE_OPERATION_OVERLAY_MODE);
   g_type_class_ref (GIMP_TYPE_OPERATION_DIFFERENCE_MODE);
diff --git a/app/operations/gimplayermodefunctions.c b/app/operations/gimplayermodefunctions.c
index a5337fe..405c70e 100644
--- a/app/operations/gimplayermodefunctions.c
+++ b/app/operations/gimplayermodefunctions.c
@@ -29,7 +29,8 @@
 #include "gimpoperationnormalmode.h"
 #include "gimpoperationdissolvemode.h"
 #include "gimpoperationbehindmode.h"
-#include "gimpoperationmultiplymode.h"
+#include "gimpoperationmultiply.h"
+#include "gimpoperationmultiplylegacy.h"
 #include "gimpoperationscreenmode.h"
 #include "gimpoperationoverlaymode.h"
 #include "gimpoperationdifferencemode.h"
@@ -79,7 +80,11 @@ get_layer_mode_function (GimpLayerMode  paint_mode,
       break;
 
     case GIMP_LAYER_MODE_MULTIPLY_LEGACY:
-      func = gimp_operation_multiply_mode_process_pixels;
+      func = gimp_operation_multiply_legacy_process_pixels;
+      break;
+
+    case GIMP_LAYER_MODE_MULTIPLY:
+      func = gimp_operation_multiply_process_pixels;
       break;
 
     case GIMP_LAYER_MODE_SCREEN_LEGACY:
diff --git a/app/operations/gimpoperationmultiply.c b/app/operations/gimpoperationmultiply.c
new file mode 100644
index 0000000..52bf728
--- /dev/null
+++ b/app/operations/gimpoperationmultiply.c
@@ -0,0 +1,135 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationmultiply.c
+ * Copyright (C) 2008 Michael Natterer <mitch gimp org>
+ *               2012 Ville Sokk <ville sokk gmail com>
+ *               2017 Øyvind Kolås <pippin gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl-plugin.h>
+
+#include "operations-types.h"
+
+#include "gimpoperationmultiply.h"
+
+
+static gboolean gimp_operation_multiply_process (GeglOperation       *operation,
+                                                 void                *in_buf,
+                                                 void                *aux_buf,
+                                                 void                *aux2_buf,
+                                                 void                *out_buf,
+                                                 glong                samples,
+                                                 const GeglRectangle *roi,
+                                                 gint                 level);
+
+
+G_DEFINE_TYPE (GimpOperationMultiply, gimp_operation_multiply,
+               GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
+
+
+static void
+gimp_operation_multiply_class_init (GimpOperationMultiplyClass *klass)
+{
+  GeglOperationClass               *operation_class;
+  GeglOperationPointComposer3Class *point_class;
+
+  operation_class = GEGL_OPERATION_CLASS (klass);
+  point_class     = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
+
+  gegl_operation_class_set_keys (operation_class,
+                                 "name",        "gimp:multiply-mode",
+                                 "description", "GIMP multiply mode operation",
+                                 NULL);
+
+  point_class->process = gimp_operation_multiply_process;
+}
+
+static void
+gimp_operation_multiply_init (GimpOperationMultiply *self)
+{
+}
+
+static gboolean
+gimp_operation_multiply_process (GeglOperation       *operation,
+                                 void                *in_buf,
+                                 void                *aux_buf,
+                                 void                *aux2_buf,
+                                 void                *out_buf,
+                                 glong                samples,
+                                 const GeglRectangle *roi,
+                                 gint                 level)
+{
+  gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
+
+  return gimp_operation_multiply_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, 
level);
+}
+
+gboolean
+gimp_operation_multiply_process_pixels (gfloat              *in,
+                                        gfloat              *layer,
+                                        gfloat              *mask,
+                                        gfloat              *out,
+                                        gfloat               opacity,
+                                        glong                samples,
+                                        const GeglRectangle *roi,
+                                        gint                 level)
+{
+  const gboolean  has_mask = mask != NULL;
+
+  while (samples--)
+    {
+      gfloat comp_alpha;
+
+      comp_alpha = layer[ALPHA] * opacity;
+      if (has_mask)
+        comp_alpha *= *mask;
+
+      if (comp_alpha != 0.0f)
+        {
+          gint   b;
+
+          for (b = RED; b < ALPHA; b++)
+            {
+              gfloat comp = layer[b] * in[b];
+              out[b] = comp * comp_alpha + in[b] * (1.0 - comp_alpha);
+              out[b] = CLAMP (out[b], 0.0, 1.0);
+            }
+        }
+      else
+        {
+          gint b;
+
+          for (b = RED; b < ALPHA; b++)
+            {
+              out[b] = in[b];
+            }
+        }
+
+      out[ALPHA] = in[ALPHA];
+
+      in    += 4;
+      layer += 4;
+      out   += 4;
+
+      if (has_mask)
+        mask++;
+    }
+
+  return TRUE;
+}
diff --git a/app/operations/gimpoperationmultiply.h b/app/operations/gimpoperationmultiply.h
new file mode 100644
index 0000000..ec3e02b
--- /dev/null
+++ b/app/operations/gimpoperationmultiply.h
@@ -0,0 +1,60 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationmultiply.h
+ * Copyright (C) 2008 Michael Natterer <mitch gimp org>
+ *               2017 Øyvind Kolås <pippin gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_OPERATION_MULTIPLY_H__
+#define __GIMP_OPERATION_MULTIPLY_H__
+
+#include "gimpoperationpointlayermode.h"
+
+#define GIMP_TYPE_OPERATION_MULTIPLY            (gimp_operation_multiply_get_type ())
+#define GIMP_OPERATION_MULTIPLY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GIMP_TYPE_OPERATION_MULTIPLY, GimpOperationMultiply))
+#define GIMP_OPERATION_MULTIPLY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  
GIMP_TYPE_OPERATION_MULTIPLY, GimpOperationMultiplyClass))
+#define GIMP_IS_OPERATION_MULTIPLY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GIMP_TYPE_OPERATION_MULTIPLY))
+#define GIMP_IS_OPERATION_MULTIPLY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  
GIMP_TYPE_OPERATION_MULTIPLY))
+#define GIMP_OPERATION_MULTIPLY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  
GIMP_TYPE_OPERATION_MULTIPLY, GimpOperationMultiplyClass))
+
+
+typedef struct _GimpOperationMultiply      GimpOperationMultiply;
+typedef struct _GimpOperationMultiplyClass GimpOperationMultiplyClass;
+
+struct _GimpOperationMultiply
+{
+  GimpOperationPointLayerMode  parent_instance;
+};
+
+struct _GimpOperationMultiplyClass
+{
+  GimpOperationPointLayerModeClass  parent_class;
+};
+
+
+GType   gimp_operation_multiply_get_type (void) G_GNUC_CONST;
+
+gboolean gimp_operation_multiply_process_pixels (gfloat              *in,
+                                                 gfloat              *layer,
+                                                 gfloat              *mask,
+                                                 gfloat              *out,
+                                                 gfloat               opacity,
+                                                 glong                samples,
+                                                 const GeglRectangle *roi,
+                                                 gint                 level);
+
+#endif /* __GIMP_OPERATION_MULTIPLY_H__ */
diff --git a/app/operations/gimpoperationmultiplylegacy.c b/app/operations/gimpoperationmultiplylegacy.c
new file mode 100644
index 0000000..704d456
--- /dev/null
+++ b/app/operations/gimpoperationmultiplylegacy.c
@@ -0,0 +1,137 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationmultiplylegacy.c
+ * Copyright (C) 2008 Michael Natterer <mitch gimp org>
+ *               2012 Ville Sokk <ville sokk gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl-plugin.h>
+
+#include "operations-types.h"
+
+#include "gimpoperationmultiplylegacy.h"
+
+
+static gboolean gimp_operation_multiply_legacy_process (GeglOperation       *operation,
+                                                        void                *in_buf,
+                                                        void                *aux_buf,
+                                                        void                *aux2_buf,
+                                                        void                *out_buf,
+                                                        glong                samples,
+                                                        const GeglRectangle *roi,
+                                                        gint                 level);
+
+
+G_DEFINE_TYPE (GimpOperationMultiplyLegacy, gimp_operation_multiply_legacy,
+               GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
+
+
+static void
+gimp_operation_multiply_legacy_class_init (GimpOperationMultiplyLegacyClass *klass)
+{
+  GeglOperationClass               *operation_class;
+  GeglOperationPointComposer3Class *point_class;
+
+  operation_class = GEGL_OPERATION_CLASS (klass);
+  point_class     = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
+
+  gegl_operation_class_set_keys (operation_class,
+                                 "name",        "gimp:multiply-legacy",
+                                 "description", "GIMP multiply legacy operation",
+                                 NULL);
+
+  point_class->process = gimp_operation_multiply_legacy_process;
+}
+
+static void
+gimp_operation_multiply_legacy_init (GimpOperationMultiplyLegacy *self)
+{
+}
+
+static gboolean
+gimp_operation_multiply_legacy_process (GeglOperation       *operation,
+                                        void                *in_buf,
+                                        void                *aux_buf,
+                                        void                *aux2_buf,
+                                        void                *out_buf,
+                                        glong                samples,
+                                        const GeglRectangle *roi,
+                                        gint                 level)
+{
+  gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
+
+  return gimp_operation_multiply_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, 
samples, roi, level);
+}
+
+gboolean
+gimp_operation_multiply_legacy_process_pixels (gfloat              *in,
+                                               gfloat              *layer,
+                                               gfloat              *mask,
+                                               gfloat              *out,
+                                               gfloat               opacity,
+                                               glong                samples,
+                                               const GeglRectangle *roi,
+                                               gint                 level)
+{
+  const gboolean  has_mask = mask != NULL;
+
+  while (samples--)
+    {
+      gfloat comp_alpha, new_alpha;
+
+      comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
+      if (has_mask)
+        comp_alpha *= *mask;
+
+      new_alpha = in[ALPHA] + (1.0 - in[ALPHA]) * comp_alpha;
+
+      if (comp_alpha && new_alpha)
+        {
+          gfloat ratio = comp_alpha / new_alpha;
+          gint   b;
+
+          for (b = RED; b < ALPHA; b++)
+            {
+              gfloat comp = layer[b] * in[b];
+              out[b] = comp * ratio + in[b] * (1.0 - ratio);
+              out[b] = CLAMP (out[b], 0.0, 1.0);
+            }
+        }
+      else
+        {
+          gint b;
+
+          for (b = RED; b < ALPHA; b++)
+            {
+              out[b] = in[b];
+            }
+        }
+
+      out[ALPHA] = in[ALPHA];
+
+      in    += 4;
+      layer += 4;
+      out   += 4;
+
+      if (has_mask)
+        mask++;
+    }
+
+  return TRUE;
+}
diff --git a/app/operations/gimpoperationmultiplylegacy.h b/app/operations/gimpoperationmultiplylegacy.h
new file mode 100644
index 0000000..f1fa2e5
--- /dev/null
+++ b/app/operations/gimpoperationmultiplylegacy.h
@@ -0,0 +1,61 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationmultiplylegacy.h
+ * Copyright (C) 2008 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_OPERATION_MULTIPLY_LEGACY_H__
+#define __GIMP_OPERATION_MULTIPLY_LEGACY_H__
+
+
+#include "gimpoperationpointlayermode.h"
+
+
+#define GIMP_TYPE_OPERATION_MULTIPLY_LEGACY            (gimp_operation_multiply_legacy_get_type ())
+#define GIMP_OPERATION_MULTIPLY_LEGACY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GIMP_TYPE_OPERATION_MULTIPLY_LEGACY, GimpOperationMultiplyLegacy))
+#define GIMP_OPERATION_MULTIPLY_LEGACY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  
GIMP_TYPE_OPERATION_MULTIPLY_LEGACY, GimpOperationMultiplyLegacyClass))
+#define GIMP_IS_OPERATION_MULTIPLY_LEGACY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GIMP_TYPE_OPERATION_MULTIPLY_LEGACY))
+#define GIMP_IS_OPERATION_MULTIPLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  
GIMP_TYPE_OPERATION_MULTIPLY_LEGACY))
+#define GIMP_OPERATION_MULTIPLY_LEGACY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  
GIMP_TYPE_OPERATION_MULTIPLY_LEGACY, GimpOperationMultiplyLegacyClass))
+
+
+typedef struct _GimpOperationMultiplyLegacy      GimpOperationMultiplyLegacy;
+typedef struct _GimpOperationMultiplyLegacyClass GimpOperationMultiplyLegacyClass;
+
+struct _GimpOperationMultiplyLegacy
+{
+  GimpOperationPointLayerMode  parent_instance;
+};
+
+struct _GimpOperationMultiplyLegacyClass
+{
+  GimpOperationPointLayerModeClass  parent_class;
+};
+
+
+GType   gimp_operation_multiply_legacy_get_type (void) G_GNUC_CONST;
+
+gboolean gimp_operation_multiply_legacy_process_pixels (gfloat              *in,
+                                                        gfloat              *layer,
+                                                        gfloat              *mask,
+                                                        gfloat              *out,
+                                                        gfloat               opacity,
+                                                        glong                samples,
+                                                        const GeglRectangle *roi,
+                                                        gint                 level);
+
+#endif /* __GIMP_OPERATION_MULTIPLY_LEGACY_H__ */
diff --git a/app/widgets/gimpwidgets-constructors.c b/app/widgets/gimpwidgets-constructors.c
index 5bfe587..6a42c51 100644
--- a/app/widgets/gimpwidgets-constructors.c
+++ b/app/widgets/gimpwidgets-constructors.c
@@ -104,7 +104,7 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode,
   GtkWidget    *combo;
 
   store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE,
-                                           26,
+                                           27,
                                            GIMP_LAYER_MODE_NORMAL,
                                            GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                            GIMP_LAYER_MODE_DISSOLVE,
@@ -115,6 +115,8 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode,
                                            GIMP_LAYER_MODE_ADDITION_LEGACY,
 
                                            GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY,
+                                           GIMP_LAYER_MODE_MULTIPLY,
+                                           GIMP_LAYER_MODE_MULTIPLY_LINEAR,
                                            GIMP_LAYER_MODE_MULTIPLY_LEGACY,
                                            GIMP_LAYER_MODE_BURN_LEGACY,
 
diff --git a/libgimp/gimpenums.h b/libgimp/gimpenums.h
index 0df7aac..5f9a20f 100644
--- a/libgimp/gimpenums.h
+++ b/libgimp/gimpenums.h
@@ -97,7 +97,9 @@ typedef enum
   GIMP_LAYER_MODE_LCH_CHROMA,
   GIMP_LAYER_MODE_LCH_COLOR,
   GIMP_LAYER_MODE_LCH_LIGHTNESS,
-  GIMP_LAYER_MODE_NORMAL
+  GIMP_LAYER_MODE_NORMAL,
+  GIMP_LAYER_MODE_MULTIPLY,
+  GIMP_LAYER_MODE_MULTIPLY_LINEAR
 } GimpLayerMode;
 
 
diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl
index 3d1187f..a0d1e79 100644
--- a/tools/pdbgen/enums.pl
+++ b/tools/pdbgen/enums.pl
@@ -697,31 +697,32 @@ package Gimp::CodeGen::enums;
          header => 'core/core-enums.h',
          symbols => [ qw(GIMP_LAYER_MODE_NORMAL_NON_LINEAR
                          GIMP_LAYER_MODE_DISSOLVE GIMP_LAYER_MODE_BEHIND
-                         GIMP_LAYER_MODE_MULTIPLY_BROKEN
-                         GIMP_LAYER_MODE_SCREEN_BROKEN
-                         GIMP_LAYER_MODE_OVERLAY_BROKEN
-                         GIMP_LAYER_MODE_DIFFERENCE_BROKEN
-                         GIMP_LAYER_MODE_ADDITION_BROKEN
-                         GIMP_LAYER_MODE_SUBTRACT_BROKEN
-                         GIMP_LAYER_MODE_DARKEN_ONLY_BROKEN
-                         GIMP_LAYER_MODE_LIGHTEN_ONLY_BROKEN
-                         GIMP_LAYER_MODE_HSV_HUE_BROKEN
-                         GIMP_LAYER_MODE_HSV_SATURATION_BROKEN
-                         GIMP_LAYER_MODE_HSV_COLOR_BROKEN
-                         GIMP_LAYER_MODE_HSV_VALUE_BROKEN
-                         GIMP_LAYER_MODE_DIVIDE_BROKEN
-                         GIMP_LAYER_MODE_DODGE_BROKEN
-                         GIMP_LAYER_MODE_BURN_BROKEN
-                         GIMP_LAYER_MODE_HARDLIGHT_BROKEN
-                         GIMP_LAYER_MODE_SOFTLIGHT_BROKEN
-                         GIMP_LAYER_MODE_GRAIN_EXTRACT_BROKEN
-                         GIMP_LAYER_MODE_GRAIN_MERGE_BROKEN
+                         GIMP_LAYER_MODE_MULTIPLY_LEGACY
+                         GIMP_LAYER_MODE_SCREEN_LEGACY
+                         GIMP_LAYER_MODE_OVERLAY_LEGACY
+                         GIMP_LAYER_MODE_DIFFERENCE_LEGACY
+                         GIMP_LAYER_MODE_ADDITION_LEGACY
+                         GIMP_LAYER_MODE_SUBTRACT_LEGACY
+                         GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY
+                         GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY
+                         GIMP_LAYER_MODE_HSV_HUE_LEGACY
+                         GIMP_LAYER_MODE_HSV_SATURATION_LEGACY
+                         GIMP_LAYER_MODE_HSV_COLOR_LEGACY
+                         GIMP_LAYER_MODE_HSV_VALUE_LEGACY
+                         GIMP_LAYER_MODE_DIVIDE_LEGACY
+                         GIMP_LAYER_MODE_DODGE_LEGACY
+                         GIMP_LAYER_MODE_BURN_LEGACY
+                         GIMP_LAYER_MODE_HARDLIGHT_LEGACY
+                         GIMP_LAYER_MODE_SOFTLIGHT_LEGACY
+                         GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY
+                         GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY
                          GIMP_LAYER_MODE_COLOR_ERASE
                          GIMP_LAYER_MODE_OVERLAY GIMP_LAYER_MODE_LCH_HUE
                          GIMP_LAYER_MODE_LCH_CHROMA
                          GIMP_LAYER_MODE_LCH_COLOR
                          GIMP_LAYER_MODE_LCH_LIGHTNESS
-                         GIMP_LAYER_MODE_NORMAL) ],
+                         GIMP_LAYER_MODE_NORMAL GIMP_LAYER_MODE_MULTIPLY
+                         GIMP_LAYER_MODE_MULTIPLY_LINEAR) ],
          mapping => { GIMP_LAYER_MODE_NORMAL_NON_LINEAR => '0',
                       GIMP_LAYER_MODE_DISSOLVE => '1',
                       GIMP_LAYER_MODE_BEHIND => '2',
@@ -750,7 +751,9 @@ package Gimp::CodeGen::enums;
                       GIMP_LAYER_MODE_LCH_CHROMA => '25',
                       GIMP_LAYER_MODE_LCH_COLOR => '26',
                       GIMP_LAYER_MODE_LCH_LIGHTNESS => '27',
-                      GIMP_LAYER_MODE_NORMAL => '28' }
+                      GIMP_LAYER_MODE_NORMAL => '28',
+                      GIMP_LAYER_MODE_MULTIPLY => '29',
+                      GIMP_LAYER_MODE_MULTIPLY_LINEAR => '30' }
        },
     GimpBrushApplicationMode =>
        { contig => 1,


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