summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbwindow.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-05-26 12:07:18 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-07-04 14:03:46 +0200
commit3acd4b546ded7523f65d60cee6f3809113a91a16 (patch)
treeac526a90c4b39229ea5ec4c80b779ca8a4b66c24 /src/plugins/platforms/xcb/qxcbwindow.cpp
parent715b41ce48c9dd78eec3223606e9ca5193cf5bad (diff)
QImage support for RGB30 formats
Adds basic support for 10-bit per color channel formats to QImage and the XCB plugin. This will make it possible to paint to and from these formats, but only at 8-bit per color channel accuracy. This also fixes Qt5 applications on X11 with native 30bit depth. [ChangeLog][QtGui][QImage] Added support for 10-bit per color channel image formats. Task-number: QTBUG-25998 Change-Id: I93ccd3c74bfbb0bd94b352476e5fe58a94119e1f Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbwindow.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index dd3084e402..908e03cd7c 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -166,16 +166,36 @@ static inline bool isTransient(const QWindow *w)
|| w->type() == Qt::Popup;
}
-static inline QImage::Format imageFormatForDepth(int depth)
+static inline QImage::Format imageFormatForVisual(int depth, quint32 red_mask, quint32 blue_mask)
{
switch (depth) {
- case 32: return QImage::Format_ARGB32_Premultiplied;
- case 24: return QImage::Format_RGB32;
- case 16: return QImage::Format_RGB16;
- default:
- qWarning("Unsupported screen depth: %d", depth);
- return QImage::Format_Invalid;
+ case 32:
+ if (blue_mask == 0xff)
+ return QImage::Format_ARGB32_Premultiplied;
+ if (red_mask == 0x3ff)
+ return QImage::Format_A2BGR30_Premultiplied;
+ if (blue_mask == 0x3ff)
+ return QImage::Format_A2RGB30_Premultiplied;
+ break;
+ case 30:
+ if (red_mask == 0x3ff)
+ return QImage::Format_BGR30;
+ if (blue_mask == 0x3ff)
+ return QImage::Format_RGB30;
+ break;
+ case 24:
+ if (blue_mask == 0xff)
+ return QImage::Format_RGB32;
+ break;
+ case 16:
+ if (blue_mask == 0x1f)
+ return QImage::Format_RGB16;
+ break;
+ default:
+ break;
}
+ qWarning("Unsupported screen format: depth: %d, red_mask: %x, blue_mask: %x", depth, red_mask, blue_mask);
+ return QImage::Format_Invalid;
}
static inline bool positionIncludesFrame(QWindow *w)
@@ -227,7 +247,9 @@ void QXcbWindow::create()
if (type == Qt::Desktop) {
m_window = m_screen->root();
m_depth = m_screen->screen()->root_depth;
- m_imageFormat = imageFormatForDepth(m_depth);
+ m_visualId = m_screen->screen()->root_visual;
+ const xcb_visualtype_t *visual = m_screen->visualForId(m_visualId);
+ m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask);
connection()->addWindowEventListener(m_window, this);
return;
}
@@ -317,7 +339,7 @@ void QXcbWindow::create()
}
if (visualInfo) {
m_depth = visualInfo->depth;
- m_imageFormat = imageFormatForDepth(m_depth);
+ m_imageFormat = imageFormatForVisual(visualInfo->depth, visualInfo->red_mask, visualInfo->blue_mask);
Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone);
XSetWindowAttributes a;
@@ -367,7 +389,8 @@ void QXcbWindow::create()
}
}
- m_imageFormat = imageFormatForDepth(m_depth);
+ const xcb_visualtype_t *visual = m_screen->visualForId(m_visualId);
+ m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask);
Q_XCB_CALL(xcb_create_window(xcb_connection(),
m_depth,