aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-09-17 14:50:13 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-11-15 16:30:00 +0000
commitda3616d1830b49bc0223bf16cf2dd8f4cfd76fc1 (patch)
tree4bd8af26c07a87fe5a0489778064f9d3582d9b0d /render
parent0ae3c7b1a2d4da0c32092782ff19a1662151d874 (diff)
render: use wlr_shm in wlr_renderer_init_wl_shm()
Diffstat (limited to 'render')
-rw-r--r--render/wlr_renderer.c38
1 files changed, 2 insertions, 36 deletions
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 7a18d95f..552488ba 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -10,6 +10,7 @@
#include <wlr/types/wlr_drm.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_matrix.h>
+#include <wlr/types/wlr_shm.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h>
#include <xf86drm.h>
@@ -213,42 +214,7 @@ bool wlr_renderer_read_pixels(struct wlr_renderer *r, uint32_t fmt,
bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
struct wl_display *wl_display) {
- 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 wl_shm: "
- "cannot get renderer formats");
- return false;
- }
-
- bool argb8888 = false, xrgb8888 = false;
- for (size_t i = 0; i < len; ++i) {
- // ARGB8888 and XRGB8888 must be supported and are implicitly
- // advertised by wl_display_init_shm
- enum wl_shm_format fmt = convert_drm_format_to_wl_shm(formats[i]);
- switch (fmt) {
- case WL_SHM_FORMAT_ARGB8888:
- argb8888 = true;
- break;
- case WL_SHM_FORMAT_XRGB8888:
- xrgb8888 = true;
- break;
- default:
- 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;
+ return wlr_shm_create_with_renderer(wl_display, 1, r) != NULL;
}
bool wlr_renderer_init_wl_display(struct wlr_renderer *r,