Skip to content
Snippets Groups Projects

Color management architecture: color profiles

Merged Pekka Paalanen requested to merge pq/weston:mr/color-output into main
All threads resolved!
2 files
+ 67
0
Compare changes
  • Side-by-side
  • Inline
Files
2
  • This adds "icc_profile" key support in [output] sections for backends
    headless, x11, wayland, and drm, and also for remoted and pipewire
    outputs FWIW. On the other hand, RDP-backend does not use output
    sections from weston.ini, and fbdev-backend does not deserve anything
    new (it wouldn't support color management anyway due to no GL-renderer).
    
    This allows one to configure an ICC v2 or v4 file to be used as an
    output profile. However, color-lcms does not actually use output
    profiles yet, so trying this will fail until support is implemented.
    
    The parent_winsys_profile argument is reserved for using the color
    profile from a parent window system where applicable, if nothing else is
    set in weston.ini. None of the nested backends provide an output color
    profile yet. It is more of a reminder of a missing feature than a
    serious implementation.
    
    Note: cms-static Weston plugin uses the exact same weston.ini key for
    loading VCGT from ICC profiles. If "color-management" option is set to
    false, this new use of "icc_profile" is disabled and the old behavior
    with cms-static is kept.
    
    Signed-off-by: default avatarPekka Paalanen <pekka.paalanen@collabora.com>
+ 59
0
@@ -122,6 +122,7 @@ struct wet_compositor {
int (*simple_output_configure)(struct weston_output *output);
bool init_failed;
struct wl_list layoutput_list; /**< wet_layoutput::compositor_link */
bool use_color_manager;
};
static FILE *weston_logfile = NULL;
@@ -1083,6 +1084,7 @@ static int
weston_compositor_init_config(struct weston_compositor *ec,
struct weston_config *config)
{
struct wet_compositor *compositor = to_wet_compositor(ec);
struct xkb_rule_names xkb_names;
struct weston_config_section *s;
int repaint_msec;
@@ -1131,6 +1133,8 @@ weston_compositor_init_config(struct weston_compositor *ec,
if (color_management) {
if (weston_compositor_load_color_manager(ec) < 0)
return -1;
else
compositor->use_color_manager = true;
}
/* weston.ini [libinput] */
@@ -1290,6 +1294,49 @@ wet_output_set_transform(struct weston_output *output,
return 0;
}
static int
wet_output_set_color_profile(struct weston_output *output,
struct weston_config_section *section,
struct weston_color_profile *parent_winsys_profile)
{
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
struct weston_color_profile *cprof;
char *icc_file = NULL;
bool ok;
if (!compositor->use_color_manager)
return 0;
if (section) {
weston_config_section_get_string(section, "icc_profile",
&icc_file, NULL);
}
if (icc_file) {
cprof = weston_compositor_load_icc_file(output->compositor,
icc_file,
WESTON_COLOR_PROFILE_KIND_OUTPUT);
free(icc_file);
} else if (parent_winsys_profile) {
cprof = weston_color_profile_ref(parent_winsys_profile);
} else {
return 0;
}
if (!cprof)
return -1;
ok = weston_output_set_color_profile(output, cprof);
if (!ok) {
weston_log("Error: failed to set color profile '%s' for output %s\n",
weston_color_profile_get_description(cprof),
output->name);
}
weston_color_profile_unref(cprof);
return ok ? 0 : -1;
}
static void
allow_content_protection(struct weston_output *output,
struct weston_config_section *section)
@@ -1354,6 +1401,9 @@ wet_configure_windowed_output_from_config(struct weston_output *output,
return -1;
}
if (wet_output_set_color_profile(output, section, NULL) < 0)
return -1;
if (api->output_set_size(output, width, height) < 0) {
weston_log("Cannot configure output \"%s\" using weston_windowed_output_api.\n",
output->name);
@@ -1794,6 +1844,9 @@ drm_backend_output_configure(struct weston_output *output,
return -1;
}
if (wet_output_set_color_profile(output, section, NULL) < 0)
return -1;
weston_config_section_get_string(section,
"gbm-format", &gbm_format, NULL);
@@ -2293,6 +2346,9 @@ drm_backend_remoted_output_configure(struct weston_output *output,
return -1;
};
if (wet_output_set_color_profile(output, section, NULL) < 0)
return -1;
weston_config_section_get_string(section, "gbm-format", &gbm_format,
NULL);
api->set_gbm_format(output, gbm_format);
@@ -2444,6 +2500,9 @@ drm_backend_pipewire_output_configure(struct weston_output *output,
return -1;
}
if (wet_output_set_color_profile(output, section, NULL) < 0)
return -1;
weston_config_section_get_string(section, "seat", &seat, "");
api->set_seat(output, seat);
Loading