mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
screencopy-v1: use DRM format code for shm buffers
Will allow us to simplify common shm/DMA-BUF logic later on.
This commit is contained in:
parent
4885c08f38
commit
77b829e15f
2 changed files with 11 additions and 10 deletions
|
@ -37,8 +37,7 @@ struct wlr_screencopy_frame_v1 {
|
|||
struct wlr_screencopy_v1_client *client;
|
||||
struct wl_list link; // wlr_screencopy_manager_v1.frames
|
||||
|
||||
enum wl_shm_format shm_format;
|
||||
uint32_t dmabuf_format;
|
||||
uint32_t shm_format, dmabuf_format; // DRM format codes
|
||||
struct wlr_box box;
|
||||
int stride;
|
||||
|
||||
|
|
|
@ -380,7 +380,8 @@ static void frame_handle_copy(struct wl_client *wl_client,
|
|||
int32_t height = 0;
|
||||
|
||||
if (shm_buffer) {
|
||||
enum wl_shm_format fmt = wl_shm_buffer_get_format(shm_buffer);
|
||||
uint32_t fmt =
|
||||
convert_wl_shm_format_to_drm(wl_shm_buffer_get_format(shm_buffer));
|
||||
if (fmt != frame->shm_format) {
|
||||
wl_resource_post_error(frame->resource,
|
||||
ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER,
|
||||
|
@ -538,20 +539,20 @@ static void capture_output(struct wl_client *wl_client,
|
|||
struct wlr_renderer *renderer = output->renderer;
|
||||
assert(renderer);
|
||||
|
||||
uint32_t drm_format = wlr_output_preferred_read_format(frame->output);
|
||||
if (drm_format == DRM_FORMAT_INVALID) {
|
||||
frame->shm_format = wlr_output_preferred_read_format(frame->output);
|
||||
if (frame->shm_format == DRM_FORMAT_INVALID) {
|
||||
wlr_log(WLR_ERROR,
|
||||
"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) {
|
||||
const struct wlr_pixel_format_info *shm_info =
|
||||
drm_get_pixel_format_info(frame->shm_format);
|
||||
if (!shm_info) {
|
||||
wlr_log(WLR_ERROR,
|
||||
"Failed to capture output: no pixel format info matching read format");
|
||||
goto error;
|
||||
}
|
||||
|
||||
frame->shm_format = convert_drm_format_to_wl_shm(drm_format);
|
||||
if (output->allocator &&
|
||||
(output->allocator->buffer_caps & WLR_BUFFER_CAP_DMABUF)) {
|
||||
frame->dmabuf_format = output->render_format;
|
||||
|
@ -577,9 +578,10 @@ static void capture_output(struct wl_client *wl_client,
|
|||
}
|
||||
|
||||
frame->box = buffer_box;
|
||||
frame->stride = (info->bpp / 8) * buffer_box.width;
|
||||
frame->stride = (shm_info->bpp / 8) * buffer_box.width;
|
||||
|
||||
zwlr_screencopy_frame_v1_send_buffer(frame->resource, frame->shm_format,
|
||||
zwlr_screencopy_frame_v1_send_buffer(frame->resource,
|
||||
convert_drm_format_to_wl_shm(frame->shm_format),
|
||||
buffer_box.width, buffer_box.height, frame->stride);
|
||||
|
||||
if (version >= 3) {
|
||||
|
|
Loading…
Reference in a new issue