-
Notifications
You must be signed in to change notification settings - Fork 0
JNode Graphics2D
Graphics2D implementation with hardware acceleration support in JNode's AWT peer layer.
JNode provides two Graphics2D implementations for AWT component rendering:
-
Current:
JNodeSurfaceGraphics2D— extendsSurfaceGraphics2D, delegates drawing operations to aSurfaceabstraction -
Deprecated:
JNodeGraphics2D— extendsAbstractSurfaceGraphics2D(which extends GNU Classpath'sAbstractGraphics2D), uses an internalBufferedImagefor software rendering
Both implementations bridge the standard Java 2D API to JNode's video driver layer via the Surface interface.
java.awt.Graphics2D
├── SurfaceGraphics2D (abstract, gui/src/awt/org/jnode/awt/util/)
│ └── JNodeSurfaceGraphics2D (gui/src/awt/org/jnode/awt/)
└── gnu.java.awt.java2d.AbstractGraphics2D (GNU Classpath)
└── AbstractSurfaceGraphics2D (abstract, deprecated, gui/src/awt/org/jnode/awt/util/)
└── JNodeGraphics2D (deprecated, gui/src/awt/org/jnode/awt/)
JNodeSurfaceGraphics2D wraps an AbstractSurface (from the video driver layer) and delegates all rendering through it:
-
getDestinationRaster()lazily creates aBufferedImage(TYPE_INT_ARGB) sized to the component -
Drawing operations (
fill,draw,drawString) delegate tosurface.draw(...),surface.fill(...), orFontManager -
updateRaster()blits theBufferedImageback to the surface viadrawImage(image, 0, 0, null)
This is a double-buffering approach: rendering writes to an offscreen BufferedImage, and updateRaster flushes it to the physical surface.
JNodeGraphics2D uses the older AbstractSurfaceGraphics2D base:
-
getDestinationRaster()lazily creates aBufferedImage(TYPE_INT_ARGB) -
Drawing operations (
rawDrawLine,rawFillRect,rawDrawString) directly call surface methods -
updateRaster()callsrawUpdateRaster()to flush the raster to the surface
AbstractSurfaceGraphics2D also manages rendering modes (PAINT_MODE vs XOR_MODE) via Surface.PAINT_MODE/Surface.XOR_MODE.
The Surface interface (org.jnode.driver.video.Surface) is the core abstraction for paintable 2D regions:
- FrameBuffer-backed: Physical video memory or memory-mapped framebuffer
- BufferedImage-backed: In-memory image buffer used as rendering target
Key surface operations used by Graphics2D:
-
surface.drawCompatibleRaster(...)— blit a raster to the surface -
surface.fillRect(...)/surface.drawLine(...)— primitive drawing -
surface.copyArea(...)— fast copy forcopyArea -
surface.draw(...)— shape rendering viaBasicSurfaceGraphics -
surface.getColorModel()— get theColorModelfor raster compatibility
Both Graphics2D implementations route text rendering through JNodeToolkit.getFontManager():
tk.getFontManager().drawText(surface, getClip(), getTransform(), text, font, x, y, getColor());The FontManager (org.jnode.awt.font.FontManager) dispatches to TrueType (TTFFontData) or BDF (BDFFontContainer) renderers. See Font-Rendering for details.
AbstractSurfaceGraphics2D maintains a mode field:
-
Surface.PAINT_MODE— normal opaque paint (set viasetPaintMode()) -
Surface.XOR_MODE— XOR composite mode for fast drawing (set viasetXORMode(Color))
Only JNodeSurfaceGraphics2D supports full Graphics2D state (AffineTransform, Composite, Stroke, Paint, RenderingHints).
JNodeToolkit.getColorModel() provides the ColorModel for the current display configuration. Graphics2D classes use this to:
- Validate raster compatibility (
isCompatibleRaster) - Convert between pixel formats when blitting images
The video driver layer supports multiple bit-depths (8bpp indexed, 16bpp, 24bpp, 32bpp), and the color model adapts accordingly.
| Class | Role |
|---|---|
BasicSurfaceGraphics |
Simple Graphics implementation delegating to Surface, handles origin translation, clipping, color, font |
SurfaceGraphics2D |
Full Graphics2D state (transform, composite, stroke, paint, hints) delegating simple operations to BasicSurfaceGraphics
|
AbstractSurface |
Base for surface implementations in org.jnode.driver.video.util
|
BufferedImageSurface |
In-memory surface wrapping BufferedImage
|
GraphicsFactory |
Factory for creating appropriate Graphics2D instances per component type |
-
Deprecated path:
JNodeGraphics2D/AbstractSurfaceGraphics2Dare marked@deprecatedand may be removed -
Missing implementations:
JNodeSurfaceGraphics2Dhas stub implementations forclip(Shape),drawRenderedImage,drawRenderableImage,drawImage(AffineTransform),drawImage(BufferedImageOp),hit(),shear()— all emit debug messages viaUnsafe.debug -
getDeviceConfiguration()returnsnullinJNodeSurfaceGraphics2D -
Double buffering overhead: The current implementation renders to a
BufferedImagethen blits to the surface, adding a copy per update cycle -
Clip transformation:
BasicSurfaceGraphicshandles origin translation;JNodeSurfaceGraphics2Dapplies anAffineTransformfrom the graphics origin for shape operations
-
gui/src/awt/org/jnode/awt/JNodeGenericPeer— the AWT peer base; creates Graphics2D instances viaGraphicsFactory -
gui/src/awt/org/jnode/awt/JNodeToolkit— providesgetGraphics()returning theAbstractSurface, color model, and font metrics -
gui/src/awt/org/jnode/awt/util/BasicSurfaceGraphics— simple Graphics implementation underlying both Graphics2D classes -
gui/src/awt/org/jnode/awt/util/AbstractSurfaceGraphics2D— deprecated base with direct surface rendering -
gui/src/driver/org/jnode/driver/video/— video driver layer withSurfaceinterface and implementations