mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
color_management_v1: set output color properties
This reports the output properties according to the current image description.
Firefox needs this to report HDR support to documents, at least.
v2: Move abort() calls out of switch to eliminate default case. Rename
functions so they don't use a wlr_ prefix like public functions do.
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
1beb25a1c8
commit
51a78cb0ed
1 changed files with 30 additions and 0 deletions
|
|
@ -76,6 +76,17 @@ static enum wlr_color_named_primaries named_primaries_to_wlr(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum wp_color_manager_v1_primaries named_primaries_from_wlr(
|
||||||
|
enum wlr_color_named_primaries primaries) {
|
||||||
|
switch (primaries) {
|
||||||
|
case WLR_COLOR_NAMED_PRIMARIES_SRGB:
|
||||||
|
return WP_COLOR_MANAGER_V1_PRIMARIES_SRGB;
|
||||||
|
case WLR_COLOR_NAMED_PRIMARIES_BT2020:
|
||||||
|
return WP_COLOR_MANAGER_V1_PRIMARIES_BT2020;
|
||||||
|
}
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
static enum wlr_color_transfer_function transfer_function_to_wlr(
|
static enum wlr_color_transfer_function transfer_function_to_wlr(
|
||||||
enum wp_color_manager_v1_transfer_function tf) {
|
enum wp_color_manager_v1_transfer_function tf) {
|
||||||
switch (tf) {
|
switch (tf) {
|
||||||
|
|
@ -90,6 +101,19 @@ static enum wlr_color_transfer_function transfer_function_to_wlr(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum wp_color_manager_v1_transfer_function transfer_function_from_wlr(
|
||||||
|
enum wlr_color_transfer_function tf) {
|
||||||
|
switch (tf) {
|
||||||
|
case WLR_COLOR_TRANSFER_FUNCTION_SRGB:
|
||||||
|
return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB;
|
||||||
|
case WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ:
|
||||||
|
return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ;
|
||||||
|
case WLR_COLOR_TRANSFER_FUNCTION_EXT_LINEAR:
|
||||||
|
return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR;
|
||||||
|
}
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t encode_cie1931_coord(float value) {
|
static int32_t encode_cie1931_coord(float value) {
|
||||||
return round(value * 1000 * 1000);
|
return round(value * 1000 * 1000);
|
||||||
}
|
}
|
||||||
|
|
@ -238,6 +262,11 @@ static void cm_output_handle_get_image_description(struct wl_client *client,
|
||||||
.tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
|
.tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
|
||||||
.primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
|
.primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
|
||||||
};
|
};
|
||||||
|
const struct wlr_output_image_description *image_desc = cm_output->output->image_description;
|
||||||
|
if (image_desc != NULL) {
|
||||||
|
data.tf_named = transfer_function_from_wlr(image_desc->transfer_function);
|
||||||
|
data.primaries_named = named_primaries_from_wlr(image_desc->primaries);
|
||||||
|
}
|
||||||
image_desc_create_ready(cm_output->manager, cm_output_resource, id, &data, true);
|
image_desc_create_ready(cm_output->manager, cm_output_resource, id, &data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -691,6 +720,7 @@ static void manager_handle_get_output(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
cm_output->manager = manager;
|
cm_output->manager = manager;
|
||||||
|
cm_output->output = output;
|
||||||
|
|
||||||
uint32_t version = wl_resource_get_version(manager_resource);
|
uint32_t version = wl_resource_get_version(manager_resource);
|
||||||
cm_output->resource = wl_resource_create(client,
|
cm_output->resource = wl_resource_create(client,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue