-
Bug
-
Resolution: Won't Fix
-
P3
-
7
-
x86
-
windows_7
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b137)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b07, mixed mode)
(Also affects at least 1.6.23 and 1.6.24.)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Enterprise 64 bit (6.1, Build 7600)
EXTRA RELEVANT SYSTEM CONFIGURATION :
GPU: GeForce 8800 GT
CPU: Intel Core2 Quad ###@###.###GHz
RAM: 4GB
A DESCRIPTION OF THE PROBLEM :
Drawing text using the default awt.font.desktophints has less than a tenth of the speed if Direct3D support is not explicitly disabled by using the sun.java2d.d3d command line flag.
Running the test program provided below gives the following results on my configuration:
java -jar DrawingTest.jar => 14 FPS
java -Dawt.useSystemAAFontSettings=off -jar DrawingTest.jar => 420 FPS
java -Dawt.useSystemAAFontSettings=on -jar DrawingTest.jar => 420 FPS
java -Dawt.useSystemAAFontSettings=lcd -jar DrawingTest.jar => 14 FPS
java -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.d3d=false -jar DrawingTest.jar => 205 FPS
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the source code provided below with the following command line arguments:
java -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=off -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=on -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=lcd -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.d3d=false -jar DrawingTest.jar
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Rendering with Direct3D support enabled (which is the default) should at least be as fast as rendering without hardware acceleration.
ACTUAL -
Rendering with Direct3D support enabled provides less than ten percent of the performance of non-accelerated drawing for text with subpixel antialiasing.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
not applicable
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.util.Map;
class TestPanel extends JPanel {
private Integer counter = 0;
private Long timeSpent = 0L;
{
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 10));
}
public void paintComponent(Graphics g) {
Integer repeats = 20;
Toolkit tk = Toolkit.getDefaultToolkit();
Map hints = (Map) tk.getDesktopProperty("awt.font.desktophints");
if(hints != null) ((Graphics2D)g).addRenderingHints(hints);
for(int i = 0; i < 10; i++) {
drawText(g);
}
Long timeStamp = System.currentTimeMillis();
for(int i = 0; i < repeats; i++) {
drawText(g);
}
timeSpent += System.currentTimeMillis() - timeStamp;
counter += repeats;
float fps = counter * 1000.0f / timeSpent;
System.out.println(fps);
}
private void drawText(Graphics g) {
for(int row = 0; row < 70; row++) {
for(int col = 0; col < 50; col++) {
g.drawString("txt", col * 20, row* 10);
}
}
}
}
public class DrawingTest {
public static void main(String[] args) {
System.out.println(System.getProperty("java.version"));
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new TestPanel());
frame.setSize(1024, 768);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Disable Direct3D support on the command line when starting the application.
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b137)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b07, mixed mode)
(Also affects at least 1.6.23 and 1.6.24.)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Enterprise 64 bit (6.1, Build 7600)
EXTRA RELEVANT SYSTEM CONFIGURATION :
GPU: GeForce 8800 GT
CPU: Intel Core2 Quad ###@###.###GHz
RAM: 4GB
A DESCRIPTION OF THE PROBLEM :
Drawing text using the default awt.font.desktophints has less than a tenth of the speed if Direct3D support is not explicitly disabled by using the sun.java2d.d3d command line flag.
Running the test program provided below gives the following results on my configuration:
java -jar DrawingTest.jar => 14 FPS
java -Dawt.useSystemAAFontSettings=off -jar DrawingTest.jar => 420 FPS
java -Dawt.useSystemAAFontSettings=on -jar DrawingTest.jar => 420 FPS
java -Dawt.useSystemAAFontSettings=lcd -jar DrawingTest.jar => 14 FPS
java -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.d3d=false -jar DrawingTest.jar => 205 FPS
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the source code provided below with the following command line arguments:
java -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=off -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=on -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=lcd -jar DrawingTest.jar
java -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.d3d=false -jar DrawingTest.jar
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Rendering with Direct3D support enabled (which is the default) should at least be as fast as rendering without hardware acceleration.
ACTUAL -
Rendering with Direct3D support enabled provides less than ten percent of the performance of non-accelerated drawing for text with subpixel antialiasing.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
not applicable
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.util.Map;
class TestPanel extends JPanel {
private Integer counter = 0;
private Long timeSpent = 0L;
{
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 10));
}
public void paintComponent(Graphics g) {
Integer repeats = 20;
Toolkit tk = Toolkit.getDefaultToolkit();
Map hints = (Map) tk.getDesktopProperty("awt.font.desktophints");
if(hints != null) ((Graphics2D)g).addRenderingHints(hints);
for(int i = 0; i < 10; i++) {
drawText(g);
}
Long timeStamp = System.currentTimeMillis();
for(int i = 0; i < repeats; i++) {
drawText(g);
}
timeSpent += System.currentTimeMillis() - timeStamp;
counter += repeats;
float fps = counter * 1000.0f / timeSpent;
System.out.println(fps);
}
private void drawText(Graphics g) {
for(int row = 0; row < 70; row++) {
for(int col = 0; col < 50; col++) {
g.drawString("txt", col * 20, row* 10);
}
}
}
}
public class DrawingTest {
public static void main(String[] args) {
System.out.println(System.getProperty("java.version"));
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new TestPanel());
frame.setSize(1024, 768);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Disable Direct3D support on the command line when starting the application.