Skip to content

Add path renderer for arcs/strokes/dashing/regions#3

Merged
jserv merged 1 commit into
mainfrom
drawing
Jun 2, 2026
Merged

Add path renderer for arcs/strokes/dashing/regions#3
jserv merged 1 commit into
mainfrom
drawing

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented Jun 2, 2026

This introduces src/path/ as an in-tree scanline path renderer (builder, quad/cubic flatten, arc-to-cubic, stroke expansion with proper miter / bevel / round joins and butt/round/projecting caps, scanline rasterizer, pixman region builder). Route through it:

  • XDrawArc/XFillArc/XDrawArcs/XFillArcs for ArcChord, dashed, wide, or large solid arcs. Small LineSolid one-pixel arcs stay on the legacy point renderer to avoid regressing tiny primitive overhead.
  • XDrawLine/XDrawLines/XDrawSegments/XDrawRectangle wide-stroke and LineOnOffDash/LineDoubleDash paths, with the X11 default miter limit (10) and dash phase carried across MoveTo within a call.
  • XPolygonRegion edge/span construction with pixman union storage.

Other coverage gaps closed:

  • Implement XDrawPoints and XDrawRectangles (previously stubs).
  • Add non-GXcopy software fallback for line, segment, polyline, and rectangle batches so GXxor/GXinvert/plane-mask take effect; batched per line bounding box instead of round-tripping per pixel.
  • XDrawRectangle now traces the spec-mandated (w+1) by (h+1) outline with no double-XOR at corners.
  • Closed-polyline strokes emit joins at the closure vertex instead of caps, so wide rectangle outlines look right.

Summary by cubic

Adds an in-tree scanline path renderer and routes arcs, wide/dashed strokes, and region ops through it for correct joins/caps, better spec compliance, and faster batched draws. Also improves GC raster ops and implements missing point/rectangle APIs.

  • New Features

    • New src/path/ renderer: builder, adaptive flattening, arc-to-cubic, stroke expansion (miter/bevel/round; butt/round/projecting caps), scanline rasterizer, and pixman span/region composition.
    • Routes XDrawArc/XFillArc/XDrawArcs/XFillArcs for ArcChord, wide strokes, dashing, and large solid arcs; tiny 1px LineSolid arcs stay on the legacy path.
    • Wide and dashed strokes for XDrawLine/XDrawLines/XDrawSegments/XDrawRectangle with miter limit 10; dash phase preserved across MoveTo.
    • XPolygonRegion built from edges/spans with pixman storage.
    • Implemented XDrawPoints and XDrawRectangles.
  • Bug Fixes

    • GC raster functions (GXxor, GXinvert, plane-mask) now apply to batched lines/segments/polylines/rectangles via a software fallback per line bbox.
    • XDrawRectangle now traces the spec-mandated (w+1)×(h+1) outline with no double XOR at corners.
    • Closed polylines emit a join at the closure vertex, fixing wide rectangle outlines.

Written for commit 21f55fc. Summary will update on new commits.

Review in cubic

cubic-dev-ai[bot]

This comment was marked as resolved.

This introduces src/path/ as an in-tree scanline path renderer (builder,
quad/cubic flatten, arc-to-cubic, stroke expansion with proper miter /
bevel / round joins and butt/round/projecting caps, scanline rasterizer,
pixman region builder). Route through it:
- XDrawArc/XFillArc/XDrawArcs/XFillArcs for ArcChord, dashed, wide, or
  large solid arcs. Small LineSolid one-pixel arcs stay on the legacy
  point renderer to avoid regressing tiny primitive overhead.
- XDrawLine/XDrawLines/XDrawSegments/XDrawRectangle wide-stroke and
  LineOnOffDash/LineDoubleDash paths, with the X11 default miter limit
  (10) and dash phase carried across MoveTo within a call.
- XPolygonRegion edge/span construction with pixman union storage.

Other coverage gaps closed:
- Implement XDrawPoints and XDrawRectangles (previously stubs).
- Add non-GXcopy software fallback for line, segment, polyline, and
  rectangle batches so GXxor/GXinvert/plane-mask take effect; batched
  per line bounding box instead of round-tripping per pixel.
- XDrawRectangle now traces the spec-mandated (w+1) by (h+1) outline
  with no double-XOR at corners.
- Closed-polyline strokes emit joins at the closure vertex instead of
  caps, so wide rectangle outlines look right.
@jserv jserv merged commit daa5bdf into main Jun 2, 2026
3 checks passed
@jserv jserv deleted the drawing branch June 2, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant