From 6b9b2024db85dfefd965482b60771705c2c7593b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sun, 24 May 2020 03:15:07 +0200 Subject: [PATCH] babl: progressively increase search depth from 2 to 4 Follow-on from previous commit, the specific paths looked for that are longer than 2 involving formats with spaces are 3 steps long. Doing a 4 step deep search in these common cases still introduces noticable "warm-up" jankiness in GIMP. To additionally ensure we're not missing used valid and faster than reference conversions in GIMP-2.10 we do an additional search at depth 5 when no converison had been found *and* the destination format has a space differing from sRGB. asdf --- babl/babl-fish-path.c | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c index ab43616..bd0d47e 100644 --- a/babl/babl-fish-path.c +++ b/babl/babl-fish-path.c @@ -590,6 +590,10 @@ babl_fish_path2 (const Babl *source, { PathContext pc; + int start_depth = max_path_length (); + int end_depth = start_depth + 2 + ((destination->format.space != sRGB)?1:0); + end_depth = MIN(end_depth, BABL_HARD_MAX_PATH_LENGTH); + pc.current_path = babl_list_init_with_size (BABL_HARD_MAX_PATH_LENGTH); pc.fish_path = babl; pc.to_format = (Babl *) destination; @@ -601,31 +605,27 @@ babl_fish_path2 (const Babl *source, */ babl_in_fish_path++; - get_conversion_path (&pc, (Babl *) source, 0, max_path_length (), tolerance); - - /* attempt with path length + 2 */ - if (babl->fish_path.conversion_list->count == 0) + for (int max_depth = start_depth; + babl->fish_path.conversion_list->count == 0 && max_depth <= end_depth; + max_depth++) { - int max_length = max_path_length () + 2; - if (max_length > BABL_HARD_MAX_PATH_LENGTH) - max_length = BABL_HARD_MAX_PATH_LENGTH; + get_conversion_path (&pc, (Babl *) source, 0, max_depth, tolerance); + } - get_conversion_path (&pc, (Babl *) source, 0, max_length, tolerance); - if (!babl->fish_path.conversion_list->count) - { - static int show_missing = -1; - if (show_missing < 0) - { - const char *val = getenv ("BABL_DEBUG_MISSING"); - if (val && strcmp (val, "0")) - show_missing = 1; - else - show_missing = 0; - } - if (show_missing) - fprintf (stderr, "babl is lacking conversion for %s to %s\n", - babl_get_name (source), babl_get_name (destination)); - } + if (!babl->fish_path.conversion_list->count) + { + static int show_missing = -1; + if (show_missing < 0) + { + const char *val = getenv ("BABL_DEBUG_MISSING"); + if (val && strcmp (val, "0")) + show_missing = 1; + else + show_missing = 0; + } + if (show_missing) + fprintf (stderr, "babl is lacking conversion for %s to %s\n", + babl_get_name (source), babl_get_name (destination)); } babl_in_fish_path--; -- 2.30.2