pub struct XPathSeg {
pub x0: f64,
pub y0: f64,
pub x1: f64,
pub y1: f64,
pub dxdy: f64,
pub dxdy_fp: i32,
pub flags: XPathFlags,
}Expand description
A single line segment in the edge table, in device space.
Matches SplashXPathSeg from splash/SplashXPath.h.
§Invariant
After construction by XPath::add_segment (internal), every non-horizontal
segment satisfies y0 ≤ y1. Horizontal segments (HORIZ flag set) are exempt.
Fields§
§x0: f64X coordinate of the segment start point, in device space.
y0: f64Y coordinate of the segment start point, in device space.
Invariant: y0 ≤ y1 for all non-horizontal segments after
construction. XPathFlags::FLIPPED is set when the original input had
y0 > y1 and the endpoints were swapped to enforce this invariant.
x1: f64X coordinate of the segment end point, in device space.
y1: f64Y coordinate of the segment end point, in device space.
Always y0 ≤ y1 for non-horizontal segments after construction.
dxdy: f64Slope (x1-x0)/(y1-y0), stored as both f64 (for initialising the
fixed-point accumulator) and as a 16.16 fixed-point i32 (dxdy_fp)
for the per-scanline stepping hot loop.
Set to 0.0 / 0 for horizontal and vertical segments.
dxdy_fp: i32Slope in 16.16 fixed-point: (dxdy * 65536.0).round() as i32.
Used by the scanner’s incremental x-accumulator: xx_fp += dxdy_fp per
scanline. Integer addition instead of f64 addition eliminates floating-
point dependency chains in the inner loop and is trivially vectorizable.
Precision: 1/65536 ≈ 1.5 × 10⁻⁵ device pixels per scanline — sufficient for any realistic document (the error accumulates as at most one pixel per ~65536 scanlines, far beyond any real page height).
flags: XPathFlagsOrientation and flip flags; see XPathFlags for the set of valid bits.