diff options
-rw-r--r-- | include/render/pixman.h | 1 | ||||
-rw-r--r-- | render/pixman/pixel_format.c | 11 | ||||
-rw-r--r-- | render/pixman/renderer.c | 12 |
3 files changed, 24 insertions, 0 deletions
diff --git a/include/render/pixman.h b/include/render/pixman.h index dd2d768b..8967f66f 100644 --- a/include/render/pixman.h +++ b/include/render/pixman.h @@ -46,6 +46,7 @@ struct wlr_pixman_texture { }; pixman_format_code_t get_pixman_format_from_drm(uint32_t fmt); +uint32_t get_drm_format_from_pixman(pixman_format_code_t fmt); const uint32_t *get_pixman_drm_formats(size_t *len); #endif diff --git a/render/pixman/pixel_format.c b/render/pixman/pixel_format.c index a57c6c34..166f8580 100644 --- a/render/pixman/pixel_format.c +++ b/render/pixman/pixel_format.c @@ -49,6 +49,17 @@ pixman_format_code_t get_pixman_format_from_drm(uint32_t fmt) { return 0; } +uint32_t get_drm_format_from_pixman(pixman_format_code_t fmt) { + for (size_t i = 0; i < sizeof(formats) / sizeof(*formats); ++i) { + if (formats[i].pixman_format == fmt) { + return formats[i].drm_format; + } + } + + wlr_log(WLR_ERROR, "pixman format 0x%"PRIX32" has no drm equivalent", fmt); + return DRM_FORMAT_INVALID; +} + const uint32_t *get_pixman_drm_formats(size_t *len) { static uint32_t drm_formats[sizeof(formats) / sizeof(formats[0])]; *len = sizeof(formats) / sizeof(formats[0]); diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c index 5e5deaa2..16541e50 100644 --- a/render/pixman/renderer.c +++ b/render/pixman/renderer.c @@ -369,6 +369,17 @@ static void pixman_destroy(struct wlr_renderer *wlr_renderer) { free(renderer); } +static uint32_t pixman_preferred_read_format( + struct wlr_renderer *wlr_renderer) { + struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer); + struct wlr_pixman_buffer *buffer = renderer->current_buffer; + + pixman_format_code_t pixman_format = pixman_image_get_format( + buffer->image); + + return get_drm_format_from_pixman(pixman_format); +} + static const struct wlr_renderer_impl renderer_impl = { .begin = pixman_begin, .clear = pixman_clear, @@ -380,6 +391,7 @@ static const struct wlr_renderer_impl renderer_impl = { .texture_from_pixels = pixman_texture_from_pixels, .bind_buffer = pixman_bind_buffer, .destroy = pixman_destroy, + .preferred_read_format = pixman_preferred_read_format, }; struct wlr_renderer *wlr_pixman_renderer_create(void) { |