0N/A/*
2362N/A * Copyright (c) 2000, 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 java.awt;
0N/A
0N/A/**
0N/A * Capabilities and properties of buffers.
0N/A *
0N/A * @see java.awt.image.BufferStrategy#getCapabilities()
0N/A * @see GraphicsConfiguration#getBufferCapabilities
0N/A * @author Michael Martak
0N/A * @since 1.4
0N/A */
0N/Apublic class BufferCapabilities implements Cloneable {
0N/A
0N/A private ImageCapabilities frontCaps;
0N/A private ImageCapabilities backCaps;
0N/A private FlipContents flipContents;
0N/A
0N/A /**
0N/A * Creates a new object for specifying buffering capabilities
0N/A * @param frontCaps the capabilities of the front buffer; cannot be
0N/A * <code>null</code>
0N/A * @param backCaps the capabilities of the back and intermediate buffers;
0N/A * cannot be <code>null</code>
0N/A * @param flipContents the contents of the back buffer after page-flipping,
0N/A * <code>null</code> if page flipping is not used (implies blitting)
0N/A * @exception IllegalArgumentException if frontCaps or backCaps are
0N/A * <code>null</code>
0N/A */
0N/A public BufferCapabilities(ImageCapabilities frontCaps,
0N/A ImageCapabilities backCaps, FlipContents flipContents) {
0N/A if (frontCaps == null || backCaps == null) {
0N/A throw new IllegalArgumentException(
0N/A "Image capabilities specified cannot be null");
0N/A }
0N/A this.frontCaps = frontCaps;
0N/A this.backCaps = backCaps;
0N/A this.flipContents = flipContents;
0N/A }
0N/A
0N/A /**
0N/A * @return the image capabilities of the front (displayed) buffer
0N/A */
0N/A public ImageCapabilities getFrontBufferCapabilities() {
0N/A return frontCaps;
0N/A }
0N/A
0N/A /**
0N/A * @return the image capabilities of all back buffers (intermediate buffers
0N/A * are considered back buffers)
0N/A */
0N/A public ImageCapabilities getBackBufferCapabilities() {
0N/A return backCaps;
0N/A }
0N/A
0N/A /**
0N/A * @return whether or not the buffer strategy uses page flipping; a set of
0N/A * buffers that uses page flipping
0N/A * can swap the contents internally between the front buffer and one or
0N/A * more back buffers by switching the video pointer (or by copying memory
0N/A * internally). A non-flipping set of
0N/A * buffers uses blitting to copy the contents from one buffer to
0N/A * another; when this is the case, <code>getFlipContents</code> returns
0N/A * <code>null</code>
0N/A */
0N/A public boolean isPageFlipping() {
0N/A return (getFlipContents() != null);
0N/A }
0N/A
0N/A /**
0N/A * @return the resulting contents of the back buffer after page-flipping.
0N/A * This value is <code>null</code> when the <code>isPageFlipping</code>
0N/A * returns <code>false</code>, implying blitting. It can be one of
0N/A * <code>FlipContents.UNDEFINED</code>
0N/A * (the assumed default), <code>FlipContents.BACKGROUND</code>,
0N/A * <code>FlipContents.PRIOR</code>, or
0N/A * <code>FlipContents.COPIED</code>.
0N/A * @see #isPageFlipping
0N/A * @see FlipContents#UNDEFINED
0N/A * @see FlipContents#BACKGROUND
0N/A * @see FlipContents#PRIOR
0N/A * @see FlipContents#COPIED
0N/A */
0N/A public FlipContents getFlipContents() {
0N/A return flipContents;
0N/A }
0N/A
0N/A /**
0N/A * @return whether page flipping is only available in full-screen mode. If this
0N/A * is <code>true</code>, full-screen exclusive mode is required for
0N/A * page-flipping.
0N/A * @see #isPageFlipping
0N/A * @see GraphicsDevice#setFullScreenWindow
0N/A */
0N/A public boolean isFullScreenRequired() {
0N/A return false;
0N/A }
0N/A
0N/A /**
0N/A * @return whether or not
0N/A * page flipping can be performed using more than two buffers (one or more
0N/A * intermediate buffers as well as the front and back buffer).
0N/A * @see #isPageFlipping
0N/A */
0N/A public boolean isMultiBufferAvailable() {
0N/A return false;
0N/A }
0N/A
0N/A /**
0N/A * @return a copy of this BufferCapabilities object.
0N/A */
0N/A public Object clone() {
0N/A try {
0N/A return super.clone();
0N/A } catch (CloneNotSupportedException e) {
0N/A // Since we implement Cloneable, this should never happen
0N/A throw new InternalError();
0N/A }
0N/A }
0N/A
0N/A // Inner class FlipContents
0N/A /**
0N/A * A type-safe enumeration of the possible back buffer contents after
0N/A * page-flipping
0N/A * @since 1.4
0N/A */
0N/A public static final class FlipContents extends AttributeValue {
0N/A
0N/A private static int I_UNDEFINED = 0;
0N/A private static int I_BACKGROUND = 1;
0N/A private static int I_PRIOR = 2;
0N/A private static int I_COPIED = 3;
0N/A
0N/A private static final String NAMES[] =
0N/A { "undefined", "background", "prior", "copied" };
0N/A
0N/A /**
0N/A * When flip contents are <code>UNDEFINED</code>, the
0N/A * contents of the back buffer are undefined after flipping.
0N/A * @see #isPageFlipping
0N/A * @see #getFlipContents
0N/A * @see #BACKGROUND
0N/A * @see #PRIOR
0N/A * @see #COPIED
0N/A */
0N/A public static final FlipContents UNDEFINED =
0N/A new FlipContents(I_UNDEFINED);
0N/A
0N/A /**
0N/A * When flip contents are <code>BACKGROUND</code>, the
0N/A * contents of the back buffer are cleared with the background color after
0N/A * flipping.
0N/A * @see #isPageFlipping
0N/A * @see #getFlipContents
0N/A * @see #UNDEFINED
0N/A * @see #PRIOR
0N/A * @see #COPIED
0N/A */
0N/A public static final FlipContents BACKGROUND =
0N/A new FlipContents(I_BACKGROUND);
0N/A
0N/A /**
0N/A * When flip contents are <code>PRIOR</code>, the
0N/A * contents of the back buffer are the prior contents of the front buffer
0N/A * (a true page flip).
0N/A * @see #isPageFlipping
0N/A * @see #getFlipContents
0N/A * @see #UNDEFINED
0N/A * @see #BACKGROUND
0N/A * @see #COPIED
0N/A */
0N/A public static final FlipContents PRIOR =
0N/A new FlipContents(I_PRIOR);
0N/A
0N/A /**
0N/A * When flip contents are <code>COPIED</code>, the
0N/A * contents of the back buffer are copied to the front buffer when
0N/A * flipping.
0N/A * @see #isPageFlipping
0N/A * @see #getFlipContents
0N/A * @see #UNDEFINED
0N/A * @see #BACKGROUND
0N/A * @see #PRIOR
0N/A */
0N/A public static final FlipContents COPIED =
0N/A new FlipContents(I_COPIED);
0N/A
0N/A private FlipContents(int type) {
0N/A super(type, NAMES);
0N/A }
0N/A
0N/A } // Inner class FlipContents
0N/A
0N/A}