<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - test/cairo-test-suite reports wrong max diff comparing different opaque images"
href="https://bugs.freedesktop.org/show_bug.cgi?id=84044#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - test/cairo-test-suite reports wrong max diff comparing different opaque images"
href="https://bugs.freedesktop.org/show_bug.cgi?id=84044">bug 84044</a>
from <span class="vcard"><a class="email" href="mailto:psychon@znc.in" title="Uli Schlachter <psychon@znc.in>"> <span class="fn">Uli Schlachter</span></a>
</span></b>
<pre>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
ARGB32.
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 }
182
183 static unsigned char
184 _get_red (const uint32_t *data, int i)
185 {
186 uint32_t pixel;
187 uint8_t alpha;
188
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....?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>