diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c index c64a9b9e..b96f3b21 100644 --- a/libweston/pixel-formats.c +++ b/libweston/pixel-formats.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "helpers.h" #include "wayland-util.h" @@ -375,6 +376,17 @@ static const struct pixel_format_info pixel_format_table[] = { }, }; +WL_EXPORT const struct pixel_format_info * +pixel_format_get_info_shm(uint32_t format) +{ + if (format == WL_SHM_FORMAT_XRGB8888) + return pixel_format_get_info(DRM_FORMAT_XRGB8888); + else if (format == WL_SHM_FORMAT_ARGB8888) + return pixel_format_get_info(DRM_FORMAT_ARGB8888); + else + return pixel_format_get_info(format); +} + WL_EXPORT const struct pixel_format_info * pixel_format_get_info(uint32_t format) { diff --git a/libweston/pixel-formats.h b/libweston/pixel-formats.h index 1f0ec1bb..4e651bbb 100644 --- a/libweston/pixel-formats.h +++ b/libweston/pixel-formats.h @@ -115,6 +115,19 @@ struct pixel_format_info { const struct pixel_format_info * pixel_format_get_info(uint32_t format); +/** + * Get pixel format information for a SHM format code + * + * Given a SHM format code, return a DRM pixel format info structure describing + * the properties of that format. + * + * @param format SHM format code to get info for. + * @returns A pixel format structure (must not be freed), or NULL if the + * format could not be found. + */ +const struct pixel_format_info * +pixel_format_get_info_shm(uint32_t format); + /** * Get pixel format information for a named DRM format *