Commit 0c67eb98 authored by Bernie Innocenti's avatar Bernie Innocenti 🕶
Browse files

[decorations] Fix rendering for depth 30 (10bpc)

When the display is set to 30-bit depth (10-bit per color component),
decorations of some clients appear garbled when compositing is disabled.
This is because the pixel format of the QImage in which the decorations
were rendered differed from the the X pixmap into which the pixels were
being copied by means of xcb_put_image().

For lack of a more robust way, this change guesses A2RGB30 for depth=30,
and keeps using ARGB32 as before for any other depth. I don't expect
anything other to 32bpp to be supported by KWin anyway.

Tested on amdgpu with KWIN_OPENGL_INTERFACE=egl.

BUG: 406302
FIXED-IN: 5.19.4
parent 72cd67cb
......@@ -19,6 +19,7 @@ along with this program. If not, see <>.
#include "decorationrenderer.h"
#include "decoratedclient.h"
#include "decorations/decorations_logging.h"
#include "deleted.h"
#include "abstract_client.h"
#include "screens.h"
......@@ -67,7 +68,25 @@ QImage Renderer::renderToImage(const QRect &geo)
auto dpr = client()->client()->screenScale();
QImage image(geo.width() * dpr, geo.height() * dpr, QImage::Format_ARGB32_Premultiplied);
// Guess the pixel format of the X pixmap into which the QImage will be copied.
QImage::Format format;
const int depth = client()->client()->depth();
switch (depth) {
case 30:
format = QImage::Format_A2RGB30_Premultiplied;
case 24:
case 32:
format = QImage::Format_ARGB32_Premultiplied;
qCCritical(KWIN_DECORATIONS) << "Unsupported client depth" << depth;
format = QImage::Format_ARGB32_Premultiplied;
QImage image(geo.width() * dpr, geo.height() * dpr, format);
QPainter p(&image);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment