mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-29 10:32:29 +00:00
backend: automatically create renderer
If a backend accepts buffers (as indicated by get_buffer_caps) but doesn't implement get_renderer, automatically create a renderer.
This commit is contained in:
parent
7ec5bf6b10
commit
bcabe34a2e
@ -15,6 +15,7 @@
|
|||||||
#include <wlr/backend/session.h>
|
#include <wlr/backend/session.h>
|
||||||
#include <wlr/backend/wayland.h>
|
#include <wlr/backend/wayland.h>
|
||||||
#include <wlr/config.h>
|
#include <wlr/config.h>
|
||||||
|
#include <wlr/render/wlr_renderer.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "backend/backend.h"
|
#include "backend/backend.h"
|
||||||
#include "backend/multi.h"
|
#include "backend/multi.h"
|
||||||
@ -35,6 +36,7 @@ void wlr_backend_init(struct wlr_backend *backend,
|
|||||||
|
|
||||||
void wlr_backend_finish(struct wlr_backend *backend) {
|
void wlr_backend_finish(struct wlr_backend *backend) {
|
||||||
wlr_signal_emit_safe(&backend->events.destroy, backend);
|
wlr_signal_emit_safe(&backend->events.destroy, backend);
|
||||||
|
wlr_renderer_destroy(backend->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_backend_start(struct wlr_backend *backend) {
|
bool wlr_backend_start(struct wlr_backend *backend) {
|
||||||
@ -56,10 +58,32 @@ void wlr_backend_destroy(struct wlr_backend *backend) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool backend_create_renderer(struct wlr_backend *backend) {
|
||||||
|
if (backend->renderer != NULL) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
backend->renderer = wlr_renderer_autocreate(backend);
|
||||||
|
if (backend->renderer == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend) {
|
struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend) {
|
||||||
if (backend->impl->get_renderer) {
|
if (backend->impl->get_renderer) {
|
||||||
return backend->impl->get_renderer(backend);
|
return backend->impl->get_renderer(backend);
|
||||||
}
|
}
|
||||||
|
if (backend_get_buffer_caps(backend) != 0) {
|
||||||
|
// If the backend is capable of presenting buffers, automatically create
|
||||||
|
// the renderer if necessary.
|
||||||
|
if (!backend_create_renderer(backend)) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create backend renderer");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return backend->renderer;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,10 @@ struct wlr_backend {
|
|||||||
/** Raised when new outputs are added, passed the wlr_output */
|
/** Raised when new outputs are added, passed the wlr_output */
|
||||||
struct wl_signal new_output;
|
struct wl_signal new_output;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
|
// Private state
|
||||||
|
|
||||||
|
struct wlr_renderer *renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user