From 9cae8745138e5136abd43713f9edc4806a46ef4f Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Fri, 3 Dec 2021 21:40:32 -0500 Subject: screencopy-v1: Fix frame stride for formats with bpp != 32 --- types/wlr_screencopy_v1.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index e2c020db..c656a916 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -542,6 +542,12 @@ static void capture_output(struct wl_client *wl_client, "Failed to capture output: no read format supported by renderer"); goto error; } + const struct wlr_pixel_format_info *info = drm_get_pixel_format_info(drm_format); + if (!info) { + wlr_log(WLR_ERROR, + "Failed to capture output: no pixel format info matching read format"); + goto error; + } frame->format = convert_drm_format_to_wl_shm(drm_format); if (output->allocator && @@ -569,7 +575,7 @@ static void capture_output(struct wl_client *wl_client, } frame->box = buffer_box; - frame->stride = 4 * buffer_box.width; // TODO: depends on read format + frame->stride = (info->bpp / 8) * buffer_box.width; zwlr_screencopy_frame_v1_send_buffer(frame->resource, frame->format, buffer_box.width, buffer_box.height, frame->stride); -- cgit v1.2.3