RenderingToCachedGraphicsTest.java revision 430
/*
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6648018 6652662
* @summary Verifies that rendering to a cached onscreen Graphics works
* @author Dmitri.Trembovetski@sun.com: area=Graphics
*/
public class RenderingToCachedGraphicsTest extends Frame {
private static volatile boolean failed = false;
private static volatile CountDownLatch latch;
private Graphics cachedGraphics;
private Canvas renderCanvas;
public RenderingToCachedGraphicsTest() {
super("Test starts in 2 seconds");
renderCanvas = new Canvas() {
repaint();
return;
}
// wait for a bit so that Vista's Window manager's animation
// effects on window's appearance are completed (6652662)
try {
runTest();
} catch (Throwable t) {
failed = true;
} finally {
}
}
};
}
private void runTest() {
// this will cause screen update manager to dump the accelerated surface
// for this canvas
do {
// grab the "unaccelerated" onscreen surface
// now the update manager should be able to accelerate onscreen
// rendering to it again
// this causes restoration of the new accelerated onscreen surface
// (it is created in "lost" state)
// and now we should be able to render to it
try {
} catch (Exception e) {
e.printStackTrace();
failed = true;
return;
}
try {
} catch (Exception e) {}
failed = true;
return;
}
}
}
}
if (depth < 16) {
return;
}
t1.setVisible(true);
if (failed) {
throw new
RuntimeException("Failed: rendering didn't show up");
}
}
}