Expand description
Built-in GPU shape pipelines (D109 / Phase 27 Step 3) — geometry, uniform layout, and WGSL sources.
Lives in rosace-render (Layer 4) so SkiaCanvas::play_picture can
convert shape DrawCommands to GPU quads without an upward dependency;
rosace-shader::builtin (Layer 5) wraps these WGSL sources into
ShaderSpecs and registers them, and re-exports everything here for
app-facing use.
The SDF fragment shaders that replace tiny-skia’s CPU rasterization
for ROSACE’s built-in DrawCommand shapes. Five pipelines cover all
eight shape variants:
| Pipeline | Serves |
|---|---|
FILL_RRECT | FillRect (r=0), FillRRect, FillCircle |
STROKE_RRECT | StrokeRect (r=0), StrokeRRect |
GRADIENT | FillGradient (two-stop, axis-aligned, rounded) |
ARC | FillArc (ring segment, round caps) |
SHADOW | DrawShadow (Gaussian-approx rounded shadow) |
Every conversion function here maps a shape in PHYSICAL pixels to
(quad_rect, uniform_bytes): the quad is the shape’s bounds inflated by
the AA/blur margin (an SDF’s anti-aliasing ramp extends past the exact
bounds; an un-inflated quad would slice the ramp off), and the uniforms
carry the true geometry in quad-local px. Colors are sRGB u8 (what
DrawCommand records) converted to LINEAR premultiplied-ready f32 here
— the fragment outputs linear, the sRGB surface encodes on write (the
same one-correct-round-trip rule as the compositor’s texture formats).
All uniform structs share ONE layout (BuiltinShapeUniforms, 64 bytes)
so every pipeline binds identically; each interprets params its own
way, documented per conversion function.
Structs§
- Builtin
Shape Uniforms - The one uniform layout every built-in pipeline binds.
Constants§
- ARC_ID
- FILL_
RRECT_ ID - Raw pipeline ids of the built-in pipelines — inside
PipelineId’s reserved built-in range (< 0x100).rosace-shader::builtinexposes the typed constants. - GRADIENT_
ID - SHADOW_
ID - STROKE_
RRECT_ ID
Functions§
- arc_
quad FillArc→ARCquad: ring segment ofthicknessalong the circle ofradiuscentered atcenter, fromstart_degsweepingsweep_degclockwise (0° = 3 o’clock, y-down), ROUND caps (the CPU path strokes withLineCap::Round). shape: (center in quad-local px); params: (radius, thickness, start_rad, sweep_rad) — sweep normalized non-negative here so the shader needs no sign handling.- builtin_
wgsl_ sources - The five built-in pipelines as
(raw_id, full_wgsl_fragment_source)— consumed byrosace-shader::builtin::register_builtins(), which wraps them inShaderSpecs (a Layer-5 type this crate cannot name). - fill_
rrect_ quad FillRect/FillRRect/FillCircle→FILL_RRECTquad. params: (corner_radius, 0, 0, 0).- gradient_
quad FillGradient→GRADIENTquad. Two stops,fromat the rect’s top/left edge totoat the bottom/right (pad spread), masked by the rounded rect. params: (corner_radius, vertical ? 1 : 0, 0, 0).- linear_
rgba - sRGB u8 RGBA → linear f32 RGBA (alpha is linear already).
- shadow_
quad DrawShadow→SHADOWquad: Gaussian-approximate drop shadow of the rounded rect. params: (corner_radius, sigma, 0, 0). Sigma maps from the CPU path’s box-blurblurparameter: three box passes of width b approximate a Gaussian with σ ≈ b/2 — tuned against the realbuild_shadow_maskoutput in the A/B demo, not derived on paper.- stroke_
rrect_ quad StrokeRect/StrokeRRect→STROKE_RRECTquad. The stroke is centered on the shape edge (tiny-skiaStrokeconvention). params: (corner_radius, stroke_width, 0, 0).