I have an app that does a fairly simple image drawing operation in Java 2D. When I run the app under Java 6 (from the Apple Java Developer package), it draws at about 130 Mpixels/sec. When I run the same app under either Oracle JDK 7 or my own build of OpenJDK 7 (from the macosx-port-dev Mercurial branch), it draws at about 20 Mpixels/sec.

You can build enough of the app to demonstrate this issue by doing:

  svn co svn://svn.code.sf.net/p/turbovnc/code/trunk/java java
  cd java
  javac com/turbovnc/vncviewer/ImageDrawTest.java
  java -Dsun.java2d.trace=count -cp . com.turbovnc.vncviewer.ImageDrawTest

Results from Java 6:
--------------------

Graphics device supports HW acceleration.
Window size: 1240 x 900
129.607164 Mpixels/sec
130.089516 Mpixels/sec
4768 calls to sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntArgbPre)

Results from Java 7:
--------------------

Graphics device supports HW acceleration.
Window size: 1240 x 900
19.109939 Mpixels/sec
20.604652 Mpixels/sec
19.849651 Mpixels/sec
316 calls to sun.java2d.opengl.OGLSwToSurfaceBlit::Blit(IntRgb, AnyAlpha, "OpenGL Surface")
2 calls to sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntRgb)
317 calls to sun.java2d.opengl.OGLRTTSurfaceToSurfaceBlit::Blit("OpenGL Surface (render-to-texture)", AnyAlpha, "OpenGL Surface")
6 calls to sun.java2d.loops.FillRect::FillRect(AnyColor, SrcNoEa, AnyInt)
641 total calls to 4 different primitives

It seems clear that Java 7 is using OpenGL by default to implement Java 2D drawing, and this path is apparently slow on my machine (probably others as well. I'm using a Mac Mini with nVidia GeForce 9400 and OS X 10.8.5.) But there appears to be no way to get back the faster loops that were used in Java 6. I'd love to be able to just do -Dsun.java2d.opengl=false, but no luck there. If I could figure out how to make the OpenGL drawing faster, that would be acceptable as well.

Any help is greatly appreciated.

Reply via email to