author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 5506 | jdk/test/sun/java2d/DirectX/NonOpaqueDestLCDAATest/NonOpaqueDestLCDAATest.java@202f599c92aa |
child 49217 | 3b820b878ebe |
permissions | -rw-r--r-- |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, 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 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
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 |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
26 |
* @bug 6728834 6749060 |
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 |
* @run main/manual/othervm -Dsun.java2d.opengl=True NonOpaqueDestLCDAATest |
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 |
|
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.AlphaComposite; |
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.Color; |
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.Dimension; |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
|
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
|
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
66 |
public NonOpaqueDestLCDAATest() { |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
67 |
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
|
68 |
desc.setText( |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
69 |
"\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
|
70 |
" 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
|
71 |
" 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
|
72 |
" 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
|
73 |
" 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
|
74 |
" 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
|
75 |
" 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
|
76 |
"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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
@Override |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
86 |
}; |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
87 |
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
|
88 |
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
|
89 |
@Override |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
90 |
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
|
91 |
images = null; |
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 |
}); |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
94 |
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
|
95 |
|
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
96 |
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
|
97 |
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
|
98 |
passedBtn.addActionListener(this); |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
99 |
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
|
100 |
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
|
101 |
p.add(passedBtn); |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
102 |
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
|
103 |
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
|
104 |
addWindowListener(new WindowAdapter() { |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
105 |
@Override |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
106 |
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
|
107 |
complete.countDown(); |
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 |
}); |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
110 |
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
|
111 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
112 |
|
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
|
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
116 |
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
|
117 |
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
|
118 |
|
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
119 |
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
|
120 |
for (Image im : images) { |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
121 |
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
|
122 |
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
|
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 |
|
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
126 |
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
|
127 |
@Override |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
128 |
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
|
129 |
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
|
130 |
passed = true; |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
131 |
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
|
132 |
} 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
|
133 |
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
|
134 |
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
|
135 |
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
|
136 |
try { |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
137 |
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
|
138 |
f += "_vi.png"; |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
139 |
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
|
140 |
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
|
141 |
} else { |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
142 |
f += "_bi.png"; |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
143 |
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
|
144 |
"png", new File(f)); |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
145 |
} |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
146 |
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
|
147 |
} 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
|
148 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
149 |
passed = false; |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
150 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
151 |
dispose(); |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
152 |
complete.countDown(); |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
153 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
154 |
|
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
if (type > OPAQUE) { |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
158 |
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
|
159 |
gg.setComposite(AlphaComposite.Src); |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
160 |
} else { |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
161 |
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
|
162 |
} |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
163 |
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
|
164 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
165 |
|
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
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
|
169 |
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
|
170 |
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
|
171 |
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
|
172 |
g2d.setColor(Color.white); |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
173 |
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
|
174 |
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
|
175 |
} |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
176 |
|
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
177 |
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
|
178 |
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
|
179 |
if (images == null) { |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
VolatileImage vi = |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
184 |
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
|
185 |
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
|
186 |
vi.validate(gc); |
1726
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
187 |
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
|
188 |
render(vi, i, s); |
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
189 |
|
6b8261d50f69
6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents:
1717
diff
changeset
|
190 |
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
|
191 |
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
|
192 |
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
|
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 |
|
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
197 |
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
|
198 |
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
|
199 |
@Override |
1717
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
200 |
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
|
201 |
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
|
202 |
t.pack(); |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
203 |
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
|
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 |
|
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
207 |
complete.await(); |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
208 |
if (!passed) { |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
209 |
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
|
210 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
211 |
} |
5d7c1102107a
6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents:
diff
changeset
|
212 |
} |