1 /*
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * - Neither the name of Oracle nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
40
41 package j2dbench;
42
43 import java.awt.Image;
44 import java.awt.Component;
45 import java.awt.GraphicsConfiguration;
46 import java.awt.Transparency;
47 import java.awt.color.ColorSpace;
48 import java.awt.image.BufferedImage;
49 import java.awt.image.ComponentColorModel;
50 import java.awt.image.DataBuffer;
51 import java.awt.image.WritableRaster;
52
53 import j2dbench.tests.GraphicsTests;
54 import j2dbench.tests.ImageTests;
55
56 public abstract class Destinations extends Option.Enable {
57 public static Group.EnableSet destroot;
58 public static Group bufimgdestroot;
59 public static Group compatimgdestroot;
60
61 public static void init() {
62 destroot = new Group.EnableSet(TestEnvironment.globaloptroot,
63 "dest", "Output Destination Options");
64
65 new Screen();
66 new OffScreen();
67
68 if (GraphicsTests.hasGraphics2D) {
69 if (ImageTests.hasCompatImage) {
70 compatimgdestroot =
71 new Group.EnableSet(destroot, "compatimg",
72 "Compatible Image Destinations");
73 compatimgdestroot.setHorizontal();
74
75 new CompatImg();
76 new CompatImg(Transparency.OPAQUE);
77 new CompatImg(Transparency.BITMASK);
78 new CompatImg(Transparency.TRANSLUCENT);
79 }
80
81 if (ImageTests.hasVolatileImage) {
82 new VolatileImg();
83 }
84
85 bufimgdestroot = new Group.EnableSet(destroot, "bufimg",
86 "BufferedImage Destinations");
87
88 new BufImg(BufferedImage.TYPE_INT_RGB);
89 new BufImg(BufferedImage.TYPE_INT_ARGB);
90 new BufImg(BufferedImage.TYPE_INT_ARGB_PRE);
91 new BufImg(BufferedImage.TYPE_3BYTE_BGR);
92 new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
93 new BufImg(BufferedImage.TYPE_BYTE_GRAY);
94 new CustomImg();
95 }
96 }
97
98 public Destinations(Group parent,
99 String nodename, String description,
100 boolean defenabled)
101 {
102 super(parent, nodename, description, defenabled);
103 }
104
105 public void modifyTest(TestEnvironment env) {
106 setDestination(env);
107 }
108
109 public void restoreTest(TestEnvironment env) {
110 env.setTestImage(null);
111 }
112
113 public String getAbbreviatedModifierDescription(Object val) {
189 }
190
191 public String getModifierValueName(Object val) {
192 return ModifierNames[transparency];
193 }
194
195 public void setDestination(TestEnvironment env) {
196 Component c = env.getCanvas();
197 GraphicsConfiguration gc = c.getGraphicsConfiguration();
198 int w = env.getWidth();
199 int h = env.getHeight();
200 if (transparency == 0) {
201 env.setTestImage(gc.createCompatibleImage(w, h));
202 } else {
203 env.setTestImage(gc.createCompatibleImage(w, h, transparency));
204 }
205 }
206 }
207
208 public static class VolatileImg extends Destinations {
209 public VolatileImg() {
210 super(destroot, "volimg", "Output to Volatile Image", false);
211 }
212
213 public String getModifierValueName(Object val) {
214 return "VolatileImg";
215 }
216
217 public void setDestination(TestEnvironment env) {
218 Component c = env.getCanvas();
219 env.setTestImage(c.createVolatileImage(env.getWidth(),
220 env.getHeight()));
221 }
222 }
223
224
225 public static class BufImg extends Destinations {
226 int type;
227 Image img;
228
229 public static String ShortNames[] = {
230 "custom",
231 "IntXrgb",
232 "IntArgb",
233 "IntArgbPre",
234 "IntXbgr",
235 "3ByteBgr",
236 "4ByteAbgr",
237 "4ByteAbgrPre",
238 "Short565",
239 "Short555",
240 "ByteGray",
|
1 /*
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * - Neither the name of Oracle nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
40
41 package j2dbench;
42
43 import java.awt.Image;
44 import java.awt.Component;
45 import java.awt.GraphicsConfiguration;
46 import java.awt.Transparency;
47 import java.awt.color.ColorSpace;
48 import java.awt.image.BufferedImage;
49 import java.awt.image.ComponentColorModel;
50 import java.awt.image.DataBuffer;
51 import java.awt.image.WritableRaster;
52
53 import j2dbench.tests.GraphicsTests;
54 import j2dbench.tests.ImageTests;
55
56 public abstract class Destinations extends Option.Enable {
57 public static Group.EnableSet destroot;
58 public static Group bufimgdestroot;
59 public static Group compatimgdestroot;
60 public static Group volimgdestroot;
61
62 public static void init() {
63 destroot = new Group.EnableSet(TestEnvironment.globaloptroot,
64 "dest", "Output Destination Options");
65
66 new Screen();
67 new OffScreen();
68
69 if (GraphicsTests.hasGraphics2D) {
70 if (ImageTests.hasCompatImage) {
71 compatimgdestroot =
72 new Group.EnableSet(destroot, "compatimg",
73 "Compatible Image Destinations");
74 compatimgdestroot.setHorizontal();
75
76 new CompatImg();
77 new CompatImg(Transparency.OPAQUE);
78 new CompatImg(Transparency.BITMASK);
79 new CompatImg(Transparency.TRANSLUCENT);
80 }
81
82 if (ImageTests.hasVolatileImage) {
83 volimgdestroot = new Group.EnableSet(destroot, "volimg",
84 "Output to Volatile Image");
85
86 volimgdestroot.setHorizontal();
87 new VolatileImg();
88 if (ImageTests.hasTransparentVolatileImage) {
89 new VolatileImg(Transparency.OPAQUE);
90 new VolatileImg(Transparency.BITMASK);
91 new VolatileImg(Transparency.TRANSLUCENT);
92 }
93 }
94
95 bufimgdestroot = new Group.EnableSet(destroot, "bufimg",
96 "BufferedImage Destinations");
97
98 new BufImg(BufferedImage.TYPE_INT_RGB);
99 new BufImg(BufferedImage.TYPE_INT_ARGB);
100 new BufImg(BufferedImage.TYPE_INT_ARGB_PRE);
101 new BufImg(BufferedImage.TYPE_3BYTE_BGR);
102 new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
103 new BufImg(BufferedImage.TYPE_BYTE_GRAY);
104 new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
105 new BufImg(BufferedImage.TYPE_4BYTE_ABGR_PRE);
106 new CustomImg();
107 }
108 }
109
110 public Destinations(Group parent,
111 String nodename, String description,
112 boolean defenabled)
113 {
114 super(parent, nodename, description, defenabled);
115 }
116
117 public void modifyTest(TestEnvironment env) {
118 setDestination(env);
119 }
120
121 public void restoreTest(TestEnvironment env) {
122 env.setTestImage(null);
123 }
124
125 public String getAbbreviatedModifierDescription(Object val) {
201 }
202
203 public String getModifierValueName(Object val) {
204 return ModifierNames[transparency];
205 }
206
207 public void setDestination(TestEnvironment env) {
208 Component c = env.getCanvas();
209 GraphicsConfiguration gc = c.getGraphicsConfiguration();
210 int w = env.getWidth();
211 int h = env.getHeight();
212 if (transparency == 0) {
213 env.setTestImage(gc.createCompatibleImage(w, h));
214 } else {
215 env.setTestImage(gc.createCompatibleImage(w, h, transparency));
216 }
217 }
218 }
219
220 public static class VolatileImg extends Destinations {
221 private final int transparency;
222
223 public static final String[] ShortNames = {
224 "volimg",
225 "opqvolimg",
226 "bmvolimg",
227 "transvolimg",
228 };
229
230 public static final String[] ShortDescriptions = {
231 "Default",
232 "Opaque",
233 "Bitmask",
234 "Translucent",
235 };
236
237 public static final String[] LongDescriptions = {
238 "Default VolatileImg Image",
239 "Opaque VolatileImg Image",
240 "Bitmask VolatileImg Image",
241 "Translucent VolatileImg Image",
242 };
243
244 public static final String[] ModifierNames = {
245 "VolatileImg()",
246 "VolatileImg(Opaque)",
247 "VolatileImg(Bitmask)",
248 "VolatileImg(Translucent)",
249 };
250
251 public VolatileImg() {
252 this(0);
253 }
254
255 public VolatileImg(final int transparency) {
256 super(volimgdestroot,
257 ShortNames[transparency],
258 ShortDescriptions[transparency],
259 false);
260 this.transparency = transparency;
261 }
262
263 public String getModifierValueName(final Object val) {
264 return ModifierNames[transparency];
265 }
266
267 public void setDestination(final TestEnvironment env) {
268 Component c = env.getCanvas();
269 GraphicsConfiguration gc = c.getGraphicsConfiguration();
270 int w = env.getWidth();
271 int h = env.getHeight();
272 if (transparency == 0) {
273 env.setTestImage(gc.createCompatibleVolatileImage(w, h));
274 } else {
275 env.setTestImage(gc.createCompatibleVolatileImage(w, h, transparency));
276 }
277 }
278 }
279
280
281 public static class BufImg extends Destinations {
282 int type;
283 Image img;
284
285 public static String ShortNames[] = {
286 "custom",
287 "IntXrgb",
288 "IntArgb",
289 "IntArgbPre",
290 "IntXbgr",
291 "3ByteBgr",
292 "4ByteAbgr",
293 "4ByteAbgrPre",
294 "Short565",
295 "Short555",
296 "ByteGray",
|