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/SurfaceManagerFactory.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/java2d/SurfaceManagerFactory.java+91−0
@@ -0,0 +1,91 @@
1/*
2 * Copyright (c) 2003, 2008, 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;
27
28import sun.awt.image.SunVolatileImage;
29import sun.awt.image.VolatileSurfaceManager;
30
31/**
32 * This factory creates platform specific VolatileSurfaceManager
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 */
40public 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 */
89 public abstract VolatileSurfaceManager
90 createVolatileManager(SunVolatileImage image, Object context);
91}