From c3ef79b3ef31f5999bc78409f14ee80ab0f0f31b Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 10 Jan 2025 22:31:36 +0100 Subject: [PATCH] Issue #12577: get rid of the gamma hack. What it was doing was casting the input buffer to another TRC, basically pretending the data was what it was not. In particular, it was casting linear input buffers to non-linear and all other TRCs to linear. As was noted in #1958, this was in fact a useful trick, yet it's still a trick. Basically when it's needed, it's either: 1. because the operation implementation does not work in the technically correct space. Then the operation code should be fixed; 2. or because several work TRC are valid, then an option should be proposed by the operation; 3. or for artistic reasons, which people are free to implement as plug-ins or third-party filters, but it should not be a core GIMP feature. Therefore for most cases where it felt needed, the real solution will be to improve the operations' implementations. --- app/config/gimpguiconfig.c | 14 ---- app/config/gimpguiconfig.h | 1 - app/core/gimpdrawablefilter.c | 88 -------------------------- app/core/gimpdrawablefilter.h | 3 - app/dialogs/preferences-dialog.c | 13 ---- app/operations/gimpoperationsettings.c | 21 +----- app/operations/gimpoperationsettings.h | 1 - app/tools/gimpfiltertool.c | 35 +--------- docs/gimprc.5.in | 5 -- etc/gimprc.in | 5 -- 10 files changed, 2 insertions(+), 184 deletions(-) diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c index 4c55ce843f..f8d4cfe4ff 100644 --- a/app/config/gimpguiconfig.c +++ b/app/config/gimpguiconfig.c @@ -51,7 +51,6 @@ enum PROP_MOVE_TOOL_CHANGES_ACTIVE, PROP_FILTER_TOOL_MAX_RECENT, PROP_FILTER_TOOL_USE_LAST_SETTINGS, - PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS, PROP_TRUST_DIRTY_FLAG, PROP_SAVE_DEVICE_STATUS, PROP_DEVICES_SHARE_TOOL, @@ -165,13 +164,6 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass) FALSE, GIMP_PARAM_STATIC_STRINGS); - GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS, - "filter-tool-show-color-options", - "Show advanced color options in filters", - FILTER_TOOL_SHOW_COLOR_OPTIONS_BLURB, - FALSE, - GIMP_PARAM_STATIC_STRINGS); - GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_TRUST_DIRTY_FLAG, "trust-dirty-flag", "Trust dirty flag", @@ -632,9 +624,6 @@ gimp_gui_config_set_property (GObject *object, case PROP_FILTER_TOOL_USE_LAST_SETTINGS: gui_config->filter_tool_use_last_settings = g_value_get_boolean (value); break; - case PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS: - gui_config->filter_tool_show_color_options = g_value_get_boolean (value); - break; case PROP_TRUST_DIRTY_FLAG: gui_config->trust_dirty_flag = g_value_get_boolean (value); break; @@ -819,9 +808,6 @@ gimp_gui_config_get_property (GObject *object, case PROP_FILTER_TOOL_USE_LAST_SETTINGS: g_value_set_boolean (value, gui_config->filter_tool_use_last_settings); break; - case PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS: - g_value_set_boolean (value, gui_config->filter_tool_show_color_options); - break; case PROP_TRUST_DIRTY_FLAG: g_value_set_boolean (value, gui_config->trust_dirty_flag); break; diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h index 54f94a17df..4e4f2dd8d5 100644 --- a/app/config/gimpguiconfig.h +++ b/app/config/gimpguiconfig.h @@ -45,7 +45,6 @@ struct _GimpGuiConfig gboolean move_tool_changes_active; gint filter_tool_max_recent; gboolean filter_tool_use_last_settings; - gboolean filter_tool_show_color_options; gboolean trust_dirty_flag; gboolean save_device_status; gboolean devices_share_tool; diff --git a/app/core/gimpdrawablefilter.c b/app/core/gimpdrawablefilter.c index b26f107136..730f487632 100644 --- a/app/core/gimpdrawablefilter.c +++ b/app/core/gimpdrawablefilter.c @@ -97,7 +97,6 @@ struct _GimpDrawableFilter GimpLayerCompositeMode composite_mode; gboolean add_alpha; gboolean color_managed; - gboolean gamma_hack; gboolean override_constraints; @@ -106,8 +105,6 @@ struct _GimpDrawableFilter GeglNode *translate; GeglNode *crop_before; - GeglNode *cast_before; - GeglNode *cast_after; GeglNode *crop_after; GimpApplicator *applicator; }; @@ -140,7 +137,6 @@ static void gimp_drawable_filter_sync_mode (GimpDrawableFilter static void gimp_drawable_filter_sync_affect (GimpDrawableFilter *filter); static void gimp_drawable_filter_sync_format (GimpDrawableFilter *filter); static void gimp_drawable_filter_sync_mask (GimpDrawableFilter *filter); -static void gimp_drawable_filter_sync_gamma_hack (GimpDrawableFilter *filter); static gboolean gimp_drawable_filter_is_added (GimpDrawableFilter *filter); static gboolean gimp_drawable_filter_is_active (GimpDrawableFilter *filter); @@ -386,28 +382,18 @@ gimp_drawable_filter_new (GimpDrawable *drawable, "operation", "gegl:crop", NULL); - filter->cast_before = gegl_node_new_child (node, - "operation", "gegl:nop", - NULL); - gegl_node_link_many (input, filter->translate, filter->crop_before, - filter->cast_before, filter->operation, NULL); } - filter->cast_after = gegl_node_new_child (node, - "operation", "gegl:nop", - NULL); - filter->crop_after = gegl_node_new_child (node, "operation", "gegl:crop", NULL); gegl_node_link_many (filter->operation, - filter->cast_after, filter->crop_after, NULL); @@ -1015,23 +1001,6 @@ gimp_drawable_filter_set_add_alpha (GimpDrawableFilter *filter, } } -void -gimp_drawable_filter_set_gamma_hack (GimpDrawableFilter *filter, - gboolean gamma_hack) -{ - g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter)); - - if (gamma_hack != filter->gamma_hack) - { - filter->gamma_hack = gamma_hack; - - gimp_drawable_filter_sync_gamma_hack (filter); - - if (gimp_drawable_filter_is_active (filter)) - gimp_drawable_filter_update_drawable (filter, NULL); - } -} - void gimp_drawable_filter_set_override_constraints (GimpDrawableFilter *filter, gboolean override_constraints) @@ -1596,62 +1565,6 @@ gimp_drawable_filter_sync_mask (GimpDrawableFilter *filter) } } -static void -gimp_drawable_filter_sync_gamma_hack (GimpDrawableFilter *filter) -{ - if (filter->gamma_hack) - { - const Babl *drawable_format; - const Babl *cast_format; - GimpTRCType trc = GIMP_TRC_LINEAR; - - switch (gimp_drawable_get_trc (filter->drawable)) - { - case GIMP_TRC_LINEAR: trc = GIMP_TRC_NON_LINEAR; break; - case GIMP_TRC_NON_LINEAR: trc = GIMP_TRC_LINEAR; break; - case GIMP_TRC_PERCEPTUAL: trc = GIMP_TRC_LINEAR; break; - } - - drawable_format = - gimp_drawable_get_format_with_alpha (filter->drawable); - - cast_format = - gimp_babl_format (gimp_babl_format_get_base_type (drawable_format), - gimp_babl_precision (gimp_babl_format_get_component_type (drawable_format), - trc), - TRUE, - babl_format_get_space (drawable_format)); - - if (filter->has_input) - { - gegl_node_set (filter->cast_before, - "operation", "gegl:cast-format", - "input-format", drawable_format, - "output-format", cast_format, - NULL); - } - - gegl_node_set (filter->cast_after, - "operation", "gegl:cast-format", - "input-format", cast_format, - "output-format", drawable_format, - NULL); - } - else - { - if (filter->has_input) - { - gegl_node_set (filter->cast_before, - "operation", "gegl:nop", - NULL); - } - - gegl_node_set (filter->cast_after, - "operation", "gegl:nop", - NULL); - } -} - static gboolean gimp_drawable_filter_is_added (GimpDrawableFilter *filter) { @@ -1690,7 +1603,6 @@ gimp_drawable_filter_add_filter (GimpDrawableFilter *filter) gimp_drawable_filter_sync_mode (filter); gimp_drawable_filter_sync_affect (filter); gimp_drawable_filter_sync_format (filter); - gimp_drawable_filter_sync_gamma_hack (filter); gimp_drawable_add_filter (filter->drawable, GIMP_FILTER (filter)); diff --git a/app/core/gimpdrawablefilter.h b/app/core/gimpdrawablefilter.h index 844b5eefe5..5bec7b79e6 100644 --- a/app/core/gimpdrawablefilter.h +++ b/app/core/gimpdrawablefilter.h @@ -120,9 +120,6 @@ void gimp_drawable_filter_set_mode (GimpDrawableFilter *filter, void gimp_drawable_filter_set_add_alpha (GimpDrawableFilter *filter, gboolean add_alpha); -void gimp_drawable_filter_set_gamma_hack (GimpDrawableFilter *filter, - gboolean gamma_hack); - void gimp_drawable_filter_set_override_constraints (GimpDrawableFilter *filter, gboolean override_constraints); diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 0e60ad61f5..170d42e390 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -408,7 +408,6 @@ prefs_color_management_reset (GtkWidget *widget, gimp_config_reset (GIMP_CONFIG (core_config->color_management)); gimp_config_reset_property (config, "color-profile-policy"); - gimp_config_reset_property (config, "filter-tool-show-color-options"); } static void @@ -434,7 +433,6 @@ prefs_dialog_defaults_reset (GtkWidget *widget, gimp_config_reset_property (config, "filter-tool-max-recent"); gimp_config_reset_property (config, "filter-tool-use-last-settings"); - gimp_config_reset_property (config, "filter-tool-show-color-options"); g_object_thaw_notify (config); @@ -1506,14 +1504,6 @@ prefs_dialog_new (Gimp *gimp, _("_File Open behavior:"), GTK_GRID (grid), 0, size_group); - /* Filter Dialogs */ - vbox2 = prefs_frame_new (_("Filter Dialogs"), GTK_CONTAINER (vbox), - FALSE); - - button = prefs_check_button_add (object, "filter-tool-show-color-options", - _("Show _advanced color options"), - GTK_BOX (vbox2)); - g_clear_object (&size_group); g_object_unref (store); @@ -2431,9 +2421,6 @@ prefs_dialog_new (Gimp *gimp, button = prefs_check_button_add (object, "filter-tool-use-last-settings", _("Default to the last used settings"), GTK_BOX (vbox2)); - button = prefs_check_button_add (object, "filter-tool-show-color-options", - _("Show advanced color options"), - GTK_BOX (vbox2)); /* Canvas Size Dialog */ vbox2 = prefs_frame_new (_("Canvas Size Dialog"), diff --git a/app/operations/gimpoperationsettings.c b/app/operations/gimpoperationsettings.c index 13d7dc5e19..c1bc86155e 100644 --- a/app/operations/gimpoperationsettings.c +++ b/app/operations/gimpoperationsettings.c @@ -44,7 +44,6 @@ enum PROP_REGION, PROP_MODE, PROP_OPACITY, - PROP_GAMMA_HACK }; @@ -101,13 +100,6 @@ gimp_operation_settings_class_init (GimpOperationSettingsClass *klass) NULL, 0.0, 1.0, 1.0, GIMP_CONFIG_PARAM_DEFAULTS); - - GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_GAMMA_HACK, - "gimp-gamma-hack", - "Gamma hack (temp hack, please ignore)", - NULL, - FALSE, - GIMP_CONFIG_PARAM_DEFAULTS); } static void @@ -141,10 +133,6 @@ gimp_operation_settings_get_property (GObject *object, g_value_set_double (value, settings->opacity); break; - case PROP_GAMMA_HACK: - g_value_set_boolean (value, settings->gamma_hack); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -177,10 +165,6 @@ gimp_operation_settings_set_property (GObject *object, settings->opacity = g_value_get_double (value); break; - case PROP_GAMMA_HACK: - settings->gamma_hack = g_value_get_boolean (value); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -210,7 +194,6 @@ gimp_operation_settings_sync_drawable_filter (GimpOperationSettings *settings, GIMP_LAYER_COLOR_SPACE_AUTO, GIMP_LAYER_COMPOSITE_AUTO); gimp_drawable_filter_set_opacity (filter, settings->opacity); - gimp_drawable_filter_set_gamma_hack (filter, settings->gamma_hack); } @@ -223,7 +206,6 @@ static const gchar * const base_properties[] = "gimp-region", "gimp-mode", "gimp-opacity", - "gimp-gamma-hack" }; gboolean @@ -256,8 +238,7 @@ gimp_operation_settings_config_equal_base (GimpConfig *a, return settings_a->clip == settings_b->clip && settings_a->region == settings_b->region && settings_a->mode == settings_b->mode && - settings_a->opacity == settings_b->opacity && - settings_a->gamma_hack == settings_b->gamma_hack; + settings_a->opacity == settings_b->opacity; } void diff --git a/app/operations/gimpoperationsettings.h b/app/operations/gimpoperationsettings.h index 1033faef4c..bb65db5f82 100644 --- a/app/operations/gimpoperationsettings.h +++ b/app/operations/gimpoperationsettings.h @@ -43,7 +43,6 @@ struct _GimpOperationSettings GimpFilterRegion region; GimpLayerMode mode; gdouble opacity; - gboolean gamma_hack; }; struct _GimpOperationSettingsClass diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c index 5572c430ee..aac7a2f5ca 100644 --- a/app/tools/gimpfiltertool.c +++ b/app/tools/gimpfiltertool.c @@ -1090,8 +1090,7 @@ gimp_filter_tool_real_config_notify (GimpFilterTool *filter_tool, { if (! strcmp (pspec->name, "gimp-clip") || ! strcmp (pspec->name, "gimp-mode") || - ! strcmp (pspec->name, "gimp-opacity") || - ! strcmp (pspec->name, "gimp-gamma-hack")) + ! strcmp (pspec->name, "gimp-opacity")) { gimp_filter_tool_update_filter (filter_tool); } @@ -1381,9 +1380,7 @@ gimp_filter_tool_dialog (GimpFilterTool *filter_tool) static void gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool) { - GimpTool *tool = GIMP_TOOL (filter_tool); GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool); - GimpImage *image = gimp_display_get_image (tool->display); if (filter_tool->operation_settings_box) { @@ -1398,7 +1395,6 @@ gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool) GtkWidget *vbox2; GtkWidget *mode_box; GtkWidget *scale; - GtkWidget *toggle; vbox = filter_tool->operation_settings_box; @@ -1459,35 +1455,6 @@ gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool) gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0); gtk_widget_show (scale); - - /* The Color Options expander */ - expander = gtk_expander_new (_("Advanced Color Options")); - gtk_box_pack_start (GTK_BOX (vbox), expander, - FALSE, FALSE, 0); - - g_object_bind_property (image->gimp->config, - "filter-tool-show-color-options", - expander, "visible", - G_BINDING_SYNC_CREATE); - g_object_bind_property (options, "color-options-expanded", - expander, "expanded", - G_BINDING_SYNC_CREATE | - G_BINDING_BIDIRECTIONAL); - - frame = gimp_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (expander), frame); - gtk_widget_show (frame); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); - gtk_container_add (GTK_CONTAINER (frame), vbox2); - gtk_widget_show (vbox2); - - /* The gamma hack toggle */ - toggle = gimp_prop_check_button_new (filter_tool->config, - "gimp-gamma-hack", NULL); - gtk_box_pack_start (GTK_BOX (vbox2), toggle, - FALSE, FALSE, 0); - gtk_widget_show (toggle); } } } diff --git a/docs/gimprc.5.in b/docs/gimprc.5.in index d6ff146f71..4e5e779914 100644 --- a/docs/gimprc.5.in +++ b/docs/gimprc.5.in @@ -873,11 +873,6 @@ value. Default to the last used settings in filter tools. Possible values are yes and no. -.TP -(filter-tool-show-color-options no) - -Show advanced color options in filter tools. Possible values are yes and no. - .TP (trust-dirty-flag no) diff --git a/etc/gimprc.in b/etc/gimprc.in index 3fbaa34f4c..20873d8182 100644 --- a/etc/gimprc.in +++ b/etc/gimprc.in @@ -684,11 +684,6 @@ # # (filter-tool-use-last-settings no) -# Show advanced color options in filter tools. Possible values are yes and -# no. -# -# (filter-tool-show-color-options no) - # When enabled, GIMP will not save an image if it has not been changed since # it was opened. Possible values are yes and no. #