Escher on OpenJDK graphics

After a couple of hours hacking I’ve got a small Swing demo running pretty cool on my ‘next generation’ Escher peer implementation:

This uses the JDK Java2D rendering pipeline architecture. The cool thing is, that there are generic implementations for (almost?) everything Java2D. I started out with a bare minimum implementation which only could set and get single pixel. This was awefully slow. I optimized a couple things: accelerated (X Pixmap) volatile images instead of buffered images, blitting between those and the window surface, drawing lines, filling and drawing rectangles and a very simple font renderer. This is already enough to allow large pieces of Swing to render pretty fast. And it covers all of Java2D with no extra effort (but slowly).

Regarding the font rendering, I am not sure why it looks so crappy. I have the feeling that the glyphs are not hinted, but this is the FreeType font engine and it should do hinting (or not?). At the graphics level I only set the pixels that I am told to set. Besides that I have nothing to do with the glyphs at all. The EscherTextRenderer is a simple subclass of GlyphListPipe, which implements only drawGlyphList(). If anybody has a good guess how I can improve the glyph rendering, please comment.

Kudos to whoever designed the Java2D pipeline architecture (I think it was Jim Graham). It is really well thought out in most places. I think I will write up some documentation on how to get started, so that implementing new graphics backends becomes a little easier.


2 Responses to Escher on OpenJDK graphics

  1. Dmitri Trembovetski says:

    I passed the kudos to Jim =)

  2. Bob Igo says:

    Would you be willing to post the code you used? I tried a very minimal HelloWorldSwing program on an iPaq hx4700 running Angstrom and using jamvm and GNU classpath, and it took 4 minutes between running the program and it displaying “Hello World” in a JLabel within a JFrame. My guess is that the hx4700 is just too weak to properly handle Swing, but you had mentioned some optimizations that you did, which, while a longshot, may help performance on the hx4700.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: