auto merge of #1570 : larsbergstrom/servo/reftest_better, r=metajack

Previously, small errors were very hard to see because they would only have a value that was off by a few points from solid white. Now, they will show up vibrantly!

I considered reconstructing the pixels and using either black/white or a scaling "red" but in practice this gives good results on a wide variety of errors and has the bonus that if you've got chroma-power you can tell if there's an R, G, or B error :-)

r? @metajack
This commit is contained in:
bors-servo 2014-01-27 13:46:59 -08:00
commit fa02b82b88

View file

@ -14,7 +14,6 @@ extern mod std;
use std::io;
use std::io::{File, Reader};
use std::io::process::ExitStatus;
use std::num::abs;
use std::os;
use std::run::{Process, ProcessOptions};
use std::str;
@ -139,9 +138,16 @@ fn check_reftest(reftest: Reftest) {
let right = png::load_png(&from_str::<Path>(right_filename).unwrap()).unwrap();
let pixels: ~[u8] = left.pixels.iter().zip(right.pixels.iter()).map(|(&a, &b)| {
let a_signed = a as i8;
let b_signed = b as i8;
255-abs(a_signed - b_signed) as u8
if (a as i8 - b as i8 == 0) {
// White for correct
0xFF
} else {
// "1100" in the RGBA channel with an error for an incorrect value
// This results in some number of C0 and FFs, which is much more
// readable (and distinguishable) than the previous difference-wise
// scaling but does not require reconstructing the actual RGBA pixel.
0xC0
}
}).collect();
if pixels.iter().any(|&a| a < 255) {