Avoid triggering OpenGL initialization for RasterSurface

Application that do not require OpenGL need a way to opt-out of
GLX/EGL calls completely. The initialization can be expensive and what
is more, some systems may not have functional GLX at all (some VMs are
known to crash when trying to get FBConfigs for the window).

QApplication already has AA_ForceRasterWidgets, which causes the use
of plain RasterSurface everywhere instead of RasterGLSurface. Combined
with a trivial check in the xcb backend to skip all the Xlib+GLX/EGL
path, the attribute will allow apps to ensure that no GLX/EGL calls
are ever made.

This however implies a change in QWindowContainer: the embedded window
must use the same initialization path as the parent otherwise we will
end up with a BadMatch. QWindowContainer can do this transparently to
the applications, unless the QWindow is already created.

Change-Id: I846af7edb8b92b9836cdbd93c6a5eec5a6147a49
Task-number: QTBUG-46765
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
bb10
John Lindgren 2015-08-29 15:21:43 -04:00 committed by Laszlo Agocs
parent 715a8e6f4e
commit 5d5e0a4e97
2 changed files with 11 additions and 1 deletions

View File

@ -389,7 +389,8 @@ void QXcbWindow::create()
resolveFormat();
#ifdef XCB_USE_XLIB
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
if (window()->surfaceType() != QSurface::RasterSurface
&& QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
XVisualInfo *visualInfo = Q_NULLPTR;
if (connection()->hasDefaultVisualId())
visualInfo = CREATE_VISUALINFO_FROM_DEFAULT_VISUALID(this);

View File

@ -34,6 +34,8 @@
#include "qwindowcontainer_p.h"
#include "qwidget_p.h"
#include <QtGui/qwindow.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#include <QDebug>
#include <QMdiSubWindow>
@ -196,6 +198,13 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt:
return;
}
// The embedded QWindow must use the same logic as QWidget when it comes to the surface type.
// Otherwise we may end up with BadMatch failures on X11.
if (embeddedWindow->surfaceType() == QSurface::RasterSurface
&& QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)
&& !QApplication::testAttribute(Qt::AA_ForceRasterWidgets))
embeddedWindow->setSurfaceType(QSurface::RasterGLSurface);
d->window = embeddedWindow;
d->window->setParent(&d->fakeParent);
setAcceptDrops(true);