diff options
author | 2021-11-15 13:32:52 -0500 | |
---|---|---|
committer | 2021-11-18 17:47:19 +0100 | |
commit | 5865af75cf8029cc703cda36b68daafcb658c97b (patch) | |
tree | 0446444369c63c05109ffab3c027127ac19da17f | |
parent | container: fix surface_is_popup() (diff) | |
download | sway-5865af75cf8029cc703cda36b68daafcb658c97b.tar.gz sway-5865af75cf8029cc703cda36b68daafcb658c97b.tar.zst sway-5865af75cf8029cc703cda36b68daafcb658c97b.zip |
sway: create wlr_renderer and wlr_allocator
wlroots now required the compositor to create its own wlr_renderer and
wlr_allocator to initialize the wlr_output
-rw-r--r-- | include/sway/server.h | 3 | ||||
-rw-r--r-- | sway/desktop/output.c | 6 | ||||
-rw-r--r-- | sway/desktop/render.c | 16 | ||||
-rw-r--r-- | sway/server.c | 22 | ||||
-rw-r--r-- | sway/tree/container.c | 3 |
5 files changed, 31 insertions, 19 deletions
diff --git a/include/sway/server.h b/include/sway/server.h index f99bbda6..109097d7 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <wayland-server-core.h> | 4 | #include <wayland-server-core.h> |
5 | #include <wlr/backend.h> | 5 | #include <wlr/backend.h> |
6 | #include <wlr/backend/session.h> | 6 | #include <wlr/backend/session.h> |
7 | #include <wlr/render/allocator.h> | ||
7 | #include <wlr/render/wlr_renderer.h> | 8 | #include <wlr/render/wlr_renderer.h> |
8 | #include <wlr/types/wlr_compositor.h> | 9 | #include <wlr/types/wlr_compositor.h> |
9 | #include <wlr/types/wlr_data_device.h> | 10 | #include <wlr/types/wlr_data_device.h> |
@@ -35,6 +36,8 @@ struct sway_server { | |||
35 | struct wlr_backend *noop_backend; | 36 | struct wlr_backend *noop_backend; |
36 | // secondary headless backend used for creating virtual outputs on-the-fly | 37 | // secondary headless backend used for creating virtual outputs on-the-fly |
37 | struct wlr_backend *headless_backend; | 38 | struct wlr_backend *headless_backend; |
39 | struct wlr_renderer *renderer; | ||
40 | struct wlr_allocator *allocator; | ||
38 | 41 | ||
39 | struct wlr_compositor *compositor; | 42 | struct wlr_compositor *compositor; |
40 | struct wl_listener compositor_new_surface; | 43 | struct wl_listener compositor_new_surface; |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index edec71ad..cd9fd3a6 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -850,6 +850,12 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
850 | return; | 850 | return; |
851 | } | 851 | } |
852 | 852 | ||
853 | if (!wlr_output_init_render(wlr_output, server->allocator, | ||
854 | server->renderer)) { | ||
855 | sway_log(SWAY_ERROR, "Failed to init output render"); | ||
856 | return; | ||
857 | } | ||
858 | |||
853 | struct sway_output *output = output_create(wlr_output); | 859 | struct sway_output *output = output_create(wlr_output); |
854 | if (!output) { | 860 | if (!output) { |
855 | return; | 861 | return; |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 17fc8f6f..6c8c77ed 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -52,7 +52,7 @@ static int scale_length(int length, int offset, float scale) { | |||
52 | 52 | ||
53 | static void scissor_output(struct wlr_output *wlr_output, | 53 | static void scissor_output(struct wlr_output *wlr_output, |
54 | pixman_box32_t *rect) { | 54 | pixman_box32_t *rect) { |
55 | struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); | 55 | struct wlr_renderer *renderer = wlr_output->renderer; |
56 | assert(renderer); | 56 | assert(renderer); |
57 | 57 | ||
58 | struct wlr_box box = { | 58 | struct wlr_box box = { |
@@ -100,8 +100,7 @@ static void render_texture(struct wlr_output *wlr_output, | |||
100 | pixman_region32_t *output_damage, struct wlr_texture *texture, | 100 | pixman_region32_t *output_damage, struct wlr_texture *texture, |
101 | const struct wlr_fbox *src_box, const struct wlr_box *dst_box, | 101 | const struct wlr_fbox *src_box, const struct wlr_box *dst_box, |
102 | const float matrix[static 9], float alpha) { | 102 | const float matrix[static 9], float alpha) { |
103 | struct wlr_renderer *renderer = | 103 | struct wlr_renderer *renderer = wlr_output->renderer; |
104 | wlr_backend_get_renderer(wlr_output->backend); | ||
105 | struct sway_output *output = wlr_output->data; | 104 | struct sway_output *output = wlr_output->data; |
106 | 105 | ||
107 | pixman_region32_t damage; | 106 | pixman_region32_t damage; |
@@ -218,8 +217,7 @@ void render_rect(struct sway_output *output, | |||
218 | pixman_region32_t *output_damage, const struct wlr_box *_box, | 217 | pixman_region32_t *output_damage, const struct wlr_box *_box, |
219 | float color[static 4]) { | 218 | float color[static 4]) { |
220 | struct wlr_output *wlr_output = output->wlr_output; | 219 | struct wlr_output *wlr_output = output->wlr_output; |
221 | struct wlr_renderer *renderer = | 220 | struct wlr_renderer *renderer = wlr_output->renderer; |
222 | wlr_backend_get_renderer(wlr_output->backend); | ||
223 | 221 | ||
224 | struct wlr_box box; | 222 | struct wlr_box box; |
225 | memcpy(&box, _box, sizeof(struct wlr_box)); | 223 | memcpy(&box, _box, sizeof(struct wlr_box)); |
@@ -1013,13 +1011,7 @@ static void render_seatops(struct sway_output *output, | |||
1013 | void output_render(struct sway_output *output, struct timespec *when, | 1011 | void output_render(struct sway_output *output, struct timespec *when, |
1014 | pixman_region32_t *damage) { | 1012 | pixman_region32_t *damage) { |
1015 | struct wlr_output *wlr_output = output->wlr_output; | 1013 | struct wlr_output *wlr_output = output->wlr_output; |
1016 | 1014 | struct wlr_renderer *renderer = output->server->renderer; | |
1017 | struct wlr_renderer *renderer = | ||
1018 | wlr_backend_get_renderer(wlr_output->backend); | ||
1019 | if (!sway_assert(renderer != NULL, | ||
1020 | "expected the output backend to have a renderer")) { | ||
1021 | return; | ||
1022 | } | ||
1023 | 1015 | ||
1024 | struct sway_workspace *workspace = output->current.active_workspace; | 1016 | struct sway_workspace *workspace = output->current.active_workspace; |
1025 | if (workspace == NULL) { | 1017 | if (workspace == NULL) { |
diff --git a/sway/server.c b/sway/server.c index b187fcd5..0d179c88 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -73,12 +73,23 @@ static void handle_drm_lease_request(struct wl_listener *listener, void *data) { | |||
73 | bool server_init(struct sway_server *server) { | 73 | bool server_init(struct sway_server *server) { |
74 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); | 74 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); |
75 | 75 | ||
76 | struct wlr_renderer *renderer = wlr_backend_get_renderer(server->backend); | 76 | server->renderer = wlr_renderer_autocreate(server->backend); |
77 | assert(renderer); | 77 | if (!server->renderer) { |
78 | sway_log(SWAY_ERROR, "Failed to create renderer"); | ||
79 | return false; | ||
80 | } | ||
81 | |||
82 | wlr_renderer_init_wl_display(server->renderer, server->wl_display); | ||
78 | 83 | ||
79 | wlr_renderer_init_wl_display(renderer, server->wl_display); | 84 | server->allocator = wlr_allocator_autocreate(server->backend, |
85 | server->renderer); | ||
86 | if (!server->allocator) { | ||
87 | sway_log(SWAY_ERROR, "Failed to create allocator"); | ||
88 | return false; | ||
89 | } | ||
80 | 90 | ||
81 | server->compositor = wlr_compositor_create(server->wl_display, renderer); | 91 | server->compositor = wlr_compositor_create(server->wl_display, |
92 | server->renderer); | ||
82 | server->compositor_new_surface.notify = handle_compositor_new_surface; | 93 | server->compositor_new_surface.notify = handle_compositor_new_surface; |
83 | wl_signal_add(&server->compositor->events.new_surface, | 94 | wl_signal_add(&server->compositor->events.new_surface, |
84 | &server->compositor_new_surface); | 95 | &server->compositor_new_surface); |
@@ -212,7 +223,8 @@ bool server_init(struct sway_server *server) { | |||
212 | root->noop_output = output_create(wlr_output); | 223 | root->noop_output = output_create(wlr_output); |
213 | 224 | ||
214 | server->headless_backend = | 225 | server->headless_backend = |
215 | wlr_headless_backend_create_with_renderer(server->wl_display, renderer); | 226 | wlr_headless_backend_create_with_renderer(server->wl_display, |
227 | server->renderer); | ||
216 | if (!server->headless_backend) { | 228 | if (!server->headless_backend) { |
217 | sway_log(SWAY_INFO, "Failed to create secondary headless backend, " | 229 | sway_log(SWAY_INFO, "Failed to create secondary headless backend, " |
218 | "starting without it"); | 230 | "starting without it"); |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 943d3d53..eb88b47e 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -547,8 +547,7 @@ static void render_titlebar_text_texture(struct sway_output *output, | |||
547 | cairo_surface_flush(surface); | 547 | cairo_surface_flush(surface); |
548 | unsigned char *data = cairo_image_surface_get_data(surface); | 548 | unsigned char *data = cairo_image_surface_get_data(surface); |
549 | int stride = cairo_image_surface_get_stride(surface); | 549 | int stride = cairo_image_surface_get_stride(surface); |
550 | struct wlr_renderer *renderer = wlr_backend_get_renderer( | 550 | struct wlr_renderer *renderer = output->wlr_output->renderer; |
551 | output->wlr_output->backend); | ||
552 | *texture = wlr_texture_from_pixels( | 551 | *texture = wlr_texture_from_pixels( |
553 | renderer, DRM_FORMAT_ARGB8888, stride, width, height, data); | 552 | renderer, DRM_FORMAT_ARGB8888, stride, width, height, data); |
554 | cairo_surface_destroy(surface); | 553 | cairo_surface_destroy(surface); |