From 3f3b29ba12ab2619b83e6e91d6741c3f1ede7a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sat, 30 Nov 2024 02:06:53 +0100 Subject: [PATCH] app, libgimp, pdb: fix perceptual blend space for linear TRC ICC profiles In previous versions what has been stored/specified as perceptual blending or compositing spaces has really been the non-linear variant of the images babl space. To maintain loading of old files, the code has been updated to actually mean non-linear and a new perceptual value has been added to the GimpLayerColorSpace enum, while preserving all old enum values. This change bumps XCF file version to 23 --- app/actions/layers-actions.c | 16 +++ app/core/gimpimage.c | 14 +++ app/dialogs/layer-options-dialog.c | 9 +- app/gegl/gimp-gegl-nodes.c | 1 + app/operations/layer-modes/gimp-layer-modes.c | 97 ++++++++++--------- .../layer-modes/gimpoperationlayermode.c | 45 ++++++++- .../layer-modes/gimpoperationlayermode.h | 2 +- app/operations/operations-enums.c | 6 +- app/operations/operations-enums.h | 3 +- app/xcf/xcf.c | 1 + libgimp/gimpenums.h | 4 + menus/layers-menu.ui | 2 + pdb/enums.pl | 6 +- 13 files changed, 148 insertions(+), 58 deletions(-) diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c index fb534a6f4c..376b5254b6 100644 --- a/app/actions/layers-actions.c +++ b/app/actions/layers-actions.c @@ -321,6 +321,12 @@ static const GimpRadioActionEntry layers_blend_space_actions[] = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, NULL }, + { "layers-blend-space-rgb-non-linear", NULL, + NC_("layers-action", "RGB (from color profile)"), NULL, { NULL }, + NC_("layers-action", "Layer Blend Space: RGB (from color profile)"), + GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + NULL }, + { "layers-blend-space-rgb-perceptual", NULL, NC_("layers-action", "RGB (perceptual)"), NULL, { NULL }, NC_("layers-action", "Layer Blend Space: RGB (perceptual)"), @@ -342,6 +348,12 @@ static const GimpRadioActionEntry layers_composite_space_actions[] = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, NULL }, + { "layers-composite-space-rgb-non-linear", NULL, + NC_("layers-action", "RGB (from color profile)"), NULL, { NULL }, + NC_("layers-action", "Layer Composite Space: RGB (from color profile)"), + GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + NULL }, + { "layers-composite-space-rgb-perceptual", NULL, NC_("layers-action", "RGB (perceptual)"), NULL, { NULL }, NC_("layers-action", "Layer Composite Space: RGB (perceptual)"), @@ -920,6 +932,8 @@ layers_actions_update (GimpActionGroup *group, action = "layers-blend-space-auto"; break; case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR: action = "layers-blend-space-rgb-linear"; break; + case GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR: + action = "layers-blend-space-rgb-non-linear"; break; case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: action = "layers-blend-space-rgb-perceptual"; break; default: @@ -935,6 +949,8 @@ layers_actions_update (GimpActionGroup *group, action = "layers-composite-space-auto"; break; case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR: action = "layers-composite-space-rgb-linear"; break; + case GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR: + action = "layers-composite-space-rgb-non-linear"; break; case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: action = "layers-composite-space-rgb-perceptual"; break; default: diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 31d29ee64c..b299a6d86c 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -2951,6 +2951,20 @@ gimp_image_get_xcf_version (GimpImage *image, */ version = MAX (22, version); } + + if ((gimp_layer_get_real_blend_space (layer) == GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL) + ||(gimp_layer_get_real_composite_space (layer) == GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL)) + { + ADD_REASON (g_strdup_printf (_("Blending space fixes in %s"), + "GIMP 3.0")); + /* The blending space variant corresponding to SPACE_RGB_PERCEPTUAL in <3.0 + * corresponds to R'G'B'A which is NON_LINEAR in babl. Perceptual in babl is + * R~G~B~A, >= 3.0 the code, comments and usage matches the existing enum value + * as being NON_LINEAR and new layers created use the new interger value for + * PERCEPTUAL. + */ + version = MAX (23, version); + } } g_list_free (items); diff --git a/app/dialogs/layer-options-dialog.c b/app/dialogs/layer-options-dialog.c index 1132725d8e..afcd354537 100644 --- a/app/dialogs/layer-options-dialog.c +++ b/app/dialogs/layer-options-dialog.c @@ -194,9 +194,12 @@ layer_options_dialog_new (GimpImage *image, private); space_model = - gimp_enum_store_new_with_range (GIMP_TYPE_LAYER_COLOR_SPACE, - GIMP_LAYER_COLOR_SPACE_AUTO, - GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL); + gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_COLOR_SPACE, + 4, + GIMP_LAYER_COLOR_SPACE_AUTO, + GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, + GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL); private->blend_space_combo = combo = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (space_model)); diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c index 6cc24c7091..2b084e8254 100644 --- a/app/gegl/gimp-gegl-nodes.c +++ b/app/gegl/gimp-gegl-nodes.c @@ -42,6 +42,7 @@ gimp_gegl_create_flatten_node (GeglColor *background, g_return_val_if_fail (GEGL_IS_COLOR (background), NULL); g_return_val_if_fail (composite_space == GIMP_LAYER_COLOR_SPACE_RGB_LINEAR || + composite_space == GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR || composite_space == GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, NULL); diff --git a/app/operations/layer-modes/gimp-layer-modes.c b/app/operations/layer-modes/gimp-layer-modes.c index 3f39bfa568..7b85979381 100644 --- a/app/operations/layer-modes/gimp-layer-modes.c +++ b/app/operations/layer-modes/gimp-layer-modes.c @@ -65,7 +65,7 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION, .composite_mode = GIMP_LAYER_COMPOSITE_UNION, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_DISSOLVE, @@ -90,7 +90,7 @@ static const GimpLayerModeInfo layer_mode_infos[] = GIMP_LAYER_MODE_CONTEXT_FILTER, .paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION, .composite_mode = GIMP_LAYER_COMPOSITE_UNION, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_MULTIPLY_LEGACY, @@ -103,8 +103,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_SCREEN_LEGACY, @@ -117,8 +117,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_OVERLAY_LEGACY, @@ -131,8 +131,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_DIFFERENCE_LEGACY, @@ -145,8 +145,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_ADDITION_LEGACY, @@ -159,8 +159,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_SUBTRACT_LEGACY, @@ -173,8 +173,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY, @@ -187,8 +187,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY, @@ -201,8 +201,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HSV_HUE_LEGACY, @@ -215,8 +215,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HSV_SATURATION_LEGACY, @@ -229,8 +229,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HSL_COLOR_LEGACY, @@ -243,8 +243,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HSV_VALUE_LEGACY, @@ -257,8 +257,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_DIVIDE_LEGACY, @@ -271,8 +271,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_DODGE_LEGACY, @@ -285,8 +285,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_BURN_LEGACY, @@ -299,8 +299,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HARDLIGHT_LEGACY, @@ -313,8 +313,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_SOFTLIGHT_LEGACY, @@ -327,8 +327,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY, @@ -341,8 +341,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY, @@ -355,8 +355,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = .context = GIMP_LAYER_MODE_CONTEXT_ALL, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_COLOR_ERASE_LEGACY, @@ -372,8 +372,8 @@ static const GimpLayerModeInfo layer_mode_infos[] = GIMP_LAYER_MODE_CONTEXT_FILTER, .paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, - .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_OVERLAY, @@ -545,7 +545,7 @@ static const GimpLayerModeInfo layer_mode_infos[] = .paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HSV_SATURATION, @@ -557,7 +557,7 @@ static const GimpLayerModeInfo layer_mode_infos[] = .paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HSL_COLOR, @@ -569,7 +569,7 @@ static const GimpLayerModeInfo layer_mode_infos[] = .paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_HSV_VALUE, @@ -581,7 +581,7 @@ static const GimpLayerModeInfo layer_mode_infos[] = .paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION, .composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP, .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, - .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL + .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR }, { GIMP_LAYER_MODE_DIVIDE, @@ -1533,9 +1533,12 @@ gimp_layer_mode_get_format (GimpLayerMode mode, case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR: return babl_format_with_space ("RGBA float", preferred_format); - case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: + case GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR: return babl_format_with_space ("R'G'B'A float", preferred_format); + case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: + return babl_format_with_space ("R~G~B~A float", preferred_format); + case GIMP_LAYER_COLOR_SPACE_LAB: return babl_format_with_space ("CIE Lab alpha float", preferred_format); } diff --git a/app/operations/layer-modes/gimpoperationlayermode.c b/app/operations/layer-modes/gimpoperationlayermode.c index 59749d7ec0..398f158c2b 100644 --- a/app/operations/layer-modes/gimpoperationlayermode.c +++ b/app/operations/layer-modes/gimpoperationlayermode.c @@ -657,8 +657,8 @@ gimp_operation_layer_mode_real_process (GeglOperation *operation, if (blend_space != GIMP_LAYER_COLOR_SPACE_AUTO) { - gimp_assert (composite_space >= 1 && composite_space < 4); - gimp_assert (blend_space >= 1 && blend_space < 4); + gimp_assert (composite_space >= 1 && composite_space < 5); + gimp_assert (blend_space >= 1 && blend_space < 5); /* Make sure the cache is set up from the start as the * operation's prepare() method may have not been run yet. @@ -903,8 +903,15 @@ gimp_operation_layer_mode_cache_fishes (GimpOperationLayerMode *op, op->space_fish /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] = + babl_fish (babl_format_with_space ("RGBA float", format), + babl_format_with_space ("R~G~B~A float", format)); + + op->space_fish + /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] + /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR - 1] = babl_fish (babl_format_with_space ("RGBA float", format), babl_format_with_space ("R'G'B'A float", format)); + op->space_fish /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] /* to */ [GIMP_LAYER_COLOR_SPACE_LAB - 1] = @@ -912,12 +919,25 @@ gimp_operation_layer_mode_cache_fishes (GimpOperationLayerMode *op, babl_format_with_space ("CIE Lab alpha float", format)); op->space_fish - /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] + /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR - 1] /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] = babl_fish (babl_format_with_space("R'G'B'A float", format), babl_format_with_space ( "RGBA float", format)); + op->space_fish /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] + /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] = + babl_fish (babl_format_with_space("R~G~B~A float", format), + babl_format_with_space ( "RGBA float", format)); + + op->space_fish + /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] + /* to */ [GIMP_LAYER_COLOR_SPACE_LAB - 1] = + babl_fish (babl_format_with_space("R~G~B~A float", format), + babl_format_with_space ( "CIE Lab alpha float", format)); + + op->space_fish + /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR - 1] /* to */ [GIMP_LAYER_COLOR_SPACE_LAB - 1] = babl_fish (babl_format_with_space("R'G'B'A float", format), babl_format_with_space ( "CIE Lab alpha float", format)); @@ -927,11 +947,30 @@ gimp_operation_layer_mode_cache_fishes (GimpOperationLayerMode *op, /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] = babl_fish (babl_format_with_space("CIE Lab alpha float", format), babl_format_with_space ( "RGBA float", format)); + op->space_fish /* from */ [GIMP_LAYER_COLOR_SPACE_LAB - 1] /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] = + babl_fish (babl_format_with_space("CIE Lab alpha float", format), + babl_format_with_space ( "R~G~B~A float", format)); + + op->space_fish + /* from */ [GIMP_LAYER_COLOR_SPACE_LAB - 1] + /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR - 1] = babl_fish (babl_format_with_space("CIE Lab alpha float", format), babl_format_with_space ( "R'G'B'A float", format)); + + op->space_fish + /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] + /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR - 1] = + babl_fish (babl_format_with_space("R~G~B~A float", format), + babl_format_with_space ( "R'G'B'A float", format)); + + op->space_fish + /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR - 1] + /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] = + babl_fish (babl_format_with_space("R'G'B'A float", format), + babl_format_with_space ( "R~G~B~A float", format)); } } diff --git a/app/operations/layer-modes/gimpoperationlayermode.h b/app/operations/layer-modes/gimpoperationlayermode.h index b0327d312f..725841b48a 100644 --- a/app/operations/layer-modes/gimpoperationlayermode.h +++ b/app/operations/layer-modes/gimpoperationlayermode.h @@ -45,7 +45,7 @@ struct _GimpOperationLayerMode GimpLayerColorSpace composite_space; GimpLayerCompositeMode composite_mode; const Babl *cached_fish_format; - const Babl *space_fish[3 /* from */][3 /* to */]; + const Babl *space_fish[4 /* from */][4 /* to */]; gdouble prop_opacity; GimpLayerCompositeMode prop_composite_mode; diff --git a/app/operations/operations-enums.c b/app/operations/operations-enums.c index 2638245367..3430e2080d 100644 --- a/app/operations/operations-enums.c +++ b/app/operations/operations-enums.c @@ -16,8 +16,9 @@ gimp_layer_color_space_get_type (void) { { GIMP_LAYER_COLOR_SPACE_AUTO, "GIMP_LAYER_COLOR_SPACE_AUTO", "auto" }, { GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, "GIMP_LAYER_COLOR_SPACE_RGB_LINEAR", "rgb-linear" }, - { GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, "GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL", "rgb-perceptual" }, + { GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, "GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR", "rgb-non-linear" }, { GIMP_LAYER_COLOR_SPACE_LAB, "GIMP_LAYER_COLOR_SPACE_LAB", "lab" }, + { GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, "GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL", "rgb-perceptual" }, { 0, NULL, NULL } }; @@ -25,8 +26,9 @@ gimp_layer_color_space_get_type (void) { { GIMP_LAYER_COLOR_SPACE_AUTO, NC_("layer-color-space", "Auto"), NULL }, { GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, NC_("layer-color-space", "RGB (linear)"), NULL }, - { GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, NC_("layer-color-space", "RGB (perceptual)"), NULL }, + { GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, NC_("layer-color-space", "RGB (from color profile)"), NULL }, { GIMP_LAYER_COLOR_SPACE_LAB, NC_("layer-color-space", "LAB"), NULL }, + { GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, NC_("layer-color-space", "RGB (perceptual)"), NULL }, { 0, NULL, NULL } }; diff --git a/app/operations/operations-enums.h b/app/operations/operations-enums.h index b11832f3e3..d2099f34e8 100644 --- a/app/operations/operations-enums.h +++ b/app/operations/operations-enums.h @@ -29,8 +29,9 @@ typedef enum { GIMP_LAYER_COLOR_SPACE_AUTO, /*< desc="Auto" >*/ GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, /*< desc="RGB (linear)" >*/ + GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, /*< desc="RGB (from color profile)" >*/ + GIMP_LAYER_COLOR_SPACE_LAB, /*< desc="LAB" >*/ GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, /*< desc="RGB (perceptual)" >*/ - GIMP_LAYER_COLOR_SPACE_LAB, /*< desc="LAB", pdb-skip >*/ } GimpLayerColorSpace; diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index 826fb5acd6..b5f6f2b896 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -91,6 +91,7 @@ static GimpXcfLoaderFunc * const xcf_loaders[] = xcf_load_image, /* version 20 */ xcf_load_image, /* version 21 */ xcf_load_image, /* version 22 */ + xcf_load_image, /* version 23 */ }; diff --git a/libgimp/gimpenums.h b/libgimp/gimpenums.h index 5de98add90..fcab197794 100644 --- a/libgimp/gimpenums.h +++ b/libgimp/gimpenums.h @@ -98,6 +98,8 @@ GType gimp_layer_color_space_get_type (void) G_GNUC_CONST; * GimpLayerColorSpace: * @GIMP_LAYER_COLOR_SPACE_AUTO: GIMP_LAYER_COLOR_SPACE_AUTO * @GIMP_LAYER_COLOR_SPACE_RGB_LINEAR: GIMP_LAYER_COLOR_SPACE_RGB_LINEAR + * @GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR: GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR + * @GIMP_LAYER_COLOR_SPACE_LAB: GIMP_LAYER_COLOR_SPACE_LAB * @GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL * * Extracted from app/operations/operations-enums.h @@ -106,6 +108,8 @@ typedef enum { GIMP_LAYER_COLOR_SPACE_AUTO, GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, + GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR, + GIMP_LAYER_COLOR_SPACE_LAB, GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL } GimpLayerColorSpace; diff --git a/menus/layers-menu.ui b/menus/layers-menu.ui index 2aea47e9f0..e780d64387 100644 --- a/menus/layers-menu.ui +++ b/menus/layers-menu.ui @@ -12,12 +12,14 @@ Blend Space app.layers-blend-space-auto app.layers-blend-space-rgb-linear + app.layers-blend-space-rgb-non-linear app.layers-blend-space-rgb-perceptual Composite Space app.layers-composite-space-auto app.layers-composite-space-rgb-linear + app.layers-composite-space-rgb-non-linear app.layers-composite-space-rgb-perceptual diff --git a/pdb/enums.pl b/pdb/enums.pl index eaa3b9c16e..b0344df6ee 100644 --- a/pdb/enums.pl +++ b/pdb/enums.pl @@ -679,10 +679,14 @@ package Gimp::CodeGen::enums; header => 'operations/operations-enums.h', symbols => [ qw(GIMP_LAYER_COLOR_SPACE_AUTO GIMP_LAYER_COLOR_SPACE_RGB_LINEAR + GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR + GIMP_LAYER_COLOR_SPACE_LAB GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL) ], mapping => { GIMP_LAYER_COLOR_SPACE_AUTO => '0', GIMP_LAYER_COLOR_SPACE_RGB_LINEAR => '1', - GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL => '2' } + GIMP_LAYER_COLOR_SPACE_RGB_NON_LINEAR => '2', + GIMP_LAYER_COLOR_SPACE_LAB => '3', + GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL => '4' } }, GimpLayerCompositeMode => { contig => 1,