File: wayland-Invert-flipped-transforms.patch

package info (click to toggle)
gtk4 4.20.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 180,184 kB
  • sloc: ansic: 778,064; xml: 3,092; javascript: 3,054; python: 1,911; java: 752; sh: 682; makefile: 314; perl: 162; cpp: 21
file content (62 lines) | stat: -rw-r--r-- 2,326 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 11 Sep 2025 13:04:42 +0200
Subject: wayland: Invert flipped transforms

So the visual results match when running with and without
GDK_DISABLE=offload. The comment above already hinted in this direction,
without being matched by the code - it looks like GdkDihedral applies
flips and rotations in the inverse manner.

This came up when testing the upcoming versions of Snapshot, GTK and the
gtk4paintablesink on mobile phones using the libcamera software ISP. In
this scenario there are usually two cameras, both 90 or 270 degree
rotated - and the front one will get an additional flip in order to
create a "mirror" effect. The recent improvements to the mentioned
components resulted in offloading now being used by default (the
software ISP generates RGB buffers - thus unlike for YUV formats
GDK_DEBUG=color-mgmt is not required for offloading).

Part-of: <https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/8931>
(cherry picked from commit a7f2d9b2b05ae5e702a7664b180d20f1be163b1b)

Origin: upstream, after 4.20.1
---
 gdk/wayland/gdksubsurface-wayland.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/gdk/wayland/gdksubsurface-wayland.c b/gdk/wayland/gdksubsurface-wayland.c
index b49dd9f..b8f5f98 100644
--- a/gdk/wayland/gdksubsurface-wayland.c
+++ b/gdk/wayland/gdksubsurface-wayland.c
@@ -47,13 +47,29 @@
 static inline enum wl_output_transform
 gdk_texture_transform_to_wl (GdkDihedral transform)
 {
-  return (enum wl_output_transform) transform;
+  enum wl_output_transform tf;
+
+  if (transform == GDK_DIHEDRAL_FLIPPED_90)
+    tf = WL_OUTPUT_TRANSFORM_FLIPPED_270;
+  else if (transform == GDK_DIHEDRAL_FLIPPED_270)
+    tf = WL_OUTPUT_TRANSFORM_FLIPPED_90;
+  else
+    tf = (enum wl_output_transform) transform;
+  return tf;
 }
 
 static inline GdkDihedral
 wl_output_transform_to_gdk (enum wl_output_transform transform)
 {
-  return (GdkDihedral) transform;
+  GdkDihedral tf;
+
+  if (transform == WL_OUTPUT_TRANSFORM_FLIPPED_90)
+    tf = GDK_DIHEDRAL_FLIPPED_270;
+  else if (transform == WL_OUTPUT_TRANSFORM_FLIPPED_270)
+    tf = GDK_DIHEDRAL_FLIPPED_90;
+  else
+    tf = (GdkDihedral) transform;
+  return tf;
 }
 
 G_STATIC_ASSERT ((int) WL_OUTPUT_TRANSFORM_NORMAL == (int) GDK_DIHEDRAL_NORMAL);