6976076: sun/java2d/pipe/MutableColorTest/MutableColorTest.java failed

Reviewed-by: igor, prr
This commit is contained in:
Andrew Brygin 2010-10-05 10:23:14 +04:00
parent c299b2e4c0
commit 014b414926

View File

@ -105,7 +105,7 @@ public class MutableColorTest {
for (int y = 0; y < snapshot.getHeight(); y++) {
for (int x = 0; x < snapshot.getWidth(); x++) {
int snapRGB = snapshot.getRGB(x, y);
if (snapRGB != evilColor) {
if (!isSameColor(snapRGB, evilColor)) {
System.err.printf("Wrong RGB for %s at (%d,%d): 0x%x " +
"instead of 0x%x\n", desc, x, y, snapRGB, evilColor);
String fileName = "MutableColorTest_"+desc+".png";
@ -166,4 +166,24 @@ public class MutableColorTest {
System.err.println("Test passed.");
}
/*
* We assume that colors with slightly different components
* are the same. This is done just in order to workaround
* peculiarities of OGL rendering pipeline on some platforms.
* See CR 6989217 for more details.
*/
private static boolean isSameColor(int color1, int color2) {
final int tolerance = 2;
for (int i = 0; i < 32; i += 8) {
int c1 = 0xff & (color1 >> i);
int c2 = 0xff & (color2 >> i);
if (Math.abs(c1 - c2) > tolerance) {
return false;
}
}
return true;
}
}