changeset 2990:b96e6b8761bc

6976076: sun/java2d/pipe/MutableColorTest/MutableColorTest.java failed Reviewed-by: igor, prr
author bae
date Tue, 05 Oct 2010 10:23:14 +0400
parents 160f7ffc3d14
children 93d0daa9aa7a
files test/sun/java2d/pipe/MutableColorTest/MutableColorTest.java
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/java2d/pipe/MutableColorTest/MutableColorTest.java	Sat Oct 02 12:41:20 2010 +0400
+++ b/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;
+    }
 }