提交 c096f95c 编写于 作者: T tdv

6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)

Reviewed-by: campbell, prr
上级 0b0f9f6b
...@@ -449,7 +449,8 @@ public abstract class SurfaceData ...@@ -449,7 +449,8 @@ public abstract class SurfaceData
// For now the answer can only be true in the following cases: // For now the answer can only be true in the following cases:
if (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY && if (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR) sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR &&
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE)
{ {
if (haveLCDLoop == LCDLOOP_UNKNOWN) { if (haveLCDLoop == LCDLOOP_UNKNOWN) {
DrawGlyphListLCD loop = DrawGlyphListLCD loop =
......
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
/* /*
* @test * @test
* @bug 6728834 * @bug 6728834 6749060
* @summary Tests that LCD AA text rendering works properly with destinations * @summary Tests that LCD AA text rendering works properly with destinations
* being VolatileImage of all transparency types * being VolatileImage of all transparency types
* @author Dmitri.Trembovetski: area=Graphics * @author Dmitri.Trembovetski: area=Graphics
* @run main/manual/othervm -Dsun.java2d.d3d=false NonOpaqueDestLCDAATest
* @run main/manual/othervm NonOpaqueDestLCDAATest * @run main/manual/othervm NonOpaqueDestLCDAATest
* @run main/manual/othervm -Dsun.java2d.opengl=True NonOpaqueDestLCDAATest * @run main/manual/othervm -Dsun.java2d.opengl=True NonOpaqueDestLCDAATest
*/ */
...@@ -35,9 +36,11 @@ import java.awt.AlphaComposite; ...@@ -35,9 +36,11 @@ import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration; import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
...@@ -45,6 +48,7 @@ import java.awt.event.ComponentAdapter; ...@@ -45,6 +48,7 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
import java.io.File; import java.io.File;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
...@@ -62,35 +66,43 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener { ...@@ -62,35 +66,43 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener {
public NonOpaqueDestLCDAATest() { public NonOpaqueDestLCDAATest() {
JTextArea desc = new JTextArea(); JTextArea desc = new JTextArea();
desc.setText( desc.setText(
"\n Instructions: the three text strings below should appear\n" + "\n Instructions: the three text strings below should appear" +
" readable, without smudges or misshapen bold glyphs.\n\n" + " readable, without smudges or misshapen bold glyphs.\n" +
" If they look fine the test PASSED otherwise it FAILED.\n"); " You may need a magnifier to notice some bad colorfringing in "+
" in SW Translucent case, especially in vertical stems.\n\n"+
" Basically text rendered to TRANSLUCENT destination should look"+
" similar to one rendered to OPAQUE - it may differ in whether or" +
" not it's LCD, but it should look 'correct'\n\n"+
"If the text looks fine the test PASSED otherwise it FAILED.\n");
desc.setEditable(false); desc.setEditable(false);
desc.setBackground(Color.black); desc.setBackground(Color.black);
desc.setForeground(Color.green); desc.setForeground(Color.green);
add("North", desc); add("North", desc);
JPanel renderPanel = new JPanel() { JPanel renderPanel = new JPanel() {
@Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
render(g, getWidth(), getHeight()); render(g, getWidth(), getHeight());
} }
}; };
renderPanel.setPreferredSize(new Dimension(350, 150)); renderPanel.setPreferredSize(new Dimension(1024, 650));
renderPanel.addComponentListener(new ComponentAdapter() { renderPanel.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
images = null; images = null;
} }
}); });
add("Center", renderPanel); add("Center", renderPanel);
JButton passed = new JButton("Passed"); JButton passedBtn = new JButton("Passed");
JButton failed = new JButton("Failed"); JButton failedBtn = new JButton("Failed");
passed.addActionListener(this); passedBtn.addActionListener(this);
failed.addActionListener(this); failedBtn.addActionListener(this);
JPanel p = new JPanel(); JPanel p = new JPanel();
p.add(passed); p.add(passedBtn);
p.add(failed); p.add(failedBtn);
add("South", p); add("South", p);
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
complete.countDown(); complete.countDown();
} }
...@@ -101,14 +113,18 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener { ...@@ -101,14 +113,18 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener {
public void render(Graphics g, int w, int h) { public void render(Graphics g, int w, int h) {
initImages(w, h); initImages(w, h);
g.setColor(new Color(0xAD, 0xD8, 0xE6));
g.fillRect(0, 0, w, h);
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
for (VolatileImage vi : images) { for (Image im : images) {
g2d.drawImage(vi, 0, 0, null); g2d.drawImage(im, 0, 0, null);
g2d.translate(0, vi.getHeight()); g2d.translate(0, im.getHeight(null));
} }
} }
String tr[] = { "OPAQUE", "BITMASK", "TRANSLUCENT" }; String tr[] = { "OPAQUE", "BITMASK", "TRANSLUCENT" };
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Passed")) { if (e.getActionCommand().equals("Passed")) {
passed = true; passed = true;
...@@ -116,9 +132,17 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener { ...@@ -116,9 +132,17 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener {
} else if (e.getActionCommand().equals("Failed")) { } else if (e.getActionCommand().equals("Failed")) {
System.out.println("Test Failed"); System.out.println("Test Failed");
for (int i = 0; i < images.length; i++) { for (int i = 0; i < images.length; i++) {
String f = "NonOpaqueDestLCDAATest_"+tr[i]+".png"; String f = "NonOpaqueDestLCDAATest_"+tr[i];
try { try {
ImageIO.write(images[i].getSnapshot(), "png", new File(f)); if (images[i] instanceof VolatileImage) {
f += "_vi.png";
ImageIO.write(((VolatileImage)images[i]).
getSnapshot(), "png", new File(f));
} else {
f += "_bi.png";
ImageIO.write((BufferedImage)images[i],
"png", new File(f));
}
System.out.printf("Dumped %s image to %s\n", tr[i], f); System.out.printf("Dumped %s image to %s\n", tr[i], f);
} catch (Throwable t) {} } catch (Throwable t) {}
} }
...@@ -128,37 +152,51 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener { ...@@ -128,37 +152,51 @@ public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener {
complete.countDown(); complete.countDown();
} }
static void clear(Graphics2D g, int w, int h) { static void clear(Graphics2D g, int type, int w, int h) {
Graphics2D gg = (Graphics2D) g.create(); Graphics2D gg = (Graphics2D) g.create();
gg.setColor(new Color(0, 0, 0, 0)); if (type > OPAQUE) {
gg.setComposite(AlphaComposite.Src); gg.setColor(new Color(0, 0, 0, 0));
gg.setComposite(AlphaComposite.Src);
} else {
gg.setColor(new Color(0xAD, 0xD8, 0xE6));
}
gg.fillRect(0, 0, w, h); gg.fillRect(0, 0, w, h);
} }
VolatileImage images[]; private void render(Image im, int type, String s) {
Graphics2D g2d = (Graphics2D) im.getGraphics();
clear(g2d, type, im.getWidth(null), im.getHeight(null));
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
Font f = new Font("Dialog", Font.BOLD, 40);// g2d.getFont().deriveFont(32.0f);
g2d.setColor(Color.white);
g2d.setFont(g2d.getFont().deriveFont(36.0f));
g2d.drawString(s, 10, im.getHeight(null) / 2);
}
Image images[];
private void initImages(int w, int h) { private void initImages(int w, int h) {
if (images == null) { if (images == null) {
images = new VolatileImage[3]; images = new Image[6];
GraphicsConfiguration gc = getGraphicsConfiguration(); GraphicsConfiguration gc = getGraphicsConfiguration();
for (int i = OPAQUE; i <= TRANSLUCENT; i++) { for (int i = OPAQUE; i <= TRANSLUCENT; i++) {
VolatileImage vi = VolatileImage vi =
gc.createCompatibleVolatileImage(w,h/3,i); gc.createCompatibleVolatileImage(w,h/images.length,i);
images[i-1] = vi; images[i-1] = vi;
vi.validate(gc); vi.validate(gc);
Graphics2D g2d = (Graphics2D) vi.getGraphics(); String s = "LCD AA Text rendered to " + tr[i - 1] + " HW destination";
if (i > OPAQUE) { render(vi, i, s);
clear(g2d, vi.getWidth(), vi.getHeight());
} s = "LCD AA Text rendered to " + tr[i - 1] + " SW destination";
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, images[i-1+3] = gc.createCompatibleImage(w, h/images.length, i);
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); render(images[i-1+3], i, s);
String s = "LCD AA Text rendered to "+tr[i-1]+ " destination";
g2d.drawString(s, 10, vi.getHeight()/2);
} }
} }
} }
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
NonOpaqueDestLCDAATest t = new NonOpaqueDestLCDAATest(); NonOpaqueDestLCDAATest t = new NonOpaqueDestLCDAATest();
t.pack(); t.pack();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册