From 28b505e9601abf5dbda6b4855b28b4165cdf4e44 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sun, 5 May 2024 13:37:29 -0400 Subject: [PATCH] tinywl: Use wlr_output_manager --- tinywl/tinywl.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 07a6b055a..5d509a52e 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -8,13 +8,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -35,8 +35,7 @@ enum tinywl_cursor_mode { struct tinywl_server { struct wl_display *wl_display; struct wlr_backend *backend; - struct wlr_renderer *renderer; - struct wlr_allocator *allocator; + struct wlr_output_manager output_manager; struct wlr_scene *scene; struct wlr_scene_output_layout *scene_layout; @@ -599,9 +598,10 @@ static void server_new_output(struct wl_listener *listener, void *data) { wl_container_of(listener, server, new_output); struct wlr_output *wlr_output = data; - /* Configures the output created by the backend to use our allocator - * and our renderer. Must be done once, before commiting the output */ - wlr_output_init_render(wlr_output, server->allocator, server->renderer); + /* Configures the output created by the backend using the output manager + * to allocate a renderer and a allocator for us. Must be done once, + * before commiting the output */ + wlr_output_manager_init_output(&server->output_manager, wlr_output); /* The output may be disabled, switch it on. */ struct wlr_output_state state; @@ -904,28 +904,16 @@ int main(int argc, char *argv[]) { return 1; } - /* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user - * can also specify a renderer using the WLR_RENDERER env var. - * The renderer is responsible for defining the various pixel formats it - * supports for shared memory, this configures that for clients. */ - server.renderer = wlr_renderer_autocreate(server.backend); - if (server.renderer == NULL) { - wlr_log(WLR_ERROR, "failed to create wlr_renderer"); + /* This is a helper that will automatically create renderers and allocators + * for each output. This serves as the bridge between the output and the + * backend for rendering. + */ + if (!wlr_output_manager_init(&server.output_manager, server.backend)) { + wlr_log(WLR_ERROR, "failed to create wlr_output_manager"); return 1; } - wlr_renderer_init_wl_display(server.renderer, server.wl_display); - - /* Autocreates an allocator for us. - * The allocator is the bridge between the renderer and the backend. It - * handles the buffer creation, allowing wlroots to render onto the - * screen */ - server.allocator = wlr_allocator_autocreate(server.backend, - server.renderer); - if (server.allocator == NULL) { - wlr_log(WLR_ERROR, "failed to create wlr_allocator"); - return 1; - } + wlr_output_manager_init_wl_display(&server.output_manager, server.wl_display); /* This creates some hands-off wlroots interfaces. The compositor is * necessary for clients to allocate surfaces, the subcompositor allows to @@ -1057,10 +1045,8 @@ int main(int argc, char *argv[]) { wl_display_destroy_clients(server.wl_display); wlr_scene_node_destroy(&server.scene->tree.node); wlr_xcursor_manager_destroy(server.cursor_mgr); - wlr_cursor_destroy(server.cursor); - wlr_allocator_destroy(server.allocator); - wlr_renderer_destroy(server.renderer); wlr_backend_destroy(server.backend); + wlr_output_manager_finish(&server.output_manager); wl_display_destroy(server.wl_display); return 0; }