History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/java2d/cmm/ProfileDeferralMgr.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/java2d/cmm/ProfileDeferralMgr.java+119−0
@@ -0,0 +1,119 @@
1/*
2 * Copyright (c) 1998, 2006, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package sun.java2d.cmm;
27
28import java.awt.color.ProfileDataException;
29import java.util.Vector;
30
31
32/**
33 * A class to manage the deferral of CMM initialization of profile
34 * data for internal ICC_Profile objects - i.e. when we "trust" that
35 * the profile data is valid and we think it may not be needed. An
36 * example is the sRGB profile which gets loaded by any program doing
37 * graphics, but which may not be needed if the program does not need
38 * high quality color conversion.
39 */
40public class ProfileDeferralMgr {
41
42 public static boolean deferring = true;
43 private static Vector<ProfileActivator> aVector;
44
45 /**
46 * Records a ProfileActivator object whose activate method will
47 * be called if the CMM needs to be activated.
48 */
49 public static void registerDeferral(ProfileActivator pa) {
50
51 if (!deferring) {
52 return;
53 }
54 if (aVector == null) {
55 aVector = new Vector<ProfileActivator>(3, 3);
56 }
57 aVector.addElement(pa);
58 return;
59 }
60
61
62 /**
63 * Removes a ProfileActivator object from the vector of ProfileActivator
64 * objects whose activate method will be called if the CMM needs to be
65 * activated.
66 */
67 public static void unregisterDeferral(ProfileActivator pa) {
68
69 if (!deferring) {
70 return;
71 }
72 if (aVector == null) {
73 return;
74 }
75 aVector.removeElement(pa);
76 return;
77 }
78
79 /**
80 * Removes a ProfileActivator object from the vector of ProfileActivator
81 * objects whose activate method will be called if the CMM needs to be
82 * activated.
83 */
84 public static void activateProfiles() {
85
86 int i, n;
87
88 deferring = false;
89 if (aVector == null) {
90 return;
91 }
92 n = aVector.size();
93 for (ProfileActivator pa : aVector) {
94 try {
95 pa.activate();
96 } catch (ProfileDataException e) {
97 /*
98 * Ignore profile activation error for now:
99 * such exception is pssible due to absence
100 * or corruption of standard color profile.
101 * As for now we expect all profiles should
102 * be shiped with jre and presence of this
103 * exception is indication of some configuration
104 * problem in jre installation.
105 *
106 * NB: we still are greedy loading deferred profiles
107 * and load them all if any of them is needed.
108 * Therefore broken profile (if any) might be never used.
109 * If there will be attempt to use broken profile then
110 * it will result in CMMException.
111 */
112 }
113 }
114 aVector.removeAllElements();
115 aVector = null;
116 return;
117 }
118
119}