From dbc7a5cada37d192821e1104b356ff891b8bd787 Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Mon, 11 Sep 2023 19:59:41 -0400 Subject: [PATCH] screencopy_v1: only bind, not render with, buffer in shm copy path wlr_renderer_read_pixels does not need to be called inside a render pass; rather, it only needs to have the correct buffer bound to the renderer. This commit optimizes the implementation of frame_shm_copy(...) by only binding the source buffer instead of starting a no-op render pass with it. --- types/wlr_screencopy_v1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index bb90d35a..a421954b 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -11,6 +11,7 @@ #include #include "wlr-screencopy-unstable-v1-protocol.h" #include "render/pixel_format.h" +#include "render/wlr_renderer.h" #define SCREENCOPY_MANAGER_VERSION 3 @@ -208,12 +209,12 @@ static bool frame_shm_copy(struct wlr_screencopy_frame_v1 *frame, } bool ok = false; - if (!wlr_renderer_begin_with_buffer(renderer, src_buffer)) { + if (!renderer_bind_buffer(renderer, src_buffer)) { goto out; } ok = wlr_renderer_read_pixels(renderer, format, stride, width, height, x, y, 0, 0, data); - wlr_renderer_end(renderer); + renderer_bind_buffer(renderer, NULL); out: wlr_buffer_end_data_ptr_access(frame->buffer);