summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2011-10-04 10:36:47 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-04 11:21:25 +0200
commit76a7f2048e45039a56f87dca5af1b0b01c9ef812 (patch)
tree4d387e864fb1cc79154dbb5ecf66b63bad717e9e /src
parent992a37234c5ec7494fc2f24217d36400f6c1630a (diff)
Fix XCB back-end on Harmattan
Use RGB16 as image format on 16-bpp displays. Based on patch by Jocelyn Change-Id: Ic91ab33132769da59a2097abb43b64a2d09c0009 Reviewed-on: http://codereview.qt-project.org/5971 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index c5aee5c81d..d21d5d00cd 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -118,6 +118,18 @@ static inline bool isTransient(const QWindow *w)
|| w->windowType() == Qt::Popup;
}
+static inline QImage::Format imageFormatForDepth(int depth)
+{
+ switch (depth) {
+ case 32: return QImage::Format_ARGB32_Premultiplied;
+ case 24: return QImage::Format_RGB32;
+ case 16: return QImage::Format_RGB16;
+ default: break;
+ }
+ qFatal("Unsupported display depth %d", depth);
+ return QImage::Format_Invalid;
+}
+
QXcbWindow::QXcbWindow(QWindow *window)
: QPlatformWindow(window)
, m_window(0)
@@ -147,7 +159,7 @@ void QXcbWindow::create()
if (type == Qt::Desktop) {
m_window = m_screen->root();
m_depth = m_screen->screen()->root_depth;
- m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_imageFormat = imageFormatForDepth(m_depth);
connection()->addWindow(m_window, this);
return;
}
@@ -209,7 +221,7 @@ void QXcbWindow::create()
#endif //XCB_USE_GLX
if (visualInfo) {
m_depth = visualInfo->depth;
- m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_imageFormat = imageFormatForDepth(m_depth);
Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone);
XSetWindowAttributes a;
@@ -227,7 +239,7 @@ void QXcbWindow::create()
{
m_window = xcb_generate_id(xcb_connection());
m_depth = m_screen->screen()->root_depth;
- m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_imageFormat = imageFormatForDepth(m_depth);
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root