mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
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
This commit is contained in:
parent
cbecc5cbae
commit
5865af75cf
@ -4,6 +4,7 @@
|
|||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
#include <wlr/backend.h>
|
#include <wlr/backend.h>
|
||||||
#include <wlr/backend/session.h>
|
#include <wlr/backend/session.h>
|
||||||
|
#include <wlr/render/allocator.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
#include <wlr/types/wlr_compositor.h>
|
#include <wlr/types/wlr_compositor.h>
|
||||||
#include <wlr/types/wlr_data_device.h>
|
#include <wlr/types/wlr_data_device.h>
|
||||||
@ -35,6 +36,8 @@ struct sway_server {
|
|||||||
struct wlr_backend *noop_backend;
|
struct wlr_backend *noop_backend;
|
||||||
// secondary headless backend used for creating virtual outputs on-the-fly
|
// secondary headless backend used for creating virtual outputs on-the-fly
|
||||||
struct wlr_backend *headless_backend;
|
struct wlr_backend *headless_backend;
|
||||||
|
struct wlr_renderer *renderer;
|
||||||
|
struct wlr_allocator *allocator;
|
||||||
|
|
||||||
struct wlr_compositor *compositor;
|
struct wlr_compositor *compositor;
|
||||||
struct wl_listener compositor_new_surface;
|
struct wl_listener compositor_new_surface;
|
||||||
|
@ -850,6 +850,12 @@ void handle_new_output(struct wl_listener *listener, void *data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!wlr_output_init_render(wlr_output, server->allocator,
|
||||||
|
server->renderer)) {
|
||||||
|
sway_log(SWAY_ERROR, "Failed to init output render");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct sway_output *output = output_create(wlr_output);
|
struct sway_output *output = output_create(wlr_output);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
return;
|
return;
|
||||||
|
@ -52,7 +52,7 @@ static int scale_length(int length, int offset, float scale) {
|
|||||||
|
|
||||||
static void scissor_output(struct wlr_output *wlr_output,
|
static void scissor_output(struct wlr_output *wlr_output,
|
||||||
pixman_box32_t *rect) {
|
pixman_box32_t *rect) {
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
struct wlr_renderer *renderer = wlr_output->renderer;
|
||||||
assert(renderer);
|
assert(renderer);
|
||||||
|
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
@ -100,8 +100,7 @@ static void render_texture(struct wlr_output *wlr_output,
|
|||||||
pixman_region32_t *output_damage, struct wlr_texture *texture,
|
pixman_region32_t *output_damage, struct wlr_texture *texture,
|
||||||
const struct wlr_fbox *src_box, const struct wlr_box *dst_box,
|
const struct wlr_fbox *src_box, const struct wlr_box *dst_box,
|
||||||
const float matrix[static 9], float alpha) {
|
const float matrix[static 9], float alpha) {
|
||||||
struct wlr_renderer *renderer =
|
struct wlr_renderer *renderer = wlr_output->renderer;
|
||||||
wlr_backend_get_renderer(wlr_output->backend);
|
|
||||||
struct sway_output *output = wlr_output->data;
|
struct sway_output *output = wlr_output->data;
|
||||||
|
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
@ -218,8 +217,7 @@ void render_rect(struct sway_output *output,
|
|||||||
pixman_region32_t *output_damage, const struct wlr_box *_box,
|
pixman_region32_t *output_damage, const struct wlr_box *_box,
|
||||||
float color[static 4]) {
|
float color[static 4]) {
|
||||||
struct wlr_output *wlr_output = output->wlr_output;
|
struct wlr_output *wlr_output = output->wlr_output;
|
||||||
struct wlr_renderer *renderer =
|
struct wlr_renderer *renderer = wlr_output->renderer;
|
||||||
wlr_backend_get_renderer(wlr_output->backend);
|
|
||||||
|
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
memcpy(&box, _box, sizeof(struct wlr_box));
|
memcpy(&box, _box, sizeof(struct wlr_box));
|
||||||
@ -1013,13 +1011,7 @@ static void render_seatops(struct sway_output *output,
|
|||||||
void output_render(struct sway_output *output, struct timespec *when,
|
void output_render(struct sway_output *output, struct timespec *when,
|
||||||
pixman_region32_t *damage) {
|
pixman_region32_t *damage) {
|
||||||
struct wlr_output *wlr_output = output->wlr_output;
|
struct wlr_output *wlr_output = output->wlr_output;
|
||||||
|
struct wlr_renderer *renderer = output->server->renderer;
|
||||||
struct wlr_renderer *renderer =
|
|
||||||
wlr_backend_get_renderer(wlr_output->backend);
|
|
||||||
if (!sway_assert(renderer != NULL,
|
|
||||||
"expected the output backend to have a renderer")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct sway_workspace *workspace = output->current.active_workspace;
|
struct sway_workspace *workspace = output->current.active_workspace;
|
||||||
if (workspace == NULL) {
|
if (workspace == NULL) {
|
||||||
|
@ -73,12 +73,23 @@ static void handle_drm_lease_request(struct wl_listener *listener, void *data) {
|
|||||||
bool server_init(struct sway_server *server) {
|
bool server_init(struct sway_server *server) {
|
||||||
sway_log(SWAY_DEBUG, "Initializing Wayland server");
|
sway_log(SWAY_DEBUG, "Initializing Wayland server");
|
||||||
|
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(server->backend);
|
server->renderer = wlr_renderer_autocreate(server->backend);
|
||||||
assert(renderer);
|
if (!server->renderer) {
|
||||||
|
sway_log(SWAY_ERROR, "Failed to create renderer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
wlr_renderer_init_wl_display(renderer, server->wl_display);
|
wlr_renderer_init_wl_display(server->renderer, server->wl_display);
|
||||||
|
|
||||||
server->compositor = wlr_compositor_create(server->wl_display, renderer);
|
server->allocator = wlr_allocator_autocreate(server->backend,
|
||||||
|
server->renderer);
|
||||||
|
if (!server->allocator) {
|
||||||
|
sway_log(SWAY_ERROR, "Failed to create allocator");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
server->compositor = wlr_compositor_create(server->wl_display,
|
||||||
|
server->renderer);
|
||||||
server->compositor_new_surface.notify = handle_compositor_new_surface;
|
server->compositor_new_surface.notify = handle_compositor_new_surface;
|
||||||
wl_signal_add(&server->compositor->events.new_surface,
|
wl_signal_add(&server->compositor->events.new_surface,
|
||||||
&server->compositor_new_surface);
|
&server->compositor_new_surface);
|
||||||
@ -212,7 +223,8 @@ bool server_init(struct sway_server *server) {
|
|||||||
root->noop_output = output_create(wlr_output);
|
root->noop_output = output_create(wlr_output);
|
||||||
|
|
||||||
server->headless_backend =
|
server->headless_backend =
|
||||||
wlr_headless_backend_create_with_renderer(server->wl_display, renderer);
|
wlr_headless_backend_create_with_renderer(server->wl_display,
|
||||||
|
server->renderer);
|
||||||
if (!server->headless_backend) {
|
if (!server->headless_backend) {
|
||||||
sway_log(SWAY_INFO, "Failed to create secondary headless backend, "
|
sway_log(SWAY_INFO, "Failed to create secondary headless backend, "
|
||||||
"starting without it");
|
"starting without it");
|
||||||
|
@ -547,8 +547,7 @@ static void render_titlebar_text_texture(struct sway_output *output,
|
|||||||
cairo_surface_flush(surface);
|
cairo_surface_flush(surface);
|
||||||
unsigned char *data = cairo_image_surface_get_data(surface);
|
unsigned char *data = cairo_image_surface_get_data(surface);
|
||||||
int stride = cairo_image_surface_get_stride(surface);
|
int stride = cairo_image_surface_get_stride(surface);
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(
|
struct wlr_renderer *renderer = output->wlr_output->renderer;
|
||||||
output->wlr_output->backend);
|
|
||||||
*texture = wlr_texture_from_pixels(
|
*texture = wlr_texture_from_pixels(
|
||||||
renderer, DRM_FORMAT_ARGB8888, stride, width, height, data);
|
renderer, DRM_FORMAT_ARGB8888, stride, width, height, data);
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
Loading…
Reference in New Issue
Block a user