Color management: Query default view from display

Solves weird situation when default display name is queried
from OCIO, but Default view being assumed to be set for it.

Now view is initialized to a default view of that display.
This commit is contained in:
Sergey Sharybin 2018-12-05 12:06:48 +01:00
parent 0a28bb1422
commit c603a755bd
6 changed files with 46 additions and 22 deletions

View File

@ -87,18 +87,26 @@ void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, con
void scopes_free(struct Scopes *scopes);
void scopes_new(struct Scopes *scopes);
void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings);
void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings,
const struct ColorManagedDisplaySettings *settings);
void BKE_color_managed_display_settings_init(
struct ColorManagedDisplaySettings *settings);
void BKE_color_managed_display_settings_copy(
struct ColorManagedDisplaySettings *new_settings,
const struct ColorManagedDisplaySettings *settings);
void BKE_color_managed_view_settings_init(struct ColorManagedViewSettings *settings);
void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings,
const struct ColorManagedViewSettings *settings);
void BKE_color_managed_view_settings_init(
struct ColorManagedViewSettings *settings,
const struct ColorManagedDisplaySettings *display_settings);
void BKE_color_managed_view_settings_copy(
struct ColorManagedViewSettings *new_settings,
const struct ColorManagedViewSettings *settings);
void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings);
void BKE_color_managed_colorspace_settings_init(struct ColorManagedColorspaceSettings *colorspace_settings);
void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings,
const struct ColorManagedColorspaceSettings *settings);
bool BKE_color_managed_colorspace_settings_equals(const struct ColorManagedColorspaceSettings *settings1,
const struct ColorManagedColorspaceSettings *settings2);
void BKE_color_managed_colorspace_settings_init(
struct ColorManagedColorspaceSettings *colorspace_settings);
void BKE_color_managed_colorspace_settings_copy(
struct ColorManagedColorspaceSettings *colorspace_settings,
const struct ColorManagedColorspaceSettings *settings);
bool BKE_color_managed_colorspace_settings_equals(
const struct ColorManagedColorspaceSettings *settings1,
const struct ColorManagedColorspaceSettings *settings2);
#endif

View File

@ -1484,17 +1484,23 @@ void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_se
BLI_strncpy(new_settings->display_device, settings->display_device, sizeof(new_settings->display_device));
}
void BKE_color_managed_view_settings_init(ColorManagedViewSettings *settings)
void BKE_color_managed_view_settings_init(
ColorManagedViewSettings *view_settings,
const ColorManagedDisplaySettings *display_settings)
{
/* OCIO_TODO: use default view transform here when OCIO is completely integrated
* and proper versioning stuff is added.
* for now use NONE to be compatible with all current files
*/
BLI_strncpy(settings->view_transform, "Default", sizeof(settings->view_transform));
BLI_strncpy(settings->look, "None", sizeof(settings->look));
struct ColorManagedDisplay *display =
IMB_colormanagement_display_get_named(
display_settings->display_device);
BLI_strncpy(
view_settings->view_transform,
IMB_colormanagement_display_get_default_view_transform_name(display),
sizeof(view_settings->view_transform));
/* TODO(sergey): Find a way to make look query more reliable with non
* default configuration. */
BLI_strncpy(view_settings->look, "None", sizeof(view_settings->look));
settings->gamma = 1.0f;
settings->exposure = 0.0f;
view_settings->gamma = 1.0f;
view_settings->exposure = 0.0f;
}
void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings,

View File

@ -1482,7 +1482,8 @@ void BKE_imformat_defaults(ImageFormatData *im_format)
im_format->compress = 15;
BKE_color_managed_display_settings_init(&im_format->display_settings);
BKE_color_managed_view_settings_init(&im_format->view_settings);
BKE_color_managed_view_settings_init(&im_format->view_settings,
&im_format->display_settings);
}
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf)

View File

@ -799,7 +799,8 @@ void BKE_scene_init(Scene *sce)
colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER);
BKE_color_managed_display_settings_init(&sce->display_settings);
BKE_color_managed_view_settings_init(&sce->view_settings);
BKE_color_managed_view_settings_init(&sce->view_settings,
&sce->display_settings);
BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name,
sizeof(sce->sequencer_colorspace_settings.name));

View File

@ -132,6 +132,8 @@ const char *IMB_colormanagement_display_get_indexed_name(int index);
const char *IMB_colormanagement_display_get_default_name(void);
struct ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name);
const char *IMB_colormanagement_display_get_none_name(void);
const char *IMB_colormanagement_display_get_default_view_transform_name(
struct ColorManagedDisplay *display);
/* ** View funcrions ** */
int IMB_colormanagement_view_get_named_index(const char *name);

View File

@ -2352,6 +2352,12 @@ const char *IMB_colormanagement_display_get_none_name(void)
return colormanage_display_get_default_name();
}
const char *IMB_colormanagement_display_get_default_view_transform_name(
struct ColorManagedDisplay *display)
{
return colormanage_view_get_default_name(display);
}
/*********************** View functions *************************/
const char *colormanage_view_get_default_name(const ColorManagedDisplay *display)