backend: introduce backend_get_buffer_caps

master
Simon Zeni 4 years ago committed by Simon Ser
parent 6ec6527855
commit 144189674e

@ -16,6 +16,7 @@
#include <wlr/backend/wayland.h>
#include <wlr/config.h>
#include <wlr/util/log.h>
#include "backend/backend.h"
#include "backend/multi.h"
#if WLR_HAS_X11_BACKEND
@ -78,6 +79,14 @@ 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) {

@ -12,6 +12,7 @@
#include <wlr/util/log.h>
#include <xf86drm.h>
#include "backend/drm/drm.h"
#include "types/wlr_buffer.h"
#include "util/signal.h"
struct wlr_drm_backend *get_drm_backend_from_backend(
@ -89,12 +90,17 @@ static int backend_get_drm_fd(struct wlr_backend *backend) {
}
}
static uint32_t backend_get_buffer_caps(struct wlr_backend *backend) {
return WLR_BUFFER_CAP_DMABUF;
}
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_renderer = backend_get_renderer,
.get_presentation_clock = backend_get_presentation_clock,
.get_drm_fd = backend_get_drm_fd,
.get_buffer_caps = backend_get_buffer_caps,
};
bool wlr_backend_is_drm(struct wlr_backend *b) {

@ -13,6 +13,7 @@
#include "render/drm_format_set.h"
#include "render/gbm_allocator.h"
#include "render/wlr_renderer.h"
#include "types/wlr_buffer.h"
#include "util/signal.h"
struct wlr_headless_backend *headless_backend_from_backend(
@ -92,11 +93,18 @@ static int backend_get_drm_fd(struct wlr_backend *wlr_backend) {
return backend->drm_fd;
}
static uint32_t backend_get_buffer_caps(struct wlr_backend *wlr_backend) {
return WLR_BUFFER_CAP_DATA_PTR
| WLR_BUFFER_CAP_DMABUF
| WLR_BUFFER_CAP_SHM;
}
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_renderer = backend_get_renderer,
.get_drm_fd = backend_get_drm_fd,
.get_buffer_caps = backend_get_buffer_caps,
};
static void handle_display_destroy(struct wl_listener *listener, void *data) {

@ -23,6 +23,7 @@
#include "render/pixel_format.h"
#include "render/shm_allocator.h"
#include "render/wlr_renderer.h"
#include "types/wlr_buffer.h"
#include "util/signal.h"
#include "drm-client-protocol.h"
@ -364,11 +365,18 @@ static int backend_get_drm_fd(struct wlr_backend *backend) {
return wl->drm_fd;
}
static uint32_t backend_get_buffer_caps(struct wlr_backend *backend) {
struct wlr_wl_backend *wl = get_wl_backend_from_backend(backend);
return (wl->zwp_linux_dmabuf_v1 ? WLR_BUFFER_CAP_DMABUF : 0)
| (wl->shm ? WLR_BUFFER_CAP_SHM : 0);
}
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_renderer = backend_get_renderer,
.get_drm_fd = backend_get_drm_fd,
.get_buffer_caps = backend_get_buffer_caps,
};
bool wlr_backend_is_wl(struct wlr_backend *b) {

@ -35,6 +35,7 @@
#include "render/gbm_allocator.h"
#include "render/shm_allocator.h"
#include "render/wlr_renderer.h"
#include "types/wlr_buffer.h"
#include "util/signal.h"
// See dri2_format_for_depth in mesa
@ -223,11 +224,18 @@ static int backend_get_drm_fd(struct wlr_backend *backend) {
return x11->drm_fd;
}
static uint32_t backend_get_buffer_caps(struct wlr_backend *backend) {
struct wlr_x11_backend *x11 = get_x11_backend_from_backend(backend);
return (x11->have_dri3 ? WLR_BUFFER_CAP_DMABUF : 0)
| (x11->have_shm ? WLR_BUFFER_CAP_SHM : 0);
}
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_renderer = backend_get_renderer,
.get_drm_fd = backend_get_drm_fd,
.get_buffer_caps = backend_get_buffer_caps,
};
bool wlr_backend_is_x11(struct wlr_backend *backend) {

@ -0,0 +1,13 @@
#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

@ -20,6 +20,7 @@ struct wlr_backend_impl {
struct wlr_session *(*get_session)(struct wlr_backend *backend);
clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
int (*get_drm_fd)(struct wlr_backend *backend);
uint32_t (*get_buffer_caps)(struct wlr_backend *backend);
};
/**

Loading…
Cancel
Save