diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-11-15 15:59:11 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-17 16:53:24 +0100 |
commit | 8a04cc7dc6707d3ee11565fe2c3d76fdce98187f (patch) | |
tree | a0a6c9295584b5bc14ec2ddca3acd6f660cc39a9 /src | |
parent | 2fa65a8697f36950bcd1b52398ece0ae328ff76d (diff) |
Fixed QQuickShaderEffect::lookThroughShaderCode(), added autotest.
Change-Id: I1e4a1589e1482c21eedab4cd052c16b6653344fb
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qquickshadereffect.cpp | 28 | ||||
-rw-r--r-- | src/declarative/items/qquickshadereffect_p.h | 2 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/declarative/items/qquickshadereffect.cpp b/src/declarative/items/qquickshadereffect.cpp index ea7350df97..78c23d46e7 100644 --- a/src/declarative/items/qquickshadereffect.cpp +++ b/src/declarative/items/qquickshadereffect.cpp @@ -557,39 +557,45 @@ namespace { if (qt_isalpha(s[index])) { // Read identifier. - int identifierIndex = index; + int idIndex = index; ++index; while (qt_isalnum(s[index])) ++index; - int identifierLength = index - identifierIndex; + int idLength = index - idIndex; + + const int attrLen = sizeof("attribute") - 1; + const int uniLen = sizeof("uniform") - 1; + const int loLen = sizeof("lowp") - 1; + const int medLen = sizeof("mediump") - 1; + const int hiLen = sizeof("highp") - 1; switch (expected) { case QualifierIdentifier: - if (qstrncmp("attribute", s + identifierIndex, identifierLength) == 0) { + if (idLength == attrLen && qstrncmp("attribute", s + idIndex, attrLen) == 0) { decl = AttributeQualifier; expected = PrecisionIdentifier; - } else if (qstrncmp("uniform", s + identifierIndex, identifierLength) == 0) { + } else if (idLength == uniLen && qstrncmp("uniform", s + idIndex, uniLen) == 0) { decl = UniformQualifier; expected = PrecisionIdentifier; } break; case PrecisionIdentifier: - if (qstrncmp("lowp", s + identifierIndex, identifierLength) == 0 - || qstrncmp("mediump", s + identifierIndex, identifierLength) == 0 - || qstrncmp("highp", s + identifierIndex, identifierLength) == 0) + if ((idLength == loLen && qstrncmp("lowp", s + idIndex, loLen) == 0) + || (idLength == medLen && qstrncmp("mediump", s + idIndex, medLen) == 0) + || (idLength == hiLen && qstrncmp("highp", s + idIndex, hiLen) == 0)) { expected = TypeIdentifier; break; } // Fall through. case TypeIdentifier: - typeIndex = identifierIndex; - typeLength = identifierLength; + typeIndex = idIndex; + typeLength = idLength; expected = NameIdentifier; break; case NameIdentifier: - nameIndex = identifierIndex; - nameLength = identifierLength; + nameIndex = idIndex; + nameLength = idLength; return index; // Attribute or uniform declaration found. Return result. default: break; diff --git a/src/declarative/items/qquickshadereffect_p.h b/src/declarative/items/qquickshadereffect_p.h index 257fa40aa8..ee38c3118b 100644 --- a/src/declarative/items/qquickshadereffect_p.h +++ b/src/declarative/items/qquickshadereffect_p.h @@ -64,7 +64,7 @@ class QSGContext; class QSignalMapper; class QQuickCustomMaterialShader; -class QQuickShaderEffect : public QQuickItem +class Q_AUTOTEST_EXPORT QQuickShaderEffect : public QQuickItem { Q_OBJECT Q_PROPERTY(QByteArray fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY fragmentShaderChanged) |