Compositor
Overview
The Compositor merges off-screen window buffers into a final image before sending to the screen. Modern OSs don't let windows draw over each other directly; they draw to off-screen buffers, and the Compositor handles transparency, shadows, and z-order.
Architecture Update: The compositor will be integrated into the fwcompositor window manager service. Applications will send window buffers via IPC, and the fwcompositor service will handle compositing and send the final composite to the kernel. See Windowing Architecture for details.
Current Implementation: The Node.js compositor (
system/compositor.js) is a structural implementation that demonstrates the compositing logic. It will be used by the fwcompositor service once implemented.
Key Features
- Z-order management
- Transparency and alpha blending
- Shadow rendering
- Invalidation region calculation
- Window buffer registration
Methods
registerWindow(hwnd, dc)
Registers a window's Device Context with the compositor.
render() / composite()
Renders all windows to the framebuffer. The render() method (aliased as composite()) uses the graphics bridge to blit window buffers directly to the VESA framebuffer. Draws from bottom to top in Z-order.
render() {
const graphicsBridge = require('./graphics-bridge');
// Initialize graphics if needed
if (!graphicsBridge.initialized) {
graphicsBridge.init();
}
// Clear screen
graphicsBridge.clear(0xFF000000);
// Blit all windows to framebuffer
for (const window of windows) {
if (window.visible && window.dirty) {
graphicsBridge.blitWindow(
window.x, window.y,
window.width, window.height,
window.dc.buffer // RGBA buffer
);
window.dirty = false;
}
}
}
invalidateRegion(x, y, width, height)
Calculates which windows intersect with an invalidated region.
bringToTop(hwnd) / sendToBottom(hwnd)
Manages window z-order.
Graphics Integration
The Compositor is fully integrated with the kernel graphics system:
- Uses
graphics-bridge.jsto access kernel VESA driver - Blits window RGBA buffers directly to framebuffer
- Supports 1024x768x32 graphics mode
- Handles window dirty regions for efficient updates
See Graphics System for complete details on the graphics bridge and VESA driver.