diff options
author | Simon Ser <contact@emersion.fr> | 2023-05-08 22:17:26 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-05-21 20:28:45 +0000 |
commit | 96f3f3c92e8db16f9acc551b2673db70108988f2 (patch) | |
tree | b5f5fdcfe6164fb38d61c4e02b3a1b71c40f9e2a /include/render | |
parent | 78a1ac540ec1bd1e336f066f6691451643e7b99d (diff) |
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.
Diffstat (limited to 'include/render')
-rw-r--r-- | include/render/pixel_format.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/include/render/pixel_format.h b/include/render/pixel_format.h index 04a095b2..a024ff9d 100644 --- a/include/render/pixel_format.h +++ b/include/render/pixel_format.h @@ -7,6 +7,13 @@ * Information about a pixel format. * * A pixel format is identified via its DRM four character code (see <drm_fourcc.h>). + * + * Simple formats have a block size of 1×1 pixels and bytes_per_block contains + * the number of bytes per pixel (including padding). + * + * Tiled formats (e.g. sub-sampled YCbCr) are described with a block size + * greater than 1×1 pixels. A block is a rectangle of pixels which are stored + * next to each other in a byte-aligned memory region. */ struct wlr_pixel_format_info { uint32_t drm_format; @@ -16,8 +23,10 @@ struct wlr_pixel_format_info { */ uint32_t opaque_substitute; - /* Bits per pixels */ - uint32_t bpp; + /* Bytes per block (including padding) */ + uint32_t bytes_per_block; + /* Size of a block in pixels (zero for 1×1) */ + uint32_t block_width, block_height; /* True if the format has an alpha channel */ bool has_alpha; @@ -30,6 +39,14 @@ struct wlr_pixel_format_info { */ const struct wlr_pixel_format_info *drm_get_pixel_format_info(uint32_t fmt); /** + * Get the number of pixels per block for a pixel format. + */ +uint32_t pixel_format_info_pixels_per_block(const struct wlr_pixel_format_info *info); +/** + * Get the minimum stride for a given pixel format and width. + */ +int32_t pixel_format_info_min_stride(const struct wlr_pixel_format_info *info, int32_t width); +/** * Check whether a stride is large enough for a given pixel format and width. */ bool pixel_format_info_check_stride(const struct wlr_pixel_format_info *info, |