render: add wlr_renderer_init_wl_shm
This allows compositors to initialize wl_shm without initializing other globals like linux-dmabuf.
This commit is contained in:
parent
c9f3c2b4f7
commit
77d811a21b
|
@ -99,13 +99,19 @@ 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);
|
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.
|
* Returns false on failure.
|
||||||
*/
|
*/
|
||||||
bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
|
bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
|
||||||
struct wl_display *wl_display);
|
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.
|
* Obtains the FD of the DRM device used for rendering, or -1 if unavailable.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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);
|
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) {
|
struct wl_display *wl_display) {
|
||||||
if (wl_display_init_shm(wl_display)) {
|
if (wl_display_init_shm(wl_display) != 0) {
|
||||||
wlr_log(WLR_ERROR, "Failed to initialize shm");
|
wlr_log(WLR_ERROR, "Failed to initialize wl_shm");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len;
|
size_t len;
|
||||||
const uint32_t *formats = wlr_renderer_get_shm_texture_formats(r, &len);
|
const uint32_t *formats = wlr_renderer_get_shm_texture_formats(r, &len);
|
||||||
if (formats == NULL) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,11 +230,24 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
|
||||||
xrgb8888 = true;
|
xrgb8888 = true;
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
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_dmabuf_texture_formats(r) != NULL) {
|
||||||
if (wlr_renderer_get_drm_fd(r) >= 0) {
|
if (wlr_renderer_get_drm_fd(r) >= 0) {
|
||||||
if (wlr_drm_create(wl_display, r) == NULL) {
|
if (wlr_drm_create(wl_display, r) == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue