From 1dcbc3c6f8626cd6fa8051716ebc0cf27f88d526 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 26 Oct 2022 19:18:37 +0200 Subject: [PATCH] backends/drm: fix format sorting As the drm format number of 10 bit colors is lower, the fallback sorting preferred those formats, even if KWIN_DRM_PREFER_COLOR_DEPTH=24 was set. To fix that, prefer 8 bit colors over something random. --- src/backends/drm/drm_egl_layer_surface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backends/drm/drm_egl_layer_surface.cpp b/src/backends/drm/drm_egl_layer_surface.cpp index 0e416a0279..664a452d26 100644 --- a/src/backends/drm/drm_egl_layer_surface.cpp +++ b/src/backends/drm/drm_egl_layer_surface.cpp @@ -225,10 +225,13 @@ bool EglGbmLayerSurface::createGbmSurface(const QSize &size, const QMap rhs.alphaSize; } else if (m_eglBackend->prefer10bpc() && ((lhs.bpp == 30) != (rhs.bpp == 30))) { // prefer 10bpc / 30bpp formats - return lhs.bpp == 30 ? true : false; + return lhs.bpp == 30; + } else if ((lhs.bpp == 24) != (rhs.bpp == 24)) { + // prefer 8bpc / 24bpp formats over something we don't ask for + return lhs.bpp == 24; } else { - // fallback - return lhs.drmFormat < rhs.drmFormat; + // fallback: prefer higher bpp + return lhs.bpp > rhs.bpp; } }); for (const auto &format : qAsConst(sortedFormats)) {