aboutsummaryrefslogtreecommitdiff
path: root/backend/x11/backend.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-29 09:33:54 +0200
committerKenny Levinsen <kl@kl.wtf>2021-05-21 22:13:54 +0200
commitfd2b1f018e8e736c40ee31949e818e0b6939e308 (patch)
tree47c49037eec0e03fb924f33122410d4255461af7 /backend/x11/backend.c
parentc82f37542d3a63c3b5dd573dcdb8559ea1f888f7 (diff)
backend/x11: use common renderer and allocator
Instead of managing our own renderer and allocator, let the common code do it.
Diffstat (limited to 'backend/x11/backend.c')
-rw-r--r--backend/x11/backend.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 17b8b7c0..fbc9d33e 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -30,6 +30,7 @@
#include <wlr/render/wlr_renderer.h>
#include <wlr/util/log.h>
+#include "backend/backend.h"
#include "backend/x11.h"
#include "render/drm_format_set.h"
#include "render/gbm_allocator.h"
@@ -198,8 +199,6 @@ static void backend_destroy(struct wlr_backend *backend) {
}
wl_list_remove(&x11->display_destroy.link);
- wlr_renderer_destroy(x11->renderer);
- wlr_allocator_destroy(x11->allocator);
wlr_drm_format_set_finish(&x11->dri3_formats);
wlr_drm_format_set_finish(&x11->shm_formats);
free(x11->drm_format);
@@ -213,18 +212,12 @@ static void backend_destroy(struct wlr_backend *backend) {
free(x11);
}
-static struct wlr_renderer *backend_get_renderer(
- struct wlr_backend *backend) {
- struct wlr_x11_backend *x11 = get_x11_backend_from_backend(backend);
- return x11->renderer;
-}
-
static int backend_get_drm_fd(struct wlr_backend *backend) {
struct wlr_x11_backend *x11 = get_x11_backend_from_backend(backend);
return x11->drm_fd;
}
-static uint32_t backend_get_buffer_caps(struct wlr_backend *backend) {
+static uint32_t get_buffer_caps(struct wlr_backend *backend) {
struct wlr_x11_backend *x11 = get_x11_backend_from_backend(backend);
return (x11->have_dri3 ? WLR_BUFFER_CAP_DMABUF : 0)
| (x11->have_shm ? WLR_BUFFER_CAP_SHM : 0);
@@ -233,9 +226,8 @@ static uint32_t backend_get_buffer_caps(struct wlr_backend *backend) {
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
- .get_renderer = backend_get_renderer,
.get_drm_fd = backend_get_drm_fd,
- .get_buffer_caps = backend_get_buffer_caps,
+ .get_buffer_caps = get_buffer_caps,
};
bool wlr_backend_is_x11(struct wlr_backend *backend) {
@@ -621,14 +613,13 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
}
}
- x11->renderer = wlr_renderer_autocreate(&x11->backend);
- if (x11->renderer == NULL) {
- wlr_log(WLR_ERROR, "Failed to create renderer");
+ struct wlr_renderer *renderer = wlr_backend_get_renderer(&x11->backend);
+ struct wlr_allocator *allocator = backend_get_allocator(&x11->backend);
+ if (renderer == NULL || allocator == NULL) {
goto error_event;
}
- uint32_t caps = renderer_get_render_buffer_caps(x11->renderer);
-
+ uint32_t caps = renderer_get_render_buffer_caps(renderer);
const struct wlr_drm_format_set *pixmap_formats;
if (x11->have_dri3 && (caps & WLR_BUFFER_CAP_DMABUF)) {
pixmap_formats = &x11->dri3_formats;
@@ -640,14 +631,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
goto error_event;
}
- x11->allocator = wlr_allocator_autocreate(&x11->backend, x11->renderer);
- if (x11->allocator == NULL) {
- wlr_log(WLR_ERROR, "Failed to create allocator");
- goto error_event;
- }
-
const struct wlr_drm_format_set *render_formats =
- wlr_renderer_get_render_formats(x11->renderer);
+ wlr_renderer_get_render_formats(renderer);
if (render_formats == NULL) {
wlr_log(WLR_ERROR, "Failed to get available DRM formats from renderer");
return false;