OpenGL: port away from QLatin1String

Replace the uses of QLatin1String with corresponding string literals
where applies, or with QLatin1StringView.

As a drive-by, fix formatting of a warning message in
qopenglengineshadermanager.cpp.

Task-number: QTBUG-98434
Change-Id: I12f4479637a8fe265138f240a1310d2d576454a7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Sona Kurazyan 2022-04-25 10:42:03 +02:00 committed by Marc Mutz
parent 1ed449e168
commit c1db1788c0
3 changed files with 15 additions and 15 deletions

View File

@ -454,11 +454,9 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO
if (!inCache) if (!inCache)
shaderCache.store(newProg->program, QOpenGLContext::currentContext()); shaderCache.store(newProg->program, QOpenGLContext::currentContext());
} else { } else {
QString error; qWarning("Shader program failed to link\n"
error = QLatin1String("Shader program failed to link") " Error Log:\n"
+ QLatin1String(" Error Log:\n") " %ls", qUtf16Printable(newProg->program->log()));
+ QLatin1String(" ") + newProg->program->log();
qWarning() << error;
break; break;
} }

View File

@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*! /*!
\class QOpenGLShaderProgram \class QOpenGLShaderProgram
\brief The QOpenGLShaderProgram class allows OpenGL shader programs to be linked and used. \brief The QOpenGLShaderProgram class allows OpenGL shader programs to be linked and used.
@ -398,7 +400,7 @@ bool QOpenGLShaderPrivate::compile(QOpenGLShader *q)
if (logBuffer) if (logBuffer)
log = QString::fromLatin1(logBuffer); log = QString::fromLatin1(logBuffer);
else else
log = QLatin1String("failed"); log = u"failed"_s;
if (name.isEmpty()) if (name.isEmpty())
qWarning("QOpenGLShader::compile(%s): %s", type, qPrintable(log)); qWarning("QOpenGLShader::compile(%s): %s", type, qPrintable(log));
@ -579,7 +581,7 @@ static QVersionDirectivePosition findVersionDirectivePosition(const char *source
case CommentEnding: case CommentEnding:
if (*c == '/') if (*c == '/')
state = Normal; state = Normal;
else if (*c != QLatin1Char('*')) else if (*c != u'*')
state = MultiLineComment; state = MultiLineComment;
break; break;
} }

View File

@ -345,11 +345,11 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
{ {
QString source; QString source;
#ifdef Q_OS_WASM #ifdef Q_OS_WASM
source.append(QLatin1String(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader));
source.append(QLatin1String(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader));
#else #else
source.append(QLatin1String(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader));
source.append(QLatin1String(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader));
#endif #endif
m_blitProgram->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, source); m_blitProgram->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, source);
} }
@ -357,11 +357,11 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
{ {
QString source; QString source;
#ifdef Q_OS_WASM #ifdef Q_OS_WASM
source.append(QLatin1String(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader));
source.append(QLatin1String(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader));
#else #else
source.append(QLatin1String(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader));
source.append(QLatin1String(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader)); source.append(QLatin1StringView(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader));
#endif #endif
m_blitProgram->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, source); m_blitProgram->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, source);
} }