reftest-compare: Treat colour channels as undefined if alpha is zero
authorSimon McVittie <smcv@debian.org>
Thu, 2 Sep 2021 21:34:14 +0000 (22:34 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 31 Oct 2021 21:52:04 +0000 (17:52 -0400)
If the alpha channel is zero, it doesn't matter what the values of the
red, green and blue channels are: the pixel is still fully transparent.
On most architectures, fully transparent pixels end up all-zeroes
(fully transparent black), matching what's in the reference PNG file;
but on mips*el the blend-difference and blend-normal tests get all-ones
(fully transparent white) and a test failure.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/4227
Signed-off-by: Simon McVittie <smcv@debian.org>
testsuite/reftests/reftest-compare.c

index 5c682e1591bf138c8f1a5278f9f5a9c92ef31bae..5bccb697b8aaefd7efdc04555d69f55fb4dc1a25 100644 (file)
@@ -104,7 +104,12 @@ buffer_diff_core (const guchar *buf_a,
           /* check if the pixels are the same */
           if (row_a[x] == row_b[x])
             continue;
-        
+
+          /* even if they're not literally the same, fully-transparent
+           * pixels are effectively the same regardless of colour */
+          if ((row_a[x] & 0xff000000) == 0 && (row_b[x] & 0xff000000) == 0)
+            continue;
+
           if (diff == NULL)
             {
               diff = cairo_image_surface_create (CAIRO_FORMAT_RGB24,