Made xcb plugin work when the GLX extension is not present.
Change-Id: I9285d7524586ff404206c088019ece33335137d9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
7d7f09650c
commit
cdc2161b6f
57
config.tests/qpa/xcb-glx/xcb-glx.cpp
Normal file
57
config.tests/qpa/xcb-glx/xcb-glx.cpp
Normal file
@ -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;
|
||||
}
|
5
config.tests/qpa/xcb-glx/xcb-glx.pro
Normal file
5
config.tests/qpa/xcb-glx/xcb-glx.pro
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCES = xcb-glx.cpp
|
||||
CONFIG -= qt
|
||||
|
||||
LIBS += -lxcb -lxcb-glx
|
||||
|
6
configure
vendored
6
configure
vendored
@ -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"
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user