aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-06-07 16:31:53 +0200
committerSimon Ser <contact@emersion.fr>2021-12-07 15:15:28 +0100
commit77d811a21b3d1dfb4ef6634e870c6c37228f3c15 (patch)
tree9543457521bf491908c7a04fc29f82b863657e6f
parentc9f3c2b4f7052e4d4901661a953072ac030bf153 (diff)
render: add wlr_renderer_init_wl_shm
This allows compositors to initialize wl_shm without initializing other globals like linux-dmabuf.
-rw-r--r--include/wlr/render/wlr_renderer.h8
-rw-r--r--render/wlr_renderer.c24
2 files changed, 26 insertions, 6 deletions
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
index bae2fa97..d8b04dc7 100644
--- a/include/wlr/render/wlr_renderer.h
+++ b/include/wlr/render/wlr_renderer.h
@@ -99,7 +99,7 @@ bool wlr_renderer_read_pixels(struct wlr_renderer *r, uint32_t fmt,
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, void *data);
/**
- * Creates necessary shm and invokes the initialization of the implementation.
+ * Initializes wl_shm, linux-dmabuf and other buffer factory protocols.
*
* Returns false on failure.
*/
@@ -107,6 +107,12 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
struct wl_display *wl_display);
/**
+ * Initializes wl_shm on the provided wl_display.
+ */
+bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
+ struct wl_display *wl_display);
+
+/**
* Obtains the FD of the DRM device used for rendering, or -1 if unavailable.
*
* The caller doesn't have ownership of the FD, it must not close it.
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index ff315913..2b5cf994 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -202,17 +202,18 @@ bool wlr_renderer_read_pixels(struct wlr_renderer *r, uint32_t fmt,
src_x, src_y, dst_x, dst_y, data);
}
-bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
+bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
struct wl_display *wl_display) {
- if (wl_display_init_shm(wl_display)) {
- wlr_log(WLR_ERROR, "Failed to initialize shm");
+ if (wl_display_init_shm(wl_display) != 0) {
+ wlr_log(WLR_ERROR, "Failed to initialize wl_shm");
return false;
}
size_t len;
const uint32_t *formats = wlr_renderer_get_shm_texture_formats(r, &len);
if (formats == NULL) {
- wlr_log(WLR_ERROR, "Failed to initialize shm: cannot get formats");
+ wlr_log(WLR_ERROR, "Failed to initialize wl_shm: "
+ "cannot get renderer formats");
return false;
}
@@ -229,11 +230,24 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
xrgb8888 = true;
break;
default:
- wl_display_add_shm_format(wl_display, fmt);
+ if (wl_display_add_shm_format(wl_display, fmt) == NULL) {
+ wlr_log(WLR_ERROR, "Failed to initialize wl_shm: "
+ "failed to add format");
+ return false;
+ }
}
}
assert(argb8888 && xrgb8888);
+ return true;
+}
+
+bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
+ struct wl_display *wl_display) {
+ if (!wlr_renderer_init_wl_shm(r, wl_display)) {
+ return false;
+ }
+
if (wlr_renderer_get_dmabuf_texture_formats(r) != NULL) {
if (wlr_renderer_get_drm_fd(r) >= 0) {
if (wlr_drm_create(wl_display, r) == NULL) {