[gimp] libgimpconfig: add "optimize" options for display and softproofing



commit a743ae712b0305f2303c1b9ee715fd302200751d
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 6 01:15:26 2016 +0200

    libgimpconfig: add "optimize" options for display and softproofing
    
    Honor them in gimp_widget_get_color_transform() and make them
    configurable in prefs. The code and GUI avoid the negation in
    the lcms "NOOPTIMIZE" flag.

 app/dialogs/preferences-dialog.c  |   16 ++++++-
 libgimpconfig/gimpcolorconfig.c   |   90 +++++++++++++++++++++++++++++++++++--
 libgimpconfig/gimpcolorconfig.h   |    2 +
 libgimpconfig/gimpconfig.def      |    2 +
 libgimpwidgets/gimpwidgetsutils.c |   10 +---
 5 files changed, 107 insertions(+), 13 deletions(-)
---
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 1fba78d..3f550b9 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1367,7 +1367,6 @@ prefs_dialog_new (Gimp       *gimp,
                                          "display-profile-from-gdk",
                                          _("_Try to use the system monitor "
                                            "profile"));
-
     gtk_table_attach_defaults (GTK_TABLE (table),
                                button, 1, 2, row, row + 1);
     gtk_widget_show (button);
@@ -1381,10 +1380,18 @@ prefs_dialog_new (Gimp       *gimp,
     button = gimp_prop_check_button_new (color_config,
                                          "display-use-black-point-compensation",
                                          _("Use _black point compensation"));
+    gtk_table_attach_defaults (GTK_TABLE (table),
+                               button, 1, 2, row, row + 1);
+    gtk_widget_show (button);
+    row++;
 
+    button = gimp_prop_check_button_new (color_config,
+                                         "display-optimize",
+                                         _("_Optimize display color transforms"));
     gtk_table_attach_defaults (GTK_TABLE (table),
                                button, 1, 2, row, row + 1);
     gtk_widget_show (button);
+    row++;
 
     /*  Print Simulation (Softproofing)  */
     vbox2 = prefs_frame_new (_("Print Simulation (Softproofing)"),
@@ -1409,7 +1416,14 @@ prefs_dialog_new (Gimp       *gimp,
     button = gimp_prop_check_button_new (color_config,
                                          "simulation-use-black-point-compensation",
                                          _("Use black _point compensation"));
+    gtk_table_attach_defaults (GTK_TABLE (table),
+                               button, 1, 2, row, row + 1);
+    gtk_widget_show (button);
+    row++;
 
+    button = gimp_prop_check_button_new (color_config,
+                                         "simulation-optimize",
+                                         _("O_ptimize simulation color transforms"));
     gtk_table_attach_defaults (GTK_TABLE (table),
                                button, 1, 2, row, row + 1);
     gtk_widget_show (button);
diff --git a/libgimpconfig/gimpcolorconfig.c b/libgimpconfig/gimpcolorconfig.c
index 45773f1..99d57de 100644
--- a/libgimpconfig/gimpcolorconfig.c
+++ b/libgimpconfig/gimpcolorconfig.c
@@ -84,7 +84,11 @@
 
 #define DISPLAY_USE_BPC_BLURB \
   _("Do use black point compensation (unless you know you have a reason " \
-    "not to). ")
+    "not to).")
+
+#define DISPLAY_OPTIMIZE_BLURB \
+  _("When disabled, image display might be of better quality " \
+    "at the cost of speed.")
 
 #define SIMULATION_RENDERING_INTENT_BLURB \
   _("How colors are converted from your image's color space to the "  \
@@ -95,6 +99,10 @@
   _("Try with and without black point compensation "\
     "and choose what looks best. ")
 
+#define SIMULATION_OPTIMIZE_BLURB \
+  _("When disabled, simulation might be of better quality " \
+    "at the cost of speed.")
+
 #define SIMULATION_GAMUT_CHECK_BLURB \
   _("When enabled, the print simulation will mark colors " \
     "which can not be represented in the target color space.")
@@ -115,14 +123,30 @@ enum
   PROP_SIMULATION_PROFILE,
   PROP_DISPLAY_RENDERING_INTENT,
   PROP_DISPLAY_USE_BPC,
+  PROP_DISPLAY_OPTIMIZE,
   PROP_SIMULATION_RENDERING_INTENT,
   PROP_SIMULATION_USE_BPC,
+  PROP_SIMULATION_OPTIMIZE,
   PROP_SIMULATION_GAMUT_CHECK,
   PROP_OUT_OF_GAMUT_COLOR,
   PROP_DISPLAY_MODULE
 };
 
 
+typedef struct _GimpColorConfigPrivate GimpColorConfigPrivate;
+
+struct _GimpColorConfigPrivate
+{
+  gboolean display_optimize;
+  gboolean simulation_optimize;
+};
+
+#define GET_PRIVATE(obj) \
+        G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+                                     GIMP_TYPE_COLOR_CONFIG, \
+                                     GimpColorConfigPrivate)
+
+
 static void  gimp_color_config_finalize               (GObject          *object);
 static void  gimp_color_config_set_property           (GObject          *object,
                                                        guint             property_id,
@@ -236,6 +260,13 @@ gimp_color_config_class_init (GimpColorConfigClass *klass)
                             TRUE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_DISPLAY_OPTIMIZE,
+                            "display-optimize",
+                            _("Optimize display color transformations"),
+                            DISPLAY_OPTIMIZE_BLURB,
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_ENUM (object_class, PROP_SIMULATION_RENDERING_INTENT,
                          "simulation-rendering-intent",
                          _("Softproof rendering intent"),
@@ -251,6 +282,13 @@ gimp_color_config_class_init (GimpColorConfigClass *klass)
                             FALSE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SIMULATION_OPTIMIZE,
+                            "simulation-optimize",
+                            _("Optimize simulation color transformations"),
+                            SIMULATION_OPTIMIZE_BLURB,
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SIMULATION_GAMUT_CHECK,
                             "simulation-gamut-check",
                             _("Mark out of gamut colors"),
@@ -270,6 +308,8 @@ gimp_color_config_class_init (GimpColorConfigClass *klass)
                            NULL, NULL,
                            "CdisplayLcms",
                            GIMP_PARAM_STATIC_STRINGS);
+
+  g_type_class_add_private (object_class, sizeof (GimpColorConfigPrivate));
 }
 
 static void
@@ -309,8 +349,9 @@ gimp_color_config_set_property (GObject      *object,
                                 const GValue *value,
                                 GParamSpec   *pspec)
 {
-  GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
-  GError          *error        = NULL;
+  GimpColorConfig        *color_config = GIMP_COLOR_CONFIG (object);
+  GimpColorConfigPrivate *priv         = GET_PRIVATE (object);
+  GError                 *error        = NULL;
 
   switch (property_id)
     {
@@ -351,12 +392,18 @@ gimp_color_config_set_property (GObject      *object,
     case PROP_DISPLAY_USE_BPC:
       color_config->display_use_black_point_compensation = g_value_get_boolean (value);
       break;
+    case PROP_DISPLAY_OPTIMIZE:
+      priv->display_optimize = g_value_get_boolean (value);
+      break;
     case PROP_SIMULATION_RENDERING_INTENT:
       color_config->simulation_intent = g_value_get_enum (value);
       break;
     case PROP_SIMULATION_USE_BPC:
       color_config->simulation_use_black_point_compensation = g_value_get_boolean (value);
       break;
+    case PROP_SIMULATION_OPTIMIZE:
+      priv->simulation_optimize = g_value_get_boolean (value);
+      break;
     case PROP_SIMULATION_GAMUT_CHECK:
       color_config->simulation_gamut_check = g_value_get_boolean (value);
       break;
@@ -386,7 +433,8 @@ gimp_color_config_get_property (GObject    *object,
                                 GValue     *value,
                                 GParamSpec *pspec)
 {
-  GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
+  GimpColorConfig        *color_config = GIMP_COLOR_CONFIG (object);
+  GimpColorConfigPrivate *priv         = GET_PRIVATE (object);
 
   switch (property_id)
     {
@@ -417,12 +465,18 @@ gimp_color_config_get_property (GObject    *object,
     case PROP_DISPLAY_USE_BPC:
       g_value_set_boolean (value, color_config->display_use_black_point_compensation);
       break;
+    case PROP_DISPLAY_OPTIMIZE:
+      g_value_set_boolean (value, priv->display_optimize);
+      break;
     case PROP_SIMULATION_RENDERING_INTENT:
       g_value_set_enum (value, color_config->simulation_intent);
       break;
     case PROP_SIMULATION_USE_BPC:
       g_value_set_boolean (value, color_config->simulation_use_black_point_compensation);
       break;
+    case PROP_SIMULATION_OPTIMIZE:
+      g_value_set_boolean (value, priv->simulation_optimize);
+      break;
     case PROP_SIMULATION_GAMUT_CHECK:
       g_value_set_boolean (value, color_config->simulation_gamut_check);
       break;
@@ -487,6 +541,20 @@ gimp_color_config_get_display_bpc (GimpColorConfig *config)
 }
 
 /**
+ * gimp_color_config_get_display_optimize:
+ * @config: a #GimpColorConfig
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_color_config_get_display_optimize (GimpColorConfig *config)
+{
+  g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), FALSE);
+
+  return GET_PRIVATE (config)->display_optimize;
+}
+
+/**
  * gimp_color_config_get_display_profile_from_gdk:
  * @config: a #GimpColorConfig
  *
@@ -530,6 +598,20 @@ gimp_color_config_get_simulation_bpc (GimpColorConfig *config)
 }
 
 /**
+ * gimp_color_config_get_simulation_optimize:
+ * @config: a #GimpColorConfig
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_color_config_get_simulation_optimize (GimpColorConfig *config)
+{
+  g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), FALSE);
+
+  return GET_PRIVATE (config)->simulation_optimize;
+}
+
+/**
  * gimp_color_config_get_simulation_gamut_check:
  * @config: a #GimpColorConfig
  *
diff --git a/libgimpconfig/gimpcolorconfig.h b/libgimpconfig/gimpcolorconfig.h
index ce8d96c..39e96d9 100644
--- a/libgimpconfig/gimpcolorconfig.h
+++ b/libgimpconfig/gimpcolorconfig.h
@@ -86,11 +86,13 @@ GimpColorManagementMode
 GimpColorRenderingIntent
                    gimp_color_config_get_display_intent           (GimpColorConfig  *config);
 gboolean           gimp_color_config_get_display_bpc              (GimpColorConfig  *config);
+gboolean           gimp_color_config_get_display_optimize         (GimpColorConfig  *config);
 gboolean           gimp_color_config_get_display_profile_from_gdk (GimpColorConfig  *config);
 
 GimpColorRenderingIntent
                    gimp_color_config_get_simulation_intent        (GimpColorConfig  *config);
 gboolean           gimp_color_config_get_simulation_bpc           (GimpColorConfig  *config);
+gboolean           gimp_color_config_get_simulation_optimize      (GimpColorConfig  *config);
 gboolean           gimp_color_config_get_simulation_gamut_check   (GimpColorConfig  *config);
 
 GimpColorProfile * gimp_color_config_get_rgb_color_profile        (GimpColorConfig  *config,
diff --git a/libgimpconfig/gimpconfig.def b/libgimpconfig/gimpconfig.def
index 537ae0d..c9e74c6 100644
--- a/libgimpconfig/gimpconfig.def
+++ b/libgimpconfig/gimpconfig.def
@@ -3,6 +3,7 @@ EXPORTS
        gimp_color_config_get_display_bpc
        gimp_color_config_get_display_color_profile
        gimp_color_config_get_display_intent
+       gimp_color_config_get_display_optimize
        gimp_color_config_get_display_profile_from_gdk
        gimp_color_config_get_gray_color_profile
        gimp_color_config_get_mode
@@ -11,6 +12,7 @@ EXPORTS
        gimp_color_config_get_simulation_color_profile
        gimp_color_config_get_simulation_gamut_check
        gimp_color_config_get_simulation_intent
+       gimp_color_config_get_simulation_optimize
        gimp_color_config_get_type
        gimp_color_management_mode_get_type
        gimp_color_rendering_intent_get_type
diff --git a/libgimpwidgets/gimpwidgetsutils.c b/libgimpwidgets/gimpwidgetsutils.c
index 391d49f..5843f4f 100644
--- a/libgimpwidgets/gimpwidgetsutils.c
+++ b/libgimpwidgets/gimpwidgetsutils.c
@@ -774,11 +774,8 @@ gimp_widget_get_color_transform (GtkWidget        *widget,
       if (gimp_color_config_get_simulation_bpc (config))
         flags |= GIMP_COLOR_TRANSFORM_FLAGS_BLACK_POINT_COMPENSATION;
 
-#if 0
-      /* FIXME add this to GimpColorConfig */
-      if (gimp_color_config_get_simulation_nooptimize (config))
+      if (! gimp_color_config_get_simulation_optimize (config))
         flags |= GIMP_COLOR_TRANSFORM_FLAGS_NOOPTIMIZE;
-#endif
 
       if (gimp_color_config_get_simulation_gamut_check (config))
         {
@@ -813,11 +810,8 @@ gimp_widget_get_color_transform (GtkWidget        *widget,
       if (gimp_color_config_get_display_bpc (config))
         flags |= GIMP_COLOR_TRANSFORM_FLAGS_BLACK_POINT_COMPENSATION;
 
-#if 0
-      /* FIXME add this to GimpColorConfig */
-      if (gimp_color_config_get_display_nooptimize (config))
+      if (! gimp_color_config_get_display_optimize (config))
         flags |= GIMP_COLOR_TRANSFORM_FLAGS_NOOPTIMIZE;
-#endif
 
       cache->transform =
         gimp_color_transform_new (cache->src_profile,


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