Phase 3, Issue 6: Software Renderer#
Implement a software renderer in the render crate that paints the layout tree into a CoreGraphics bitmap.
Requirements#
Display list generation:
- Walk the layout tree and generate a flat list of paint commands
- Paint commands:
FillRect(x, y, w, h, color),DrawGlyph(x, y, glyph_bitmap, color) - Z-order: paint in tree order (background first, then text)
Painting:
- Block backgrounds: fill rectangle with background color (white default)
- Text: render each glyph bitmap from the text crate into the CG bitmap
- Text color: black default
- Blend glyph coverage (grayscale anti-aliasing) with text color onto background
API:
Renderer::new(width: u32, height: u32) -> RendererRenderer::paint(layout_tree: &LayoutTree, font: &Font)Renderer::pixels() -> &[u8]— BGRA pixel data ready for CoreGraphics- Or:
render_to_bitmap(layout: &LayoutTree, font: &Font, width: u32, height: u32) -> BitmapContext
Color:
- Simple
Colorstruct with r, g, b, a (u8 each) - Predefined:
Color::BLACK,Color::WHITE
Acceptance criteria#
- Renders a simple page with text visible in the output bitmap
- Block backgrounds are painted
- Text glyphs are composited with anti-aliasing
- Output is BGRA format compatible with platform crate's BitmapContext
-
cargo clippy -p we-render -- -D warningspasses -
cargo test -p we-renderpasses - No unsafe code in render crate (unsafe only in platform crate for CG calls)
- No external dependencies