6976076: sun/java2d/pipe/MutableColorTest/MutableColorTest.java failed
Reviewed-by: igor, prr
--- a/jdk/test/sun/java2d/pipe/MutableColorTest/MutableColorTest.java Sat Oct 02 12:41:20 2010 +0400
+++ b/jdk/test/sun/java2d/pipe/MutableColorTest/MutableColorTest.java Tue Oct 05 10:23:14 2010 +0400
@@ -105,7 +105,7 @@
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 @@
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;
+ }
}