forked from 1b-agent/opencadstudio-upstream
Paper content viewports with a circle / spline / ellipse clip boundary drew their model content to the full bounding rectangle instead of the shape. Each paper content viewport is its own render into its own screen rectangle, so clipping is done per viewport: the boundary polygon is projected into that viewport's render-target NDC (paper shape mapped through the same visible-sub-rect crop as the content, so it stays fixed to the viewport frame) and stamped into the stencil buffer with an even-odd Invert, which marks the interior of any shape, convex or not, without triangulation. Every content pass then draws only where the stencil is set, so hatch, wire, mesh, 3DFACE, text, image, wipeout and selection are all clipped uniformly. Because Invert turns the cleared 0x00 into 0xFF, clipped content draws with stencil reference 0xFF (unclipped content keeps reference 0). The shared depth buffer moves to Depth24PlusStencil8 across every pipeline. Rectangular viewports keep clipping via their own render rectangle and XCLIP keeps its existing CPU wire clip; neither needs the stencil path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>