Skip to main content

compute_coverage

Function compute_coverage 

Source
pub fn compute_coverage(xleft: [i32; 4], xright: [i32; 4], x: i32) -> u8
Expand description

The 8-bit sub-pixel coverage mask for integer pixel column x, given the per-Y-subpixel left/right span edges (each s.3, from quantize_x).

The RDP samples 4 Y-subpixels × 2 X-samples = 8 sub-positions. The two X-samples sit at sub-pixel fractions that alternate by Y-subpixel — {0, 4} for Y-subpixels 0/2 and {2, 6} for 1/3 — the RDP’s diamond sample pattern (coverage.h:31-44 u16x4(0, 4, 2, 6)). A sample is covered when it lies in the half-open span [xleft, xright) of its Y-subpixel.

Bit layout. The oracle’s clip_x0 * (1,2,4,8) + clip_x1 * (16,32,64,128) packs the two X-samples of each Y-subpixel into adjacent bits — bit 2·Ysub + Xsample — so the mask reads (LSB→MSB) Y0X0 Y0X1 Y1X0 Y1X1 Y2X0 Y2X1 Y3X0 Y3X1, not all-X0 then all-X1. Bit 0 is therefore the top-left sample (Y-subpixel 0, X-sample 0), which is the one the AA-off path tests. The popcount (u8::count_ones) is the coverage count (0–8) regardless of order.

See quantize_x for the domain of xleft/xright and why this has no runtime caller yet.