Add proposed patch to fix FTBFS on s390x
authorSimon McVittie <smcv@debian.org>
Sat, 8 Jan 2022 17:21:35 +0000 (17:21 +0000)
committerSimon McVittie <smcv@debian.org>
Sat, 8 Jan 2022 17:21:35 +0000 (17:21 +0000)
debian/patches/png-Correct-endianness-for-big-endian-machines.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/png-Correct-endianness-for-big-endian-machines.patch b/debian/patches/png-Correct-endianness-for-big-endian-machines.patch
new file mode 100644 (file)
index 0000000..8667082
--- /dev/null
@@ -0,0 +1,73 @@
+From: Simon McVittie <smcv@debian.org>
+Date: Sat, 8 Jan 2022 16:39:36 +0000
+Subject: png: Correct endianness for big-endian machines
+
+libpng wants to receive samples in either RGB or RGBA order, whether
+each sample is big-endian or not. This resolves test failures in
+testsuite/gdk/memorytexture.c (and a lot of reftests) on s390x, and
+probably the PowerPC family too.
+
+Modifying the test to show the color in use and write out the PNG bytes
+to a file, and running the memorytexture test on s390x, produces a PNG
+that loads with the correct color values in GIMP (on an x86_64 machine),
+which seems like evidence that this is the correct change and not just
+compensating errors.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/4616
+Signed-off-by: Simon McVittie <smcv@debian.org>
+Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4357
+---
+ gdk/loaders/gdkpng.c | 16 ----------------
+ 1 file changed, 16 deletions(-)
+
+diff --git a/gdk/loaders/gdkpng.c b/gdk/loaders/gdkpng.c
+index b998deb..2071121 100644
+--- a/gdk/loaders/gdkpng.c
++++ b/gdk/loaders/gdkpng.c
+@@ -222,11 +222,7 @@ gdk_load_png (GBytes  *bytes,
+     case PNG_COLOR_TYPE_RGB_ALPHA:
+       if (depth == 8)
+         {
+-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+           format = GDK_MEMORY_R8G8B8A8;
+-#elif G_BYTE_ORDER == G_BIG_ENDIAN
+-          format = GDK_MEMORY_A8B8G8R8;
+-#endif
+         }
+       else
+         {
+@@ -236,11 +232,7 @@ gdk_load_png (GBytes  *bytes,
+     case PNG_COLOR_TYPE_RGB:
+       if (depth == 8)
+         {
+-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+           format = GDK_MEMORY_R8G8B8;
+-#elif G_BYTE_ORDER == G_BIG_ENDIAN
+-          format = GDK_MEMORY_B8G8R8;
+-#endif
+         }
+       else if (depth == 16)
+         {
+@@ -325,22 +317,14 @@ gdk_save_png (GdkTexture *texture)
+     case GDK_MEMORY_A8R8G8B8:
+     case GDK_MEMORY_R8G8B8A8:
+     case GDK_MEMORY_A8B8G8R8:
+-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+       format = GDK_MEMORY_R8G8B8A8;
+-#elif G_BYTE_ORDER == G_BIG_ENDIAN
+-      format = GDK_MEMORY_A8B8G8R8;
+-#endif
+       png_format = PNG_COLOR_TYPE_RGB_ALPHA;
+       depth = 8;
+       break;
+     case GDK_MEMORY_R8G8B8:
+     case GDK_MEMORY_B8G8R8:
+-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+       format = GDK_MEMORY_R8G8B8;
+-#elif G_BYTE_ORDER == G_BIG_ENDIAN
+-      format = GDK_MEMORY_B8G8R8;
+-#endif
+       png_format = PNG_COLOR_TYPE_RGB;
+       depth = 8;
+       break;
index 9e99e854194f6b7ca6da8e524c8a6f5eb9459211..ab7f10027c002afa9be92d1b88186bcdb74c0cdf 100644 (file)
@@ -1,5 +1,6 @@
 Make-our-stack-noexec.patch
 build-Tell-glib-compile-resources-to-make-symbols-interna.patch
+png-Correct-endianness-for-big-endian-machines.patch
 reftest_compare_surfaces-Report-how-much-the-images-diffe.patch
 reftests-Allow-minor-differences-to-be-tolerated.patch
 debian/Disable-web-fonts-for-now.patch