aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-01-16 22:26:44 +0100
committerSimon Ser <contact@emersion.fr>2021-01-16 22:52:26 +0100
commit2f1191461349f29c0c6b995ad98c2dde7927ba9b (patch)
tree1f11cfaecb3587a7acca1033ac9a4f5509f47eaf
parent32c30481d397d545b368ee0e328f485923c0e8c6 (diff)
render: introduce private wlr_renderer_autocreate_with_drm_fd
-rw-r--r--include/render/wlr_renderer.h4
-rw-r--r--render/wlr_renderer.c20
2 files changed, 16 insertions, 8 deletions
diff --git a/include/render/wlr_renderer.h b/include/render/wlr_renderer.h
index 9e41f86f..dab9fd12 100644
--- a/include/render/wlr_renderer.h
+++ b/include/render/wlr_renderer.h
@@ -4,6 +4,10 @@
#include <wlr/render/wlr_renderer.h>
/**
+ * Automatically select and create a renderer suitable for the DRM FD.
+ */
+struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd);
+/**
* Bind a buffer to the renderer.
*
* All subsequent rendering operations will operate on the supplied buffer.
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 3c757430..4a565b1d 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -250,14 +250,8 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
return true;
}
-struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {
- int fd = backend_get_drm_fd(backend);
- if (fd < 0) {
- wlr_log(WLR_ERROR, "Failed to get DRM FD from backend");
- return NULL;
- }
-
- struct gbm_device *gbm_device = gbm_create_device(fd);
+struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) {
+ struct gbm_device *gbm_device = gbm_create_device(drm_fd);
if (!gbm_device) {
wlr_log(WLR_ERROR, "Failed to create GBM device");
return NULL;
@@ -282,6 +276,16 @@ struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {
return renderer;
}
+struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {
+ int drm_fd = backend_get_drm_fd(backend);
+ if (drm_fd < 0) {
+ wlr_log(WLR_ERROR, "Failed to get DRM FD from backend");
+ return NULL;
+ }
+
+ return wlr_renderer_autocreate_with_drm_fd(drm_fd);
+}
+
int wlr_renderer_get_drm_fd(struct wlr_renderer *r) {
if (!r->impl->get_drm_fd) {
return -1;