test/jdk/sun/java2d/DirectX/NonOpaqueDestLCDAATest/NonOpaqueDestLCDAATest.java
author pnarayanan
Fri, 02 Mar 2018 14:39:29 +0530
changeset 49217 3b820b878ebe
parent 47216 71c04702a3d5
permissions -rw-r--r--
8198613: Test cases result in failure or timeout when run with OpenGL backend Reviewed-by: serb, jdv
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     1
/*
49217
3b820b878ebe 8198613: Test cases result in failure or timeout when run with OpenGL backend
pnarayanan
parents: 47216
diff changeset
     2
 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     4
 *
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     8
 *
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    13
 * accompanied this code).
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    14
 *
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1726
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1726
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1726
diff changeset
    21
 * questions.
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    22
 */
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    23
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    24
/*
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    25
 * @test
49217
3b820b878ebe 8198613: Test cases result in failure or timeout when run with OpenGL backend
pnarayanan
parents: 47216
diff changeset
    26
 * @bug 6728834 6749060 8198613
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    27
 * @summary Tests that LCD AA text rendering works properly with destinations
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    28
 * being VolatileImage of all transparency types
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    29
 * @author Dmitri.Trembovetski: area=Graphics
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    30
 * @run main/manual/othervm -Dsun.java2d.d3d=false NonOpaqueDestLCDAATest
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    31
 * @run main/manual/othervm NonOpaqueDestLCDAATest
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    32
 */
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    33
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    34
import java.awt.AlphaComposite;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    35
import java.awt.Color;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    36
import java.awt.Dimension;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    37
import java.awt.EventQueue;
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    38
import java.awt.Font;
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    39
import java.awt.Graphics;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    40
import java.awt.Graphics2D;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    41
import java.awt.GraphicsConfiguration;
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    42
import java.awt.Image;
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    43
import java.awt.RenderingHints;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    44
import java.awt.event.ActionEvent;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    45
import java.awt.event.ActionListener;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    46
import java.awt.event.ComponentAdapter;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    47
import java.awt.event.ComponentEvent;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    48
import java.awt.event.WindowAdapter;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    49
import java.awt.event.WindowEvent;
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    50
import java.awt.image.BufferedImage;
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    51
import java.awt.image.VolatileImage;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    52
import java.io.File;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    53
import java.util.concurrent.CountDownLatch;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    54
import javax.imageio.ImageIO;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    55
import javax.swing.JButton;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    56
import javax.swing.JFrame;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    57
import javax.swing.JPanel;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    58
import javax.swing.JTextArea;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    59
import static java.awt.Transparency.*;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    60
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    61
public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    62
    private static volatile boolean passed = true;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    63
    private static CountDownLatch complete = new CountDownLatch(1);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    64
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    65
    public NonOpaqueDestLCDAATest() {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    66
        JTextArea desc = new JTextArea();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    67
        desc.setText(
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    68
            "\n  Instructions: the three text strings below should appear" +
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    69
            "  readable, without smudges or misshapen bold glyphs.\n" +
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    70
            "  You may need a magnifier to notice some bad colorfringing in "+
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    71
            "  in SW Translucent case, especially in vertical stems.\n\n"+
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    72
            "  Basically text rendered to TRANSLUCENT destination should look"+
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    73
            "  similar to one rendered to OPAQUE - it may differ in whether or" +
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    74
            "  not it's LCD, but it should look 'correct'\n\n"+
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    75
            "If the text looks fine the test PASSED otherwise it FAILED.\n");
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    76
        desc.setEditable(false);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    77
        desc.setBackground(Color.black);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    78
        desc.setForeground(Color.green);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    79
        add("North", desc);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    80
        JPanel renderPanel = new JPanel() {
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    81
            @Override
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    82
            public void paintComponent(Graphics g) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    83
                render(g, getWidth(), getHeight());
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    84
            }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    85
        };
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    86
        renderPanel.setPreferredSize(new Dimension(1024, 650));
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    87
        renderPanel.addComponentListener(new ComponentAdapter() {
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    88
            @Override
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    89
            public void componentResized(ComponentEvent e) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    90
                images = null;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    91
            }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    92
        });
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    93
        add("Center", renderPanel);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    94
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    95
        JButton passedBtn = new JButton("Passed");
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    96
        JButton failedBtn = new JButton("Failed");
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    97
        passedBtn.addActionListener(this);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
    98
        failedBtn.addActionListener(this);
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
    99
        JPanel p = new JPanel();
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   100
        p.add(passedBtn);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   101
        p.add(failedBtn);
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   102
        add("South", p);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   103
        addWindowListener(new WindowAdapter() {
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   104
            @Override
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   105
            public void windowClosing(WindowEvent e) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   106
                complete.countDown();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   107
            }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   108
        });
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   109
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   110
    }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   111
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   112
    public void render(Graphics g, int w, int h) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   113
        initImages(w, h);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   114
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   115
        g.setColor(new Color(0xAD, 0xD8, 0xE6));
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   116
        g.fillRect(0, 0, w, h);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   117
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   118
        Graphics2D g2d = (Graphics2D) g.create();
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   119
        for (Image im : images) {
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   120
            g2d.drawImage(im, 0, 0, null);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   121
            g2d.translate(0, im.getHeight(null));
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   122
        }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   123
    }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   124
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   125
    String tr[] = { "OPAQUE", "BITMASK", "TRANSLUCENT" };
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   126
    @Override
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   127
    public void actionPerformed(ActionEvent e) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   128
        if (e.getActionCommand().equals("Passed")) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   129
            passed = true;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   130
            System.out.println("Test Passed");
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   131
        } else if (e.getActionCommand().equals("Failed")) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   132
            System.out.println("Test Failed");
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   133
            for (int i = 0; i < images.length; i++) {
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   134
                String f = "NonOpaqueDestLCDAATest_"+tr[i];
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   135
                try {
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   136
                    if (images[i] instanceof VolatileImage) {
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   137
                        f += "_vi.png";
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   138
                        ImageIO.write(((VolatileImage)images[i]).
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   139
                                getSnapshot(), "png", new File(f));
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   140
                    } else {
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   141
                        f += "_bi.png";
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   142
                        ImageIO.write((BufferedImage)images[i],
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   143
                                       "png", new File(f));
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   144
                    }
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   145
                    System.out.printf("Dumped %s image to %s\n", tr[i], f);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   146
                } catch (Throwable t) {}
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   147
            }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   148
            passed = false;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   149
        }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   150
        dispose();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   151
        complete.countDown();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   152
    }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   153
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   154
    static void clear(Graphics2D  g, int type, int w, int h) {
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   155
        Graphics2D gg = (Graphics2D) g.create();
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   156
        if (type > OPAQUE) {
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   157
            gg.setColor(new Color(0, 0, 0, 0));
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   158
            gg.setComposite(AlphaComposite.Src);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   159
        } else {
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   160
            gg.setColor(new Color(0xAD, 0xD8, 0xE6));
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   161
        }
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   162
        gg.fillRect(0, 0, w, h);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   163
    }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   164
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   165
    private void render(Image im, int type, String s) {
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   166
        Graphics2D g2d = (Graphics2D) im.getGraphics();
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   167
        clear(g2d, type, im.getWidth(null), im.getHeight(null));
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   168
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   169
                RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   170
        Font f = new Font("Dialog", Font.BOLD, 40);// g2d.getFont().deriveFont(32.0f);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   171
        g2d.setColor(Color.white);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   172
        g2d.setFont(g2d.getFont().deriveFont(36.0f));
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   173
        g2d.drawString(s, 10, im.getHeight(null) / 2);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   174
    }
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   175
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   176
    Image images[];
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   177
    private void initImages(int w, int h) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   178
        if (images == null) {
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   179
            images = new Image[6];
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   180
            GraphicsConfiguration gc = getGraphicsConfiguration();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   181
            for (int i = OPAQUE; i <= TRANSLUCENT; i++) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   182
                VolatileImage vi =
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   183
                    gc.createCompatibleVolatileImage(w,h/images.length,i);
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   184
                images[i-1] = vi;
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   185
                vi.validate(gc);
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   186
                String s = "LCD AA Text rendered to " + tr[i - 1] + " HW destination";
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   187
                render(vi, i, s);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   188
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   189
                s = "LCD AA Text rendered to " + tr[i - 1] + " SW destination";
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   190
                images[i-1+3] = gc.createCompatibleImage(w, h/images.length, i);
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   191
                render(images[i-1+3], i, s);
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   192
            }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   193
        }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   194
    }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   195
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   196
    public static void main(String[] args) throws InterruptedException {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   197
        EventQueue.invokeLater(new Runnable() {
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 1717
diff changeset
   198
            @Override
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   199
            public void run() {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   200
                NonOpaqueDestLCDAATest t = new NonOpaqueDestLCDAATest();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   201
                t.pack();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   202
                t.setVisible(true);
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   203
            }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   204
        });
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   205
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   206
        complete.await();
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   207
        if (!passed) {
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   208
            throw new RuntimeException("Test Failed!");
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   209
        }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   210
    }
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff changeset
   211
}