From cf6f7a0726f8fd0f9bca7cfe228f9ceeda9ffd1f Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Thu, 4 Nov 2021 18:56:08 +0100 Subject: [PATCH] gbm: use Xrgb8888, if alpha variant is not available --- src/backend/drm/surface/gbm.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/drm/surface/gbm.rs b/src/backend/drm/surface/gbm.rs index 12a94ef..c75c606 100644 --- a/src/backend/drm/surface/gbm.rs +++ b/src/backend/drm/surface/gbm.rs @@ -62,16 +62,21 @@ where // Once we have proper color management and possibly HDR support, // we need to have a more sophisticated picker. // (Or maybe just pick ARGB2101010, if available, we will see.) - let code = Fourcc::Argb8888; + let mut code = Fourcc::Argb8888; let logger = crate::slog_or_fallback(log).new(o!("backend" => "drm_render")); // select a format - let plane_formats = drm + let mut plane_formats = drm .supported_formats(drm.plane())? .iter() - .filter(|fmt| fmt.code == code) .cloned() .collect::>(); + + // try non alpha variant if not available + if !plane_formats.iter().any(|fmt| fmt.code == code) { + code = Fourcc::Xrgb8888; + } + plane_formats.retain(|fmt| fmt.code == code); renderer_formats.retain(|fmt| fmt.code == code); trace!(logger, "Plane formats: {:?}", plane_formats);