compositor: add icc_profile weston.ini option for outputs

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: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 4 years ago committed by Pekka Paalanen
parent 9a9e6ced1b
commit a882794027
  1. 58
      compositor/main.c
  2. 8
      man/weston.ini.man

@ -126,6 +126,7 @@ struct wet_compositor {
struct wl_list child_process_list;
pid_t autolaunch_pid;
bool autolaunch_watch;
bool use_color_manager;
};
static FILE *weston_logfile = NULL;
@ -1095,6 +1096,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;
@ -1143,6 +1145,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] */
@ -1302,6 +1306,48 @@ 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);
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)
@ -1366,6 +1412,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);
@ -1806,6 +1855,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);
@ -2305,6 +2357,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);
@ -2456,6 +2511,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);

@ -545,6 +545,14 @@ An integer, 1 by default, typically configured as 2 or higher when needed,
denoting the scaling multiplier for the output.
.RE
.TP 7
.BI "icc_profile=" file
If option
.B color-management
is true, load the given ICC file as the output color profile. This works only
on DRM, headless, wayland, and x11 backends, and for remoting and pipewire
outputs.
.RE
.TP 7
.BI "seat=" name
The logical seat name that this output should be associated with. If this
is set then the seat's input will be confined to the output that has the seat

Loading…
Cancel
Save