summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-24 10:33:37 +0100
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-01-25 20:06:06 +0100
commit318b58562ae89453fb98e8145cd0440e14ba60b0 (patch)
tree622bc032cf076b4569621032f3a3315d95c3ae88 /src/gui/opengl
parentc28fde3fdac19fd5a5f614bb7983080031c924b3 (diff)
parent79352528a1726b4551ea4d9285dd2394dd0d43da (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: .qmake.conf mkspecs/common/msvc-desktop.conf mkspecs/common/msvc-version.conf mkspecs/common/winrt_winphone/qmake.conf mkspecs/features/mac/default_post.prf mkspecs/features/mac/sdk.prf mkspecs/features/qt.prf mkspecs/features/uikit/default_post.prf mkspecs/features/winrt/default_pre.prf mkspecs/winphone-arm-msvc2013/qmake.conf mkspecs/winphone-x86-msvc2013/qmake.conf mkspecs/winrt-arm-msvc2013/qmake.conf mkspecs/winrt-x64-msvc2013/qmake.conf mkspecs/winrt-x86-msvc2013/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/gui/kernel/qwindowsysteminterface.cpp src/network/kernel/qhostaddress.cpp src/plugins/platforms/mirclient/qmirclientplugin.cpp src/plugins/platforms/mirclient/qmirclientplugin.h src/widgets/util/qsystemtrayicon.cpp tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp tools/configure/Makefile.mingw tools/configure/Makefile.win32 Done-with: Jake Petroules <jake.petroules@qt.io> Done-with: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Change-Id: I4be3262d3994e11929d3b1ded2c3379783797dbe
Diffstat (limited to 'src/gui/opengl')
-rw-r--r--src/gui/opengl/qopengl.cpp22
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp5
-rw-r--r--src/gui/opengl/qopenglversionfunctions.cpp18
-rw-r--r--src/gui/opengl/qopenglvertexarrayobject.cpp94
4 files changed, 72 insertions, 67 deletions
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index e61473cb7b..7e663d48bb 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -65,6 +65,10 @@ typedef const GLubyte * (QOPENGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint);
QOpenGLExtensionMatcher::QOpenGLExtensionMatcher()
{
QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ if (!ctx) {
+ qWarning("QOpenGLExtensionMatcher::QOpenGLExtensionMatcher: No context");
+ return;
+ }
QOpenGLFunctions *funcs = ctx->functions();
const char *extensionStr = 0;
@@ -80,19 +84,17 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher()
// clear error state
while (funcs->glGetError()) {}
- if (ctx) {
- qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi");
+ qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi");
- if (!glGetStringi)
- return;
+ if (!glGetStringi)
+ return;
- GLint numExtensions = 0;
- funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
+ GLint numExtensions = 0;
+ funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
- for (int i = 0; i < numExtensions; ++i) {
- const char *str = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
- m_extensions.insert(str);
- }
+ for (int i = 0; i < numExtensions; ++i) {
+ const char *str = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
+ m_extensions.insert(str);
}
#endif // QT_OPENGL_3
}
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index e4e7c6d1b5..ad8b19a2bc 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -2196,9 +2196,10 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *c)
#ifndef QT_OPENGL_ES_2
// setup fallbacks in case some methods couldn't get resolved
- if (!f.ClearDepthf)
+ bool es = QOpenGLContext::currentContext()->isOpenGLES();
+ if (!f.ClearDepthf || !es)
f.ClearDepthf = qopenglfSpecialClearDepthf;
- if (!f.DepthRangef)
+ if (!f.DepthRangef || !es)
f.DepthRangef = qopenglfSpecialDepthRangef;
if (!f.GetShaderPrecisionFormat)
f.GetShaderPrecisionFormat = qopenglfSpecialGetShaderPrecisionFormat;
diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp
index 54df2e5734..a3d3bb6bd1 100644
--- a/src/gui/opengl/qopenglversionfunctions.cpp
+++ b/src/gui/opengl/qopenglversionfunctions.cpp
@@ -74,15 +74,21 @@ QOpenGLVersionFunctionsStorage::QOpenGLVersionFunctionsStorage()
QOpenGLVersionFunctionsStorage::~QOpenGLVersionFunctionsStorage()
{
+#ifndef QT_OPENGL_ES
if (backends) {
- for (int i = 0; i < QOpenGLVersionFunctionsBackend::OpenGLVersionBackendCount; ++i) {
- if (backends[i] && !--backends[i]->refs) {
- // deleting the base class is ok, as the derived classes don't have a destructor
- delete backends[i];
- }
- }
+
+ int i = 0;
+
+#define DELETE_BACKEND(X) \
+ if (backends[i] && !--backends[i]->refs) \
+ delete static_cast<QOpenGLFunctions_##X##Backend*>(backends[i]); \
+ ++i;
+
+ QT_OPENGL_VERSIONS(DELETE_BACKEND)
+#undef DELETE_BACKEND
delete[] backends;
}
+#endif
}
QOpenGLVersionFunctionsBackend *QOpenGLVersionFunctionsStorage::backend(QOpenGLContext *context, QOpenGLVersionFunctionsBackend::Version v)
diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp
index babe52aa83..0262538250 100644
--- a/src/gui/opengl/qopenglvertexarrayobject.cpp
+++ b/src/gui/opengl/qopenglvertexarrayobject.cpp
@@ -197,33 +197,59 @@ void QOpenGLVertexArrayObjectPrivate::destroy()
{
Q_Q(QOpenGLVertexArrayObject);
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ QOpenGLContext *oldContext = 0;
+ QSurface *oldContextSurface = 0;
+ QScopedPointer<QOffscreenSurface> offscreenSurface;
+ if (context && context != ctx) {
+ oldContext = ctx;
+ oldContextSurface = ctx ? ctx->surface() : 0;
+ // Cannot just make the current surface current again with another context.
+ // The format may be incompatible and some platforms (iOS) may impose
+ // restrictions on using a window with different contexts. Create an
+ // offscreen surface (a pbuffer or a hidden window) instead to be safe.
+ offscreenSurface.reset(new QOffscreenSurface);
+ offscreenSurface->setFormat(context->format());
+ offscreenSurface->create();
+ if (context->makeCurrent(offscreenSurface.data())) {
+ ctx = context;
+ } else {
+ qWarning("QOpenGLVertexArrayObject::destroy() failed to make VAO's context current");
+ ctx = 0;
+ }
+ }
+
if (context) {
QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));
context = 0;
}
- if (!vao)
- return;
-
- switch (vaoFuncsType) {
+ if (vao) {
+ switch (vaoFuncsType) {
#ifndef QT_OPENGL_ES_2
- case Core_3_2:
- vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao);
- break;
- case Core_3_0:
- vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao);
- break;
+ case Core_3_2:
+ vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao);
+ break;
+ case Core_3_0:
+ vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao);
+ break;
#endif
- case ARB:
- case APPLE:
- case OES:
- vaoFuncs.helper->glDeleteVertexArrays(1, &vao);
- break;
- default:
- break;
+ case ARB:
+ case APPLE:
+ case OES:
+ vaoFuncs.helper->glDeleteVertexArrays(1, &vao);
+ break;
+ default:
+ break;
+ }
+
+ vao = 0;
}
- vao = 0;
+ if (oldContext && oldContextSurface) {
+ if (!oldContext->makeCurrent(oldContextSurface))
+ qWarning("QOpenGLVertexArrayObject::destroy() failed to restore current context");
+ }
}
/*!
@@ -354,37 +380,7 @@ QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPriva
*/
QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject()
{
- QOpenGLContext* ctx = QOpenGLContext::currentContext();
-
- Q_D(QOpenGLVertexArrayObject);
- QOpenGLContext *oldContext = 0;
- QSurface *oldContextSurface = 0;
- QScopedPointer<QOffscreenSurface> offscreenSurface;
- if (d->context && ctx && d->context != ctx) {
- oldContext = ctx;
- oldContextSurface = ctx->surface();
- // Cannot just make the current surface current again with another context.
- // The format may be incompatible and some platforms (iOS) may impose
- // restrictions on using a window with different contexts. Create an
- // offscreen surface (a pbuffer or a hidden window) instead to be safe.
- offscreenSurface.reset(new QOffscreenSurface);
- offscreenSurface->setFormat(d->context->format());
- offscreenSurface->create();
- if (d->context->makeCurrent(offscreenSurface.data())) {
- ctx = d->context;
- } else {
- qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to make VAO's context current");
- ctx = 0;
- }
- }
-
- if (ctx)
- destroy();
-
- if (oldContext) {
- if (!oldContext->makeCurrent(oldContextSurface))
- qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context");
- }
+ destroy();
}
/*!