Skip to main content

blend_pixel

Function blend_pixel 

Source
pub(crate) fn blend_pixel(dst: &mut [u8], r: u8, g: u8, b: u8, a: u8)
Expand description

Alpha-blend a source pixel (pre-split into r,g,b,a) over a BGRA destination pixel.

Overlay pixels are overwhelmingly either fully opaque or fully transparent, and this runs per pixel per frame on the CPU, so the two extremes are special-cased to skip the blend arithmetic entirely: an opaque source (a == 255) simply overwrites, a fully transparent source (a == 0) is left as-is, and only genuine edge pixels pay for the integer source-over. In every case only the B / G / R bytes are written; the destination’s alpha byte is left as the capture delivered it.