diff options
author | Liang Qi <liang.qi@qt.io> | 2016-11-17 14:15:53 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-11-17 14:43:26 +0100 |
commit | e5ac4afbf954a3e1616ce8543d46ddc668d0374f (patch) | |
tree | be6d97001edebd5cb74c64aaf0010f3cc76a7293 /src/gui/opengl | |
parent | e3ed95dd44b95b6e9361b562807e711d7ce5a58b (diff) | |
parent | 03c1a6ac717e3c5693653a5e294214056bda970e (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
mkspecs/features/mac/default_post.prf
mkspecs/features/uikit/default_post.prf
Change-Id: I2a6f783451f2ac9eb4c1a050f605435d2dacf218
Diffstat (limited to 'src/gui/opengl')
-rw-r--r-- | src/gui/opengl/opengl.pri | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopengl.cpp | 6 | ||||
-rw-r--r-- | src/gui/opengl/qopengl.h | 18 | ||||
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 6 | ||||
-rw-r--r-- | src/gui/opengl/qopenglshaderprogram.cpp | 81 |
5 files changed, 73 insertions, 40 deletions
diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index 2c3cca6b18..712cf144e0 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -3,7 +3,7 @@ qtConfig(opengl): CONFIG += opengl qtConfig(opengles2): CONFIG += opengles2 -qtConfig(opengl(es2)?) { +qtConfig(opengl) { HEADERS += opengl/qopengl.h \ opengl/qopengl_p.h \ diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 4f4f543ba8..e61473cb7b 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -136,9 +136,6 @@ QDebug operator<<(QDebug d, const QOpenGLConfig::Gpu &g) return d; } -enum Operator { NotEqual, LessThan, LessEqualThan, Equals, GreaterThan, GreaterEqualThan }; -static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="}; - typedef QJsonArray::ConstIterator JsonArrayConstIt; static inline bool contains(const QJsonArray &haystack, unsigned needle) @@ -160,6 +157,9 @@ static inline bool contains(const QJsonArray &haystack, const QString &needle) } namespace { +enum Operator { NotEqual, LessThan, LessEqualThan, Equals, GreaterThan, GreaterEqualThan }; +static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="}; + // VersionTerm describing a version term consisting of number and operator // found in os.version and driver_version. struct VersionTerm { diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h index c7a3e79666..cd44ddfe4d 100644 --- a/src/gui/opengl/qopengl.h +++ b/src/gui/opengl/qopengl.h @@ -95,8 +95,11 @@ typedef void* GLeglImageOES; // applications cannot target ES 3. Therefore QOpenGLFunctions and // friends do everything dynamically and never rely on these macros. +// Some Khronos headers use the ext proto guard in the standard headers as well, +// which is bad. Work it around, but avoid spilling over to the ext header. # ifndef GL_GLEXT_PROTOTYPES # define GL_GLEXT_PROTOTYPES +# define QGL_TEMP_GLEXT_PROTO # endif # if defined(QT_OPENGL_ES_3_1) @@ -107,6 +110,11 @@ typedef void* GLeglImageOES; # include <GLES2/gl2.h> #endif +# ifdef QGL_TEMP_GLEXT_PROTO +# undef GL_GLEXT_PROTOTYPES +# undef QGL_TEMP_GLEXT_PROTO +# endif + /* Some GLES2 implementations (like the one on Harmattan) are missing the typedef for GLchar. Work around it here by adding it. The Kkronos headers @@ -125,7 +133,15 @@ typedef char GLchar; # include <OpenGL/glext.h> # else # define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h -# include <GL/gl.h> +// Some Khronos headers use the ext proto guard in the standard headers as well, +// which is bad. Work it around, but avoid spilling over to the ext header. +# ifndef GL_GLEXT_PROTOTYPES +# define GL_GLEXT_PROTOTYPES +# include <GL/gl.h> +# undef GL_GLEXT_PROTOTYPES +# else +# include <GL/gl.h> +# endif # include <QtGui/qopenglext.h> # endif // Q_OS_MAC #endif // QT_OPENGL_ES_2 diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 4833617377..cedbe19191 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -950,6 +950,12 @@ QOpenGLFramebufferObject::~QOpenGLFramebufferObject() d->stencil_buffer_guard->free(); if (d->fbo_guard) d->fbo_guard->free(); + + QOpenGLContextPrivate *contextPrv = QOpenGLContextPrivate::get(QOpenGLContext::currentContext()); + if (contextPrv && contextPrv->qgl_current_fbo == this) { + contextPrv->qgl_current_fbo_invalid = true; + contextPrv->qgl_current_fbo = Q_NULLPTR; + } } /*! diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 1ed5f7317a..b92d97c143 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -493,73 +493,84 @@ static QVersionDirectivePosition findVersionDirectivePosition(const char *source { Q_ASSERT(source); - QString working = QString::fromUtf8(source); - // According to the GLSL spec the #version directive must not be // preceded by anything but whitespace and comments. // In order to not get confused by #version directives within a - // multiline comment, we need to run a minimal preprocessor first. + // multiline comment, we need to do some minimal comment parsing + // while searching for the directive. enum { Normal, + StartOfLine, + PreprocessorDirective, CommentStarting, MultiLineComment, SingleLineComment, CommentEnding - } state = Normal; + } state = StartOfLine; - for (QChar *c = working.begin(); c != working.end(); ++c) { + const char *c = source; + while (*c) { switch (state) { + case PreprocessorDirective: + if (*c == ' ' || *c == '\t') + break; + if (!strncmp(c, "version", strlen("version"))) { + // Found version directive + c += strlen("version"); + while (*c && *c != '\n') + ++c; + int splitPosition = c - source + 1; + int linePosition = int(std::count(source, c, '\n')) + 1; + return QVersionDirectivePosition(splitPosition, linePosition); + } else if (*c == '/') + state = CommentStarting; + else if (*c == '\n') + state = StartOfLine; + else + state = Normal; + break; + case StartOfLine: + if (*c == ' ' || *c == '\t') + break; + else if (*c == '#') { + state = PreprocessorDirective; + break; + } + state = Normal; + // fall through case Normal: - if (*c == QLatin1Char('/')) + if (*c == '/') state = CommentStarting; + else if (*c == '\n') + state = StartOfLine; break; case CommentStarting: - if (*c == QLatin1Char('*')) + if (*c == '*') state = MultiLineComment; - else if (*c == QLatin1Char('/')) + else if (*c == '/') state = SingleLineComment; else state = Normal; break; case MultiLineComment: - if (*c == QLatin1Char('*')) + if (*c == '*') state = CommentEnding; - else if (*c == QLatin1Char('#')) - *c = QLatin1Char('_'); break; case SingleLineComment: - if (*c == QLatin1Char('\n')) + if (*c == '\n') state = Normal; - else if (*c == QLatin1Char('#')) - *c = QLatin1Char('_'); break; case CommentEnding: - if (*c == QLatin1Char('/')) { + if (*c == '/') state = Normal; - } else { - if (*c == QLatin1Char('#')) - *c = QLatin1Char('_'); - if (*c != QLatin1Char('*')) - state = MultiLineComment; - } + else if (*c != QLatin1Char('*')) + state = MultiLineComment; break; } + ++c; } - // Search for #version directive - int splitPosition = 0; - int linePosition = 1; - - static const QRegularExpression pattern(QStringLiteral("^\\s*#\\s*version.*(\\n)?"), - QRegularExpression::MultilineOption - | QRegularExpression::OptimizeOnFirstUsageOption); - QRegularExpressionMatch match = pattern.match(working); - if (match.hasMatch()) { - splitPosition = match.capturedEnd(); - linePosition += int(std::count(working.begin(), working.begin() + splitPosition, QLatin1Char('\n'))); - } - - return QVersionDirectivePosition(splitPosition, linePosition); + return QVersionDirectivePosition(0, 1); } /*! |