render/pixel-format: add support for block-based formats

Some formats like sub-sampled YCbCr use a block of bytes to
store the color values for more than one pixel. Update our format
table to be able to handle such formats.
This commit is contained in:
Simon Ser 2023-05-08 22:17:26 +02:00
parent 78a1ac540e
commit 96f3f3c92e
9 changed files with 117 additions and 56 deletions

View file

@ -71,8 +71,7 @@ static struct wlr_buffer *allocator_create_buffer(
wlr_buffer_init(&buffer->base, &buffer_impl, width, height);
// TODO: consider using a single file for multiple buffers
int bytes_per_pixel = info->bpp / 8;
int stride = width * bytes_per_pixel; // TODO: align?
int stride = pixel_format_info_min_stride(info, width); // TODO: align?
buffer->size = stride * height;
buffer->shm.fd = allocate_shm_file(buffer->size);
if (buffer->shm.fd < 0) {