51
51
import java .util .StringTokenizer ;
52
52
53
53
import sun .awt .AWTAccessor ;
54
+ import sun .java2d .cmm .BuiltinProfileInfo ;
54
55
import sun .java2d .cmm .CMSManager ;
55
56
import sun .java2d .cmm .PCMM ;
56
57
import sun .java2d .cmm .Profile ;
57
58
import sun .java2d .cmm .ProfileDataVerifier ;
58
- import sun .java2d .cmm .ProfileDeferralInfo ;
59
59
60
60
import static sun .java2d .cmm .ProfileDataVerifier .HEADER_SIZE ;
61
61
@@ -102,20 +102,11 @@ public sealed class ICC_Profile implements Serializable
102
102
private transient volatile Profile cmmProfile ;
103
103
104
104
/**
105
- * Stores some information about {@code ICC_Profile} without causing a
106
- * deferred profile to be loaded. Note that we can defer the loading of
107
- * standard profiles only. If this field is null, then {@link #cmmProfile}
108
- * should be used to access profile information.
105
+ * Stores information about a built-in profile without triggering profile
106
+ * loading. If this field is null, {@link #cmmProfile} should be used to
107
+ * access profile data. If not null, the profile is considered immutable.
109
108
*/
110
- private transient volatile ProfileDeferralInfo deferralInfo ;
111
-
112
-
113
- /**
114
- * Set to {@code true} for {@code BuiltInProfile}, {@code false} otherwise.
115
- * This flag is used in {@link #setData(int, byte[])} to prevent modifying
116
- * built-in profiles.
117
- */
118
- private final transient boolean builtIn ;
109
+ private transient final BuiltinProfileInfo builtInInfo ;
119
110
120
111
/**
121
112
* The lazy registry of singleton profile objects for specific built-in
@@ -124,22 +115,22 @@ public sealed class ICC_Profile implements Serializable
124
115
*/
125
116
private interface BuiltInProfile {
126
117
/*
127
- * ProfileDeferralInfo is used for built-in profile creation only,
118
+ * BuiltinProfileInfo is used for built-in profile creation only,
128
119
* and all built-in profiles should be constructed using it.
129
120
*/
130
- ICC_Profile SRGB = new ICC_ProfileRGB (new ProfileDeferralInfo (
121
+ ICC_Profile SRGB = new ICC_ProfileRGB (new BuiltinProfileInfo (
131
122
"sRGB.pf" , ColorSpace .TYPE_RGB , 3 , CLASS_DISPLAY ));
132
123
133
- ICC_Profile LRGB = new ICC_ProfileRGB (new ProfileDeferralInfo (
124
+ ICC_Profile LRGB = new ICC_ProfileRGB (new BuiltinProfileInfo (
134
125
"LINEAR_RGB.pf" , ColorSpace .TYPE_RGB , 3 , CLASS_DISPLAY ));
135
126
136
- ICC_Profile XYZ = new ICC_Profile (new ProfileDeferralInfo (
127
+ ICC_Profile XYZ = new ICC_Profile (new BuiltinProfileInfo (
137
128
"CIEXYZ.pf" , ColorSpace .TYPE_XYZ , 3 , CLASS_ABSTRACT ));
138
129
139
- ICC_Profile PYCC = new ICC_Profile (new ProfileDeferralInfo (
130
+ ICC_Profile PYCC = new ICC_Profile (new BuiltinProfileInfo (
140
131
"PYCC.pf" , ColorSpace .TYPE_3CLR , 3 , CLASS_COLORSPACECONVERSION ));
141
132
142
- ICC_Profile GRAY = new ICC_ProfileGray (new ProfileDeferralInfo (
133
+ ICC_Profile GRAY = new ICC_ProfileGray (new BuiltinProfileInfo (
143
134
"GRAY.pf" , ColorSpace .TYPE_GRAY , 1 , CLASS_DISPLAY ));
144
135
}
145
136
@@ -771,20 +762,19 @@ private interface BuiltInProfile {
771
762
*/
772
763
ICC_Profile (Profile p ) {
773
764
cmmProfile = p ;
774
- builtIn = false ;
765
+ builtInInfo = null ;
775
766
}
776
767
777
768
/**
778
769
* Constructs an {@code ICC_Profile} object whose loading will be deferred.
779
770
* The ID will be 0 until the profile is loaded.
780
771
*
781
772
* <p>
782
- * Note: {@code ProfileDeferralInfo } is used for built-in profile
773
+ * Note: {@code BuiltinProfileInfo } is used for built-in profile
783
774
* creation only, and all built-in profiles should be constructed using it.
784
775
*/
785
- ICC_Profile (ProfileDeferralInfo pdi ) {
786
- deferralInfo = pdi ;
787
- builtIn = true ;
776
+ ICC_Profile (BuiltinProfileInfo pdi ) {
777
+ builtInInfo = pdi ;
788
778
}
789
779
790
780
/**
@@ -934,16 +924,14 @@ private Profile cmmProfile() {
934
924
if (cmmProfile != null ) {
935
925
return cmmProfile ;
936
926
}
937
- var is = getStandardProfileInputStream (deferralInfo .filename );
927
+ var is = getStandardProfileInputStream (builtInInfo .filename );
938
928
if (is == null ) {
939
929
return null ;
940
930
}
941
931
try (is ) {
942
932
byte [] data = getProfileDataFromStream (is );
943
933
if (data != null ) {
944
934
p = cmmProfile = CMSManager .getModule ().loadProfile (data );
945
- // from now we cannot use the deferred value, drop it
946
- deferralInfo = null ;
947
935
}
948
936
} catch (CMMException | IOException ignore ) {
949
937
}
@@ -975,9 +963,8 @@ public int getMinorVersion() {
975
963
* @return one of the predefined profile class constants
976
964
*/
977
965
public int getProfileClass () {
978
- ProfileDeferralInfo info = deferralInfo ;
979
- if (info != null ) {
980
- return info .profileClass ;
966
+ if (builtInInfo != null ) {
967
+ return builtInInfo .profileClass ;
981
968
}
982
969
byte [] theHeader = getData (cmmProfile (), icSigHead );
983
970
return getProfileClass (theHeader );
@@ -1012,9 +999,8 @@ private static int getProfileClass(byte[] data) {
1012
999
* {@code ColorSpace} class
1013
1000
*/
1014
1001
public int getColorSpaceType () {
1015
- ProfileDeferralInfo info = deferralInfo ;
1016
- if (info != null ) {
1017
- return info .colorSpaceType ;
1002
+ if (builtInInfo != null ) {
1003
+ return builtInInfo .colorSpaceType ;
1018
1004
}
1019
1005
byte [] theHeader = getData (cmmProfile (), icSigHead );
1020
1006
return getColorSpaceType (theHeader );
@@ -1160,8 +1146,8 @@ static byte[] getData(Profile p, int tagSignature) {
1160
1146
* @see ColorSpace
1161
1147
*/
1162
1148
public void setData (int tagSignature , byte [] tagData ) {
1163
- if (builtIn ) {
1164
- throw new IllegalArgumentException ("Built -in profile cannot be modified " );
1149
+ if (builtInInfo != null ) {
1150
+ throw new IllegalArgumentException ("Can't modify built -in profile" );
1165
1151
}
1166
1152
1167
1153
if (tagSignature == ICC_Profile .icSigHead ) {
@@ -1205,9 +1191,8 @@ private static void checkRenderingIntent(byte[] data) {
1205
1191
* @throws ProfileDataException if color space is in the profile is invalid
1206
1192
*/
1207
1193
public int getNumComponents () {
1208
- ProfileDeferralInfo info = deferralInfo ;
1209
- if (info != null ) {
1210
- return info .numComponents ;
1194
+ if (builtInInfo != null ) {
1195
+ return builtInInfo .numComponents ;
1211
1196
}
1212
1197
byte [] theHeader = getData (cmmProfile (), icSigHead );
1213
1198
int theColorSpaceSig = intFromBigEndian (theHeader , icHdrColorSpace );
0 commit comments