aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2021-04-28 10:09:33 -0400
committerSimon Ser <contact@emersion.fr>2021-04-28 20:55:57 +0200
commit144189674edbf908d72467cd497a0250b3d80b8b (patch)
treec71455402e227053381aaed7038ba3a477a6079b /backend
parent6ec652785587b9027512f1a1bc141c5ed27c3ddb (diff)
backend: introduce backend_get_buffer_caps
Diffstat (limited to 'backend')
-rw-r--r--backend/backend.c9
-rw-r--r--backend/drm/backend.c6
-rw-r--r--backend/headless/backend.c8
-rw-r--r--backend/wayland/backend.c8
-rw-r--r--backend/x11/backend.c8
5 files changed, 39 insertions, 0 deletions
diff --git a/backend/backend.c b/backend/backend.c
index b93b1e22..c7fa043d 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -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) {
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 3240b375..6520adc3 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -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) {
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index 1ca1c183..7f1e6aa4 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -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) {
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 60ac76cb..f0cb2e42 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -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) {
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 743f19ff..9ffdfb2d 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -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) {