diff options
author | Manuel Stoeckl <code@mstoeckl.com> | 2021-12-03 21:40:32 -0500 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-05-23 07:37:24 +0000 |
commit | 9cae8745138e5136abd43713f9edc4806a46ef4f (patch) | |
tree | 59c8ddad36ec5687ca684a2eb5c32e54955768a8 | |
parent | ee122c9c2a6c6d0e9286ee434375245f4ed5d04c (diff) |
screencopy-v1: Fix frame stride for formats with bpp != 32
-rw-r--r-- | types/wlr_screencopy_v1.c | 8 |
1 files changed, 7 insertions, 1 deletions
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); |