Skip to content

Commit

Permalink
Revert "output: atomic mode"
Browse files Browse the repository at this point in the history
This reverts commit ee5f98a.

This intoduced problems where outputs could not be turned off because
they had flips pending.
  • Loading branch information
Emantor authored and Drew DeVault committed Aug 7, 2019
1 parent 4d36cc8 commit 01f9038
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 289 deletions.
38 changes: 6 additions & 32 deletions backend/drm/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,12 @@ static bool drm_connector_attach_render(struct wlr_output *output,
return make_drm_surface_current(&conn->crtc->primary->surf, buffer_age);
}

static bool drm_connector_commit_buffer(struct wlr_output *output) {
static bool drm_connector_commit(struct wlr_output *output) {
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
if (!drm->session->active) {
return false;
}

struct wlr_drm_crtc *crtc = conn->crtc;
if (!crtc) {
Expand Down Expand Up @@ -401,37 +404,6 @@ static bool drm_connector_commit_buffer(struct wlr_output *output) {
return true;
}

static bool drm_connector_commit(struct wlr_output *output) {
struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);

if (!drm->session->active) {
return false;
}

if (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
if (!enable_drm_connector(output, output->pending.enabled)) {
return false;
}
}

if (output->pending.committed & WLR_OUTPUT_STATE_MODE) {
if (output->pending.mode_type != WLR_OUTPUT_STATE_MODE_FIXED) {
return false;
}
if (!drm_connector_set_mode(output, output->pending.mode)) {
return false;
}
}

if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
if (!drm_connector_commit_buffer(output)) {
return false;
}
}

return true;
}

static void fill_empty_gamma_table(size_t size,
uint16_t *r, uint16_t *g, uint16_t *b) {
for (uint32_t i = 0; i < size; ++i) {
Expand Down Expand Up @@ -950,6 +922,8 @@ static void drm_connector_destroy(struct wlr_output *output) {
}

static const struct wlr_output_impl output_impl = {
.enable = enable_drm_connector,
.set_mode = drm_connector_set_mode,
.set_cursor = drm_connector_set_cursor,
.move_cursor = drm_connector_move_cursor,
.destroy = drm_connector_destroy,
Expand Down
23 changes: 3 additions & 20 deletions backend/headless/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,8 @@ static bool output_attach_render(struct wlr_output *wlr_output,
}

static bool output_commit(struct wlr_output *wlr_output) {
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
wlr_log(WLR_DEBUG, "Cannot disable a headless output");
return false;
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_MODE) {
assert(wlr_output->pending.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM);
if (!output_set_custom_mode(wlr_output,
wlr_output->pending.custom_mode.width,
wlr_output->pending.custom_mode.height,
wlr_output->pending.custom_mode.refresh)) {
return false;
}
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
// Nothing needs to be done for pbuffers
wlr_output_send_present(wlr_output, NULL);
}

// Nothing needs to be done for pbuffers
wlr_output_send_present(wlr_output, NULL);
return true;
}

Expand All @@ -94,6 +76,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
}

static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.destroy = output_destroy,
.attach_render = output_attach_render,
.commit = output_commit,
Expand Down
26 changes: 8 additions & 18 deletions backend/noop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,19 @@ static struct wlr_noop_output *noop_output_from_output(
return (struct wlr_noop_output *)wlr_output;
}

static bool output_set_custom_mode(struct wlr_output *wlr_output,
int32_t width, int32_t height, int32_t refresh) {
wlr_output_update_custom_mode(wlr_output, width, height, refresh);
return true;
}

static bool output_attach_render(struct wlr_output *wlr_output,
int *buffer_age) {
return false;
}

static bool output_commit(struct wlr_output *wlr_output) {
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
wlr_log(WLR_DEBUG, "Cannot disable a noop output");
return false;
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_MODE) {
assert(wlr_output->pending.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM);
wlr_output_update_custom_mode(wlr_output,
wlr_output->pending.custom_mode.width,
wlr_output->pending.custom_mode.height,
wlr_output->pending.custom_mode.refresh);
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
return false;
}

return true;
return false;
}

static void output_destroy(struct wlr_output *wlr_output) {
Expand All @@ -48,6 +37,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
}

static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.destroy = output_destroy,
.attach_render = output_attach_render,
.commit = output_commit,
Expand Down
34 changes: 4 additions & 30 deletions backend/rdp/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ static bool nsc_swap_buffers(
return true;
}

static bool output_commit_buffer(struct wlr_rdp_output *output) {
struct wlr_output *wlr_output = &output->wlr_output;

static bool output_commit(struct wlr_output *wlr_output) {
struct wlr_rdp_output *output =
rdp_output_from_output(wlr_output);
bool ret = false;

pixman_region32_t output_region;
Expand Down Expand Up @@ -220,33 +220,6 @@ static bool output_commit_buffer(struct wlr_rdp_output *output) {
return ret;
}

static bool output_commit(struct wlr_output *wlr_output) {
struct wlr_rdp_output *output = rdp_output_from_output(wlr_output);

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
wlr_log(WLR_DEBUG, "Cannot disable an RDP output");
return false;
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_MODE) {
assert(wlr_output->pending.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM);
if (!output_set_custom_mode(wlr_output,
wlr_output->pending.custom_mode.width,
wlr_output->pending.custom_mode.height,
wlr_output->pending.custom_mode.refresh)) {
return false;
}
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
if (!output_commit_buffer(output)) {
return false;
}
}

return true;
}

static void output_destroy(struct wlr_output *wlr_output) {
struct wlr_rdp_output *output =
rdp_output_from_output(wlr_output);
Expand All @@ -261,6 +234,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
}

static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.destroy = output_destroy,
.attach_render = output_attach_render,
.commit = output_commit,
Expand Down
45 changes: 14 additions & 31 deletions backend/wayland/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,26 @@ static bool output_commit(struct wlr_output *wlr_output) {
struct wlr_wl_output *output =
get_wl_output_from_output(wlr_output);

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
wlr_log(WLR_DEBUG, "Cannot disable a Wayland output");
if (output->frame_callback != NULL) {
wlr_log(WLR_ERROR, "Skipping buffer swap");
return false;
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_MODE) {
assert(wlr_output->pending.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM);
if (!output_set_custom_mode(wlr_output,
wlr_output->pending.custom_mode.width,
wlr_output->pending.custom_mode.height,
wlr_output->pending.custom_mode.refresh)) {
return false;
}
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
if (output->frame_callback != NULL) {
wlr_log(WLR_ERROR, "Skipping buffer swap");
return false;
}

output->frame_callback = wl_surface_frame(output->surface);
wl_callback_add_listener(output->frame_callback, &frame_listener, output);

pixman_region32_t *damage = NULL;
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
damage = &wlr_output->pending.damage;
}
output->frame_callback = wl_surface_frame(output->surface);
wl_callback_add_listener(output->frame_callback, &frame_listener, output);

if (!wlr_egl_swap_buffers(&output->backend->egl,
output->egl_surface, damage)) {
return false;
}
pixman_region32_t *damage = NULL;
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
damage = &wlr_output->pending.damage;
}

// TODO: if available, use the presentation-time protocol
wlr_output_send_present(wlr_output, NULL);
if (!wlr_egl_swap_buffers(&output->backend->egl,
output->egl_surface, damage)) {
return false;
}

// TODO: if available, use the presentation-time protocol
wlr_output_send_present(wlr_output, NULL);
return true;
}

Expand Down Expand Up @@ -237,6 +219,7 @@ static bool output_schedule_frame(struct wlr_output *wlr_output) {
}

static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.destroy = output_destroy,
.attach_render = output_attach_render,
.commit = output_commit,
Expand Down
31 changes: 7 additions & 24 deletions backend/x11/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,38 +103,21 @@ static bool output_commit(struct wlr_output *wlr_output) {
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
struct wlr_x11_backend *x11 = output->x11;

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
wlr_log(WLR_DEBUG, "Cannot disable an X11 output");
return false;
pixman_region32_t *damage = NULL;
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
damage = &wlr_output->pending.damage;
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_MODE) {
assert(wlr_output->pending.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM);
if (!output_set_custom_mode(wlr_output,
wlr_output->pending.custom_mode.width,
wlr_output->pending.custom_mode.height,
wlr_output->pending.custom_mode.refresh)) {
return false;
}
}

if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
pixman_region32_t *damage = NULL;
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
damage = &wlr_output->pending.damage;
}

if (!wlr_egl_swap_buffers(&x11->egl, output->surf, damage)) {
return false;
}

wlr_output_send_present(wlr_output, NULL);
if (!wlr_egl_swap_buffers(&x11->egl, output->surf, damage)) {
return false;
}

wlr_output_send_present(wlr_output, NULL);
return true;
}

static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.destroy = output_destroy,
.attach_render = output_attach_render,
.commit = output_commit,
Expand Down
4 changes: 4 additions & 0 deletions include/wlr/interfaces/wlr_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <wlr/types/wlr_output.h>

struct wlr_output_impl {
bool (*enable)(struct wlr_output *output, bool enable);
bool (*set_mode)(struct wlr_output *output, struct wlr_output_mode *mode);
bool (*set_custom_mode)(struct wlr_output *output, int32_t width,
int32_t height, int32_t refresh);
bool (*set_cursor)(struct wlr_output *output, struct wlr_texture *texture,
int32_t scale, enum wl_output_transform transform,
int32_t hotspot_x, int32_t hotspot_y, bool update_texture);
Expand Down
Loading

0 comments on commit 01f9038

Please sign in to comment.