Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/sun/java2d/pipe/hw/ExtendedBufferCapabilities.java
41161 views
1
/*
2
* Copyright (c) 2007, 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
26
package sun.java2d.pipe.hw;
27
28
import java.awt.BufferCapabilities;
29
import java.awt.ImageCapabilities;
30
31
/**
32
* Provides extended BufferStrategy capabilities, allowing to specify
33
* the type of vertical refresh synchronization for a buffer strategy.
34
*
35
* This BS capability is always page flipping because v-sync is only relevant
36
* to flipping buffer strategies.
37
*
38
* Note that asking for a v-synced BS doesn't necessarily guarantee that it will
39
* be v-synced since the vsync capability may be disabled in the driver, or
40
* there may be other restriction (like a number of v-synced buffer strategies
41
* allowed per vm). Because of this {@code createBufferStrategy} doesn't
42
* throw {@code AWTException} when a v-synced BS could not be created when
43
* requested.
44
*
45
* @see java.awt.Canvas#createBufferStrategy(int, BufferCapabilities)
46
* @see java.awt.Window#createBufferStrategy(int, BufferCapabilities)
47
*/
48
public class ExtendedBufferCapabilities extends BufferCapabilities {
49
50
/**
51
* Type of synchronization on vertical retrace.
52
*/
53
public static enum VSyncType {
54
/**
55
* Use the default v-sync mode appropriate for given BufferStrategy
56
* and situation.
57
*/
58
VSYNC_DEFAULT(0),
59
60
/**
61
* Synchronize flip on vertical retrace.
62
*/
63
VSYNC_ON(1),
64
65
/**
66
* Do not synchronize flip on vertical retrace.
67
*/
68
VSYNC_OFF(2);
69
70
/**
71
* Used to identify the v-sync type (independent of the constants
72
* order as opposed to {@code ordinal()}).
73
*/
74
public int id() {
75
return id;
76
}
77
78
private VSyncType(int id) {
79
this.id = id;
80
}
81
private int id;
82
}
83
84
private VSyncType vsync;
85
86
/**
87
* Creates an ExtendedBufferCapabilities object with front/back/flip caps
88
* from the passed cap, and VSYNC_DEFAULT v-sync mode.
89
*/
90
public ExtendedBufferCapabilities(BufferCapabilities caps) {
91
super(caps.getFrontBufferCapabilities(),
92
caps.getBackBufferCapabilities(),
93
caps.getFlipContents());
94
95
this.vsync = VSyncType.VSYNC_DEFAULT;
96
}
97
98
/**
99
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
100
* from the passed caps, and VSYNC_DEFAULT v-sync mode.
101
*/
102
public ExtendedBufferCapabilities(ImageCapabilities front,
103
ImageCapabilities back, FlipContents flip)
104
{
105
super(front, back, flip);
106
107
this.vsync = VSyncType.VSYNC_DEFAULT;
108
}
109
110
/**
111
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
112
* from the passed image/flip caps, and the v-sync type.
113
*/
114
public ExtendedBufferCapabilities(ImageCapabilities front,
115
ImageCapabilities back, FlipContents flip,
116
VSyncType t)
117
{
118
super(front, back, flip);
119
120
this.vsync = t;
121
}
122
123
/**
124
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
125
* from the passed cap, and the passed v-sync mode.
126
*/
127
public ExtendedBufferCapabilities(BufferCapabilities caps, VSyncType t) {
128
super(caps.getFrontBufferCapabilities(),
129
caps.getBackBufferCapabilities(),
130
caps.getFlipContents());
131
132
this.vsync = t;
133
}
134
135
/**
136
* Creates an ExtendedBufferCapabilities instance with front/back/flip caps
137
* from the object, and passed v-sync mode.
138
*/
139
public ExtendedBufferCapabilities derive(VSyncType t) {
140
return new ExtendedBufferCapabilities(this, t);
141
}
142
143
/**
144
* Returns the type of v-sync requested by this capabilities instance.
145
*/
146
public VSyncType getVSync() {
147
return vsync;
148
}
149
150
@Override
151
public final boolean isPageFlipping() {
152
return true;
153
}
154
}
155
156