From a9a630401f553d680220764b0436c51e415fb26b Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 20 Nov 2018 17:04:57 +0200 Subject: [PATCH] pixel-formats: Added pixel_format_get_info_shm() helper for printing SHM buffers In current form SHM buffers pixel format can only be printed as 0 and 1. With the help of this helper we align with DRM_FORMAT_ pixel format. Signed-off-by: Marius Vlad --- libweston/pixel-formats.c | 12 ++++++++++++ libweston/pixel-formats.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) 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 *