summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsintegration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsintegration.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp101
1 files changed, 53 insertions, 48 deletions
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 54fb138d85..58d675876b 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -130,7 +130,6 @@ struct QWindowsIntegrationPrivate
{
explicit QWindowsIntegrationPrivate(const QStringList &paramList);
~QWindowsIntegrationPrivate();
- bool ensureStaticOpenGLContext();
unsigned m_options;
QWindowsContext m_context;
@@ -266,7 +265,9 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co
case OpenGL:
return true;
case ThreadedOpenGL:
- return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->supportsThreadedOpenGL() : false;
+ if (const QWindowsStaticOpenGLContext *glContext = QWindowsIntegration::staticOpenGLContext())
+ return glContext->supportsThreadedOpenGL();
+ return false;
#endif // !QT_NO_OPENGL
case WindowMasks:
return true;
@@ -312,11 +313,6 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const
QWindowSystemInterface::handleGeometryChange(window, QWindowsScaling::mapFromNative(obtained.geometry));
}
-#ifndef QT_NO_OPENGL
- d->ensureStaticOpenGLContext();
- obtained.staticOpenGLContext = d->m_staticOpenGLContext;
-#endif // QT_NO_OPENGL
-
return obtained;
}
@@ -328,61 +324,65 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
}
#ifndef QT_NO_OPENGL
-static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0;
-QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create()
+QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate()
{
- QWindowsStaticOpenGLContext *ctx = 0;
-
#if defined(QT_OPENGL_DYNAMIC)
- const QByteArray requested = qgetenv("QT_OPENGL"); // angle, desktop, software
- const bool angleRequested = QCoreApplication::testAttribute(Qt::AA_UseOpenGLES) || requested == "angle";
- const bool desktopRequested = QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL) || requested == "desktop";
- const bool softwareRequested = QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL) || requested == "software";
-
+ QWindowsOpenGLTester::Renderer requestedRenderer = QWindowsOpenGLTester::requestedRenderer();
+ switch (requestedRenderer) {
+ case QWindowsOpenGLTester::DesktopGl:
+ if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create())
+ return glCtx;
+ qCWarning(lcQpaGl, "System OpenGL failed. Falling back to Software OpenGL.");
+ return QOpenGLStaticContext::create(true);
// If ANGLE is requested, use it, don't try anything else.
- if (angleRequested) {
- ctx = QWindowsEGLStaticContext::create();
- } else {
- // If opengl32.dll seems to be OpenGL 2.x capable, or desktop OpenGL is requested, use it.
- if (!softwareRequested && (desktopRequested || QWindowsOpenGLTester::testDesktopGL()))
- ctx = QOpenGLStaticContext::create();
- // If failed and desktop OpenGL is not explicitly requested, try ANGLE.
- if (!ctx && !desktopRequested && !softwareRequested)
- ctx = QWindowsEGLStaticContext::create();
- // Try software.
- if (!ctx) {
- ctx = QOpenGLStaticContext::create(true);
- // If software was explicitly requested but failed, try the regular one.
- if (!ctx && softwareRequested && QWindowsOpenGLTester::testDesktopGL()) {
- qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
- ctx = QOpenGLStaticContext::create();
- }
- }
+ case QWindowsOpenGLTester::AngleRendererD3d9:
+ case QWindowsOpenGLTester::AngleRendererD3d11:
+ case QWindowsOpenGLTester::AngleRendererD3d11Warp:
+ return QWindowsEGLStaticContext::create(requestedRenderer);
+ case QWindowsOpenGLTester::Gles:
+ return QWindowsEGLStaticContext::create(QWindowsOpenGLTester::supportedGlesRenderers());
+ case QWindowsOpenGLTester::SoftwareRasterizer:
+ if (QWindowsStaticOpenGLContext *swCtx = QOpenGLStaticContext::create(true))
+ return swCtx;
+ qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
+ if (QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DesktopGl)
+ return QOpenGLStaticContext::create();
+ return Q_NULLPTR;
+ default:
+ break;
+ }
+
+ const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers();
+ if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) {
+ if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create())
+ return glCtx;
+ }
+ if (QWindowsOpenGLTester::Renderers glesRenderers = supportedRenderers & QWindowsOpenGLTester::GlesMask) {
+ if (QWindowsEGLStaticContext *eglCtx = QWindowsEGLStaticContext::create(glesRenderers))
+ return eglCtx;
}
+ return QOpenGLStaticContext::create(true);
#elif defined(QT_OPENGL_ES_2)
- ctx = QWindowsEGLStaticContext::create();
+ QWindowsOpenGLTester::Renderers glesRenderers = QWindowsOpenGLTester::requestedGlesRenderer();
+ if (glesRenderers == QWindowsOpenGLTester::InvalidRenderer)
+ glesRenderers = QWindowsOpenGLTester::supportedGlesRenderers();
+ return QWindowsEGLStaticContext::create(glesRenderers);
#elif !defined(QT_NO_OPENGL)
- ctx = QOpenGLStaticContext::create();
+ return QOpenGLStaticContext::create();
#endif
-
- q_staticOpenGLContext = ctx;
-
- return ctx;
}
-bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext()
+QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create()
{
- if (m_staticOpenGLContext.isNull())
- m_staticOpenGLContext = QSharedPointer<QWindowsStaticOpenGLContext>(QWindowsStaticOpenGLContext::create());
- return !m_staticOpenGLContext.isNull();
+ return QWindowsStaticOpenGLContext::doCreate();
}
QPlatformOpenGLContext *QWindowsIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
qCDebug(lcQpaGl) << __FUNCTION__ << context->format();
- if (d->ensureStaticOpenGLContext()) {
- QScopedPointer<QWindowsOpenGLContext> result(d->m_staticOpenGLContext->createContext(context));
+ if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) {
+ QScopedPointer<QWindowsOpenGLContext> result(staticOpenGLContext->createContext(context));
if (result->isValid())
return result.take();
}
@@ -396,13 +396,18 @@ QOpenGLContext::OpenGLModuleType QWindowsIntegration::openGLModuleType()
#elif !defined(QT_OPENGL_DYNAMIC)
return QOpenGLContext::LibGL;
#else
- return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->moduleType() : QOpenGLContext::LibGL;
+ if (const QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
+ return staticOpenGLContext->moduleType();
+ return QOpenGLContext::LibGL;
#endif
}
QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext()
{
- return q_staticOpenGLContext;
+ QWindowsIntegrationPrivate *d = QWindowsIntegration::instance()->d.data();
+ if (d->m_staticOpenGLContext.isNull())
+ d->m_staticOpenGLContext = QSharedPointer<QWindowsStaticOpenGLContext>(QWindowsStaticOpenGLContext::create());
+ return d->m_staticOpenGLContext.data();
}
#endif // !QT_NO_OPENGL