mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
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:
parent
78a1ac540e
commit
96f3f3c92e
9 changed files with 117 additions and 56 deletions
|
|
@ -44,6 +44,9 @@ static struct wlr_drm_dumb_buffer *create_buffer(
|
|||
wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" not supported",
|
||||
format->format);
|
||||
return NULL;
|
||||
} else if (pixel_format_info_pixels_per_block(info) != 1) {
|
||||
wlr_log(WLR_ERROR, "Block formats are not supported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_drm_dumb_buffer *buffer = calloc(1, sizeof(*buffer));
|
||||
|
|
@ -55,7 +58,8 @@ static struct wlr_drm_dumb_buffer *create_buffer(
|
|||
|
||||
buffer->drm_fd = alloc->drm_fd;
|
||||
|
||||
if (drmModeCreateDumbBuffer(alloc->drm_fd, width, height, info->bpp, 0,
|
||||
uint32_t bpp = 8 * info->bytes_per_block;
|
||||
if (drmModeCreateDumbBuffer(alloc->drm_fd, width, height, bpp, 0,
|
||||
&buffer->handle, &buffer->stride, &buffer->size) != 0) {
|
||||
wlr_log_errno(WLR_ERROR, "Failed to create DRM dumb buffer");
|
||||
goto create_destroy;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue