1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17/**
18 * @author Alexey A. Petrenko
19 * @version $Revision$
20 */
21
22package java.awt;
23
24/**
25 * The BufferCapabilities class represents the capabilities and other properties
26 * of the image buffers.
27 *
28 * @since Android 1.0
29 */
30public class BufferCapabilities implements Cloneable {
31
32    /**
33     * The front buffer capabilities.
34     */
35    private final ImageCapabilities frontBufferCapabilities;
36
37    /**
38     * The back buffer capabilities.
39     */
40    private final ImageCapabilities backBufferCapabilities;
41
42    /**
43     * The flip contents.
44     */
45    private final FlipContents flipContents;
46
47    /**
48     * Instantiates a new BufferCapabilities object.
49     *
50     * @param frontBufferCapabilities
51     *            the front buffer capabilities, can not be null.
52     * @param backBufferCapabilities
53     *            the the back and intermediate buffers capabilities, can not be
54     *            null.
55     * @param flipContents
56     *            the back buffer contents after page flipping, null if page
57     *            flipping is not used.
58     */
59    public BufferCapabilities(ImageCapabilities frontBufferCapabilities,
60            ImageCapabilities backBufferCapabilities, FlipContents flipContents) {
61        if (frontBufferCapabilities == null || backBufferCapabilities == null) {
62            throw new IllegalArgumentException();
63        }
64
65        this.frontBufferCapabilities = frontBufferCapabilities;
66        this.backBufferCapabilities = backBufferCapabilities;
67        this.flipContents = flipContents;
68    }
69
70    /**
71     * Returns a copy of the BufferCapabilities object.
72     *
73     * @return a copy of the BufferCapabilities object.
74     */
75    @Override
76    public Object clone() {
77        return new BufferCapabilities(frontBufferCapabilities, backBufferCapabilities, flipContents);
78    }
79
80    /**
81     * Gets the image capabilities of the front buffer.
82     *
83     * @return the ImageCapabilities object represented capabilities of the
84     *         front buffer.
85     */
86    public ImageCapabilities getFrontBufferCapabilities() {
87        return frontBufferCapabilities;
88    }
89
90    /**
91     * Gets the image capabilities of the back buffer.
92     *
93     * @return the ImageCapabilities object represented capabilities of the back
94     *         buffer.
95     */
96    public ImageCapabilities getBackBufferCapabilities() {
97        return backBufferCapabilities;
98    }
99
100    /**
101     * Gets the flip contents of the back buffer after page-flipping.
102     *
103     * @return the FlipContents of the back buffer after page-flipping.
104     */
105    public FlipContents getFlipContents() {
106        return flipContents;
107    }
108
109    /**
110     * Checks if the buffer strategy uses page flipping.
111     *
112     * @return true, if the buffer strategy uses page flipping, false otherwise.
113     */
114    public boolean isPageFlipping() {
115        return flipContents != null;
116    }
117
118    /**
119     * Checks if page flipping is only available in full-screen mode.
120     *
121     * @return true, if page flipping is only available in full-screen mode,
122     *         false otherwise.
123     */
124    public boolean isFullScreenRequired() {
125        return false;
126    }
127
128    /**
129     * Checks if page flipping can be performed using more than two buffers.
130     *
131     * @return true, if page flipping can be performed using more than two
132     *         buffers, false otherwise.
133     */
134    public boolean isMultiBufferAvailable() {
135        return false;
136    }
137
138    /**
139     * The FlipContents class represents a set of possible back buffer contents
140     * after page-flipping.
141     *
142     * @since Android 1.0
143     */
144    public static final class FlipContents {
145
146        /**
147         * The back buffered contents are cleared with the background color
148         * after flipping.
149         */
150        public static final FlipContents BACKGROUND = new FlipContents();
151
152        /**
153         * The back buffered contents are copied to the front buffer before
154         * flipping.
155         */
156        public static final FlipContents COPIED = new FlipContents();
157
158        /**
159         * The back buffer contents are the prior contents of the front buffer.
160         */
161        public static final FlipContents PRIOR = new FlipContents();
162
163        /**
164         * The back buffer contents are undefined after flipping
165         */
166        public static final FlipContents UNDEFINED = new FlipContents();
167
168        /**
169         * Instantiates a new flip contents.
170         */
171        private FlipContents() {
172
173        }
174
175        /**
176         * Returns the hash code of the FlipContents object.
177         *
178         * @return the hash code of the FlipContents object.
179         */
180        @Override
181        public int hashCode() {
182            return super.hashCode();
183        }
184
185        /**
186         * Returns the String representation of the FlipContents object.
187         *
188         * @return the string
189         */
190        @Override
191        public String toString() {
192            return super.toString();
193        }
194    }
195}
196