web engine - experimental web browser

Software renderer: paint to CG bitmap #36

open opened by pierrelf.com

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) -> Renderer
  • Renderer::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 Color struct 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 warnings passes
  • cargo test -p we-render passes
  • No unsafe code in render crate (unsafe only in platform crate for CG calls)
  • No external dependencies
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mfubu6tdco2k