wip: backend props

This commit is contained in:
Simon Ser 2023-07-10 16:33:22 +02:00
parent 214df8eda0
commit 16cec14591
5 changed files with 20 additions and 24 deletions

View file

@ -13,7 +13,6 @@
#include <wlr/config.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/util/log.h>
#include "backend/backend.h"
#include "backend/multi.h"
#include "render/allocator/allocator.h"
#include "util/env.h"
@ -116,7 +115,12 @@ static struct wlr_session *session_create_and_wait(struct wl_display *disp) {
#endif
}
const struct wlr_backend_props *wlr_backend_get_props(struct wlr_backend *backend) {
return backend->impl->get_props(backend);
}
clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) {
return wlr_backend_get_props(backend)->presentation_clock;
if (backend->impl->get_presentation_clock) {
return backend->impl->get_presentation_clock(backend);
}
@ -130,14 +134,6 @@ int wlr_backend_get_drm_fd(struct wlr_backend *backend) {
return backend->impl->get_drm_fd(backend);
}
uint32_t backend_get_buffer_caps(struct wlr_backend *backend) {
if (!backend->impl->get_buffer_caps) {
return 0;
}
return backend->impl->get_buffer_caps(backend);
}
static size_t parse_outputs_env(const char *name) {
const char *outputs_str = getenv(name);
if (outputs_str == NULL) {

View file

@ -1,13 +0,0 @@
#ifndef BACKEND_WLR_BACKEND_H
#define BACKEND_WLR_BACKEND_H
#include <wlr/backend.h>
/**
* Get the supported buffer capabilities.
*
* This functions returns a bitfield of supported wlr_buffer_cap.
*/
uint32_t backend_get_buffer_caps(struct wlr_backend *backend);
#endif

View file

@ -30,6 +30,16 @@ struct wlr_backend {
} events;
};
/**
* Backend properties.
*/
struct wlr_backend_props {
/* Supported buffer capabilities, bitfield of enum wlr_buffer_cap */
uint32_t buffer_caps;
/* Clock used for presentation feedback */
clockid_t presentation_clock;
};
/**
* Automatically initializes the most suitable backend given the environment.
* Will always return a multi-backend. The backend is created but not started.
@ -51,6 +61,10 @@ bool wlr_backend_start(struct wlr_backend *backend);
* automatically when the struct wl_display is destroyed.
*/
void wlr_backend_destroy(struct wlr_backend *backend);
/**
* Get backend properties.
*/
const struct wlr_backend_props *wlr_backend_get_props(struct wlr_backend *backend);
/**
* Returns the clock used by the backend for presentation feedback.
*/

View file

@ -16,7 +16,7 @@
struct wlr_backend_impl {
bool (*start)(struct wlr_backend *backend);
void (*destroy)(struct wlr_backend *backend);
clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
const struct wlr_backend_props *(*get_props)(struct wlr_backend *backend);
int (*get_drm_fd)(struct wlr_backend *backend);
uint32_t (*get_buffer_caps)(struct wlr_backend *backend);
};

View file

@ -9,7 +9,6 @@
#include <wlr/util/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "backend/backend.h"
#include "render/allocator/allocator.h"
#include "render/allocator/drm_dumb.h"
#include "render/allocator/shm.h"