jdk/test/sun/java2d/XRenderBlitsTest.java
author amurillo
Wed, 15 Aug 2012 16:49:38 -0700
changeset 13465 d3fc5d192448
parent 8940 7a0c1d4e2982
child 39056 d99e63b6d962
permissions -rw-r--r--
7191765: make jdk8 the default jprt release for hs24 Reviewed-by: jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8940
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     1
/*
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     4
 *
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     8
 *
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    13
 * accompanied this code).
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    14
 *
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    18
 *
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    21
 * questions.
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    22
 */
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    23
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    24
/*
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    25
* @test
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    26
* @bug     6985593
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    27
* @summary Test verifies that rendering standard images to screen does
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    28
*          not caiuse a crash in case of XRender.
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    29
* @run main/othervm -Dsun.java2d.xrender=True XRenderBlitsTest
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    30
*/
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    31
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    32
import java.awt.Color;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    33
import java.awt.Component;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    34
import java.awt.Dimension;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    35
import java.awt.Frame;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    36
import java.awt.Graphics;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    37
import java.awt.Graphics2D;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    38
import java.awt.image.BufferedImage;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    39
import java.util.ArrayList;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    40
import java.util.concurrent.CountDownLatch;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    41
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    42
public class XRenderBlitsTest {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    43
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    44
    private static final int w = 10;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    45
    private static final int h = 10;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    46
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    47
    public static void main(String[] args) {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    48
        final CountDownLatch done = new CountDownLatch(1);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    49
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    50
        final ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    51
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    52
        int type = BufferedImage.TYPE_INT_RGB;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    53
        do {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    54
            BufferedImage img = new BufferedImage(w, h, type++);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    55
            Graphics2D g2d = img.createGraphics();
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    56
            g2d.setColor(Color.pink);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    57
            g2d.fillRect(0, 0, w, h);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    58
            g2d.dispose();
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    59
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    60
            images.add(img);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    61
        } while (type <= BufferedImage.TYPE_BYTE_INDEXED);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    62
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    63
        Frame f = new Frame("Draw images");
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    64
        Component c = new Component() {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    65
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    66
            @Override
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    67
            public Dimension getPreferredSize() {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    68
                return new Dimension(w * images.size(), h);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    69
            }
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    70
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    71
            @Override
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    72
            public void paint(Graphics g) {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    73
                int x = 0;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    74
                for (BufferedImage img : images) {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    75
                    System.out.println("Draw image " + img.getType());
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    76
                    g.drawImage(img, x, 0, this);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    77
                    x += w;
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    78
                }
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    79
                done.countDown();
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    80
            }
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    81
        };
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    82
        f.add("Center", c);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    83
        f.pack();
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    84
        f.setVisible(true);
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    85
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    86
        // now wait for test results
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    87
        try {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    88
        done.await();
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    89
        } catch (InterruptedException e) {
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    90
        }
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    91
        System.out.println("Test passed");
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    92
        f.dispose();
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    93
    }
7a0c1d4e2982 6985593: Crash in Java_sun_java2d_loops_MaskBlit_MaskBlit on oel5.5-x64
bae
parents:
diff changeset
    94
}