pub enum ClipRole {
Content,
Narrow,
Widen,
}Expand description
What a draw does with the stencil buffer.
§Why the stencil holds a depth rather than a mask
The obvious encoding gives each clip a bit, which caps nesting at eight and
makes intersecting two clips a per-bit affair. Storing the nesting depth
instead lets a clip stack of any size fit in the same eight bits, and makes
the test a single comparison: content belongs to depth d and draws where
the stencil holds d, which is true only where every clip down to that
depth admitted the pixel.
It also makes undoing a clip a local operation. Because a stack unwinds in the order it was built, no pixel can hold more than the depth being left, so stepping back is a decrement rather than a recomputation from the remaining clips.
Variants§
Content
Draw color where the stencil already matches. Leaves the stencil alone.
Narrow
Narrow the clip: step the stencil forward where it matches and this draw covers. Writes no color.
The geometry must be a triangulation of the clip region rather than an overlapping set, since a pixel covered twice would step forward twice and stop matching anything. The fill tessellator produces exactly that, which is what lets this be a plain increment instead of the parity trick an overlapping fan would need.
Widen
Widen the clip back: step the stencil back where it matches. Writes no color.
Implementations§
Source§impl ClipRole
impl ClipRole
Sourcepub const fn writes_color(self) -> bool
pub const fn writes_color(self) -> bool
Whether this role writes to the color attachment.
Sourcepub const fn writes_stencil(self) -> bool
pub const fn writes_stencil(self) -> bool
Whether this role modifies the stencil.