diff --git a/config.tests/qpa/xcb-glx/xcb-glx.cpp b/config.tests/qpa/xcb-glx/xcb-glx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa2c62133a25c11e231dbfec1547a1ee5f958932 --- /dev/null +++ b/config.tests/qpa/xcb-glx/xcb-glx.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the config.tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <xcb/xcb.h> +#include <xcb/glx.h> + +int main(int, char **) +{ + int primaryScreen = 0; + + xcb_connection_t *connection = xcb_connect("", &primaryScreen); + xcb_generic_error_t *error = 0; + xcb_glx_query_version_cookie_t xglx_query_cookie = xcb_glx_query_version(connection, + XCB_GLX_MAJOR_VERSION, + XCB_GLX_MINOR_VERSION); + xcb_glx_query_version_reply(connection, xglx_query_cookie, &error); + + return 0; +} diff --git a/config.tests/qpa/xcb-glx/xcb-glx.pro b/config.tests/qpa/xcb-glx/xcb-glx.pro new file mode 100644 index 0000000000000000000000000000000000000000..d7fd1d72083ba8a00f0ce629571d55de65e6e959 --- /dev/null +++ b/config.tests/qpa/xcb-glx/xcb-glx.pro @@ -0,0 +1,5 @@ +SOURCES = xcb-glx.cpp +CONFIG -= qt + +LIBS += -lxcb -lxcb-glx + diff --git a/configure b/configure index d130b69ef4cbc68714db24e4cf652bab81a2a7b7..5229c2b0ea16be3f8f4929f022b73b3f46b08664 100755 --- a/configure +++ b/configure @@ -801,6 +801,7 @@ CFG_XINPUT2=auto CFG_XINPUT=runtime CFG_XKB=auto CFG_XCB=auto +CFG_XCB_GLX=no CFG_XCB_LIMITED=yes CFG_EGLFS=auto CFG_DIRECTFB=auto @@ -4790,6 +4791,11 @@ if [ "$CFG_XCB" != "no" ]; then QT_CONFIG="$QT_CONFIG xcb-render" fi + if compileTest qpa/xcb-glx "xcb-glx" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then + CFG_XCB_GLX=yes + QT_CONFIG="$QT_CONFIG xcb-glx" + fi + if compileTest qpa/xcb-poll-for-queued-event "xcb-poll-for-queued-event" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then CFG_XCB_LIMITED=no QT_CONFIG="$QT_CONFIG xcb-poll-for-queued-event" diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README index 264d28c6b48b28cb0e653056398f8ef0c0dd368b..59d9ffe39b54c06356ca733e7e0db80ae9d4ec63 100644 --- a/src/plugins/platforms/xcb/README +++ b/src/plugins/platforms/xcb/README @@ -1,14 +1,14 @@ Requires libxcb >= 1.5. Required packages: -libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev libxcb-sync0 libxcb-sync0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev +libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev libxcb-sync0 libxcb-sync0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev On Ubuntu 11.10 icccm1 is replaced by icccm4 and xcb-render-util is not available: -libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev +libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev The packages for xcb-render-util can be installed manually from http://packages.ubuntu.com/natty/libxcb-render-util0 and http://packages.ubuntu.com/natty/libxcb-render-util0-dev On Ubuntu 12.04 icccm1 is replaced by icccm4 and xcb-render-util can be installed automatically: -libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0 libxcb-render-util0-dev +libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-glx0-dev On Fedora, the following packages are required: diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index ad9fb1d19c3305662b1116ec9f37993b15b523b3..bb5f301fea003216e903fb173ad88a6c3deef408 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -72,6 +72,10 @@ #include <xcb/render.h> #endif +#if defined(XCB_HAS_XCB_GLX) +#include <xcb/glx.h> +#endif + #ifdef XCB_USE_EGL //don't pull in eglext prototypes #include <EGL/egl.h> #endif @@ -263,6 +267,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char #endif , xfixes_first_event(0) , xrandr_first_event(0) + , has_glx_extension(false) , has_shape_extension(false) , has_randr_extension(false) , has_input_shape(false) @@ -320,6 +325,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY, m_screens.at(0)->screen()->root_visual, 0, 0); + initializeGLX(); initializeXFixes(); initializeXRender(); m_xi2Enabled = false; @@ -1312,6 +1318,33 @@ void QXcbConnection::initializeXRender() #endif } +void QXcbConnection::initializeGLX() +{ +#ifdef XCB_HAS_XCB_GLX + const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_glx_id); + if (!reply || !reply->present) + return; + + has_glx_extension = true; + + xcb_generic_error_t *error = 0; + xcb_glx_query_version_cookie_t xglx_query_cookie = xcb_glx_query_version(m_connection, + XCB_GLX_MAJOR_VERSION, + XCB_GLX_MINOR_VERSION); + xcb_glx_query_version_reply_t *xglx_query = xcb_glx_query_version_reply(m_connection, + xglx_query_cookie, &error); + if (!xglx_query || error) { + qWarning("QXcbConnection: Failed to initialize GLX"); + free(error); + has_glx_extension = false; + } + free(xglx_query); +#else + // no way to check, assume GLX is present + has_glx_extension = true; +#endif +} + void QXcbConnection::initializeXRandr() { const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_randr_id); diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 8a6c41878897b4c4e57a513aa934077edb5a1ffa..cbfdd803f2ebaa7f32432c3279c39bb526fe8557 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -374,6 +374,7 @@ public: inline xcb_timestamp_t time() const { return m_time; } inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; } + bool hasGLX() const { return has_glx_extension; } bool hasXFixes() const { return xfixes_first_event > 0; } bool hasXShape() const { return has_shape_extension; } bool hasXRandr() const { return has_randr_extension; } @@ -387,6 +388,7 @@ private slots: private: void initializeAllAtoms(); void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0); + void initializeGLX(); void initializeXFixes(); void initializeXRender(); void initializeXRandr(); @@ -507,6 +509,7 @@ private: uint32_t xfixes_first_event; uint32_t xrandr_first_event; + bool has_glx_extension; bool has_shape_extension; bool has_randr_extension; bool has_input_shape; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 2ace68036bbcc67ea4cf3f7a70fa628385457c4c..f6077316e66f5b0cc0f9272565d258ca7dc2fc04 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -192,9 +192,11 @@ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLCont screen->connection()->egl_display(), screen->connection()); #elif defined(XCB_USE_DRI2) return new QDri2Context(context->format(), context->shareHandle()); -#endif +#else + Q_UNUSED(screen); qWarning("QXcbIntegration: Cannot create platform OpenGL context, none of GLX, EGL, or DRI2 are enabled"); return 0; +#endif } #endif @@ -207,7 +209,13 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { case ThreadedPixmaps: return true; +#if defined(XCB_USE_GLX) + case OpenGL: return m_connections.at(0)->hasGLX(); +#elif defined(XCB_USE_EGL) || defined(XCB_USE_DRI2) case OpenGL: return true; +#else + case OpenGL: return false; +#endif case ThreadedOpenGL: return false; case WindowMasks: return true; default: return QPlatformIntegration::hasCapability(cap); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index bab1884a9a9e36904e302f9c28f1c0da5d18ccb4..30f833012c0a85783a3774847100c33f549233ce 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -233,9 +233,7 @@ void QXcbWindow::create() m_format = window()->requestedFormat(); #if (defined(XCB_USE_GLX) || defined(XCB_USE_EGL)) && defined(XCB_USE_XLIB) - if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) - || m_format.hasAlpha()) - { + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber(), &m_format); if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 116951d36d5a1a7446093805c538ffa90102a1bc..617f2e685ceffcdc6227a852a8f6a3b197e46742 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -98,6 +98,10 @@ contains(DEFINES, XCB_USE_DRI2) { HEADERS += qglxintegration.h SOURCES += qglxintegration.cpp LIBS += $$QMAKE_LIBS_DYNLOAD + contains(QT_CONFIG, xcb-glx) { + DEFINES += XCB_HAS_XCB_GLX + LIBS += -lxcb-glx + } } }