[backends/fbdev] Support framebuffers with different color depths

Support more framebuffer color depths

REVIEW: 126262
BUG: 355569
FIXED-IN: 5.5.1
This commit is contained in:
Nerdopolis Turfwalker 2015-12-15 13:04:23 +01:00 committed by Martin Gräßlin
parent 14b9046ad2
commit 3247382752

View file

@ -157,15 +157,48 @@ QImage::Format FramebufferBackend::imageFormat() const
if (m_fd < 0) {
return QImage::Format_Invalid;
}
if (m_alpha.length == 0 &&
qCDebug(KWIN_FB) << "Bits Per Pixel: " << m_bitsPerPixel;
qCDebug(KWIN_FB) << "Buffer Length: " << m_bufferLength;
qCDebug(KWIN_FB) << "Bytes Per Line: " << m_bytesPerLine;
qCDebug(KWIN_FB) << "Alpha Length: " << m_alpha.length;
qCDebug(KWIN_FB) << "Red Length: " << m_red.length;
qCDebug(KWIN_FB) << "Green Length: " << m_green.length;
qCDebug(KWIN_FB) << "Blue Length: " << m_blue.length;
qCDebug(KWIN_FB) << "Blue Offset: " << m_blue.offset;
qCDebug(KWIN_FB) << "Green Offset: " << m_green.offset;
qCDebug(KWIN_FB) << "Red Offset: " << m_red.offset;
qCDebug(KWIN_FB) << "Alpha Offset: " << m_alpha.offset;
if (m_bitsPerPixel == 32 &&
m_red.length == 8 &&
m_green.length == 8 &&
m_blue.length == 8 &&
m_blue.offset == 0 &&
m_green.offset == 8 &&
m_red.offset == 16) {
qCDebug(KWIN_FB) << "Framebuffer format is RGB32";
return QImage::Format_RGB32;
} else if (m_bitsPerPixel == 24 &&
m_red.length == 8 &&
m_green.length == 8 &&
m_blue.length == 8 &&
m_blue.offset == 0 &&
m_green.offset == 8 &&
m_red.offset == 16) {
qCDebug(KWIN_FB) << "Framebuffer Format is RGB888";
return QImage::Format_RGB888;
} else if (m_bitsPerPixel == 16 &&
m_red.length == 5 &&
m_green.length == 6 &&
m_blue.length == 5 &&
m_blue.offset == 0 &&
m_green.offset == 5 &&
m_red.offset == 11) {
qCDebug(KWIN_FB) << "Framebuffer Format is RGB16";
return QImage::Format_RGB16;
}
qCWarning(KWIN_FB) << "Framebuffer format is unknown";
return QImage::Format_Invalid;
}