Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / java / awt / BufferCapabilities.java
blobbba83dcb0d93c114fbdf5bb72683fbf447a34dbe
1 /* BufferCapabilities.java -- double-buffering capabilities descriptor
2 Copyright (C) 2002, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.awt;
41 import java.awt.image.BufferStrategy;
43 /**
44 * A double-buffering capability descriptor. This class exposes
45 * details about the double-buffering algorithms used by image
46 * buffers.
48 * BufferCapabilities represents algorithms that involve at least two
49 * buffers but it can also specify so-called "multi-buffer" schemes
50 * involving more than two buffers. This class describes the
51 * capabilities of the front and back buffers as well as the results
52 * of "flipping" -- that is, what happens when an image is transferred
53 * from the back buffer to the front buffer.
55 * Flipping may or may not be supported or may be supported only in
56 * fullscreen mode. If it is not supported then "blitting" is implied
57 * -- that is, the contents of the back buffer are copied using a fast
58 * block transfer operation from the back buffer to the front buffer.
60 * The front buffer is the one that is displayed.
62 * @author Eric Blake (ebb9@email.byu.edu)
64 * @see BufferStrategy#getCapabilities()
65 * @see GraphicsConfiguration#getBufferCapabilities()
67 * @since 1.4
69 public class BufferCapabilities implements Cloneable
71 /**
72 * A type-safe enumeration of buffer flipping results.
74 * @see AttributeValue
76 public static final class FlipContents extends AttributeValue
78 /**
79 * The names of the different flipping results.
81 private static final String[] NAMES
82 = { "undefined", "background", "prior", "copied" };
84 /**
85 * The contents of the back buffer are undefined after flipping.
87 public static final FlipContents UNDEFINED = new FlipContents(0);
89 /**
90 * The back buffer is cleared with the background color after
91 * flipping.
93 public static final FlipContents BACKGROUND = new FlipContents(1);
95 /**
96 * The back buffer contains the pre-flipping contents of the front
97 * buffer after flipping. In other words a true "flip" has been
98 * performed.
100 public static final FlipContents PRIOR = new FlipContents(2);
103 * The back buffer has the same contents as the front buffer after
104 * flipping.
106 public static final FlipContents COPIED = new FlipContents(3);
109 * Create a new flipping result descriptor.
111 * @param value the enumeration value
113 private FlipContents(int value)
115 super(value, NAMES);
120 * Front buffer capabilities descriptor.
122 private final ImageCapabilities front;
125 * Back buffer capabilities descriptor.
127 private final ImageCapabilities back;
130 * Describes the results of a "flip" operation.
132 private final FlipContents flip;
135 * Creates a buffer capabilities object.
137 * @param frontCaps front buffer capabilities descriptor
138 * @param backCaps back buffer capabilities descriptor
139 * @param flip the results of a flip operation or null if
140 * flipping is not supported
142 * @exception IllegalArgumentException if frontCaps or backCaps is
143 * null
145 public BufferCapabilities(ImageCapabilities frontCaps,
146 ImageCapabilities backCaps,
147 FlipContents flip)
149 if (frontCaps == null || backCaps == null)
150 throw new IllegalArgumentException();
151 this.front = frontCaps;
152 this.back = backCaps;
153 this.flip = flip;
157 * Retrieve the front buffer's image capabilities.
159 * @return the front buffer's image capabilities
161 public ImageCapabilities getFrontBufferCapabilities()
163 return front;
167 * Retrieve the back buffer's image capabilities.
169 * @return the back buffer's image capabilities
171 public ImageCapabilities getBackBufferCapabilities()
173 return back;
177 * Return whether or not flipping is supported.
179 * @return true if flipping is supported, false otherwise
181 public boolean isPageFlipping()
183 return flip != null;
187 * Retrieve the result of a flipping operation. If this method
188 * returns null then flipping is not supported. This implies that
189 * "blitting", a fast block transfer, is used to copy the contents
190 * of the back buffer to the front buffer. Other possible return
191 * values are:
192 * <ul>
193 * <li><code>FlipContents.UNDEFINED</code> the contents of the
194 * back buffer are undefined after flipping.</li>
195 * <li><code>FlipContents.BACKGROUND</code> the contents of the
196 * back buffer are cleared to the background color after
197 * flipping.</li>
198 * <li><code>FlipContents.PRIOR</code> the back buffer contains
199 * the pre-flipping contents of the front * buffer after
200 * flipping.</li>
201 * <li><code>FlipContents.COPIED</code> the back buffer has the
202 * same contents as the front buffer after flipping.</li>
203 * </ul>
205 * @return the result of a flipping operation or null if flipping is
206 * not supported
208 public FlipContents getFlipContents()
210 return flip;
214 * Returns true if flipping is only supported in fullscreen mode.
216 * @return true if flipping is only supported in fullscreen mode,
217 * false otherwise
219 public boolean isFullScreenRequired()
221 return true;
225 * Returns true if flipping can involve more than two buffers. One
226 * or more intermediate buffers may be available in addition to the
227 * front and back buffers.
229 * @return true if there are more than two buffers available for
230 * flipping, false otherwise
232 public boolean isMultiBufferAvailable()
234 return false;
238 * Clone this buffering capability descriptor.
240 * @return a clone of this buffer capability descriptor
242 public Object clone()
246 return super.clone();
248 catch (CloneNotSupportedException e)
250 throw (Error) new InternalError().initCause(e);