Color management: Improve non-color managed versioning #110581

Merged
Sergey Sharybin merged 3 commits from Sergey/blender:color_management_agx_versioning into main 2023-08-01 14:58:27 +02:00
4 changed files with 42 additions and 1 deletions

View File

@ -3063,7 +3063,7 @@ void BKE_scene_disable_color_management(Scene *scene)
STRNCPY(display_settings->display_device, none_display_name);
view = IMB_colormanagement_view_get_default_name(display_settings->display_device);
view = IMB_colormanagement_view_get_raw_or_default_name(display_settings->display_device);
if (view) {
STRNCPY(view_settings->view_transform, view);

View File

@ -35,6 +35,7 @@
#include "BKE_mesh_legacy_convert.h"
#include "BKE_node.hh"
#include "BKE_node_runtime.hh"
#include "BKE_scene.h"
#include "BKE_tracking.h"
#include "BLO_readfile.h"
@ -505,6 +506,21 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 13)) {
/* For the scenes configured to use the "None" display disable the color management
* again. This will handle situation when the "None" display is removed and is replaced with
* a "Raw" view instead.
*
* Note that this versioning will do nothing if the "None" display exists in the OCIO
* configuration. */
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
const ColorManagedDisplaySettings &display_settings = scene->display_settings;
if (STREQ(display_settings.display_device, "None")) {
BKE_scene_disable_color_management(scene);
}
}
}
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -345,6 +345,7 @@ int IMB_colormanagement_colorspace_get_named_index(const char *name);
const char *IMB_colormanagement_colorspace_get_indexed_name(int index);
const char *IMB_colormanagement_colorspace_get_name(const struct ColorSpace *colorspace);
const char *IMB_colormanagement_view_get_default_name(const char *display_name);
const char *IMB_colormanagement_view_get_raw_or_default_name(const char *display_name);
void IMB_colormanagement_colorspace_from_ibuf_ftype(
struct ColorManagedColorspaceSettings *colorspace_settings, struct ImBuf *ibuf);

View File

@ -3036,6 +3036,30 @@ const char *IMB_colormanagement_view_get_default_name(const char *display_name)
return nullptr;
}
const char *IMB_colormanagement_view_get_raw_or_default_name(const char *display_name)
{
ColorManagedDisplay *display = colormanage_display_get_named(display_name);
if (!display) {
return nullptr;
}
ColorManagedView *view = nullptr;
if (!view) {
view = colormanage_view_get_named_for_display(display_name, "Raw");
}
if (!view) {
view = colormanage_view_get_default(display);
}
if (!view) {
return nullptr;
}
return view->name;
}
/** \} */
/* -------------------------------------------------------------------- */