mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Fix alpha channel checking in RGBGFX test driver
Compare CGB colors only, including ignoring RGB components if alpha says the color is transparent
This commit is contained in:
@@ -359,17 +359,21 @@ int main(int argc, char **argv) {
|
|||||||
Rgba px0 = image0.pixel(x, y);
|
Rgba px0 = image0.pixel(x, y);
|
||||||
Rgba px1 = image1.pixel(x, y);
|
Rgba px1 = image1.pixel(x, y);
|
||||||
|
|
||||||
#define compare(WHAT, NAME) \
|
auto cgbColor = [](Rgba const &rgba) {
|
||||||
if (px0.WHAT >> 3 != px1.WHAT >> 3) { \
|
auto field = [](uint16_t component, uint8_t shift) {
|
||||||
error(NAME " component at (%" PRIu32 ", %" PRIu32 \
|
return (component & 0x1F) << shift;
|
||||||
") does not match (source = %u, result = %u)", \
|
};
|
||||||
x, y, px0.WHAT >> 3, px1.WHAT >> 3); \
|
return rgba.isTransparent()
|
||||||
|
? Rgba::transparent
|
||||||
|
: field(rgba.red, 0) | field(rgba.green, 5) | field(rgba.blue, 10);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cgbColor(px0) != cgbColor(px1)) {
|
||||||
|
error("Color mismatch at (%" PRIu32 ", %" PRIu32
|
||||||
|
"): (%u,%u,%u,%u) became (%u,%u,%u,%u) after round-tripping",
|
||||||
|
x, y, px0.red, px0.green, px0.blue, px0.alpha, px1.red, px1.green, px1.blue,
|
||||||
|
px1.alpha);
|
||||||
}
|
}
|
||||||
compare(red, "Red");
|
|
||||||
compare(green, "Green");
|
|
||||||
compare(blue, "Blue");
|
|
||||||
compare(alpha, "Alpha");
|
|
||||||
#undef compare
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user