Fix: Save as Render does not work for some OCIO configs
There was an incorrect assumption that the display colorspace of a view + display transform uniquely identifies it. But with modern OCIO configs there is no longer a unique display colorspace per view. The same wrong assumption was made in the code that refreshes the image editor after save, and that was fixed as well. Ref #145519 Pull Request: https://projects.blender.org/blender/blender/pulls/146449
This commit is contained in:
committed by
Brecht Van Lommel
parent
e753460e95
commit
6bef804d17
@@ -291,15 +291,15 @@ static void image_save_post(ReportList *reports,
|
||||
blender::StringRefNull colorspace_name = IMB_colormanagement_colorspace_get_name(colorspace);
|
||||
if (colorspace_name != ima->colorspace_settings.name) {
|
||||
STRNCPY(ima->colorspace_settings.name, colorspace_name.c_str());
|
||||
*r_colorspace_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* View transform is now baked in, so don't apply it a second time for viewing. */
|
||||
if (ima->flag & IMA_VIEW_AS_RENDER) {
|
||||
ima->flag &= ~IMA_VIEW_AS_RENDER;
|
||||
*r_colorspace_changed = true;
|
||||
}
|
||||
|
||||
*r_colorspace_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,6 +689,7 @@ bool BKE_image_save(
|
||||
|
||||
if (colorspace_changed) {
|
||||
BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_COLORMANAGE);
|
||||
BKE_image_partial_update_mark_full_update(ima);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
@@ -780,14 +780,6 @@ void IMB_colormanagement_display_settings_from_ctx(
|
||||
}
|
||||
}
|
||||
|
||||
static const ColorSpace *get_display_colorspace(
|
||||
const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings)
|
||||
{
|
||||
return g_config->get_display_view_color_space(display_settings->display_device,
|
||||
view_settings->view_transform);
|
||||
}
|
||||
|
||||
static const ColorSpace *get_untonemapped_display_colorspace(
|
||||
const ColorManagedDisplaySettings *display_settings)
|
||||
{
|
||||
@@ -829,13 +821,14 @@ static std::shared_ptr<const ocio::CPUProcessor> get_display_buffer_processor(
|
||||
return g_config->get_display_cpu_processor(display_parameters);
|
||||
}
|
||||
|
||||
void IMB_colormanagement_init_untonemapped_view_settings(
|
||||
ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
|
||||
static const ocio::View *imb_get_untonemapped_view(
|
||||
const ColorManagedDisplaySettings *display_settings)
|
||||
{
|
||||
const ocio::Display *display = g_config->get_display_by_name(display_settings->display_device);
|
||||
if (!display) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Try to guess what the untonemapped view is. */
|
||||
const ocio::View *default_view = display->get_untonemapped_view();
|
||||
/* If that fails, we fall back to the default view transform of the display
|
||||
@@ -843,6 +836,15 @@ void IMB_colormanagement_init_untonemapped_view_settings(
|
||||
if (default_view == nullptr) {
|
||||
default_view = display->get_default_view();
|
||||
}
|
||||
|
||||
return default_view;
|
||||
}
|
||||
|
||||
void IMB_colormanagement_init_untonemapped_view_settings(
|
||||
ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
|
||||
{
|
||||
/* Try to guess what the untonemapped view is. */
|
||||
const ocio::View *default_view = imb_get_untonemapped_view(display_settings);
|
||||
if (default_view != nullptr) {
|
||||
STRNCPY_UTF8(view_settings->view_transform, default_view->name().c_str());
|
||||
}
|
||||
@@ -1805,12 +1807,13 @@ static bool is_colorspace_same_as_display(const ColorSpace *colorspace,
|
||||
return false;
|
||||
}
|
||||
|
||||
const ColorSpace *display_colorspace = get_display_colorspace(view_settings, display_settings);
|
||||
if (display_colorspace == colorspace) {
|
||||
return true;
|
||||
const ColorSpace *display_colorspace = get_untonemapped_display_colorspace(display_settings);
|
||||
if (display_colorspace != colorspace) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
const ocio::View *default_view = imb_get_untonemapped_view(display_settings);
|
||||
return default_view && default_view->name() == view_settings->view_transform;
|
||||
}
|
||||
|
||||
bool IMB_colormanagement_display_processor_needed(
|
||||
@@ -3984,7 +3987,7 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(
|
||||
applied_view_settings = &untonemapped_view_settings;
|
||||
}
|
||||
|
||||
display_colorspace = get_display_colorspace(applied_view_settings, display_settings);
|
||||
display_colorspace = get_untonemapped_display_colorspace(display_settings);
|
||||
if (display_colorspace) {
|
||||
cm_processor->is_data_result = display_colorspace->is_data();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user