aboutsummaryrefslogtreecommitdiff
path: root/backend/headless
diff options
context:
space:
mode:
Diffstat (limited to 'backend/headless')
-rw-r--r--backend/headless/backend.c10
-rw-r--r--backend/headless/output.c16
2 files changed, 18 insertions, 8 deletions
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index 5e5cee6a..963773a5 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -71,10 +71,11 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
wlr_signal_emit_safe(&wlr_backend->events.destroy, backend);
free(backend->format);
- if (backend->egl == &backend->priv_egl) {
+
+ if (!backend->has_parent_renderer) {
wlr_renderer_destroy(backend->renderer);
- wlr_egl_finish(&backend->priv_egl);
}
+
wlr_allocator_destroy(backend->allocator);
free(backend);
}
@@ -114,7 +115,6 @@ static bool backend_init(struct wlr_headless_backend *backend,
backend->allocator = allocator;
backend->renderer = renderer;
- backend->egl = wlr_gles2_renderer_get_egl(renderer);
const struct wlr_drm_format_set *formats =
wlr_renderer_get_dmabuf_render_formats(backend->renderer);
@@ -206,7 +206,7 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
goto error_backend;
}
- struct wlr_renderer *renderer = wlr_renderer_autocreate(&backend->priv_egl,
+ struct wlr_renderer *renderer = wlr_renderer_autocreate(
EGL_PLATFORM_GBM_KHR, gbm_alloc->gbm_device);
if (!renderer) {
wlr_log(WLR_ERROR, "Failed to create renderer");
@@ -257,6 +257,8 @@ struct wlr_backend *wlr_headless_backend_create_with_renderer(
goto error_backend;
}
+ backend->has_parent_renderer = true;
+
if (!backend_init(backend, display, &gbm_alloc->base, renderer)) {
goto error_init;
}
diff --git a/backend/headless/output.c b/backend/headless/output.c
index bb15c23d..ee1fd317 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <wlr/interfaces/wlr_output.h>
+#include <wlr/render/gles2.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/util/log.h>
#include "backend/headless.h"
@@ -42,6 +43,8 @@ static bool output_attach_render(struct wlr_output *wlr_output,
int *buffer_age) {
struct wlr_headless_output *output =
headless_output_from_output(wlr_output);
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
+ output->backend->renderer);
wlr_buffer_unlock(output->back_buffer);
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
@@ -49,7 +52,7 @@ static bool output_attach_render(struct wlr_output *wlr_output,
return false;
}
- if (!wlr_egl_make_current(output->backend->egl, EGL_NO_SURFACE, NULL)) {
+ if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
return false;
}
if (!wlr_renderer_bind_buffer(output->backend->renderer,
@@ -97,7 +100,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
assert(output->back_buffer != NULL);
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
- wlr_egl_unset_current(output->backend->egl);
+
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
+ output->backend->renderer);
+ wlr_egl_unset_current(egl);
buffer = output->back_buffer;
output->back_buffer = NULL;
@@ -122,10 +128,12 @@ static bool output_commit(struct wlr_output *wlr_output) {
static void output_rollback_render(struct wlr_output *wlr_output) {
struct wlr_headless_output *output =
headless_output_from_output(wlr_output);
- assert(wlr_egl_is_current(output->backend->egl));
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
+ output->backend->renderer);
+ assert(wlr_egl_is_current(egl));
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
- wlr_egl_unset_current(output->backend->egl);
+ wlr_egl_unset_current(egl);
wlr_buffer_unlock(output->back_buffer);
output->back_buffer = NULL;