aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/backend.c7
-rw-r--r--backend/drm/backend.c9
-rw-r--r--backend/headless/backend.c17
-rw-r--r--backend/multi/backend.c14
-rw-r--r--backend/wayland/backend.c22
-rw-r--r--backend/x11/backend.c17
6 files changed, 77 insertions, 9 deletions
diff --git a/backend/backend.c b/backend/backend.c
index 54e1cdca..a71cf6b8 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -52,6 +52,13 @@ struct wlr_egl *wlr_backend_get_egl(struct wlr_backend *backend) {
return NULL;
}
+struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend) {
+ if (backend->impl->get_renderer) {
+ return backend->impl->get_renderer(backend);
+ }
+ return NULL;
+}
+
static struct wlr_backend *attempt_wl_backend(struct wl_display *display) {
struct wlr_backend *backend = wlr_wl_backend_create(display, NULL);
if (backend) {
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index c0e49f18..de69dad5 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -50,10 +50,17 @@ static struct wlr_egl *wlr_drm_backend_get_egl(struct wlr_backend *backend) {
return &drm->renderer.egl;
}
+static struct wlr_renderer *wlr_drm_backend_get_renderer(
+ struct wlr_backend *backend) {
+ struct wlr_drm_backend *drm = (struct wlr_drm_backend *)backend;
+ return drm->renderer.wlr_rend;
+}
+
static struct wlr_backend_impl backend_impl = {
.start = wlr_drm_backend_start,
.destroy = wlr_drm_backend_destroy,
- .get_egl = wlr_drm_backend_get_egl
+ .get_egl = wlr_drm_backend_get_egl,
+ .get_renderer = wlr_drm_backend_get_renderer,
};
bool wlr_backend_is_drm(struct wlr_backend *b) {
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index cef8eec4..61409d41 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -1,6 +1,6 @@
#include <stdlib.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
+#include <wlr/render/egl.h>
+#include <wlr/render/gles2.h>
#include <wlr/util/log.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
@@ -61,10 +61,18 @@ static struct wlr_egl *backend_get_egl(struct wlr_backend *wlr_backend) {
return &backend->egl;
}
+static struct wlr_renderer *backend_get_renderer(
+ struct wlr_backend *wlr_backend) {
+ struct wlr_headless_backend *backend =
+ (struct wlr_headless_backend *)wlr_backend;
+ return backend->renderer;
+}
+
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_egl = backend_get_egl,
+ .get_renderer = backend_get_renderer,
};
static void handle_display_destroy(struct wl_listener *listener, void *data) {
@@ -103,6 +111,11 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
return NULL;
}
+ backend->renderer = wlr_gles2_renderer_create(&backend->backend);
+ if (backend->renderer == NULL) {
+ wlr_log(L_ERROR, "Failed to create renderer");
+ }
+
backend->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &backend->display_destroy);
diff --git a/backend/multi/backend.c b/backend/multi/backend.c
index de6035f8..1e574475 100644
--- a/backend/multi/backend.c
+++ b/backend/multi/backend.c
@@ -62,10 +62,24 @@ static struct wlr_egl *multi_backend_get_egl(struct wlr_backend *wlr_backend) {
return NULL;
}
+static struct wlr_renderer *multi_backend_get_renderer(
+ struct wlr_backend *backend) {
+ struct wlr_multi_backend *multi = (struct wlr_multi_backend *)backend;
+ struct subbackend_state *sub;
+ wl_list_for_each(sub, &multi->backends, link) {
+ struct wlr_renderer *rend = wlr_backend_get_renderer(sub->backend);
+ if (rend != NULL) {
+ return rend;
+ }
+ }
+ return NULL;
+}
+
struct wlr_backend_impl backend_impl = {
.start = multi_backend_start,
.destroy = multi_backend_destroy,
.get_egl = multi_backend_get_egl,
+ .get_renderer = multi_backend_get_renderer,
};
static void handle_display_destroy(struct wl_listener *listener, void *data) {
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index f85498eb..eca79350 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -6,6 +6,7 @@
#include <EGL/eglext.h>
#include <wayland-server.h>
#include <wlr/render/egl.h>
+#include <wlr/render/gles2.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
@@ -106,15 +107,22 @@ static void wlr_wl_backend_destroy(struct wlr_backend *_backend) {
free(backend);
}
-static struct wlr_egl *wlr_wl_backend_get_egl(struct wlr_backend *_backend) {
- struct wlr_wl_backend *backend = (struct wlr_wl_backend *)_backend;
+static struct wlr_egl *wlr_wl_backend_get_egl(struct wlr_backend *wlr_backend) {
+ struct wlr_wl_backend *backend = (struct wlr_wl_backend *)wlr_backend;
return &backend->egl;
}
+static struct wlr_renderer *wlr_wl_backend_get_renderer(
+ struct wlr_backend *wlr_backend) {
+ struct wlr_wl_backend *backend = (struct wlr_wl_backend *)wlr_backend;
+ return backend->renderer;
+}
+
static struct wlr_backend_impl backend_impl = {
.start = wlr_wl_backend_start,
.destroy = wlr_wl_backend_destroy,
- .get_egl = wlr_wl_backend_get_egl
+ .get_egl = wlr_wl_backend_get_egl,
+ .get_renderer = wlr_wl_backend_get_renderer,
};
bool wlr_backend_is_wl(struct wlr_backend *b) {
@@ -191,7 +199,8 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, const char
return false;
}
- if (!(backend->registry = wl_display_get_registry(backend->remote_display))) {
+ backend->registry = wl_display_get_registry(backend->remote_display);
+ if (backend->registry == NULL) {
wlr_log_errno(L_ERROR, "Could not obtain reference to remote registry");
return false;
}
@@ -200,6 +209,11 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, const char
backend->remote_display, NULL, WL_SHM_FORMAT_ARGB8888);
wlr_egl_bind_display(&backend->egl, backend->local_display);
+ backend->renderer = wlr_gles2_renderer_create(&backend->backend);
+ if (backend->renderer == NULL) {
+ wlr_log_errno(L_ERROR, "Could not create renderer");
+ }
+
backend->local_display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &backend->local_display_destroy);
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index e1622d06..3e450dbd 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -16,6 +16,7 @@
#include <wlr/backend/interface.h>
#include <wlr/backend/x11.h>
#include <wlr/render/egl.h>
+#include <wlr/render/gles2.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
@@ -272,16 +273,23 @@ static struct wlr_egl *wlr_x11_backend_get_egl(struct wlr_backend *backend) {
return &x11->egl;
}
-bool wlr_backend_is_x11(struct wlr_backend *backend) {
- return backend->impl == &backend_impl;
+static struct wlr_renderer *wlr_x11_backend_get_renderer(
+ struct wlr_backend *backend) {
+ struct wlr_x11_backend *x11 = (struct wlr_x11_backend *)backend;
+ return x11->renderer;
}
static struct wlr_backend_impl backend_impl = {
.start = wlr_x11_backend_start,
.destroy = wlr_x11_backend_destroy,
.get_egl = wlr_x11_backend_get_egl,
+ .get_renderer = wlr_x11_backend_get_renderer,
};
+bool wlr_backend_is_x11(struct wlr_backend *backend) {
+ return backend->impl == &backend_impl;
+}
+
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_x11_backend *x11 =
wl_container_of(listener, x11, display_destroy);
@@ -330,6 +338,11 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
goto error_event;
}
+ x11->renderer = wlr_gles2_renderer_create(&x11->backend);
+ if (x11->renderer == NULL) {
+ wlr_log(L_ERROR, "Failed to create renderer");
+ }
+
wlr_input_device_init(&x11->keyboard_dev, WLR_INPUT_DEVICE_KEYBOARD,
&input_device_impl, "X11 keyboard", 0, 0);
wlr_keyboard_init(&x11->keyboard, NULL);