diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-01-15 17:04:29 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2015-01-19 13:18:02 +0100 |
commit | a8f37e47751d7d29ab63bef55f5849056f826e8b (patch) | |
tree | c3f800fbe3f3f8e119da9e257955184c05fdeb68 /src/plugins/platforms/windows/qwindowsintegration.cpp | |
parent | 5ee8ed27e05f17dc7911a5917c012d0a4fa5afcb (diff) |
Windows: Delay creation of the static OpenGL context.
Delay initialization/GL detection until a surface is requested.
Remove member variable from window and access static context
from QWindowsIntegration only.
Task-number: QTBUG-43832
Change-Id: I4b9a324b58af4399df5c314bfb2b952455b1e080
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsintegration.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsintegration.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 82686f38ad..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 ¶mList); ~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; } @@ -377,26 +373,16 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() #endif } -static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0; - QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create() { - q_staticOpenGLContext = QWindowsStaticOpenGLContext::doCreate(); - return q_staticOpenGLContext; -} - -bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext() -{ - 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(); } @@ -410,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 |