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.
This commit is contained in:
Kenny Levinsen 2025-02-04 10:01:08 +01:00 committed by Alexander Orzechowski
parent edd8df76d8
commit dc7dba8b1f

View file

@ -129,8 +129,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;