Use helpers to get supported TFs/primaries

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5086
This commit is contained in:
Simon Ser 2025-10-04 11:54:31 +02:00
parent b4a9a1716f
commit 818c1c5f2e

View file

@ -458,15 +458,12 @@ bool server_init(struct sway_server *server) {
const enum wp_color_manager_v1_render_intent render_intents[] = {
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL,
};
const enum wp_color_manager_v1_transfer_function transfer_functions[] = {
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ,
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
};
const enum wp_color_manager_v1_primaries primaries[] = {
WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
};
size_t transfer_functions_len = 0;
enum wp_color_manager_v1_transfer_function *transfer_functions =
wlr_color_manager_v1_transfer_function_list_from_renderer(server->renderer, &transfer_functions_len);
size_t primaries_len = 0;
enum wp_color_manager_v1_primaries *primaries =
wlr_color_manager_v1_primaries_list_from_renderer(server->renderer, &primaries_len);
struct wlr_color_manager_v1 *cm = wlr_color_manager_v1_create(
server->wl_display, 1, &(struct wlr_color_manager_v1_options){
.features = {
@ -476,10 +473,12 @@ bool server_init(struct sway_server *server) {
.render_intents = render_intents,
.render_intents_len = sizeof(render_intents) / sizeof(render_intents[0]),
.transfer_functions = transfer_functions,
.transfer_functions_len = sizeof(transfer_functions) / sizeof(transfer_functions[0]),
.transfer_functions_len = transfer_functions_len,
.primaries = primaries,
.primaries_len = sizeof(primaries) / sizeof(primaries[0]),
.primaries_len = primaries_len,
});
free(transfer_functions);
free(primaries);
wlr_scene_set_color_manager_v1(root->root_scene, cm);
}