Java 6 hardware acceleration on Mac OS X

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.

+5
source share
3 answers

Run the profiler in "jvisualvm" to determine where the time is going.

+2
source

Apple JVM MacOS X. , , JVM . , ( , Windows, ). , Apple CPU.

+1

OpenGL can be enabled when calling java, for example.

java -Dsun.java2d.opengl = true MyJavaGame

It's too easy to enable opengl from your java application

System.setProperty("sun.java2d.opengl", "true"); 

Not sure how this works on iOS / Linux / Android and may need more attention.

0
source

All Articles