I have a java application that I wrote that loads a TTF font and uses the drawString method from Graphics2D. This is called every 50 ms when the x and y positions change each time so that the text moves. When I run the program on Windows, I get 0-1% of the processor load, but on Mac I get about 75% of the usage. This Windows machine has a better processor, but there shouldn't be that much difference. I think this is due to hardware acceleration, and I want to know how to do it. I discovered some Mac-specific Java properties , but none of them reduced my CPU usage. Any ideas on how to improve Java 2D performance on OS X? Thank.
EDIT1: I thought these properties would help, but they did not.
System.setProperty("sun.java2d.opengl", "true");
System.setProperty("apple.awt.graphics.UseQuartz","true"); System.setProperty("apple.awt.graphics.EnableQ2DX","true");
EDIT2: You can download the project source code and byte code here: http://drop.io/ExampleScreenSaver
EDIT3: Since drop.io no longer exists, I uploaded the project to Google Code . Now you can view the code without downloading it. I still don’t know how to approach this problem, so any help would be appreciated.
source
share