Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java
38918 views
/*1* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.java2d.cmm;2627import java.awt.color.ProfileDataException;28import java.util.Vector;293031/**32* A class to manage the deferral of CMM initialization of profile33* data for internal ICC_Profile objects - i.e. when we "trust" that34* the profile data is valid and we think it may not be needed. An35* example is the sRGB profile which gets loaded by any program doing36* graphics, but which may not be needed if the program does not need37* high quality color conversion.38*/39public class ProfileDeferralMgr {4041public static boolean deferring = true;42private static Vector<ProfileActivator> aVector;4344/**45* Records a ProfileActivator object whose activate method will46* be called if the CMM needs to be activated.47*/48public static void registerDeferral(ProfileActivator pa) {4950if (!deferring) {51return;52}53if (aVector == null) {54aVector = new Vector<ProfileActivator>(3, 3);55}56aVector.addElement(pa);57return;58}596061/**62* Removes a ProfileActivator object from the vector of ProfileActivator63* objects whose activate method will be called if the CMM needs to be64* activated.65*/66public static void unregisterDeferral(ProfileActivator pa) {6768if (!deferring) {69return;70}71if (aVector == null) {72return;73}74aVector.removeElement(pa);75return;76}7778/**79* Removes a ProfileActivator object from the vector of ProfileActivator80* objects whose activate method will be called if the CMM needs to be81* activated.82*/83public static void activateProfiles() {8485int i, n;8687deferring = false;88if (aVector == null) {89return;90}91n = aVector.size();92for (ProfileActivator pa : aVector) {93try {94pa.activate();95} catch (ProfileDataException e) {96/*97* Ignore profile activation error for now:98* such exception is pssible due to absence99* or corruption of standard color profile.100* As for now we expect all profiles should101* be shiped with jre and presence of this102* exception is indication of some configuration103* problem in jre installation.104*105* NB: we still are greedy loading deferred profiles106* and load them all if any of them is needed.107* Therefore broken profile (if any) might be never used.108* If there will be attempt to use broken profile then109* it will result in CMMException.110*/111}112}113aVector.removeAllElements();114aVector = null;115return;116}117118}119120121