diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-03-22 21:14:42 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-03-23 17:21:58 +0300 |
commit | 5ac4e6c911f6c61a33193f0bf796e1ab093a94e7 (patch) | |
tree | c22d50b8d186ce5774f18470d4211a59cb4f0a0f /source/blender/imbuf | |
parent | 7aab508e3273ae1762ae815bbecc8842938f0926 (diff) |
Color Management: add support for OpenColorIO color space aliases
This enables the configuration to specify aliases for compatibility with other
configurations.
When a colorspace name is saved in a.blend, that is the alias of a colorspace
in the current configuration, it will show the main colorspace from the
configuration in the user interface and Python API instead.
Loading & saving the .blend file does not make any changes to the stored name,
so as to not make hidden modifications. Only when setting the property again
will the alias name be overwritten by the main colorspace name.
Fixes T96049
Differential Revision: https://developer.blender.org/D14419
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/IMB_colormanagement_intern.h | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/colormanagement.c | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h index 42941ace40b..c89b15480a2 100644 --- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h +++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h @@ -33,6 +33,9 @@ typedef struct ColorSpace { struct OCIO_ConstCPUProcessorRcPtr *to_scene_linear; struct OCIO_ConstCPUProcessorRcPtr *from_scene_linear; + char (*aliases)[MAX_COLORSPACE_NAME]; + int num_aliases; + bool is_invertible; bool is_data; diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 15a586ea762..3f8464d003e 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -504,7 +504,16 @@ static void colormanage_load_config(OCIO_ConstConfigRcPtr *config) is_invertible = OCIO_colorSpaceIsInvertible(ocio_colorspace); is_data = OCIO_colorSpaceIsData(ocio_colorspace); - colormanage_colorspace_add(name, description, is_invertible, is_data); + ColorSpace *colorspace = colormanage_colorspace_add(name, description, is_invertible, is_data); + + colorspace->num_aliases = OCIO_colorSpaceGetNumAliases(ocio_colorspace); + if (colorspace->num_aliases > 0) { + colorspace->aliases = MEM_callocN(sizeof(*colorspace->aliases) * colorspace->num_aliases, + "ColorSpace aliases"); + for (int i = 0; i < colorspace->num_aliases; i++) { + STRNCPY(colorspace->aliases[i], OCIO_colorSpaceGetAlias(ocio_colorspace, i)); + } + } OCIO_colorSpaceRelease(ocio_colorspace); } @@ -587,6 +596,7 @@ static void colormanage_free_config(void) } /* free color space itself */ + MEM_SAFE_FREE(colorspace->aliases); MEM_freeN(colorspace); colorspace = colorspace_next; @@ -3053,6 +3063,12 @@ ColorSpace *colormanage_colorspace_get_named(const char *name) if (STREQ(colorspace->name, name)) { return colorspace; } + + for (int i = 0; i < colorspace->num_aliases; i++) { + if (STREQ(colorspace->aliases[i], name)) { + return colorspace; + } + } } return NULL; |