6830714: cmm test failures with OpenJDK
authorbae
Fri, 07 Jun 2013 14:45:29 +0400
changeset 18114 8b16a9643b24
parent 18113 acd987685b67
child 18115 dbd9791b69d2
6830714: cmm test failures with OpenJDK Reviewed-by: prr
jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java
jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvDCMTest.java
jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvTest.java
--- a/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java	Thu Jun 06 13:57:25 2013 +0400
+++ b/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java	Fri Jun 07 14:45:29 2013 +0400
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 6476665 7033534
+ * @bug 6476665 7033534 6830714
  * @summary Verifies color conversion of Component Color Model based images
  * @run main ColConvCCMTest
  */
@@ -57,9 +57,9 @@
     final static double [] ACCURACY = {
     // Accuracy for color conversions
         2.5,        // sRGB
-        6.5,        // LINEAR_RGB
+        (isOpenProfile() ? 45.0 : 10.1), // LINEAR_RGB
         10.5,       // GRAY
-        45.5,       // PYCC
+        (isOpenProfile() ? 207 : 45.5), // PYCC
         47.5        // CIEXYZ
     };
 
--- a/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvDCMTest.java	Thu Jun 06 13:57:25 2013 +0400
+++ b/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvDCMTest.java	Fri Jun 07 14:45:29 2013 +0400
@@ -62,7 +62,11 @@
         ColorSpace.CS_LINEAR_RGB,
     };
 
-    final static double ACCURACY = 2.5;
+    final static double [] ACCURACY = {
+        // Accuracy for color conversions
+        2.5, // sRGB
+        (isOpenProfile() ? 45.0 : 2.5), // LINEAR_RGB
+    };
 
     final static String [] gldImgNames = {
         "SRGB.png", "SRGB555.png", "SRGB565.png", "LRGB.png", "LRGB555.png",
@@ -142,7 +146,7 @@
 
             if (!testImage(imgTypes[i][0], imgTypes[i][1], imgTypes[i][2],
                            imgTypes[i][3], cSpaces[imgTypes[i][4]], gldImage,
-                           ACCURACY))
+                           ACCURACY[imgTypes[i][4]]))
             {
                 throw new RuntimeException(
                     "Invalid result of the ColorConvertOp for " +
@@ -154,7 +158,8 @@
 
             if (!testSubImage(SI_X, SI_Y, SI_W, SI_H, imgTypes[i][0],
                               imgTypes[i][1], imgTypes[i][2], imgTypes[i][3],
-                              cSpaces[imgTypes[i][4]], gldImage, ACCURACY))
+                              cSpaces[imgTypes[i][4]], gldImage,
+                              ACCURACY[imgTypes[i][4]]))
             {
                 throw new RuntimeException(
                     "Invalid result of the ColorConvertOp for " +
--- a/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvTest.java	Thu Jun 06 13:57:25 2013 +0400
+++ b/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvTest.java	Fri Jun 07 14:45:29 2013 +0400
@@ -22,6 +22,7 @@
  */
 
 import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
 import java.awt.image.BufferedImage;
 import java.awt.image.DataBuffer;
 
@@ -126,4 +127,33 @@
     public boolean isPassed() {
         return passed;
     }
+
+    private static Boolean isOpenProfile = null;
+
+    public static boolean isOpenProfile() {
+        if (isOpenProfile == null) {
+            ICC_Profile p = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
+
+            byte[] h = p.getData(ICC_Profile.icSigHead);
+
+            if (h == null || h.length < 128) {
+                throw new RuntimeException("Test failed: invalid sRGB header");
+            }
+
+            final byte[] lcmsID = new byte[] {
+                (byte)0x6c, // l
+                (byte)0x63, // c
+                (byte)0x6d, // m
+                (byte)0x73, // s
+            };
+
+            int off = ICC_Profile.icHdrCmmId;
+
+            isOpenProfile = ((h[off + 0] == lcmsID[0])
+                    && (h[off + 1] == lcmsID[1])
+                    && (h[off + 2] == lcmsID[2])
+                    && (h[off + 3] == lcmsID[3]));
+        }
+        return isOpenProfile;
+    }
 }