0N/A/*
2362N/A * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.cmm;
0N/A
987N/Aimport java.awt.color.ProfileDataException;
0N/Aimport java.util.Vector;
0N/A
0N/A
0N/A/**
0N/A * A class to manage the deferral of CMM initialization of profile
0N/A * data for internal ICC_Profile objects - i.e. when we "trust" that
0N/A * the profile data is valid and we think it may not be needed. An
0N/A * example is the sRGB profile which gets loaded by any program doing
0N/A * graphics, but which may not be needed if the program does not need
0N/A * high quality color conversion.
0N/A */
0N/Apublic class ProfileDeferralMgr {
0N/A
0N/A public static boolean deferring = true;
987N/A private static Vector<ProfileActivator> aVector;
0N/A
0N/A /**
0N/A * Records a ProfileActivator object whose activate method will
0N/A * be called if the CMM needs to be activated.
0N/A */
0N/A public static void registerDeferral(ProfileActivator pa) {
0N/A
0N/A if (!deferring) {
0N/A return;
0N/A }
0N/A if (aVector == null) {
987N/A aVector = new Vector<ProfileActivator>(3, 3);
0N/A }
0N/A aVector.addElement(pa);
0N/A return;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Removes a ProfileActivator object from the vector of ProfileActivator
0N/A * objects whose activate method will be called if the CMM needs to be
0N/A * activated.
0N/A */
0N/A public static void unregisterDeferral(ProfileActivator pa) {
0N/A
0N/A if (!deferring) {
0N/A return;
0N/A }
0N/A if (aVector == null) {
0N/A return;
0N/A }
0N/A aVector.removeElement(pa);
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Removes a ProfileActivator object from the vector of ProfileActivator
0N/A * objects whose activate method will be called if the CMM needs to be
0N/A * activated.
0N/A */
0N/A public static void activateProfiles() {
0N/A
0N/A int i, n;
0N/A
0N/A deferring = false;
0N/A if (aVector == null) {
0N/A return;
0N/A }
0N/A n = aVector.size();
987N/A for (ProfileActivator pa : aVector) {
987N/A try {
987N/A pa.activate();
987N/A } catch (ProfileDataException e) {
987N/A /*
987N/A * Ignore profile activation error for now:
987N/A * such exception is pssible due to absence
987N/A * or corruption of standard color profile.
987N/A * As for now we expect all profiles should
987N/A * be shiped with jre and presence of this
987N/A * exception is indication of some configuration
987N/A * problem in jre installation.
987N/A *
987N/A * NB: we still are greedy loading deferred profiles
987N/A * and load them all if any of them is needed.
987N/A * Therefore broken profile (if any) might be never used.
987N/A * If there will be attempt to use broken profile then
987N/A * it will result in CMMException.
987N/A */
987N/A }
0N/A }
0N/A aVector.removeAllElements();
0N/A aVector = null;
0N/A return;
0N/A }
0N/A
0N/A}