From a6538ced35872a86d37d6ca32b1d9ddb5fe2c4b7 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Mon, 15 Nov 2021 13:42:06 -0500 Subject: tinywl: autocreate allocator and init output --- tinywl/tinywl.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tinywl') diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index b11549be..82f0977a 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ struct tinywl_server { struct wl_display *wl_display; struct wlr_backend *backend; struct wlr_renderer *renderer; + struct wlr_allocator *allocator; struct wlr_xdg_shell *xdg_shell; struct wl_listener new_xdg_surface; @@ -676,6 +678,10 @@ static void server_new_output(struct wl_listener *listener, void *data) { } } + /* Configures the output created by the backend to use our allocator + * and our renderer */ + wlr_output_init_render(wlr_output, server->allocator, server->renderer); + /* Allocates and configures our state for this output */ struct tinywl_output *output = calloc(1, sizeof(struct tinywl_output)); @@ -841,12 +847,20 @@ int main(int argc, char *argv[]) { * if an X11 server is running. */ server.backend = wlr_backend_autocreate(server.wl_display); - /* If we don't provide a renderer, autocreate makes a GLES2 renderer for us. + /* 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_backend_get_renderer(server.backend); + server.renderer = wlr_renderer_autocreate(server.backend); 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); + /* This creates some hands-off wlroots interfaces. The compositor is * necessary for clients to allocate surfaces and the data device manager * handles the clipboard. Each of these wlroots interfaces has room for you -- cgit v1.2.3