xcb: remove DISPLAY_FROM_XCB macro
... as it does not add much value and is not widely used. and cleanup code: - where we repeatedly (for no good reason) call DISPLAY_FROM_XCB, instead of storing display as a (member) variable. - inconsistency where we (in the same function) alternatingly use DISPLAY_FROM_XCB and variable holding pointer to Display (when both refer to the same display). In other places this patch replaces macros with code they would translate to (or with minor adjustments to keep sensible line length). Change-Id: Ieb2a3e055892dcf31f132891f83ed4a665e3fa6e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
ac098eef42
commit
f09f2f240f
@ -167,7 +167,7 @@ static void updateFormatFromContext(QSurfaceFormat &format)
|
|||||||
QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlatformOpenGLContext *share,
|
QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlatformOpenGLContext *share,
|
||||||
const QVariant &nativeHandle)
|
const QVariant &nativeHandle)
|
||||||
: QPlatformOpenGLContext()
|
: QPlatformOpenGLContext()
|
||||||
, m_display(DISPLAY_FROM_XCB(screen))
|
, m_display(static_cast<Display *>(screen->connection()->xlib_display()))
|
||||||
, m_config(0)
|
, m_config(0)
|
||||||
, m_context(0)
|
, m_context(0)
|
||||||
, m_shareContext(0)
|
, m_shareContext(0)
|
||||||
@ -196,7 +196,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
|
|||||||
if (share)
|
if (share)
|
||||||
m_shareContext = static_cast<const QGLXContext*>(share)->glxContext();
|
m_shareContext = static_cast<const QGLXContext*>(share)->glxContext();
|
||||||
|
|
||||||
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),m_format);
|
GLXFBConfig config = qglx_findConfig(m_display, screen->screenNumber(), m_format);
|
||||||
m_config = config;
|
m_config = config;
|
||||||
XVisualInfo *visualInfo = 0;
|
XVisualInfo *visualInfo = 0;
|
||||||
Window window = 0; // Temporary window used to query OpenGL context
|
Window window = 0; // Temporary window used to query OpenGL context
|
||||||
@ -304,10 +304,10 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
|
|||||||
|
|
||||||
// Get the basic surface format details
|
// Get the basic surface format details
|
||||||
if (m_context)
|
if (m_context)
|
||||||
qglx_surfaceFormatFromGLXFBConfig(&m_format, DISPLAY_FROM_XCB(screen), config);
|
qglx_surfaceFormatFromGLXFBConfig(&m_format, m_display, config);
|
||||||
|
|
||||||
// Create a temporary window so that we can make the new context current
|
// Create a temporary window so that we can make the new context current
|
||||||
window = createDummyWindow(DISPLAY_FROM_XCB(screen), config, screen->screenNumber(), screen->root());
|
window = createDummyWindow(m_display, config, screen->screenNumber(), screen->root());
|
||||||
} else {
|
} else {
|
||||||
// requesting an OpenGL ES context requires glXCreateContextAttribsARB, so bail out
|
// requesting an OpenGL ES context requires glXCreateContextAttribsARB, so bail out
|
||||||
if (m_format.renderableType() == QSurfaceFormat::OpenGLES)
|
if (m_format.renderableType() == QSurfaceFormat::OpenGLES)
|
||||||
@ -325,7 +325,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a temporary window so that we can make the new context current
|
// Create a temporary window so that we can make the new context current
|
||||||
window = createDummyWindow(DISPLAY_FROM_XCB(screen), visualInfo, screen->screenNumber(), screen->root());
|
window = createDummyWindow(m_display, visualInfo, screen->screenNumber(), screen->root());
|
||||||
XFree(visualInfo);
|
XFree(visualInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const
|
|||||||
// Use the provided Display, if available. If not, use our own. It may still work.
|
// Use the provided Display, if available. If not, use our own. It may still work.
|
||||||
Display *dpy = handle.display();
|
Display *dpy = handle.display();
|
||||||
if (!dpy)
|
if (!dpy)
|
||||||
dpy = DISPLAY_FROM_XCB(screen);
|
dpy = m_display;
|
||||||
|
|
||||||
// Legacy contexts created using glXCreateContext are created using a visual
|
// Legacy contexts created using glXCreateContext are created using a visual
|
||||||
// and the FBConfig cannot be queried. The only way to adapt these contexts
|
// and the FBConfig cannot be queried. The only way to adapt these contexts
|
||||||
@ -665,8 +665,10 @@ void QGLXContext::queryDummyContext()
|
|||||||
Display *display = glXGetCurrentDisplay();
|
Display *display = glXGetCurrentDisplay();
|
||||||
if (!display) {
|
if (!display) {
|
||||||
// FIXME: Since Qt 5.6 we don't need to check whether primary screen is NULL
|
// FIXME: Since Qt 5.6 we don't need to check whether primary screen is NULL
|
||||||
if (QScreen *screen = QGuiApplication::primaryScreen())
|
if (QScreen *screen = QGuiApplication::primaryScreen()) {
|
||||||
display = DISPLAY_FROM_XCB(static_cast<QXcbScreen *>(screen->handle()));
|
QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle());
|
||||||
|
display = static_cast<Display *>(xcbScreen->connection()->xlib_display());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const char *glxvendor = glXGetClientString(display, GLX_VENDOR);
|
const char *glxvendor = glXGetClientString(display, GLX_VENDOR);
|
||||||
if (glxvendor && !strcmp(glxvendor, "ATI")) {
|
if (glxvendor && !strcmp(glxvendor, "ATI")) {
|
||||||
@ -737,9 +739,10 @@ QGLXPbuffer::QGLXPbuffer(QOffscreenSurface *offscreenSurface)
|
|||||||
: QPlatformOffscreenSurface(offscreenSurface)
|
: QPlatformOffscreenSurface(offscreenSurface)
|
||||||
, m_screen(static_cast<QXcbScreen *>(offscreenSurface->screen()->handle()))
|
, m_screen(static_cast<QXcbScreen *>(offscreenSurface->screen()->handle()))
|
||||||
, m_format(m_screen->surfaceFormatFor(offscreenSurface->requestedFormat()))
|
, m_format(m_screen->surfaceFormatFor(offscreenSurface->requestedFormat()))
|
||||||
|
, m_display(static_cast<Display *>(m_screen->connection()->xlib_display()))
|
||||||
, m_pbuffer(0)
|
, m_pbuffer(0)
|
||||||
{
|
{
|
||||||
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber(), m_format);
|
GLXFBConfig config = qglx_findConfig(m_display, m_screen->screenNumber(), m_format);
|
||||||
|
|
||||||
if (config) {
|
if (config) {
|
||||||
const int attributes[] = {
|
const int attributes[] = {
|
||||||
@ -750,17 +753,17 @@ QGLXPbuffer::QGLXPbuffer(QOffscreenSurface *offscreenSurface)
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
m_pbuffer = glXCreatePbuffer(DISPLAY_FROM_XCB(m_screen), config, attributes);
|
m_pbuffer = glXCreatePbuffer(m_display, config, attributes);
|
||||||
|
|
||||||
if (m_pbuffer)
|
if (m_pbuffer)
|
||||||
qglx_surfaceFormatFromGLXFBConfig(&m_format, DISPLAY_FROM_XCB(m_screen), config);
|
qglx_surfaceFormatFromGLXFBConfig(&m_format, m_display, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QGLXPbuffer::~QGLXPbuffer()
|
QGLXPbuffer::~QGLXPbuffer()
|
||||||
{
|
{
|
||||||
if (m_pbuffer)
|
if (m_pbuffer)
|
||||||
glXDestroyPbuffer(DISPLAY_FROM_XCB(m_screen), m_pbuffer);
|
glXDestroyPbuffer(m_display, m_pbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QXcbScreen *m_screen;
|
QXcbScreen *m_screen;
|
||||||
QSurfaceFormat m_format;
|
QSurfaceFormat m_format;
|
||||||
|
Display *m_display;
|
||||||
GLXPbuffer m_pbuffer;
|
GLXPbuffer m_pbuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ const xcb_visualtype_t *QXcbGlxWindow::createVisual()
|
|||||||
|
|
||||||
qDebug(lcQpaGl) << "Requested format before FBConfig/Visual selection:" << m_format;
|
qDebug(lcQpaGl) << "Requested format before FBConfig/Visual selection:" << m_format;
|
||||||
|
|
||||||
const char *glxExts = glXQueryExtensionsString(DISPLAY_FROM_XCB(scr), scr->screenNumber());
|
Display *dpy = static_cast<Display *>(scr->connection()->xlib_display());
|
||||||
|
const char *glxExts = glXQueryExtensionsString(dpy, scr->screenNumber());
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (glxExts) {
|
if (glxExts) {
|
||||||
qCDebug(lcQpaGl, "Available GLX extensions: %s", glxExts);
|
qCDebug(lcQpaGl, "Available GLX extensions: %s", glxExts);
|
||||||
@ -70,7 +71,7 @@ const xcb_visualtype_t *QXcbGlxWindow::createVisual()
|
|||||||
flags |= QGLX_SUPPORTS_SRGB;
|
flags |= QGLX_SUPPORTS_SRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(scr), scr->screenNumber(), &m_format, GLX_WINDOW_BIT, flags);
|
XVisualInfo *visualInfo = qglx_findVisualInfo(dpy, scr->screenNumber(), &m_format, GLX_WINDOW_BIT, flags);
|
||||||
if (!visualInfo) {
|
if (!visualInfo) {
|
||||||
qWarning() << "No XVisualInfo for format" << m_format;
|
qWarning() << "No XVisualInfo for format" << m_format;
|
||||||
return Q_NULLPTR;
|
return Q_NULLPTR;
|
||||||
|
@ -1500,7 +1500,8 @@ void *QXcbConnection::createVisualInfoForDefaultVisualId() const
|
|||||||
info.visualid = m_defaultVisualId;
|
info.visualid = m_defaultVisualId;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
XVisualInfo *retVisual = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &info, &count);
|
Display *dpy = static_cast<Display *>(connection()->xlib_display());
|
||||||
|
XVisualInfo *retVisual = XGetVisualInfo(dpy, VisualIDMask, &info, &count);
|
||||||
Q_ASSERT(count < 2);
|
Q_ASSERT(count < 2);
|
||||||
return retVisual;
|
return retVisual;
|
||||||
}
|
}
|
||||||
|
@ -686,8 +686,6 @@ Q_DECLARE_TYPEINFO(QXcbConnection::TabletData, Q_MOVABLE_TYPE);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DISPLAY_FROM_XCB(object) (reinterpret_cast<Display *>(object->connection()->xlib_display()))
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
xcb_generic_event_t *QXcbConnection::checkEvent(T &checker)
|
xcb_generic_event_t *QXcbConnection::checkEvent(T &checker)
|
||||||
{
|
{
|
||||||
|
@ -579,7 +579,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
|
|||||||
if (cursor)
|
if (cursor)
|
||||||
return cursor;
|
return cursor;
|
||||||
if (!cursor && cursorId) {
|
if (!cursor && cursorId) {
|
||||||
cursor = XCreateFontCursor(DISPLAY_FROM_XCB(this), cursorId);
|
cursor = XCreateFontCursor(static_cast<Display *>(connection()->xlib_display()), cursorId);
|
||||||
if (cursor)
|
if (cursor)
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
@ -590,7 +590,7 @@ void QXcbWindow::create()
|
|||||||
|
|
||||||
#ifdef XCB_USE_XLIB
|
#ifdef XCB_USE_XLIB
|
||||||
// force sync to read outstanding requests - see QTBUG-29106
|
// force sync to read outstanding requests - see QTBUG-29106
|
||||||
XSync(DISPLAY_FROM_XCB(platformScreen), false);
|
XSync(static_cast<Display*>(platformScreen->connection()->xlib_display()), false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef QT_NO_DRAGANDDROP
|
#ifndef QT_NO_DRAGANDDROP
|
||||||
@ -1502,9 +1502,10 @@ void QXcbWindow::setWindowTitle(const QString &title)
|
|||||||
ba.constData());
|
ba.constData());
|
||||||
|
|
||||||
#ifdef XCB_USE_XLIB
|
#ifdef XCB_USE_XLIB
|
||||||
XTextProperty *text = qstringToXTP(DISPLAY_FROM_XCB(this), title);
|
Display *dpy = static_cast<Display *>(connection()->xlib_display());
|
||||||
|
XTextProperty *text = qstringToXTP(dpy, title);
|
||||||
if (text)
|
if (text)
|
||||||
XSetWMName(DISPLAY_FROM_XCB(this), m_window, text);
|
XSetWMName(dpy, m_window, text);
|
||||||
#endif
|
#endif
|
||||||
xcb_flush(xcb_connection());
|
xcb_flush(xcb_connection());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user