/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6678218 6681745 6691737
* @summary Tests that v-synced BufferStrategies works (if vsync is supported)
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @compile -XDignore.symbol.file=true VSyncedBufferStrategyTest.java
*/
private volatile boolean done = false;
private volatile boolean requestVSync;
private boolean currentBSVSynced;
this.requestVSync = requestVSync;
this.currentBSVSynced = !requestVSync;
renderThread = new Thread(this);
}
new BufferCapabilities(
new ImageCapabilities(true),
new ImageCapabilities(true),
null);
return;
}
if (requestVSync) {
new ImageCapabilities(true),
new ImageCapabilities(true),
}
try {
} catch (AWTException e) {
e.printStackTrace();
}
bs = getBufferStrategy();
String s =
}
}
}
public void run() {
while (!isShowing()) {
}
try {
do {
step();
render(g);
if (!bs.contentsRestored()) {
}
} while (bs.contentsLost());
}
} catch (Throwable e) {
// since we're not bothering with proper synchronization, exceptions
// may be thrown when the frame is closed
if (isShowing()) {
throw new RuntimeException(e);
}
}
}
private void step() {
}
if (blockX < 10) {
}
}
}
}
}
int myNum;
synchronized (VSyncedBufferStrategyTest.class) {
}
final VSyncedBufferStrategyTest component =
new VSyncedBufferStrategyTest(false);
f.setIgnoreRepaint(true);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
f.setTitle("Possibly V-Synced");
component.setRequestVSync(true);
}
});
p.add(b);
b = new Button("Relinquish VSync");
b.addActionListener(new ActionListener() {
int inc = 1;
public void actionPerformed(ActionEvent e) {
f.setTitle("Not V-Synced");
component.setRequestVSync(false);
}
});
p.add(b);
f.add("South", p);
f.pack();
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
f.dispose();
}
public void windowClosed(WindowEvent e) {
}
});
return f;
}
"Tests that v-synced BufferStrategy works. Note that it in some\n" +
"cases the v-sync can not be enabled, and it is accepted.\n" +
"The following however is true: only one buffer strategy at a time can\n"+
"be created v-synced. In order for other BS to become v-synced, the one\n"+
"that currently is v-synched (or its window) needs to be disposed.\n" +
"Try the following scenarios:\n" +
" - click the \"Request VSync\" button in one of the frames. If the\n"+
" behavior of the animation changes - the animation becomes smooth\n" +
" it had successfully created a v-synced BS. Note that the animation\n" +
" in other frames may also become smoother - this is a side-effect\n"+
" of one of the BS-es becoming v-synched\n" +
" - click the \"Relinquish VSync\" button on the same frame. If the\n"+
" behavior changes to the original (tearing)- it had successfully\n" +
" created a non-vsynced strategy.\n" +
" - next, try making another one v-synced. It should succeed.\n" +
" - next, try making another one v-synced - while there's already\n" +
" a v-synced frame. It should not succeed - meaning, it shouldn't\n" +
" appear to become smoother, and the behavior of the current v-synced\n" +
" frame shouldn't change.\n" +
"\n" +
"If there aren't any BufferStrategy-related exceptions or other\n" +
"issues, and the scenarios worked, the test passed, otherwise it\n"+
"failed.\n";
throws HeadlessException, RuntimeException
{
new JFrame("VSyncedBufferStrategyTest - Description");
public void windowClosing(WindowEvent e) {
l.countDown();
}
});
public void actionPerformed(ActionEvent e) {
l.countDown();
}
});
public void actionPerformed(ActionEvent e) {
failed = true;
l.countDown();
}
});
p.setLayout(new FlowLayout());
ta.setEditable(false);
desc.setVisible(true);
}
private static void createTestFrames() {
}
static boolean failed = false;
public void run() {
}
});
l.await();
if (failed) {
throw new RuntimeException("Test FAILED");
}
}
}