Decora

Decora is the pet name of the pixel effects framework that I developed, which serves as the foundation for the javafx.scene.effect package in JavaFX. It provides easy-to-use (Java) classes for commonly used effects, such as blurs, drop shadows, reflections, color adjustments, displacement mapping, lighting, and perspective transform. It is also intended to be extensible, so that savvy developers can provide their own effects by using a custom language that we developed called JSL (a shading language not unlike GLSL or HLSL).

The project contains a custom compiler that I wrote (using ANTLR), which takes JSL programs and compiles them down into a number of variants, like a GLSL version for use with the OpenGL backend, an HLSL version for use with the Direct3D backend, and a couple different software-based implementations (Java, C/SSE) that can run on the CPU for cases where a GPU is not available.

Although Decora was primarily designed as an implementation detail of the overall JavaFX runtime, it was also designed to be toolkit agnostic, meaning that it could be used as a standalone library, complementing Java2D and other graphics engines.

The source code was originally released on java.net under the scenegraph-effects project, but unfortunately a) that repo has not been updated for a long time because Sun management changed their minds and stopped developing the JavaFX runtime in the open, and b) the license is restrictive (GPL without classpath exception). I hope that someday Sun/Oracle will consider releasing the latest Decora source code again under a more open license, as it's a very useful library for Java developers.

Muni Status

One day in mid-2008, I suddenly became frustrated with the indecipherable status displays that are used in the underground Muni stations in San Francisco. I went home and spent just a couple hours prototyping a new display using JavaFX, which uses subtle animations and crisp scalable graphics to present clear information to Muni patrons.

I prototyped a couple different designs. Here is the original one (even nicer ones followed):

I met with the SFMTA a number of times that year, trying to get them to realize that it doesn't take much effort to come up with something better, and that San Francisco is full of designers and developers who would be glad to donate their time to the project. My designs made their way around SFMTA, and everyone seemed to like them, but in the end it turned out that they had already paid some contractors to design a new status screen that was eventually used in most stations in 2009. The new design, while an improvement over what we had before, has lots of problems and is not as usable as it could be. I regret that I didn't try harder (or get involved sooner), but the SFMTA is a frustrating bureaucracy and it was apparent that I couldn't stop a snowball in motion.

If there was one good result of the exercise, it was that JavaFX is a great platform for whipping up quick prototypes. (I'll post the code here soon just in case anyone's interested in trying it out or learning from it.)

JavaFX

I spent a couple years working on the JavaFX runtime, including Decora (see above), the core scenegraph and animation packages, and Prism, which is a small, highly tuned, GPU-accelerated graphics engine that will be the foundation of an upcoming release of JavaFX. In addition, I wrote a couple demos that are featured on javafx.com (click the thumbnails to visit the sample pages, which include live applets and links to source code):

EffectsPlayground - demonstrates how easy it is to apply pixel effects (blurs, shadows, lighting, etc) to nodes in the scenegraph


BookPanel - demonstrates a page flip effect using a combination of transforms, linear gradients, and soft clipping


I also wrote a series of entries on my old java.net blog about using the effects package in JavaFX:

Java2D and OpenGL

Prior to working on JavaFX, I spent 8+ years tuning Sun's implementation of the Java2D and Image I/O APIs. I developed the OpenGL-based Java2D pipeline from the ground up (see this article and these two blog entries). I also implemented a ton of performance optimizations over the years (see this entry for just one example). The source code for Java2D is available from the OpenJDK project. You can find the sources for the OpenGL pipeline under:
  src/{share,windows,solaris}/classes/sun/java2d/opengl
  src/{share,windows,solaris}/native/sun/java2d/opengl

In addition to my work on Java2D, I helped out a bit with the open source JOGL project, which provides Java bindings to the native OpenGL libraries, in addition to a number of utility packages. I assisted in developing a high performance version of GLJPanel that allows for mixing 2D content (using Java2D and Swing) and 3D content (using JOGL/OpenGL) in the same window. I also helped create some utility classes (TextureIO, etc) that help bridge the gap between Java2D and JOGL. Here are links to a couple blog entries I wrote that contain demos of these features (including source code):

PhotoCube - demonstrates the use of GLJPanel for easy mixing of 2D and 3D content in the same window


BezierAnim3D - demonstrates the use of the TextureIO, TextureRenderer, and TextRenderer classes to take advantage of Java2D features from a JOGL/OpenGL application


Content is © Chris Campbell. Photos are licensed under Creative Commons.