Minor fixes

This commit is contained in:
Scott Anderson 2017-10-01 22:44:24 +13:00
parent 009c3747a8
commit f6f9c40965
4 changed files with 25 additions and 9 deletions

View File

@ -143,7 +143,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
goto error_event; 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"); wlr_log(L_ERROR, "Failed to initialize renderer");
goto error_event; goto error_event;
} }

View File

@ -856,9 +856,13 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
case WLR_DRM_CONN_CLEANUP:; case WLR_DRM_CONN_CLEANUP:;
struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_crtc *crtc = conn->crtc;
for (int i = 0; i < 3; ++i) { 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]->surf);
wlr_drm_surface_finish(&crtc->planes[i]->mgpu_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]); free(crtc->planes[i]);
crtc->planes[i] = NULL; crtc->planes[i] = NULL;
} }

View File

@ -15,8 +15,9 @@
#include <wlr/render.h> #include <wlr/render.h>
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd) { bool wlr_drm_renderer_init(struct wlr_drm_backend *drm,
renderer->gbm = gbm_create_device(fd); struct wlr_drm_renderer *renderer) {
renderer->gbm = gbm_create_device(drm->fd);
if (!renderer->gbm) { if (!renderer->gbm) {
wlr_log(L_ERROR, "Failed to create GBM device"); wlr_log(L_ERROR, "Failed to create GBM device");
return false; 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, if (!wlr_egl_init(&renderer->egl, EGL_PLATFORM_GBM_MESA,
GBM_FORMAT_ARGB8888, renderer->gbm)) { GBM_FORMAT_ARGB8888, renderer->gbm)) {
gbm_device_destroy(renderer->gbm); goto error_gbm;
return false;
} }
struct wlr_drm_backend *drm = wl_container_of(renderer, drm, renderer);
renderer->wlr_rend = wlr_gles2_renderer_create(&drm->backend); 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; 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) { 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; return;
} }
wlr_renderer_destroy(renderer->wlr_rend);
wlr_egl_free(&renderer->egl); wlr_egl_free(&renderer->egl);
gbm_device_destroy(renderer->gbm); gbm_device_destroy(renderer->gbm);
} }

View File

@ -9,6 +9,7 @@
#include <wlr/render.h> #include <wlr/render.h>
struct wlr_drm_backend;
struct wlr_drm_plane; struct wlr_drm_plane;
struct wlr_drm_renderer { struct wlr_drm_renderer {
@ -32,7 +33,8 @@ struct wlr_drm_surface {
struct gbm_bo *back; struct gbm_bo *back;
}; };
bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd); bool wlr_drm_renderer_init(struct wlr_drm_backend *drm,
struct wlr_drm_renderer *renderer);
void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer); void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer);
bool wlr_drm_surface_init(struct wlr_drm_surface *surf, bool wlr_drm_surface_init(struct wlr_drm_surface *surf,