diff options
author | Erik Reider <[email protected]> | 2024-01-06 02:31:14 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-06 02:31:14 +0100 |
commit | 6759e8da7ab53a46b0eb04e5045b8c67262c3a11 (patch) | |
tree | c65ed83ca04b61bdbae7e1b8a7f2c16f29b89730 /include/render/pixel_format.h | |
parent | b929a2bbadf467864796ad4ec90882ce86cfebff (diff) | |
parent | ace97585b2b4d8cbb5ead6cd0f72fa8e8889c9d7 (diff) |
Merge pull request #24 from wlrfx/wlroots-0.17-rebase
Rebase to wlroots 0.17
Diffstat (limited to 'include/render/pixel_format.h')
-rw-r--r-- | include/render/pixel_format.h | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/include/render/pixel_format.h b/include/render/pixel_format.h index d045b6a..6ca11f3 100644 --- a/include/render/pixel_format.h +++ b/include/render/pixel_format.h @@ -1,26 +1,64 @@ -#ifndef RENDER_PIXEL_FORMAT_H -#define RENDER_PIXEL_FORMAT_H +#ifndef FX_RENDER_PIXEL_FORMAT_H +#define FX_RENDER_PIXEL_FORMAT_H #include <wayland-server-protocol.h> +/** + * 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; + uint32_t drm_format; - /* Equivalent of the format if it has an alpha channel, - * DRM_FORMAT_INVALID (0) if NA - */ - uint32_t opaque_substitute; + /* Equivalent of the format if it has an alpha channel, + * DRM_FORMAT_INVALID (0) if NA + */ + 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; + /* True if the format has an alpha channel */ + bool has_alpha; }; +/** + * Get pixel format information from a DRM FourCC. + * + * NULL is returned if the pixel format is unknown. + */ 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, + int32_t stride, int32_t width); +/** + * Convert an enum wl_shm_format to a DRM FourCC. + */ uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt); +/** + * Convert a DRM FourCC to an enum wl_shm_format. + */ enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt); #endif |