CARVIEW |
The 2D Graphics Group
The 2D Graphics group is centered around people interested in the creation and maintanence of the 2D API and implementation.
Introduction
The Java 2D API and its implementation is often not easily separable from other parts of the Java platform.
Generally it implements geometry, text and image APIs and renders these to screen and printer devices using software, or hardware accelerated means, depending on implementation and/or application or user specified system properties.
Very briefly, the core of the API is the class java.awt.Graphics2D. It provides methods for the rendering operations, as well as controlling the state of the Graphics instance.
There's a large supporting cast of classes in the packages
java.awt
java.awt.color
java.awt.font
java.awt.geom
java.awt.image
java.awt.print
(Java 2D printing to a printer graphics)javax.imageio
(aka Image I/O)javax.print
(aka the Java Printing Service, works with java.awt.print)
Image I/O provides the means load and save sampled images where the in-process image use Java2D's image format.
javax.print
is tightly integrated with
the java.awt.print package which is the 2D API for rendering to
printer graphics devices.
There is a wealth of information on the Java 2D API for application developers. e.g. See:
Regarding Java 2D's source code.
All of the Java 2D's code is in the "j2se" workspace, so all references below are relative to the root of the "j2se" workspace.
Most of the relevant sources have a java and native component.
The Java 2D-related java code is can be browsed from Netbeans by opening the "awt2d" project. This project also contains the files belonging to AWT - see the README file in the "awt2d" project directory. (note that with some effort the native code can be worked on from Netbeans as well, see the README mentioned above)
All sources are either 'share' or 'windows' or 'solaris', the latter of which in fact includes Linux(TM) and is so named for historical reasons and because in practice the Solaris(TM) code and the Linux code are usually so close that a few ifs or ifdefs suffice to distinguish them. This is partially explained by observing that for 2D, Solaris and Linux are just both platforms for X11.
Most of 2D's code is in 'share'. Even the OpenGL code.There is a still significant but lesser amount of code that is specific to X11 or Win32/GDI. But here for brevity we just point out the shared locations.
These all are under "src/share"
. The
Java classes are located corresponding to the package hierarchy.
E.g. java.awt.Graphics2D is in:
src/share/classes/java/awt/Graphics2D.java
Implementation (non-public) classes are generally in a package starting with "sun.". E.g.:
src/share/classes/sun/awt
src/share/classes/sun/awt/geom
src/share/classes/sun/awt/image
src/share/classes/sun/font
src/share/classes/sun/java2d
src/share/classes/sun/print
There are exceptions, notably:
src/share/classes/com/sun/imageio
Java 2D also has a substantial amount of native code. This is located in similar manner :
src/share/native/sun/awt/image
src/share/native/font
src/share/native/java2d
(Note that the platform-specific native code is
naturally in the corresponding
src/[platform]/native/..
directory)
The shared code location contains essentially complete implementations of everything since 2D has its own code for everything needed to implement the API.
The relevant j2se workspace make files are structured in the following way:
make/java/awt
- builds most API classesmake/javax/imageio
- builds ImageIOmake/javax/print
- builds most of the printing implementationmake/sun/awt
- builds much of the 2D implementationmake/sun/cmm
- builds much the color management systemmake/sun/dcpr
- builds the graphics rasterisermake/sun/font
- builds the 2D font implementation and rasterisermake/sun/jpeg
- builds the IJG JPEG library
One can also build the 2d source tree from the "awt2d" Netbeans project (both native and java).
Non-open Java 2D source code.
Some parts of Java 2D were not part of the initial OpenJDK source release, or are different than in the commercial releases from Sun and its licensees. We want to remove these so that the full OpenJDK can be built entirely from sources. We call this "removing encumbrances", a reference to the legal term "encumbered".
Generally the reason for this is that the code was licensed by Sun from a 3rd party. Not all code that is as yet unreleased is certain to stay that way. We are still working on disentangling the code that cannot be opened from code that can. In some cases this comes down to parts of a source file.
Since launch very substantial progress has been made on this, and what follows details that. Here's a summary of the encumbrances that were identified and the current state.
-
Native code color management system
The Color Management System - a C library - and several color profile files were licensed for use in JDK 1.2. To replace this "Little CMS" (lcms) was identified as a suitable replacement open source library. There is a pluggable layer, so that for now the commercial version can use the old CMS and OpenJDK can use lcms.
src/share/classes/sun/java2d/cmm
contains the pluggable layer. CMSManager.java is the class called by 2D code that needs to invoke color operations. On first load CMSManager uses the java.util.ServiceLoader class to locate an implementation of the PCMM interface.Glue code for LittleCMS that implements that interface is in:
src/share/classes/sun/java2d/cmm/lcms
In turn it loads the native lcms library.
The source code for OpenJDK's copy of this is in:
src/share/native/sun/java2d/cmm/lcms
Color profiles are located in:
src/share/lib/cmm/lcms
Status : This was resolved before launch. The only known issues are several bugs, eg: a couple of non-essential ICC color profiles are not in the OpenJDK. These are non-essential because the Sun JRE doesn't require them.
-
Font rasteriser
The font rasteriser is a native library licensed for use by Java 2D in JDK 1.2. To replace it in the OpenJDK we identified freetype as the most viable cross-platform alternative. It is already used by the native desktops on Linux and OpenSolaris.
Similarly to the CMS case, there is a pluggable layer so that the commercial JDK can use the licensed rasteriser whilst OpenJDK uses freetype. The file
src/share/classes/sun/font/FontScaler.java
-
src/share/classes/sun/font/FreetypeFontScaler.java
Status : This work is complete and has been in OpenJDK since Aug. 2007
-
Antialiasing graphics rasteriser.
The Ductus rasteriser is a small set of Java classes backed by a native library used to perform path stroking and filling. It was licensed for use in JDK 1.2, and needed an open source replacement.
The Pisces renderer was identified as a replacement since it was already open source and it could be adapted to the JDK relatively easily, selecting only the parts needed. Full Pisces sources are at :
- https://phoneme.dev.java.net/svn/phoneme/components/pisces/trunk
- but OpenJDK needs only about 8 files from there.
src/share/classes/sun/java2d/pipe/RenderingEngine
defines the pluggable layer. On instantiation the class uses thejava.util.ServiceLoader
class to locate an implementation of this abstract class.The partial Pisces sources and the class that implements this interface is in:
src/share/classes/sun/java2d/pisces/
Status : This is resolved although improvements can be made to the implementation. Specifically :
- Performance is not as good as the library it replaces.
- Fixed point is used with little or no overflow protection
- Support for the STROKE_CONTROL hint
-
Imaging and Color API classes.
A number of API classes are not yet in the open source area. These are selected classes in the packages :java/awt/color
java/awt/image
java/awt/image/renderable
-
Status : This is still under investigation.
Community
- Mailing lists
- 2d-dev - 2D OpenJDK development mailing list
- 2D Graphics Bloggers
Terms of Use · Privacy · Trademarks