aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/backend.c2
-rw-r--r--backend/drm/drm.c6
-rw-r--r--backend/drm/renderer.c22
3 files changed, 22 insertions, 8 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index e3148821..468fca6e 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -143,7 +143,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
goto error_event;
}
- if (!wlr_drm_renderer_init(&drm->renderer, drm->fd)) {
+ if (!wlr_drm_renderer_init(drm, &drm->renderer)) {
wlr_log(L_ERROR, "Failed to initialize renderer");
goto error_event;
}
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 3effa9ff..ccdc92d9 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -856,9 +856,13 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
case WLR_DRM_CONN_CLEANUP:;
struct wlr_drm_crtc *crtc = conn->crtc;
for (int i = 0; i < 3; ++i) {
+ if (!crtc->planes[i]) {
+ continue;
+ }
+
wlr_drm_surface_finish(&crtc->planes[i]->surf);
wlr_drm_surface_finish(&crtc->planes[i]->mgpu_surf);
- if (crtc->planes[i] && crtc->planes[i]->id == 0) {
+ if (crtc->planes[i]->id == 0) {
free(crtc->planes[i]);
crtc->planes[i] = NULL;
}
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index bcadf17e..c5840436 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -15,8 +15,9 @@
#include <wlr/render.h>
#include "backend/drm/drm.h"
-bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd) {
- renderer->gbm = gbm_create_device(fd);
+bool wlr_drm_renderer_init(struct wlr_drm_backend *drm,
+ struct wlr_drm_renderer *renderer) {
+ renderer->gbm = gbm_create_device(drm->fd);
if (!renderer->gbm) {
wlr_log(L_ERROR, "Failed to create GBM device");
return false;
@@ -24,15 +25,23 @@ bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd) {
if (!wlr_egl_init(&renderer->egl, EGL_PLATFORM_GBM_MESA,
GBM_FORMAT_ARGB8888, renderer->gbm)) {
- gbm_device_destroy(renderer->gbm);
- return false;
+ goto error_gbm;
}
- struct wlr_drm_backend *drm = wl_container_of(renderer, drm, renderer);
renderer->wlr_rend = wlr_gles2_renderer_create(&drm->backend);
+ if (!renderer->wlr_rend) {
+ wlr_log(L_ERROR, "Failed to create WLR renderer");
+ goto error_egl;
+ }
- renderer->fd = fd;
+ renderer->fd = drm->fd;
return true;
+
+error_egl:
+ wlr_egl_free(&renderer->egl);
+error_gbm:
+ gbm_device_destroy(renderer->gbm);
+ return false;
}
void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer) {
@@ -40,6 +49,7 @@ void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer) {
return;
}
+ wlr_renderer_destroy(renderer->wlr_rend);
wlr_egl_free(&renderer->egl);
gbm_device_destroy(renderer->gbm);
}