[cairo-bugs] [Bug 84044] test/cairo-test-suite reports wrong max diff comparing different opaque images

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Oct 3 11:35:09 PDT 2014


--- Comment #2 from Uli Schlachter <psychon at znc.in> ---
Isn't the bug here really in the code that compares the images?

You are blaming test/buffer-diff.c line 80 which is:

   if ((row_a[x] & mask) != (row_b[x] & mask))

However, this mask value is set by the caller to either 0xffffffff or
0x00ffffff, depending on if the image has an alpha channel. In other words,
this code correctly ignores the unused byte in RGB24 images.

The bug really is in test/pdiff/pdiff.c, function pdiff_compare(). This
function does NOT do something like "cairo_surface_get_content (surface_a) &
CAIRO_CONTENT_ALPHA ?  0xffffffff : 0x00ffffff" and treats all images as

This functions uses _get_red() etc to extract colors from the image:

 177 static uint32_t
 178 _get_pixel (const uint32_t *data, int i)
 179 {
 180     return data[i];
 181 }
 183 static unsigned char
 184 _get_red (const uint32_t *data, int i)                                     
 185 {
 186     uint32_t pixel;
 187     uint8_t alpha;
 189     pixel = _get_pixel (data, i);
 190     alpha = (pixel & 0xff000000) >> 24;
 191     if (alpha == 0)
 192         return 0;
 193     else
 194         return (((pixel & 0x00ff0000) >> 16) * 255 + alpha / 2) / alpha;
 195 }

So the real bug is in this code. No idea how it can be easily fixed. An ugly
work around would be to copy the images in case they aren't format ARGB32 yet
via cairo so that cairo makes sure the alpha channel is set to 0xff....?

You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo-bugs/attachments/20141003/bba60edc/attachment.html>

More information about the cairo-bugs mailing list