labwc/src/output-state.c
Christopher Snowhill be94b60834 chase wlroots: Add support for HDR10 output
v2: Switch XRGB to XBGR
v3: Rewrite HDR mode checking and setting
v4: Restructure HDR support detection
v5: Fix code style
v6: Fix old style function declaration
v7: This function should be declared static
v8: This helper function can accept a const struct on input
v9: Rebase now that 0.20 is merged
v10: Rewrite with multiple color format attempts
v11: Add in the parts that accidentally got left in my
     original color-management-v1 patch
v12: Add missing function prototype
2026-04-14 23:07:54 -07:00

47 lines
1.3 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
#include "output-state.h"
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_management_v1.h>
#include <wlr/util/log.h>
#include "output.h"
void
output_state_init(struct output *output)
{
wlr_output_state_init(&output->pending);
/*
* As there is no direct way to convert an existing output
* configuration to an output_state we first convert it
* to a temporary output-management config and then apply
* it to an empty wlr_output_state.
*/
struct wlr_output_configuration_v1 *backup_config =
wlr_output_configuration_v1_create();
struct wlr_output_configuration_head_v1 *backup_head =
wlr_output_configuration_head_v1_create(
backup_config, output->wlr_output);
wlr_output_head_v1_state_apply(&backup_head->state, &output->pending);
/* This must be applied outside of config */
output_state_setup_hdr(output, true);
wlr_output_configuration_v1_destroy(backup_config);
}
bool
output_state_commit(struct output *output)
{
bool committed =
wlr_output_commit_state(output->wlr_output, &output->pending);
if (committed) {
wlr_output_state_finish(&output->pending);
wlr_output_state_init(&output->pending);
output_state_setup_hdr(output, true); /* So must this */
} else {
wlr_log(WLR_ERROR, "Failed to commit frame");
}
return committed;
}