Escher on OpenJDK graphics
February 25, 2008 2 Comments
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.