output: introduce wlr_output_queue_state

This commit is contained in:
Simon Ser 2021-01-28 16:03:47 +01:00
parent 328ce2dd39
commit 92ac84a192
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 49 additions and 0 deletions

View file

@ -429,6 +429,13 @@ void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock);
*/
void wlr_output_render_software_cursors(struct wlr_output *output,
pixman_region32_t *damage);
/**
* Queue pending output state from `state`.
*
* Users need to call `wlr_output_commit` to apply the pending state.
*/
void wlr_output_queue_state(struct wlr_output *output,
const struct wlr_output_state *state);
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output);

View file

@ -728,6 +728,48 @@ void wlr_output_send_present(struct wlr_output *output,
wlr_signal_emit_safe(&output->events.present, event);
}
void wlr_output_queue_state(struct wlr_output *output,
const struct wlr_output_state *state) {
assert(state != &output->pending);
if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
assert(state->buffer_type == WLR_OUTPUT_STATE_BUFFER_SCANOUT);
wlr_output_attach_buffer(output, state->buffer);
}
if (state->committed & WLR_OUTPUT_STATE_DAMAGE) {
wlr_output_set_damage(output, (pixman_region32_t *)&state->damage);
}
if (state->committed & WLR_OUTPUT_STATE_MODE) {
switch (state->mode_type) {
case WLR_OUTPUT_STATE_MODE_FIXED:
wlr_output_set_mode(output, state->mode);
break;
case WLR_OUTPUT_STATE_MODE_CUSTOM:
wlr_output_set_custom_mode(output, state->custom_mode.width,
state->custom_mode.height, state->custom_mode.refresh);
break;
}
}
if (state->committed & WLR_OUTPUT_STATE_ENABLED) {
wlr_output_enable(output, state->enabled);
}
if (state->committed & WLR_OUTPUT_STATE_SCALE) {
wlr_output_set_scale(output, state->scale);
}
if (state->committed & WLR_OUTPUT_STATE_TRANSFORM) {
wlr_output_set_transform(output, state->transform);
}
if (state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) {
wlr_output_enable_adaptive_sync(output, state->adaptive_sync_enabled);
}
if (state->committed & WLR_OUTPUT_STATE_GAMMA_LUT) {
const uint16_t *r = state->gamma_lut;
const uint16_t *g = state->gamma_lut + state->gamma_lut_size;
const uint16_t *b = state->gamma_lut + 2 * state->gamma_lut_size;
wlr_output_set_gamma(output, state->gamma_lut_size, r, g, b);
}
}
void wlr_output_set_gamma(struct wlr_output *output, size_t size,
const uint16_t *r, const uint16_t *g, const uint16_t *b) {
output_state_clear_gamma_lut(&output->pending);