Skip to content

Commit a6c0881

Browse files
committed
8256321: Some "inactive" color profiles use the wrong profile class
Reviewed-by: prr
1 parent 9f15164 commit a6c0881

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed

src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ public static ICC_Profile getInstance (int cspace) {
857857
ProfileDeferralInfo pInfo =
858858
new ProfileDeferralInfo("CIEXYZ.pf",
859859
ColorSpace.TYPE_XYZ, 3,
860-
CLASS_DISPLAY);
860+
CLASS_ABSTRACT);
861861
XYZprofile = getDeferredInstance(pInfo);
862862
}
863863
thisProfile = XYZprofile;
@@ -871,7 +871,7 @@ public static ICC_Profile getInstance (int cspace) {
871871
ProfileDeferralInfo pInfo =
872872
new ProfileDeferralInfo("PYCC.pf",
873873
ColorSpace.TYPE_3CLR, 3,
874-
CLASS_DISPLAY);
874+
CLASS_COLORSPACECONVERSION);
875875
PYCCprofile = getDeferredInstance(pInfo);
876876
}
877877
thisProfile = PYCCprofile;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.awt.color.ColorSpace;
25+
import java.awt.color.ICC_Profile;
26+
27+
import static java.awt.color.ColorSpace.TYPE_3CLR;
28+
import static java.awt.color.ColorSpace.TYPE_GRAY;
29+
import static java.awt.color.ColorSpace.TYPE_RGB;
30+
import static java.awt.color.ColorSpace.TYPE_XYZ;
31+
import static java.awt.color.ICC_Profile.CLASS_ABSTRACT;
32+
import static java.awt.color.ICC_Profile.CLASS_COLORSPACECONVERSION;
33+
import static java.awt.color.ICC_Profile.CLASS_DISPLAY;
34+
35+
/**
36+
* @test
37+
* @bug 8256321
38+
* @summary Verifies profile properties are the same before/after activation
39+
*/
40+
public final class CheckDefaultProperties {
41+
42+
public static void main(String[] args) {
43+
ICC_Profile srgb = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
44+
ICC_Profile gray = ICC_Profile.getInstance(ColorSpace.CS_GRAY);
45+
ICC_Profile xyz = ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ);
46+
ICC_Profile lrgb = ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB);
47+
ICC_Profile pycc = ICC_Profile.getInstance(ColorSpace.CS_PYCC);
48+
49+
// check default values, before profile activation
50+
test(srgb, TYPE_RGB, 3, CLASS_DISPLAY);
51+
test(gray, TYPE_GRAY, 1, CLASS_DISPLAY);
52+
test(xyz, TYPE_XYZ, 3, CLASS_ABSTRACT);
53+
test(lrgb, TYPE_RGB, 3, CLASS_DISPLAY);
54+
test(pycc, TYPE_3CLR, 3, CLASS_COLORSPACECONVERSION);
55+
56+
// activate profiles
57+
srgb.getData();
58+
gray.getData();
59+
xyz.getData();
60+
lrgb.getData();
61+
pycc.getData();
62+
63+
// check default values, after profile activation
64+
test(srgb, TYPE_RGB, 3, CLASS_DISPLAY);
65+
test(gray, TYPE_GRAY, 1, CLASS_DISPLAY);
66+
test(xyz, TYPE_XYZ, 3, CLASS_ABSTRACT);
67+
test(lrgb, TYPE_RGB, 3, CLASS_DISPLAY);
68+
test(pycc, TYPE_3CLR, 3, CLASS_COLORSPACECONVERSION);
69+
}
70+
71+
private static void test(ICC_Profile profile, int type, int num, int pcls) {
72+
int profileClass = profile.getProfileClass();
73+
int colorSpaceType = profile.getColorSpaceType();
74+
int numComponents = profile.getNumComponents();
75+
if (profileClass != pcls) {
76+
throw new RuntimeException("Wrong profile class: " + profileClass);
77+
}
78+
if (colorSpaceType != type) {
79+
throw new RuntimeException("Wrong profile type: " + colorSpaceType);
80+
}
81+
if (numComponents != num) {
82+
throw new RuntimeException("Wrong profile comps: " + numComponents);
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)