30 * java.desktop/sun.java2d.pipe
31 * java.desktop/sun.java2d.pipe.hw
32 * @compile -XDignore.symbol.file=true RSLAPITest.java
33 * @run main/othervm RSLAPITest
34 * @run main/othervm -Dsun.java2d.noddraw=true RSLAPITest
35 * @run main/othervm -Dsun.java2d.opengl=True RSLAPITest
36 */
37
38 import java.awt.Graphics;
39 import java.awt.GraphicsConfiguration;
40 import java.awt.GraphicsDevice;
41 import java.awt.GraphicsEnvironment;
42 import java.awt.Rectangle;
43 import java.awt.Transparency;
44 import java.awt.image.VolatileImage;
45 import java.util.HashSet;
46 import sun.java2d.DestSurfaceProvider;
47 import sun.java2d.Surface;
48 import sun.java2d.pipe.BufferedContext;
49 import sun.java2d.pipe.RenderQueue;
50 import sun.java2d.pipe.hw.AccelDeviceEventListener;
51 import sun.java2d.pipe.hw.AccelGraphicsConfig;
52 import sun.java2d.pipe.hw.AccelSurface;
53 import static java.awt.Transparency.*;
54 import java.lang.reflect.Field;
55 import static sun.java2d.pipe.hw.AccelSurface.*;
56 import static sun.java2d.pipe.hw.ContextCapabilities.*;
57
58 public class RSLAPITest {
59 private static volatile boolean failed = false;
60
61 public static void main(String[] args) {
62 GraphicsEnvironment ge =
63 GraphicsEnvironment.getLocalGraphicsEnvironment();
64 GraphicsDevice gd = ge.getDefaultScreenDevice();
65 GraphicsConfiguration gc = gd.getDefaultConfiguration();
66 testGC(gc);
67
68 if (failed) {
69 throw new RuntimeException("Test FAILED. See err output for more");
70 }
237 System.out.println("Passed: VI.getGraphics()" +
238 " threw exception for texture-based VI");
239 }
240 }
241 } else {
242 System.out.printf("Passed: VI of type %d was " +
243 "created for cap=%d but accel surface is null\n",
244 type, cap);
245 }
246 }
247 } else {
248 if (vi != null) {
249 throw new RuntimeException("Failed: created VI for " +
250 "unsupported cap=" + cap);
251 }
252 }
253 }
254
255 private static void testContext(final AccelGraphicsConfig agc) {
256 BufferedContext c = agc.getContext();
257 final AccelDeviceEventListener l = new AccelDeviceEventListener() {
258 public void onDeviceDispose() {
259 System.out.println("onDeviceDispose invoked");
260 agc.removeDeviceEventListener(this);
261 }
262 public void onDeviceReset() {
263 System.out.println("onDeviceReset invoked");
264 }
265 };
266 agc.addDeviceEventListener(l);
267
268 RenderQueue rq = c.getRenderQueue();
269 rq.lock();
270 try {
271 c.saveState();
272 rq.flushNow();
273 c.restoreState();
274 rq.flushNow();
275 System.out.println("Passed: Save/Restore");
276 } finally {
277 rq.unlock();
278 }
279 }
280
281 private static void testForNPEDuringCreation(AccelGraphicsConfig agc) {
282 int iterations = 100;
283 HashSet<VolatileImage> vis = new HashSet<VolatileImage>();
284 GraphicsConfiguration gc = (GraphicsConfiguration)agc;
285 Rectangle r = gc.getBounds();
286 long ram = gc.getDevice().getAvailableAcceleratedMemory();
|
30 * java.desktop/sun.java2d.pipe
31 * java.desktop/sun.java2d.pipe.hw
32 * @compile -XDignore.symbol.file=true RSLAPITest.java
33 * @run main/othervm RSLAPITest
34 * @run main/othervm -Dsun.java2d.noddraw=true RSLAPITest
35 * @run main/othervm -Dsun.java2d.opengl=True RSLAPITest
36 */
37
38 import java.awt.Graphics;
39 import java.awt.GraphicsConfiguration;
40 import java.awt.GraphicsDevice;
41 import java.awt.GraphicsEnvironment;
42 import java.awt.Rectangle;
43 import java.awt.Transparency;
44 import java.awt.image.VolatileImage;
45 import java.util.HashSet;
46 import sun.java2d.DestSurfaceProvider;
47 import sun.java2d.Surface;
48 import sun.java2d.pipe.BufferedContext;
49 import sun.java2d.pipe.RenderQueue;
50 import sun.java2d.pipe.hw.AccelGraphicsConfig;
51 import sun.java2d.pipe.hw.AccelSurface;
52 import static java.awt.Transparency.*;
53 import java.lang.reflect.Field;
54 import static sun.java2d.pipe.hw.AccelSurface.*;
55 import static sun.java2d.pipe.hw.ContextCapabilities.*;
56
57 public class RSLAPITest {
58 private static volatile boolean failed = false;
59
60 public static void main(String[] args) {
61 GraphicsEnvironment ge =
62 GraphicsEnvironment.getLocalGraphicsEnvironment();
63 GraphicsDevice gd = ge.getDefaultScreenDevice();
64 GraphicsConfiguration gc = gd.getDefaultConfiguration();
65 testGC(gc);
66
67 if (failed) {
68 throw new RuntimeException("Test FAILED. See err output for more");
69 }
236 System.out.println("Passed: VI.getGraphics()" +
237 " threw exception for texture-based VI");
238 }
239 }
240 } else {
241 System.out.printf("Passed: VI of type %d was " +
242 "created for cap=%d but accel surface is null\n",
243 type, cap);
244 }
245 }
246 } else {
247 if (vi != null) {
248 throw new RuntimeException("Failed: created VI for " +
249 "unsupported cap=" + cap);
250 }
251 }
252 }
253
254 private static void testContext(final AccelGraphicsConfig agc) {
255 BufferedContext c = agc.getContext();
256
257 RenderQueue rq = c.getRenderQueue();
258 rq.lock();
259 try {
260 c.saveState();
261 rq.flushNow();
262 c.restoreState();
263 rq.flushNow();
264 System.out.println("Passed: Save/Restore");
265 } finally {
266 rq.unlock();
267 }
268 }
269
270 private static void testForNPEDuringCreation(AccelGraphicsConfig agc) {
271 int iterations = 100;
272 HashSet<VolatileImage> vis = new HashSet<VolatileImage>();
273 GraphicsConfiguration gc = (GraphicsConfiguration)agc;
274 Rectangle r = gc.getBounds();
275 long ram = gc.getDevice().getAvailableAcceleratedMemory();
|