3814N/A/*
3814N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3814N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3814N/A *
3814N/A * This code is free software; you can redistribute it and/or modify it
3814N/A * under the terms of the GNU General Public License version 2 only, as
3814N/A * published by the Free Software Foundation.
3814N/A *
3814N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3814N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3814N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3814N/A * version 2 for more details (a copy is included in the LICENSE file that
3814N/A * accompanied this code).
3814N/A *
3814N/A * You should have received a copy of the GNU General Public License version
3814N/A * 2 along with this work; if not, write to the Free Software Foundation,
3814N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3814N/A *
3814N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3814N/A * or visit www.oracle.com if you need additional information or have any
3814N/A * questions.
3814N/A */
3814N/A
3814N/A/*
3814N/A* @test
3814N/A* @bug 6985593
3814N/A* @summary Test verifies that rendering standard images to screen does
3814N/A* not caiuse a crash in case of XRender.
3814N/A* @run main/othervm -Dsun.java2d.xrender=True XRenderBlitsTest
3814N/A*/
3814N/A
3814N/Aimport java.awt.Color;
3814N/Aimport java.awt.Component;
3814N/Aimport java.awt.Dimension;
3814N/Aimport java.awt.Frame;
3814N/Aimport java.awt.Graphics;
3814N/Aimport java.awt.Graphics2D;
3814N/Aimport java.awt.image.BufferedImage;
3814N/Aimport java.util.ArrayList;
3814N/Aimport java.util.concurrent.CountDownLatch;
3814N/A
3814N/Apublic class XRenderBlitsTest {
3814N/A
3814N/A private static final int w = 10;
3814N/A private static final int h = 10;
3814N/A
3814N/A public static void main(String[] args) {
3814N/A final CountDownLatch done = new CountDownLatch(1);
3814N/A
3814N/A final ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
3814N/A
3814N/A int type = BufferedImage.TYPE_INT_RGB;
3814N/A do {
3814N/A BufferedImage img = new BufferedImage(w, h, type++);
3814N/A Graphics2D g2d = img.createGraphics();
3814N/A g2d.setColor(Color.pink);
3814N/A g2d.fillRect(0, 0, w, h);
3814N/A g2d.dispose();
3814N/A
3814N/A images.add(img);
3814N/A } while (type <= BufferedImage.TYPE_BYTE_INDEXED);
3814N/A
3814N/A Frame f = new Frame("Draw images");
3814N/A Component c = new Component() {
3814N/A
3814N/A @Override
3814N/A public Dimension getPreferredSize() {
3814N/A return new Dimension(w * images.size(), h);
3814N/A }
3814N/A
3814N/A @Override
3814N/A public void paint(Graphics g) {
3814N/A int x = 0;
3814N/A for (BufferedImage img : images) {
3814N/A System.out.println("Draw image " + img.getType());
3814N/A g.drawImage(img, x, 0, this);
3814N/A x += w;
3814N/A }
3814N/A done.countDown();
3814N/A }
3814N/A };
3814N/A f.add("Center", c);
3814N/A f.pack();
3814N/A f.setVisible(true);
3814N/A
3814N/A // now wait for test results
3814N/A try {
3814N/A done.await();
3814N/A } catch (InterruptedException e) {
3814N/A }
3814N/A System.out.println("Test passed");
3814N/A f.dispose();
3814N/A }
3814N/A}