summaryrefslogtreecommitdiffstats
path: root/awt/java/awt/BufferCapabilities.java
blob: cd5fe7b1c73337c8b0ef83261ea0a1317a832e1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * @author Alexey A. Petrenko
 * @version $Revision$
 */

package java.awt;

/**
 * The BufferCapabilities class represents the capabilities and other properties
 * of the image buffers.
 * 
 * @since Android 1.0
 */
public class BufferCapabilities implements Cloneable {

    /**
     * The front buffer capabilities.
     */
    private final ImageCapabilities frontBufferCapabilities;

    /**
     * The back buffer capabilities.
     */
    private final ImageCapabilities backBufferCapabilities;

    /**
     * The flip contents.
     */
    private final FlipContents flipContents;

    /**
     * Instantiates a new BufferCapabilities object.
     * 
     * @param frontBufferCapabilities
     *            the front buffer capabilities, can not be null.
     * @param backBufferCapabilities
     *            the the back and intermediate buffers capabilities, can not be
     *            null.
     * @param flipContents
     *            the back buffer contents after page flipping, null if page
     *            flipping is not used.
     */
    public BufferCapabilities(ImageCapabilities frontBufferCapabilities,
            ImageCapabilities backBufferCapabilities, FlipContents flipContents) {
        if (frontBufferCapabilities == null || backBufferCapabilities == null) {
            throw new IllegalArgumentException();
        }

        this.frontBufferCapabilities = frontBufferCapabilities;
        this.backBufferCapabilities = backBufferCapabilities;
        this.flipContents = flipContents;
    }

    /**
     * Returns a copy of the BufferCapabilities object.
     * 
     * @return a copy of the BufferCapabilities object.
     */
    @Override
    public Object clone() {
        return new BufferCapabilities(frontBufferCapabilities, backBufferCapabilities, flipContents);
    }

    /**
     * Gets the image capabilities of the front buffer.
     * 
     * @return the ImageCapabilities object represented capabilities of the
     *         front buffer.
     */
    public ImageCapabilities getFrontBufferCapabilities() {
        return frontBufferCapabilities;
    }

    /**
     * Gets the image capabilities of the back buffer.
     * 
     * @return the ImageCapabilities object represented capabilities of the back
     *         buffer.
     */
    public ImageCapabilities getBackBufferCapabilities() {
        return backBufferCapabilities;
    }

    /**
     * Gets the flip contents of the back buffer after page-flipping.
     * 
     * @return the FlipContents of the back buffer after page-flipping.
     */
    public FlipContents getFlipContents() {
        return flipContents;
    }

    /**
     * Checks if the buffer strategy uses page flipping.
     * 
     * @return true, if the buffer strategy uses page flipping, false otherwise.
     */
    public boolean isPageFlipping() {
        return flipContents != null;
    }

    /**
     * Checks if page flipping is only available in full-screen mode.
     * 
     * @return true, if page flipping is only available in full-screen mode,
     *         false otherwise.
     */
    public boolean isFullScreenRequired() {
        return false;
    }

    /**
     * Checks if page flipping can be performed using more than two buffers.
     * 
     * @return true, if page flipping can be performed using more than two
     *         buffers, false otherwise.
     */
    public boolean isMultiBufferAvailable() {
        return false;
    }

    /**
     * The FlipContents class represents a set of possible back buffer contents
     * after page-flipping.
     * 
     * @since Android 1.0
     */
    public static final class FlipContents {

        /**
         * The back buffered contents are cleared with the background color
         * after flipping.
         */
        public static final FlipContents BACKGROUND = new FlipContents();

        /**
         * The back buffered contents are copied to the front buffer before
         * flipping.
         */
        public static final FlipContents COPIED = new FlipContents();

        /**
         * The back buffer contents are the prior contents of the front buffer.
         */
        public static final FlipContents PRIOR = new FlipContents();

        /**
         * The back buffer contents are undefined after flipping
         */
        public static final FlipContents UNDEFINED = new FlipContents();

        /**
         * Instantiates a new flip contents.
         */
        private FlipContents() {

        }

        /**
         * Returns the hash code of the FlipContents object.
         * 
         * @return the hash code of the FlipContents object.
         */
        @Override
        public int hashCode() {
            return super.hashCode();
        }

        /**
         * Returns the String representation of the FlipContents object.
         * 
         * @return the string
         */
        @Override
        public String toString() {
            return super.toString();
        }
    }
}