src/java.desktop/share/classes/sun/java2d/SurfaceManagerFactory.java

Print this page




  33  * implementations.
  34  *
  35  * There are two platform specific SurfaceManagerFactories in OpenJDK,
  36  * UnixSurfaceManagerFactory and WindowsSurfaceManagerFactory.
  37  * The actually used SurfaceManagerFactory is set by the respective platform
  38  * GraphicsEnvironment implementations in the static initializer.
  39  */
  40 public abstract class SurfaceManagerFactory {
  41 
  42     /**
  43      * The single shared instance.
  44      */
  45     private static SurfaceManagerFactory instance;
  46 
  47     /**
  48      * Returns the surface manager factory instance. This returns a factory
  49      * that has been set by {@link #setInstance(SurfaceManagerFactory)}.
  50      *
  51      * @return the surface manager factory
  52      */
  53     public synchronized static SurfaceManagerFactory getInstance() {
  54 
  55         if (instance == null) {
  56             throw new IllegalStateException("No SurfaceManagerFactory set.");
  57         }
  58         return instance;
  59     }
  60 
  61     /**
  62      * Sets the surface manager factory. This may only be called once, and it
  63      * may not be set back to {@code null} when the factory is already
  64      * instantiated.
  65      *
  66      * @param factory the factory to set
  67      */
  68     public synchronized static void setInstance(SurfaceManagerFactory factory) {
  69 
  70         if (factory == null) {
  71             // We don't want to allow setting this to null at any time.
  72             throw new IllegalArgumentException("factory must be non-null");
  73         }
  74 
  75         if (instance != null) {
  76             // We don't want to re-set the instance at any time.
  77             throw new IllegalStateException("The surface manager factory is already initialized");
  78         }
  79 
  80         instance = factory;
  81     }
  82 
  83     /**
  84      * Creates a new instance of a VolatileSurfaceManager given any
  85      * arbitrary SunVolatileImage.  An optional context Object can be supplied
  86      * as a way for the caller to pass pipeline-specific context data to
  87      * the VolatileSurfaceManager (such as a backbuffer handle, for example).
  88      */


  33  * implementations.
  34  *
  35  * There are two platform specific SurfaceManagerFactories in OpenJDK,
  36  * UnixSurfaceManagerFactory and WindowsSurfaceManagerFactory.
  37  * The actually used SurfaceManagerFactory is set by the respective platform
  38  * GraphicsEnvironment implementations in the static initializer.
  39  */
  40 public abstract class SurfaceManagerFactory {
  41 
  42     /**
  43      * The single shared instance.
  44      */
  45     private static SurfaceManagerFactory instance;
  46 
  47     /**
  48      * Returns the surface manager factory instance. This returns a factory
  49      * that has been set by {@link #setInstance(SurfaceManagerFactory)}.
  50      *
  51      * @return the surface manager factory
  52      */
  53     public static synchronized SurfaceManagerFactory getInstance() {
  54 
  55         if (instance == null) {
  56             throw new IllegalStateException("No SurfaceManagerFactory set.");
  57         }
  58         return instance;
  59     }
  60 
  61     /**
  62      * Sets the surface manager factory. This may only be called once, and it
  63      * may not be set back to {@code null} when the factory is already
  64      * instantiated.
  65      *
  66      * @param factory the factory to set
  67      */
  68     public static synchronized void setInstance(SurfaceManagerFactory factory) {
  69 
  70         if (factory == null) {
  71             // We don't want to allow setting this to null at any time.
  72             throw new IllegalArgumentException("factory must be non-null");
  73         }
  74 
  75         if (instance != null) {
  76             // We don't want to re-set the instance at any time.
  77             throw new IllegalStateException("The surface manager factory is already initialized");
  78         }
  79 
  80         instance = factory;
  81     }
  82 
  83     /**
  84      * Creates a new instance of a VolatileSurfaceManager given any
  85      * arbitrary SunVolatileImage.  An optional context Object can be supplied
  86      * as a way for the caller to pass pipeline-specific context data to
  87      * the VolatileSurfaceManager (such as a backbuffer handle, for example).
  88      */