diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2017-10-05 16:35:11 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2017-10-06 08:37:16 +0000 |
commit | 248beda08f831d04e6b59df202921152b106bbfa (patch) | |
tree | 3698fa956c86f6919ad8f25efe7dba4eae4b2577 /src/plugins/platforms | |
parent | 7f7d9393809f64b37f161f64312d0704d23a11b7 (diff) |
XCB platform: Fix crash on X servers with BGR888 display
If the native visual was BGR888, the XCB plugin would assert as soon as
it needed to find the corresponding QImage format. Fix by adding the
required mapping in qt_xcb_imageFormatForVisual().
Task-number: QTBUG-62840
Change-Id: Idd9eb01a60f605ad004d5b0c3025ded63ed64271
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbimage.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugins/platforms/xcb/qxcbimage.cpp b/src/plugins/platforms/xcb/qxcbimage.cpp index c0403d589d..c419bd913d 100644 --- a/src/plugins/platforms/xcb/qxcbimage.cpp +++ b/src/plugins/platforms/xcb/qxcbimage.cpp @@ -78,6 +78,16 @@ QImage::Format qt_xcb_imageFormatForVisual(QXcbConnection *connection, uint8_t d && visual->green_mask == 0xff00 && visual->blue_mask == 0xff) return QImage::Format_RGB32; + if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) { + if (depth == 24 && format->bits_per_pixel == 32 && visual->blue_mask == 0xff0000 + && visual->green_mask == 0xff00 && visual->red_mask == 0xff) + return QImage::Format_RGBX8888; + } else { + if (depth == 24 && format->bits_per_pixel == 32 && visual->blue_mask == 0xff00 + && visual->green_mask == 0xff0000 && visual->red_mask == 0xff000000) + return QImage::Format_RGBX8888; + } + if (depth == 16 && format->bits_per_pixel == 16 && visual->red_mask == 0xf800 && visual->green_mask == 0x7e0 && visual->blue_mask == 0x1f) return QImage::Format_RGB16; @@ -128,8 +138,9 @@ QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap } break; } - case QImage::Format_RGB32: // fall-through - case QImage::Format_ARGB32_Premultiplied: { + case QImage::Format_RGB32: + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_RGBX8888: { uint *p = (uint*)image.scanLine(i); uint *end = p + image.width(); while (p < end) { @@ -146,7 +157,7 @@ QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap } // fix-up alpha channel - if (format == QImage::Format_RGB32) { + if (format == QImage::Format_RGB32 || format == QImage::Format_RGBX8888) { QRgb *p = (QRgb *)image.bits(); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) |