Path: blob/master/src/java.desktop/share/classes/sun/java2d/SurfaceManagerFactory.java
41152 views
/*1* Copyright (c) 2003, 2008, 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;2627import sun.awt.image.SunVolatileImage;28import sun.awt.image.VolatileSurfaceManager;2930/**31* This factory creates platform specific VolatileSurfaceManager32* implementations.33*34* There are two platform specific SurfaceManagerFactories in OpenJDK,35* UnixSurfaceManagerFactory and WindowsSurfaceManagerFactory.36* The actually used SurfaceManagerFactory is set by the respective platform37* GraphicsEnvironment implementations in the static initializer.38*/39public abstract class SurfaceManagerFactory {4041/**42* The single shared instance.43*/44private static SurfaceManagerFactory instance;4546/**47* Returns the surface manager factory instance. This returns a factory48* that has been set by {@link #setInstance(SurfaceManagerFactory)}.49*50* @return the surface manager factory51*/52public static synchronized SurfaceManagerFactory getInstance() {5354if (instance == null) {55throw new IllegalStateException("No SurfaceManagerFactory set.");56}57return instance;58}5960/**61* Sets the surface manager factory. This may only be called once, and it62* may not be set back to {@code null} when the factory is already63* instantiated.64*65* @param factory the factory to set66*/67public static synchronized void setInstance(SurfaceManagerFactory factory) {6869if (factory == null) {70// We don't want to allow setting this to null at any time.71throw new IllegalArgumentException("factory must be non-null");72}7374if (instance != null) {75// We don't want to re-set the instance at any time.76throw new IllegalStateException("The surface manager factory is already initialized");77}7879instance = factory;80}8182/**83* Creates a new instance of a VolatileSurfaceManager given any84* arbitrary SunVolatileImage. An optional context Object can be supplied85* as a way for the caller to pass pipeline-specific context data to86* the VolatileSurfaceManager (such as a backbuffer handle, for example).87*/88public abstract VolatileSurfaceManager89createVolatileManager(SunVolatileImage image, Object context);90}919293