diff options
author | Simon Ser <contact@emersion.fr> | 2019-05-04 11:53:40 +0300 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-07 09:06:11 -0400 |
commit | ff6b352d754cd19fc33b87fbc3d9d524f6484e35 (patch) | |
tree | aafae2db7803837da0c588e57275472cf0fca167 | |
parent | afe7b207d5ff630d85c0d428ab7234f6740cfc0c (diff) |
output: save buffer in pending state
-rw-r--r-- | types/wlr_output.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/types/wlr_output.c b/types/wlr_output.c index 941d3ce8..2eace7cf 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -398,11 +398,23 @@ struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) { return mode; } +static void output_state_clear_buffer(struct wlr_output_state *state) { + if (!(state->committed & WLR_OUTPUT_STATE_BUFFER)) { + return; + } + + wlr_buffer_unref(state->buffer); + state->buffer = NULL; + + state->committed &= ~WLR_OUTPUT_STATE_BUFFER; +} + bool wlr_output_attach_render(struct wlr_output *output, int *buffer_age) { if (!output->impl->attach_render(output, buffer_age)) { return false; } + output_state_clear_buffer(&output->pending); output->pending.committed |= WLR_OUTPUT_STATE_BUFFER; output->pending.buffer_type = WLR_OUTPUT_STATE_BUFFER_RENDER; return true; @@ -430,8 +442,9 @@ void wlr_output_set_damage(struct wlr_output *output, } static void output_state_clear(struct wlr_output_state *state) { - state->committed = 0; + output_state_clear_buffer(state); pixman_region32_clear(&state->damage); + state->committed = 0; } bool wlr_output_commit(struct wlr_output *output) { @@ -488,8 +501,10 @@ bool wlr_output_attach_buffer(struct wlr_output *output, return false; } + output_state_clear_buffer(&output->pending); output->pending.committed |= WLR_OUTPUT_STATE_BUFFER; output->pending.buffer_type = WLR_OUTPUT_STATE_BUFFER_SCANOUT; + output->pending.buffer = wlr_buffer_ref(buffer); return true; } |