aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/renderer.c11
-rw-r--r--backend/headless/backend.c10
-rw-r--r--backend/headless/output.c16
-rw-r--r--backend/wayland/backend.c3
-rw-r--r--backend/wayland/output.c20
-rw-r--r--backend/x11/backend.c3
-rw-r--r--backend/x11/output.c11
7 files changed, 49 insertions, 25 deletions
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 4c65afae..fd5d637d 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -30,8 +30,8 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
return false;
}
- renderer->wlr_rend = wlr_renderer_autocreate(&renderer->egl,
- EGL_PLATFORM_GBM_KHR, renderer->gbm);
+ renderer->wlr_rend = wlr_renderer_autocreate(EGL_PLATFORM_GBM_KHR,
+ renderer->gbm);
if (!renderer->wlr_rend) {
wlr_log(WLR_ERROR, "Failed to create EGL/WLR renderer");
goto error_gbm;
@@ -66,7 +66,6 @@ void finish_drm_renderer(struct wlr_drm_renderer *renderer) {
wlr_allocator_destroy(&renderer->allocator->base);
wlr_renderer_destroy(renderer->wlr_rend);
- wlr_egl_finish(&renderer->egl);
gbm_device_destroy(renderer->gbm);
}
@@ -117,7 +116,8 @@ bool drm_surface_make_current(struct wlr_drm_surface *surf,
return false;
}
- if (!wlr_egl_make_current(&surf->renderer->egl, EGL_NO_SURFACE, NULL)) {
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(surf->renderer->wlr_rend);
+ if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
return false;
}
if (!wlr_renderer_bind_buffer(surf->renderer->wlr_rend, surf->back_buffer)) {
@@ -130,9 +130,10 @@ bool drm_surface_make_current(struct wlr_drm_surface *surf,
void drm_surface_unset_current(struct wlr_drm_surface *surf) {
assert(surf->back_buffer != NULL);
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(surf->renderer->wlr_rend);
wlr_renderer_bind_buffer(surf->renderer->wlr_rend, NULL);
- wlr_egl_unset_current(&surf->renderer->egl);
+ wlr_egl_unset_current(egl);
wlr_buffer_unlock(surf->back_buffer);
surf->back_buffer = NULL;
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;
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index d562be7a..1e2d2d72 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -206,7 +206,6 @@ static void backend_destroy(struct wlr_backend *backend) {
wl_event_source_remove(wl->remote_display_src);
wlr_renderer_destroy(wl->renderer);
- wlr_egl_finish(&wl->egl);
wlr_drm_format_set_finish(&wl->linux_dmabuf_v1_formats);
@@ -314,7 +313,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
}
wl_event_source_check(wl->remote_display_src);
- wl->renderer = wlr_renderer_autocreate(&wl->egl, EGL_PLATFORM_WAYLAND_EXT,
+ wl->renderer = wlr_renderer_autocreate(EGL_PLATFORM_WAYLAND_EXT,
wl->remote_display);
if (!wl->renderer) {
wlr_log(WLR_ERROR, "Could not create renderer");
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 633e9a59..bf2d97ca 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -10,6 +10,7 @@
#include <wayland-client.h>
#include <wlr/interfaces/wlr_output.h>
+#include <wlr/render/gles2.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
@@ -115,6 +116,8 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
static bool output_attach_render(struct wlr_output *wlr_output,
int *buffer_age) {
struct wlr_wl_output *output = get_wl_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);
@@ -122,7 +125,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,
@@ -309,7 +312,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
wlr_buffer = output->back_buffer;
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);
break;
case WLR_OUTPUT_STATE_BUFFER_SCANOUT:;
wlr_buffer = wlr_output->pending.buffer;
@@ -369,8 +375,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
static void output_rollback_render(struct wlr_output *wlr_output) {
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
+ output->backend->renderer);
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
- wlr_egl_unset_current(&output->backend->egl);
+ wlr_egl_unset_current(egl);
}
static bool output_set_cursor(struct wlr_output *wlr_output,
@@ -402,6 +410,8 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
struct wl_surface *surface = output->cursor.surface;
if (texture != NULL) {
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(
+ output->backend->renderer);
int width = texture->width * wlr_output->scale / scale;
int height = texture->height * wlr_output->scale / scale;
@@ -423,7 +433,7 @@ static bool output_set_cursor(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, wlr_buffer)) {
@@ -447,7 +457,7 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
wlr_renderer_end(backend->renderer);
wlr_renderer_bind_buffer(output->backend->renderer, NULL);
- wlr_egl_unset_current(&output->backend->egl);
+ wlr_egl_unset_current(egl);
struct wlr_wl_buffer *buffer =
get_or_create_wl_buffer(output->backend, wlr_buffer);
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index c16191f8..e8908e5b 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -181,7 +181,6 @@ static void backend_destroy(struct wlr_backend *backend) {
wl_list_remove(&x11->display_destroy.link);
wlr_renderer_destroy(x11->renderer);
- wlr_egl_finish(&x11->egl);
wlr_allocator_destroy(x11->allocator);
wlr_drm_format_set_finish(&x11->dri3_formats);
free(x11->drm_format);
@@ -535,7 +534,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
}
x11->allocator = &gbm_alloc->base;
- x11->renderer = wlr_renderer_autocreate(&x11->egl, EGL_PLATFORM_GBM_KHR,
+ x11->renderer = wlr_renderer_autocreate(EGL_PLATFORM_GBM_KHR,
gbm_alloc->gbm_device);
if (x11->renderer == NULL) {
wlr_log(WLR_ERROR, "Failed to create renderer");
diff --git a/backend/x11/output.c b/backend/x11/output.c
index 86729ace..4d764414 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -13,6 +13,7 @@
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_touch.h>
+#include <wlr/render/gles2.h>
#include <wlr/util/log.h>
#include "backend/x11.h"
@@ -97,6 +98,7 @@ static bool output_attach_render(struct wlr_output *wlr_output,
int *buffer_age) {
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
struct wlr_x11_backend *x11 = output->x11;
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(x11->renderer);
wlr_buffer_unlock(output->back_buffer);
output->back_buffer = wlr_swapchain_acquire(output->swapchain, buffer_age);
@@ -104,7 +106,7 @@ static bool output_attach_render(struct wlr_output *wlr_output,
return false;
}
- if (!wlr_egl_make_current(&x11->egl, EGL_NO_SURFACE, NULL)) {
+ if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) {
return false;
}
if (!wlr_renderer_bind_buffer(x11->renderer, output->back_buffer)) {
@@ -204,11 +206,12 @@ static struct wlr_x11_buffer *get_or_create_x11_buffer(
static bool output_commit_buffer(struct wlr_x11_output *output) {
struct wlr_x11_backend *x11 = output->x11;
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(x11->renderer);
assert(output->back_buffer != NULL);
wlr_renderer_bind_buffer(x11->renderer, NULL);
- wlr_egl_unset_current(&x11->egl);
+ wlr_egl_unset_current(egl);
struct wlr_x11_buffer *x11_buffer =
get_or_create_x11_buffer(output, output->back_buffer);
@@ -315,8 +318,10 @@ static bool output_commit(struct wlr_output *wlr_output) {
static void output_rollback_render(struct wlr_output *wlr_output) {
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
struct wlr_x11_backend *x11 = output->x11;
+ struct wlr_egl *egl = wlr_gles2_renderer_get_egl(x11->renderer);
+
wlr_renderer_bind_buffer(x11->renderer, NULL);
- wlr_egl_unset_current(&x11->egl);
+ wlr_egl_unset_current(egl);
}
static const struct wlr_output_impl output_impl = {