server: add support for color-management-v1

Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
This commit is contained in:
Manuel Barrio Linares 2025-12-02 17:44:54 -03:00
parent f4ba2e6a6e
commit bdae48a791
2 changed files with 42 additions and 0 deletions

View file

@ -25,6 +25,7 @@ server_protocols = [
wl_protocol_dir / 'staging/ext-workspace/ext-workspace-v1.xml',
wl_protocol_dir / 'staging/ext-image-capture-source/ext-image-capture-source-v1.xml',
wl_protocol_dir / 'staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml',
wl_protocol_dir / 'staging/color-management/color-management-v1.xml',
'cosmic-workspace-unstable-v1.xml',
'wlr-layer-shell-unstable-v1.xml',
'wlr-input-inhibitor-unstable-v1.xml',

View file

@ -8,6 +8,8 @@
#include <wlr/backend/multi.h>
#include <wlr/render/allocator.h>
#include <wlr/types/wlr_alpha_modifier_v1.h>
#include <wlr/types/wlr_color_management_v1.h>
#include <wlr/types/wlr_color_representation_v1.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_drm.h>
@ -584,6 +586,45 @@ server_init(struct server *server)
* | layer-shell | background-layer | Yes | swaybg
*/
if (server->renderer->features.input_color_transform) {
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,
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22,
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_BT1886,
};
const enum wp_color_manager_v1_primaries primaries[] = {
WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
};
struct wlr_color_manager_v1 *cm = wlr_color_manager_v1_create(
server->wl_display, 1, &(struct wlr_color_manager_v1_options){
.features = {
.parametric = true,
.set_mastering_display_primaries = true,
},
.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]),
.primaries = primaries,
.primaries_len = sizeof(primaries) / sizeof(primaries[0]),
});
if (cm) {
wlr_scene_set_color_manager_v1(server->scene, cm);
} else {
wlr_log(WLR_ERROR, "unable to create color manager");
}
}
wlr_color_representation_manager_v1_create_with_renderer(
server->wl_display, 1, server->renderer);
server->view_tree_always_on_bottom = wlr_scene_tree_create(&server->scene->tree);
server->view_tree = wlr_scene_tree_create(&server->scene->tree);
server->view_tree_always_on_top = wlr_scene_tree_create(&server->scene->tree);