Skip to main content

shm_src_layout

Function shm_src_layout 

Source
fn shm_src_layout(format: u32) -> (usize, bool)
Expand description

Source bytes-per-pixel and whether R and B swap to reach BGRA, for one announced wl_shm format. The consumers downstream all read BGRA (byte order B,G,R,A), so a format is mapped by where its red and blue land in memory under the little-endian byte order wayland.xml specifies:

  • Xrgb8888 / Argb8888 ([31:0] x:R:G:B LE) are B,G,R,x in memory: already BGRA, no swap.
  • Xbgr8888 / Abgr8888 ([31:0] x:B:G:R LE) are R,G,B,x in memory: swap R/B.
  • Bgr888 ([23:0] B:G:R LE) is R,G,B in memory: swap R/B (the 24-bit NVIDIA-GLES read path).
  • Rgb888 ([23:0] R:G:B LE) is B,G,R in memory: already BGR order, no swap.

The empirical NVIDIA-GLES host could not be exercised here, so Bgr888 follows the wl_shm definition literally: [23:0] B:G:R little endian places R in the low byte, so byte 0 is red and reaching BGRA swaps R and B — the opposite of a straight copy.