vo_dmabuf_wayland: assume counter-clockwise rotations

In practice, most compositors implement the rotation clockwise which
matches mpv's option, but amusingly this is actually incorrect.
According to the spec*, wayland buffer rotations are counter-clockwise.
So with this assumption in mind, in order for the rotation to match
mpv's usual semantics, the 90 degree and 270 degree positions need to be
flipped. Of course, this will make the VO rotate the wrong way on most
compositors, but this is what the spec says (sway master is known to
currently be correct). Fixes #12508 (sort of but will break the rotation
direction on other compositors. Oh well).

*: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
This commit is contained in:
Dudemanguy 2023-09-27 18:29:58 -05:00 committed by sfan5
parent c19115c8da
commit 27ef1725e7
1 changed files with 4 additions and 1 deletions

View File

@ -677,7 +677,10 @@ done:
if (!vo_wayland_reconfig(vo))
return VO_ERROR;
wl_surface_set_buffer_transform(vo->wl->video_surface, img->params.rotate / 90);
// mpv rotates clockwise but the wayland spec has counter-clockwise rotations
// swap 1 and 3 to match mpv's direction
int transform = (360 - img->params.rotate) % 360 / 90;
wl_surface_set_buffer_transform(vo->wl->video_surface, transform);
// Immediately destroy all buffers if params change.
destroy_buffers(vo);