From 27ef1725e7724f4b6899e3992ac3a884db9fbe13 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Wed, 27 Sep 2023 18:29:58 -0500 Subject: [PATCH] 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 --- video/out/vo_dmabuf_wayland.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index 2566b96be4..5c894dcd7e 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -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);