[gimp] app: do not let pixel encoding determine layer modes



commit 735887286a2f8ee561ea27cb67be205fdb76cbae
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Dec 22 23:50:02 2016 +0100

    app: do not let pixel encoding determine layer modes
    
    See bug #757485 - woth noting that this also enables linear and thus correct
    compositing when using 8bpc perceptual gamma as the layer storage format.

 app/core/core-enums.c                  |    6 ++-
 app/core/core-enums.h                  |    3 +-
 app/gegl/gimp-gegl-nodes.c             |   45 ++++++++++++++++++++++++++++
 app/pdb/brush-select-cmds.c            |    4 +-
 app/pdb/brushes-cmds.c                 |    2 +-
 app/pdb/context-cmds.c                 |    4 +-
 app/pdb/edit-cmds.c                    |    6 ++--
 app/pdb/layer-cmds.c                   |    6 ++--
 app/widgets/gimpwidgets-constructors.c |    5 ++-
 libgimp/gimpenums.h                    |    5 ++-
 tools/pdbgen/enums.pl                  |   50 ++++++++++++++++---------------
 11 files changed, 94 insertions(+), 42 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index e4add25..06dccd9 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -289,7 +289,7 @@ gimp_layer_mode_get_type (void)
 {
   static const GEnumValue values[] =
   {
-    { GIMP_LAYER_MODE_NORMAL, "GIMP_LAYER_MODE_NORMAL", "normal" },
+    { GIMP_LAYER_MODE_NORMAL_NON_LINEAR, "GIMP_LAYER_MODE_NORMAL_NON_LINEAR", "normal-non-linear" },
     { GIMP_LAYER_MODE_DISSOLVE, "GIMP_LAYER_MODE_DISSOLVE", "dissolve" },
     { GIMP_LAYER_MODE_BEHIND, "GIMP_LAYER_MODE_BEHIND", "behind" },
     { GIMP_LAYER_MODE_MULTIPLY_LEGACY, "GIMP_LAYER_MODE_MULTIPLY_LEGACY", "multiply-legacy" },
@@ -317,6 +317,7 @@ gimp_layer_mode_get_type (void)
     { GIMP_LAYER_MODE_LCH_CHROMA, "GIMP_LAYER_MODE_LCH_CHROMA", "lch-chroma" },
     { 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_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" },
@@ -325,7 +326,7 @@ gimp_layer_mode_get_type (void)
 
   static const GimpEnumDesc descs[] =
   {
-    { GIMP_LAYER_MODE_NORMAL, NC_("layer-mode", "Normal"), NULL },
+    { 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 },
@@ -353,6 +354,7 @@ gimp_layer_mode_get_type (void)
     { GIMP_LAYER_MODE_LCH_CHROMA, NC_("layer-mode", "Chroma (LCH)"), NULL },
     { 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_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 6ad105c..2dbda12 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -154,7 +154,7 @@ GType gimp_layer_mode_get_type (void) G_GNUC_CONST;
 
 typedef enum
 {
-  GIMP_LAYER_MODE_NORMAL,                 /*< desc="Normal"               >*/
+  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"             >*/
@@ -182,6 +182,7 @@ typedef enum
   GIMP_LAYER_MODE_LCH_CHROMA,             /*< desc="Chroma (LCH)"         >*/
   GIMP_LAYER_MODE_LCH_COLOR,              /*< desc="Color (LCH)"          >*/
   GIMP_LAYER_MODE_LCH_LIGHTNESS,          /*< desc="Lightness (LCH)"      >*/
+  GIMP_LAYER_MODE_NORMAL,                 /*< desc="Normal"               >*/
 
   /* 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 ded1720..e28b449 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -288,6 +288,51 @@ gimp_gegl_mode_node_set_mode (GeglNode      *node,
                  "linear",    linear,
                  "opacity",   opacity,
                  NULL);
+
+  switch (mode)
+    {
+    case GIMP_LAYER_MODE_NORMAL:
+    case GIMP_LAYER_MODE_DISSOLVE:
+    case GIMP_LAYER_MODE_BEHIND:
+    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:
+    case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
+    case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
+    case GIMP_LAYER_MODE_HSV_COLOR_LEGACY:
+    case GIMP_LAYER_MODE_HSV_VALUE_LEGACY:
+    case GIMP_LAYER_MODE_DIVIDE_LEGACY:
+    case GIMP_LAYER_MODE_DODGE_LEGACY:
+    case GIMP_LAYER_MODE_BURN_LEGACY:
+    case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
+    case GIMP_LAYER_MODE_SOFTLIGHT_LEGACY:
+    case GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY:
+    case GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY:
+    case GIMP_LAYER_MODE_COLOR_ERASE:
+    case GIMP_LAYER_MODE_OVERLAY:
+    case GIMP_LAYER_MODE_ERASE:
+    case GIMP_LAYER_MODE_REPLACE:
+    case GIMP_LAYER_MODE_ANTI_ERASE:
+    case GIMP_LAYER_MODE_LCH_HUE:
+    case GIMP_LAYER_MODE_LCH_CHROMA:
+    case GIMP_LAYER_MODE_LCH_COLOR:
+    case GIMP_LAYER_MODE_LCH_LIGHTNESS:
+    default:
+        gegl_node_set (node,
+           "linear",   FALSE,
+           NULL);
+        break;
+    }
 }
 
 void
diff --git a/app/pdb/brush-select-cmds.c b/app/pdb/brush-select-cmds.c
index 86bd7ae..412391c 100644
--- a/app/pdb/brush-select-cmds.c
+++ b/app/pdb/brush-select-cmds.c
@@ -204,7 +204,7 @@ register_brush_select_procs (GimpPDB *pdb)
                                                   "paint mode",
                                                   "The initial paint mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
@@ -278,7 +278,7 @@ register_brush_select_procs (GimpPDB *pdb)
                                                   "paint mode",
                                                   "The initial paint mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
diff --git a/app/pdb/brushes-cmds.c b/app/pdb/brushes-cmds.c
index e03c898..f0e42e8 100644
--- a/app/pdb/brushes-cmds.c
+++ b/app/pdb/brushes-cmds.c
@@ -440,7 +440,7 @@ register_brushes_procs (GimpPDB *pdb)
                                                       "paint mode",
                                                       "The paint mode",
                                                       GIMP_TYPE_LAYER_MODE,
-                                                      GIMP_LAYER_MODE_NORMAL,
+                                                      GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                       GIMP_PARAM_READWRITE));
   gimp_procedure_add_return_value (procedure,
                                    gimp_param_spec_int32 ("width",
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index 6fc4288..d02d2aa 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -3139,7 +3139,7 @@ register_context_procs (GimpPDB *pdb)
                                                       "paint mode",
                                                       "The paint mode",
                                                       GIMP_TYPE_LAYER_MODE,
-                                                      GIMP_LAYER_MODE_NORMAL,
+                                                      GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                       GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
@@ -3163,7 +3163,7 @@ register_context_procs (GimpPDB *pdb)
                                                   "paint mode",
                                                   "The paint mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c
index bf3f0ec..f9d3526 100644
--- a/app/pdb/edit-cmds.c
+++ b/app/pdb/edit-cmds.c
@@ -1349,7 +1349,7 @@ register_edit_procs (GimpPDB *pdb)
                                                   "paint mode",
                                                   "The paint application mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
                                g_param_spec_double ("opacity",
@@ -1416,7 +1416,7 @@ register_edit_procs (GimpPDB *pdb)
                                                   "paint mode",
                                                   "The paint application mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
                                g_param_spec_double ("opacity",
@@ -1496,7 +1496,7 @@ register_edit_procs (GimpPDB *pdb)
                                                   "paint mode",
                                                   "The paint application mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
                                g_param_spec_enum ("gradient-type",
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index 4126217..a92b457 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -1212,7 +1212,7 @@ register_layer_procs (GimpPDB *pdb)
                                                   "mode",
                                                   "The layer combination mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_procedure_add_return_value (procedure,
                                    gimp_param_spec_layer_id ("layer",
@@ -2148,7 +2148,7 @@ register_layer_procs (GimpPDB *pdb)
                                                       "mode",
                                                       "The layer combination mode",
                                                       GIMP_TYPE_LAYER_MODE,
-                                                      GIMP_LAYER_MODE_NORMAL,
+                                                      GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                       GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
@@ -2178,7 +2178,7 @@ register_layer_procs (GimpPDB *pdb)
                                                   "mode",
                                                   "The new layer combination mode",
                                                   GIMP_TYPE_LAYER_MODE,
-                                                  GIMP_LAYER_MODE_NORMAL,
+                                                  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                                   GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
diff --git a/app/widgets/gimpwidgets-constructors.c b/app/widgets/gimpwidgets-constructors.c
index 780342e..5bfe587 100644
--- a/app/widgets/gimpwidgets-constructors.c
+++ b/app/widgets/gimpwidgets-constructors.c
@@ -104,8 +104,9 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode,
   GtkWidget    *combo;
 
   store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE,
-                                           25,
+                                           26,
                                            GIMP_LAYER_MODE_NORMAL,
+                                           GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                            GIMP_LAYER_MODE_DISSOLVE,
 
                                            GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY,
@@ -168,7 +169,7 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode,
   if (with_replace_modes)
     {
       gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
-                                          GIMP_LAYER_MODE_NORMAL,
+                                          GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
                                           GIMP_LAYER_MODE_REPLACE);
       gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
                                           GIMP_LAYER_MODE_COLOR_ERASE,
diff --git a/libgimp/gimpenums.h b/libgimp/gimpenums.h
index 0effb53..0df7aac 100644
--- a/libgimp/gimpenums.h
+++ b/libgimp/gimpenums.h
@@ -69,7 +69,7 @@ GType gimp_layer_mode_get_type (void) G_GNUC_CONST;
 
 typedef enum
 {
-  GIMP_LAYER_MODE_NORMAL,
+  GIMP_LAYER_MODE_NORMAL_NON_LINEAR,
   GIMP_LAYER_MODE_DISSOLVE,
   GIMP_LAYER_MODE_BEHIND,
   GIMP_LAYER_MODE_MULTIPLY_LEGACY,
@@ -96,7 +96,8 @@ typedef enum
   GIMP_LAYER_MODE_LCH_HUE,
   GIMP_LAYER_MODE_LCH_CHROMA,
   GIMP_LAYER_MODE_LCH_COLOR,
-  GIMP_LAYER_MODE_LCH_LIGHTNESS
+  GIMP_LAYER_MODE_LCH_LIGHTNESS,
+  GIMP_LAYER_MODE_NORMAL
 } GimpLayerMode;
 
 
diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl
index a1632c2..80be215 100644
--- a/tools/pdbgen/enums.pl
+++ b/tools/pdbgen/enums.pl
@@ -695,33 +695,34 @@ package Gimp::CodeGen::enums;
     GimpLayerMode =>
        { contig => 1,
          header => 'core/core-enums.h',
-         symbols => [ qw(GIMP_LAYER_MODE_NORMAL GIMP_LAYER_MODE_DISSOLVE
-                         GIMP_LAYER_MODE_BEHIND
-                         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
+         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_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) ],
-         mapping => { GIMP_LAYER_MODE_NORMAL => '0',
+                         GIMP_LAYER_MODE_LCH_LIGHTNESS
+                         GIMP_LAYER_MODE_NORMAL) ],
+         mapping => { GIMP_LAYER_MODE_NORMAL_NON_LINEAR => '0',
                       GIMP_LAYER_MODE_DISSOLVE => '1',
                       GIMP_LAYER_MODE_BEHIND => '2',
                       GIMP_LAYER_MODE_MULTIPLY_LEGACY => '3',
@@ -748,7 +749,8 @@ package Gimp::CodeGen::enums;
                       GIMP_LAYER_MODE_LCH_HUE => '24',
                       GIMP_LAYER_MODE_LCH_CHROMA => '25',
                       GIMP_LAYER_MODE_LCH_COLOR => '26',
-                      GIMP_LAYER_MODE_LCH_LIGHTNESS => '27' }
+                      GIMP_LAYER_MODE_LCH_LIGHTNESS => '27',
+                      GIMP_LAYER_MODE_NORMAL => '28' }
        },
     GimpBrushApplicationMode =>
        { contig => 1,


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