Add wlr_renderer_init_wl_shm to advertize supported renderer formats

This commit is contained in:
emersion 2018-04-20 23:58:30 +01:00
parent c18afd6731
commit 70d820be25
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 23 additions and 1 deletions

View file

@ -92,6 +92,8 @@ bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format fmt,
*/ */
bool wlr_renderer_format_supported(struct wlr_renderer *r, bool wlr_renderer_format_supported(struct wlr_renderer *r,
enum wl_shm_format fmt); enum wl_shm_format fmt);
void wlr_renderer_init_wl_shm(struct wlr_renderer *r,
struct wl_display *display);
/** /**
* Destroys this wlr_renderer. Textures must be destroyed separately. * Destroys this wlr_renderer. Textures must be destroyed separately.
*/ */

View file

@ -4,6 +4,7 @@
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
void wlr_renderer_init(struct wlr_renderer *renderer, void wlr_renderer_init(struct wlr_renderer *renderer,
const struct wlr_renderer_impl *impl) { const struct wlr_renderer_impl *impl) {
@ -151,3 +152,22 @@ bool wlr_renderer_format_supported(struct wlr_renderer *r,
enum wl_shm_format fmt) { enum wl_shm_format fmt) {
return r->impl->format_supported(r, fmt); return r->impl->format_supported(r, fmt);
} }
void wlr_renderer_init_wl_shm(struct wlr_renderer *r,
struct wl_display *display) {
if (wl_display_init_shm(display)) {
wlr_log(L_ERROR, "Failed to initialize shm");
return;
}
size_t len;
const enum wl_shm_format *formats = wlr_renderer_get_formats(r, &len);
if (formats == NULL) {
wlr_log(L_ERROR, "Failed to initialize shm: cannot get formats");
return;
}
for (size_t i = 0; i < len; ++i) {
wl_display_add_shm_format(display, formats[i]);
}
}

View file

@ -43,7 +43,7 @@ int main(int argc, char **argv) {
assert(server.renderer); assert(server.renderer);
server.data_device_manager = server.data_device_manager =
wlr_data_device_manager_create(server.wl_display); wlr_data_device_manager_create(server.wl_display);
wl_display_init_shm(server.wl_display); wlr_renderer_init_wl_shm(server.renderer, server.wl_display);
server.desktop = desktop_create(&server, server.config); server.desktop = desktop_create(&server, server.config);
server.input = input_create(&server, server.config); server.input = input_create(&server, server.config);