From f57e7e40d3605c776d640c334a37150e76e8b713 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Tue, 4 Feb 2025 10:01:08 +0100 Subject: [PATCH] scene/surface: Do not use buffer dimensions for clip The surface's buffer dimensions were used to scale the clip's x/y offset. If a surface had a larger buffer than src_box, the calculations to scale the x/y portion of the clip would be incorrect, yielding graphical glitches. This was noticed with Chromium in sway, which during resize uses a viewport with a src_box to avoid immediate buffer reallocation. While the viewport was in use, the surface would be shifted so that too much content was cropped in the upper left, and damage glitching was visible in the lower right. Use the buffer source box dimensions instead. (cherry picked from commit dc7dba8b1fde967b8da9ad1703001fa5bd2266d9) --- types/scene/surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/scene/surface.c b/types/scene/surface.c index 1905b4dfb..3208c817c 100644 --- a/types/scene/surface.c +++ b/types/scene/surface.c @@ -128,8 +128,8 @@ static void surface_reconfigure(struct wlr_scene_surface *scene_surface) { buffer_width, buffer_height); wlr_output_transform_coords(state->transform, &buffer_width, &buffer_height); - src_box.x += (double)(clip->x * buffer_width) / state->width; - src_box.y += (double)(clip->y * buffer_height) / state->height; + src_box.x += (double)(clip->x * src_box.width) / state->width; + src_box.y += (double)(clip->y * src_box.height) / state->height; src_box.width *= (double)width / state->width; src_box.height *= (double)height / state->height;