From d0dcfb815964dbbd6244a762935b9650d6609a61 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Aug 2023 15:40:34 +0200 Subject: [PATCH] Color management: Tweak compatible look check Change compatible look check so that if the view contains explicitly configured looks the non-explicit looks are not added to the list. In practice this means that if there are looks "Low Contrast" and "AgX - Low Contrast" only the latter one is considered to be compatible with the "AgX" view. Ref #110685 Pull Request: https://projects.blender.org/blender/blender/pulls/111229 --- .../blender/imbuf/intern/colormanagement.cc | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/source/blender/imbuf/intern/colormanagement.cc b/source/blender/imbuf/intern/colormanagement.cc index 1295cfb6538..1f2ea9231dc 100644 --- a/source/blender/imbuf/intern/colormanagement.cc +++ b/source/blender/imbuf/intern/colormanagement.cc @@ -737,14 +737,47 @@ void colormanagement_exit() /** \name Internal functions * \{ */ -static bool colormanage_compatible_look(ColorManagedLook *look, const char *view_name) +static bool has_explicit_look_for_view(const char *view_name) +{ + if (!view_name) { + return false; + } + + LISTBASE_FOREACH (ColorManagedLook *, look, &global_looks) { + if (STREQ(look->view, view_name)) { + return true; + } + } + + return false; +} + +static bool colormanage_compatible_look(const ColorManagedLook *look, + const char *view_name, + const bool has_explicit_look) { if (look->is_noop) { return true; } - /* Skip looks only relevant to specific view transforms. */ - return (look->view[0] == 0 || (view_name && STREQ(look->view, view_name))); + /* Skip looks only relevant to specific view transforms. + * If the view transform has view-specific look ignore non-specific looks. */ + + if (view_name && STREQ(look->view, view_name)) { + return true; + } + + if (has_explicit_look) { + return false; + } + + return look->view[0] == '\0'; +} + +static bool colormanage_compatible_look(const ColorManagedLook *look, const char *view_name) +{ + const bool has_explicit_look = has_explicit_look_for_view(view_name); + return colormanage_compatible_look(look, view_name, has_explicit_look); } static bool colormanage_use_look(const char *look, const char *view_name) @@ -3405,8 +3438,10 @@ void IMB_colormanagement_look_items_add(EnumPropertyItem **items, int *totitem, const char *view_name) { + const bool has_explicit_look = has_explicit_look_for_view(view_name); + LISTBASE_FOREACH (ColorManagedLook *, look, &global_looks) { - if (!colormanage_compatible_look(look, view_name)) { + if (!colormanage_compatible_look(look, view_name, has_explicit_look)) { continue; }