From 34ffeaa4efcc7f504362eb8edb7dcb4d6292705a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 19 Feb 2026 15:49:41 +0100 Subject: [PATCH] render/pixel_format: drop wlr_pixel_format_info.opaque_substitute Move this away from struct wlr_pixel_format_info. The next commit will generate the pixel_format_info table from kdfs, computing a compatible opaque format needs to be done separately from retrieving pixel format metadata (and is not yet supported). --- include/render/pixel_format.h | 5 ---- render/pixel_format.c | 45 ++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/include/render/pixel_format.h b/include/render/pixel_format.h index c49567759..7796ed52a 100644 --- a/include/render/pixel_format.h +++ b/include/render/pixel_format.h @@ -18,11 +18,6 @@ struct wlr_pixel_format_info { uint32_t drm_format; - /* Equivalent of the format if it has an alpha channel, - * DRM_FORMAT_INVALID (0) if NA - */ - uint32_t opaque_substitute; - /* Bytes per block (including padding) */ uint32_t bytes_per_block; /* Size of a block in pixels (zero for 1×1) */ diff --git a/render/pixel_format.c b/render/pixel_format.c index 3a9b92105..d3950de42 100644 --- a/render/pixel_format.c +++ b/render/pixel_format.c @@ -10,7 +10,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_ARGB8888, - .opaque_substitute = DRM_FORMAT_XRGB8888, .bytes_per_block = 4, }, { @@ -19,7 +18,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_ABGR8888, - .opaque_substitute = DRM_FORMAT_XBGR8888, .bytes_per_block = 4, }, { @@ -28,7 +26,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_RGBA8888, - .opaque_substitute = DRM_FORMAT_RGBX8888, .bytes_per_block = 4, }, { @@ -37,7 +34,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_BGRA8888, - .opaque_substitute = DRM_FORMAT_BGRX8888, .bytes_per_block = 4, }, { @@ -90,7 +86,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_RGBA4444, - .opaque_substitute = DRM_FORMAT_RGBX4444, .bytes_per_block = 2, }, { @@ -99,7 +94,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_BGRA4444, - .opaque_substitute = DRM_FORMAT_BGRX4444, .bytes_per_block = 2, }, { @@ -108,7 +102,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_RGBA5551, - .opaque_substitute = DRM_FORMAT_RGBX5551, .bytes_per_block = 2, }, { @@ -117,7 +110,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_BGRA5551, - .opaque_substitute = DRM_FORMAT_BGRX5551, .bytes_per_block = 2, }, { @@ -126,7 +118,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_ARGB1555, - .opaque_substitute = DRM_FORMAT_XRGB1555, .bytes_per_block = 2, }, { @@ -143,7 +134,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_ARGB2101010, - .opaque_substitute = DRM_FORMAT_XRGB2101010, .bytes_per_block = 4, }, { @@ -152,7 +142,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_ABGR2101010, - .opaque_substitute = DRM_FORMAT_XBGR2101010, .bytes_per_block = 4, }, { @@ -161,7 +150,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_ABGR16161616F, - .opaque_substitute = DRM_FORMAT_XBGR16161616F, .bytes_per_block = 8, }, { @@ -174,7 +162,6 @@ static const struct wlr_pixel_format_info pixel_format_info[] = { }, { .drm_format = DRM_FORMAT_ABGR16161616, - .opaque_substitute = DRM_FORMAT_XBGR16161616, .bytes_per_block = 8, }, { @@ -374,9 +361,33 @@ bool pixel_format_is_ycbcr(uint32_t format) { } uint32_t pixel_format_get_opaque_substitute(uint32_t fmt) { - const struct wlr_pixel_format_info *info = drm_get_pixel_format_info(fmt); - if (info == NULL) { - return DRM_FORMAT_INVALID; + switch (fmt) { + case DRM_FORMAT_ARGB8888: + return DRM_FORMAT_XRGB8888; + case DRM_FORMAT_ABGR8888: + return DRM_FORMAT_XBGR8888; + case DRM_FORMAT_RGBA8888: + return DRM_FORMAT_RGBX8888; + case DRM_FORMAT_BGRA8888: + return DRM_FORMAT_BGRX8888; + case DRM_FORMAT_RGBA4444: + return DRM_FORMAT_RGBX4444; + case DRM_FORMAT_BGRA4444: + return DRM_FORMAT_BGRX4444; + case DRM_FORMAT_RGBA5551: + return DRM_FORMAT_RGBX5551; + case DRM_FORMAT_BGRA5551: + return DRM_FORMAT_BGRX5551; + case DRM_FORMAT_ARGB1555: + return DRM_FORMAT_XRGB1555; + case DRM_FORMAT_ARGB2101010: + return DRM_FORMAT_XRGB2101010; + case DRM_FORMAT_ABGR2101010: + return DRM_FORMAT_XBGR2101010; + case DRM_FORMAT_ABGR16161616F: + return DRM_FORMAT_XBGR16161616F; + case DRM_FORMAT_ABGR16161616: + return DRM_FORMAT_XBGR16161616; } - return info->opaque_substitute; + return DRM_FORMAT_INVALID; }