Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-03-22 21:14:42 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-03-23 17:21:58 +0300
commit5ac4e6c911f6c61a33193f0bf796e1ab093a94e7 (patch)
treec22d50b8d186ce5774f18470d4211a59cb4f0a0f /source/blender/imbuf/intern/colormanagement.c
parent7aab508e3273ae1762ae815bbecc8842938f0926 (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/intern/colormanagement.c')
-rw-r--r--source/blender/imbuf/intern/colormanagement.c18
1 files changed, 17 insertions, 1 deletions
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;