use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class IncorrectClipXorModeSurface2Surface method main.
public static void main(final String[] args) throws IOException {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
AffineTransform at;
for (int size : SIZES) {
at = AffineTransform.getScaleInstance(size, size);
for (Shape clip : SHAPES) {
clip = at.createTransformedShape(clip);
for (Shape to : SHAPES) {
to = at.createTransformedShape(to);
// Prepare test images
BufferedImage snapshot;
VolatileImage source = getVolatileImage(gc, size);
VolatileImage target = getVolatileImage(gc, size);
int attempt = 0;
while (true) {
if (++attempt > 10) {
throw new RuntimeException("Too many attempts: " + attempt);
}
// Prepare source images
source.validate(gc);
Graphics2D g2d = source.createGraphics();
g2d.setColor(Color.RED);
g2d.fillRect(0, 0, size, size);
g2d.dispose();
if (source.validate(gc) != VolatileImage.IMAGE_OK) {
continue;
}
// Prepare target images
target.validate(gc);
g2d = target.createGraphics();
g2d.setColor(Color.GREEN);
g2d.fillRect(0, 0, size, size);
g2d.dispose();
if (target.validate(gc) != VolatileImage.IMAGE_OK) {
continue;
}
draw(clip, to, source, target);
snapshot = target.getSnapshot();
if (source.contentsLost() || target.contentsLost()) {
continue;
}
break;
}
// Prepare gold images
BufferedImage goldS = getSourceGold(gc, size);
BufferedImage goldT = getTargetGold(gc, size);
draw(clip, to, goldS, goldT);
validate(snapshot, goldT);
source.flush();
target.flush();
}
}
}
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class StrikeDisposalCrashTest method renderText.
private static void renderText(Frame frame, Font f1) {
VolatileImage vi = frame.createVolatileImage(256, 32);
vi.validate(frame.getGraphicsConfiguration());
Graphics2D g = vi.createGraphics();
g.setFont(f1);
g.drawString(text, 0, vi.getHeight() / 2);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g.drawString(text, 0, vi.getHeight() / 2);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g.drawString(text, 0, vi.getHeight() / 2);
Toolkit.getDefaultToolkit().sync();
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class MutableColorTest method main.
public static void main(String[] args) {
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
bmImage = gc.createCompatibleImage(64, 64, Transparency.BITMASK);
argbImage = gc.createCompatibleImage(64, 64, Transparency.TRANSLUCENT);
if (gc.getColorModel().getPixelSize() > 8) {
VolatileImage vi = gc.createCompatibleVolatileImage(64, 64, Transparency.OPAQUE);
do {
if (vi.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
vi = gc.createCompatibleVolatileImage(64, 64, Transparency.OPAQUE);
vi.validate(gc);
}
int color = testImage(vi, false, false);
testResult("vi_noclip_notx", vi.getSnapshot(), color);
color = testImage(vi, true, true);
testResult("vi_clip_tx", vi.getSnapshot(), color);
color = testImage(vi, true, false);
testResult("vi_clip_notx", vi.getSnapshot(), color);
color = testImage(vi, false, true);
testResult("vi_noclip_tx", vi.getSnapshot(), color);
} while (vi.contentsLost());
}
BufferedImage bi = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB);
int color = testImage(bi, false, false);
testResult("bi_noclip_notx", bi, color);
color = testImage(bi, true, true);
testResult("bi_clip_tx", bi, color);
color = testImage(bi, true, false);
testResult("bi_clip_notx", bi, color);
color = testImage(bi, false, true);
testResult("bi_noclip_tx", bi, color);
System.err.println("Test passed.");
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class IncorrectSourceOffset method main.
public static void main(final String[] args) throws IOException {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
VolatileImage vi = gc.createCompatibleVolatileImage(511, 255);
BufferedImage bi = new BufferedImage(511, 255, BufferedImage.TYPE_INT_ARGB);
BufferedImage gold = new BufferedImage(511, 255, BufferedImage.TYPE_INT_ARGB);
fill(gold);
while (true) {
vi.validate(gc);
fill(vi);
if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
try {
Thread.sleep(100);
} catch (final InterruptedException ignored) {
}
continue;
}
Graphics2D big = bi.createGraphics();
big.drawImage(vi, 7, 11, 127, 111, 7, 11, 127, 111, null);
big.dispose();
if (vi.contentsLost()) {
try {
Thread.sleep(100);
} catch (final InterruptedException ignored) {
}
continue;
}
break;
}
for (int x = 7; x < 127; ++x) {
for (int y = 11; y < 111; ++y) {
if (gold.getRGB(x, y) != bi.getRGB(x, y)) {
ImageIO.write(gold, "png", new File("gold.png"));
ImageIO.write(bi, "png", new File("bi.png"));
throw new RuntimeException("Test failed.");
}
}
}
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class JPEGsNotAcceleratedTest method runTestOnImage.
public void runTestOnImage(String desc, BufferedImage bi, Rectangle srcROI) {
if (srcROI == null) {
srcROI = new Rectangle(0, 0, TEST_W, TEST_H);
}
VolatileImage testVI = accelerateImage(bi);
ImageCapabilities ic = bi.getCapabilities(f.getGraphicsConfiguration());
boolean accelerated = ic.isAccelerated();
System.err.println("Testing: " + desc + " -- bi.isAccelerated(): " + accelerated);
BufferedImage snapshot = testVI.getSnapshot();
if (showRes) {
showRes(desc, snapshot);
}
for (int y = 0; y < srcROI.height; y++) {
for (int x = 0; x < srcROI.width; x++) {
int destRGB = snapshot.getRGB(x, y);
if (destRGB != testRGB && destRGB != 0xfffe0000) {
failed = true;
System.err.printf("Test failed at %dx%d pixel=%x\n", x, y, snapshot.getRGB(x, y));
if (!showRes) {
showRes(desc, snapshot);
}
break;
}
}
}
}
Aggregations