shm: support textures of 3 bytes-per-color
Adds support for BGR888 and RGB888. Some clients use it and we just fail to render them, making devs thinking that kwin is broken. Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
This commit is contained in:
parent
7fca508619
commit
559b0cccf5
2 changed files with 10 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "core/graphicsbufferview.h"
|
||||
#include "core/graphicsbuffer.h"
|
||||
#include "utils/common.h"
|
||||
#include "utils/drm_format_helper.h"
|
||||
|
||||
#include <drm_fourcc.h>
|
||||
|
||||
|
@ -34,6 +35,10 @@ static QImage::Format drmFormatToQImageFormat(uint32_t drmFormat)
|
|||
return QImage::Format_ARGB32_Premultiplied;
|
||||
case DRM_FORMAT_XRGB8888:
|
||||
return QImage::Format_RGB32;
|
||||
case DRM_FORMAT_BGR888:
|
||||
return QImage::Format_RGB888;
|
||||
case DRM_FORMAT_RGB888:
|
||||
return QImage::Format_BGR888;
|
||||
default:
|
||||
return QImage::Format_Invalid;
|
||||
}
|
||||
|
@ -65,6 +70,9 @@ GraphicsBufferView::GraphicsBufferView(GraphicsBuffer *buffer, GraphicsBuffer::M
|
|||
const auto [data, stride] = buffer->map(accessFlags);
|
||||
if (data) {
|
||||
m_image = QImage(static_cast<uchar *>(data), width, height, stride, drmFormatToQImageFormat(format));
|
||||
if (Q_UNLIKELY(m_image.isNull())) {
|
||||
qCWarning(KWIN_CORE) << "Cannot create a graphics buffer view" << buffer << FormatInfo::drmFormatName(format) << drmFormatToQImageFormat(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ static constexpr uint32_t s_formats[] = {
|
|||
WL_SHM_FORMAT_ABGR16161616,
|
||||
WL_SHM_FORMAT_XBGR16161616,
|
||||
#endif
|
||||
WL_SHM_FORMAT_BGR888,
|
||||
WL_SHM_FORMAT_RGB888,
|
||||
};
|
||||
|
||||
class ShmSigbusData
|
||||
|
|
Loading…
Reference in a new issue