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)
shaderCache.store(newProg->program, QOpenGLContext::currentContext());
} else {
QString error;
error = QLatin1String("Shader program failed to link")
+ QLatin1String(" Error Log:\n")
+ QLatin1String(" ") + newProg->program->log();
qWarning() << error;
qWarning("Shader program failed to link\n"
" Error Log:\n"
" %ls", qUtf16Printable(newProg->program->log()));
break;
}

View File

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

View File

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