backend/headless: don't store the parent renderer

This commit is contained in:
Simon Zeni 2021-11-15 13:24:55 -05:00
parent 5f11198605
commit a143093339
2 changed files with 3 additions and 38 deletions

View File

@ -51,7 +51,6 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
}
wl_list_remove(&backend->display_destroy.link);
wl_list_remove(&backend->parent_renderer_destroy.link);
struct wlr_headless_output *output, *output_tmp;
wl_list_for_each_safe(output, output_tmp, &backend->outputs, link) {
@ -70,17 +69,6 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
free(backend);
}
static struct wlr_renderer *backend_get_renderer(
struct wlr_backend *wlr_backend) {
struct wlr_headless_backend *backend =
headless_backend_from_backend(wlr_backend);
if (backend->parent_renderer != NULL) {
return backend->parent_renderer;
} else {
return wlr_backend->renderer;
}
}
static int backend_get_drm_fd(struct wlr_backend *wlr_backend) {
struct wlr_headless_backend *backend =
headless_backend_from_backend(wlr_backend);
@ -96,7 +84,6 @@ static uint32_t get_buffer_caps(struct wlr_backend *wlr_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 = get_buffer_caps,
};
@ -107,33 +94,13 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
backend_destroy(&backend->backend);
}
static void handle_renderer_destroy(struct wl_listener *listener, void *data) {
struct wlr_headless_backend *backend =
wl_container_of(listener, backend, parent_renderer_destroy);
backend_destroy(&backend->backend);
}
static bool backend_init(struct wlr_headless_backend *backend,
struct wl_display *display, struct wlr_renderer *renderer) {
struct wl_display *display) {
wlr_backend_init(&backend->backend, &backend_impl);
backend->display = display;
wl_list_init(&backend->outputs);
wl_list_init(&backend->input_devices);
wl_list_init(&backend->parent_renderer_destroy.link);
if (renderer == NULL) {
renderer = wlr_renderer_autocreate(&backend->backend);
if (!renderer) {
wlr_log(WLR_ERROR, "Failed to create renderer");
return false;
}
backend->backend.renderer = renderer;
} else {
backend->parent_renderer = renderer;
backend->parent_renderer_destroy.notify = handle_renderer_destroy;
wl_signal_add(&renderer->events.destroy, &backend->parent_renderer_destroy);
}
backend->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &backend->display_destroy);
@ -202,7 +169,7 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
wlr_log(WLR_ERROR, "Failed to open DRM render node");
}
if (!backend_init(backend, display, NULL)) {
if (!backend_init(backend, display)) {
goto error_init;
}
@ -236,7 +203,7 @@ struct wlr_backend *wlr_headless_backend_create_with_renderer(
}
}
if (!backend_init(backend, display, renderer)) {
if (!backend_init(backend, display)) {
goto error_init;
}

View File

@ -14,8 +14,6 @@ struct wlr_headless_backend {
size_t last_output_num;
struct wl_list input_devices;
struct wl_listener display_destroy;
struct wlr_renderer *parent_renderer;
struct wl_listener parent_renderer_destroy;
bool started;
};