output: check buffer in wlr_output_test

Check that buffer can be scanned out in wlr_output_test instead of
wlr_output_attach_buffer. This allows the backend to have access to the
whole pending state when performing the check.

This brings the wlr_output API more in line with the KMS API.

This removes the need for wlr_output_attach_buffer to return a value,
and for wlr_output_impl.attach_buffer.
This commit is contained in:
Simon Ser 2020-04-02 14:12:26 +02:00 committed by Drew DeVault
parent e041158988
commit 6977f3a843
7 changed files with 122 additions and 115 deletions

View file

@ -474,10 +474,30 @@ static void output_state_clear(struct wlr_output_state *state) {
}
static bool output_basic_test(struct wlr_output *output) {
if ((output->pending.committed & WLR_OUTPUT_STATE_BUFFER) &&
output->frame_pending) {
wlr_log(WLR_DEBUG, "Tried to commit a buffer while a frame is pending");
return false;
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
if (output->frame_pending) {
wlr_log(WLR_DEBUG, "Tried to commit a buffer while a frame is pending");
return false;
}
if (output->pending.buffer_type == WLR_OUTPUT_STATE_BUFFER_SCANOUT) {
if (output->attach_render_locks > 0) {
return false;
}
// If the output has at least one software cursor, refuse to attach the
// buffer
struct wlr_output_cursor *cursor;
wl_list_for_each(cursor, &output->cursors, link) {
if (cursor->enabled && cursor->visible &&
cursor != output->hardware_cursor) {
return false;
}
}
// TOOD: check width/height matches the output's, since scaling
// isn't supported
}
}
bool enabled = output->enabled;
@ -588,34 +608,12 @@ void wlr_output_rollback(struct wlr_output *output) {
output_state_clear(&output->pending);
}
bool wlr_output_attach_buffer(struct wlr_output *output,
void wlr_output_attach_buffer(struct wlr_output *output,
struct wlr_buffer *buffer) {
if (!output->impl->attach_buffer) {
return false;
}
if (output->attach_render_locks > 0) {
return false;
}
// If the output has at least one software cursor, refuse to attach the
// buffer
struct wlr_output_cursor *cursor;
wl_list_for_each(cursor, &output->cursors, link) {
if (cursor->enabled && cursor->visible &&
cursor != output->hardware_cursor) {
return false;
}
}
if (!output->impl->attach_buffer(output, buffer)) {
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_lock(buffer);
return true;
}
void wlr_output_send_frame(struct wlr_output *output) {