From 507d9bc19e05d3fd4378063ad87f4a74b3dfcfca Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 6 Apr 2020 11:53:20 +0200 Subject: Add wlr_output_impl.rollback Most of the pending output state is not forwarded to the backend prior to an output commit. For instance, wlr_output_set_mode just stashes the mode without calling any wlr_output_impl function. wlr_output_impl.commit is responsible for applying the pending mode. However, there are exceptions to this rule. The first one is wlr_output_attach_render. It won't go away before renderer v6 is complete, because it needs to set the current EGL surface. The second one is wlr_output_attach_buffer. wlr_output_impl.attach_buffer is removed in [1]. When wlr_output_rollback is called, all pending state is supposed to be cleared. This works for all the state except the two exceptions mentionned above. To fix this, introduce wlr_output_impl.rollback. Right now, the backend resets the current EGL surface. This prevents GL commands from affecting the output after wlr_output_rollback. This patch is required for FBO-based outputs to work properly. The compositor might be using FBOs for its own purposes [2], having leftover FBO state can have bad consequences. [1]: https://github.com/swaywm/wlroots/pull/2097 [2]: https://github.com/swaywm/wlroots/pull/2063#issuecomment-597614312 --- backend/headless/output.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'backend/headless') diff --git a/backend/headless/output.c b/backend/headless/output.c index 18847af0..918581f5 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -97,6 +97,12 @@ static bool output_commit(struct wlr_output *wlr_output) { return true; } +static void output_rollback(struct wlr_output *wlr_output) { + struct wlr_headless_output *output = + headless_output_from_output(wlr_output); + wlr_egl_make_current(&output->backend->egl, EGL_NO_SURFACE, NULL); +} + static void output_destroy(struct wlr_output *wlr_output) { struct wlr_headless_output *output = headless_output_from_output(wlr_output); @@ -113,6 +119,7 @@ static const struct wlr_output_impl output_impl = { .destroy = output_destroy, .attach_render = output_attach_render, .commit = output_commit, + .rollback = output_rollback, }; bool wlr_output_is_headless(struct wlr_output *wlr_output) { -- cgit v1.2.3