Skip to content

Commit

Permalink
Replace QPair/qMakePair with std::pair in qtbase/opengl
Browse files Browse the repository at this point in the history
Task-number: QTBUG-115841
Change-Id: Ic7a362a41fb52d39d8a168f0ba4ed6d33458dd73
Reviewed-by: Matthias Rauter <[email protected]>
  • Loading branch information
Isak Fyksen committed Nov 21, 2024
1 parent abe3eed commit 35022c1
Show file tree
Hide file tree
Showing 42 changed files with 116 additions and 118 deletions.
2 changes: 1 addition & 1 deletion src/opengl/qopenglengineshadermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ QOpenGLEngineSharedShaders::QOpenGLEngineSharedShaders(QOpenGLContext* context)
// Check if the user has requested an OpenGL 3.2 Core Profile or higher
// and if so use GLSL 1.50 core shaders instead of legacy ones.
const QSurfaceFormat &fmt = context->format();
const bool isCoreProfile = fmt.profile() == QSurfaceFormat::CoreProfile && fmt.version() >= qMakePair(3,2);
const bool isCoreProfile = fmt.profile() == QSurfaceFormat::CoreProfile && fmt.version() >= std::pair(3,2);

const char** code = qShaderSnippets; // shortcut

Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_1_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ bool QOpenGLFunctions_1_0::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(1, 0))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(1, 0))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_1_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ bool QOpenGLFunctions_1_1::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(1, 1))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(1, 1))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_1_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ bool QOpenGLFunctions_1_2::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(1, 2))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(1, 2))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_1_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ bool QOpenGLFunctions_1_3::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(1, 3))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(1, 3))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_1_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ bool QOpenGLFunctions_1_4::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(1, 4))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(1, 4))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_1_5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ bool QOpenGLFunctions_1_5::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(1, 5))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(1, 5))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_2_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ bool QOpenGLFunctions_2_0::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(2, 0))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(2, 0))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_2_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ bool QOpenGLFunctions_2_1::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(2, 1))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(2, 1))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_3_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ bool QOpenGLFunctions_3_0::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(3, 0))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(3, 0))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_3_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ bool QOpenGLFunctions_3_1::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(3, 1))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(3, 1))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_3_2_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ bool QOpenGLFunctions_3_2_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(3, 2))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(3, 2))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_3_2_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ bool QOpenGLFunctions_3_2_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(3, 2))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(3, 2))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_3_3_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ bool QOpenGLFunctions_3_3_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(3, 3))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(3, 3))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_3_3_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ bool QOpenGLFunctions_3_3_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(3, 3))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(3, 3))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_0_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ bool QOpenGLFunctions_4_0_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 0))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 0))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_0_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ bool QOpenGLFunctions_4_0_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 0))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 0))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_1_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ bool QOpenGLFunctions_4_1_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 1))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 1))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_1_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ bool QOpenGLFunctions_4_1_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 1))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 1))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_2_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ bool QOpenGLFunctions_4_2_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 2))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 2))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_2_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ bool QOpenGLFunctions_4_2_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 2))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 2))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_3_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ bool QOpenGLFunctions_4_3_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 3))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 3))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_3_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ bool QOpenGLFunctions_4_3_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 3))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 3))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_4_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ bool QOpenGLFunctions_4_4_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 4))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 4))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_4_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ bool QOpenGLFunctions_4_4_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 4))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 4))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_5_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ bool QOpenGLFunctions_4_5_Compatibility::isContextCompatible(QOpenGLContext *con
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 5))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 5))
return false;

if (f.profile() == QSurfaceFormat::CoreProfile)
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_4_5_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ bool QOpenGLFunctions_4_5_Core::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(4, 5))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(4, 5))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/qopenglfunctions_es2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ bool QOpenGLFunctions_ES2::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(2, 0))
const auto v = std::pair(f.majorVersion(), f.minorVersion());
if (v < std::pair(2, 0))
return false;
if (f.renderableType() != QSurfaceFormat::OpenGLES)
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/opengl/qopenglpaintengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
// still tests for QGL-QOpenGL paint engine interoperability, so keep the
// status quo for now, and avoid introducing a VAO in non-core contexts.
const bool needsVAO = d->ctx->format().profile() == QSurfaceFormat::CoreProfile
&& d->ctx->format().version() >= qMakePair(3, 2);
&& d->ctx->format().version() >= std::pair(3, 2);
if (needsVAO && !d->vao.isCreated()) {
bool created = d->vao.create();

Expand Down
16 changes: 8 additions & 8 deletions src/opengl/qopenglshaderprogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,30 @@ static inline bool isFormatGLES(const QSurfaceFormat &f)

static inline bool supportsGeometry(const QSurfaceFormat &f)
{
return f.version() >= qMakePair(3, 2);
return f.version() >= std::pair(3, 2);
}

static inline bool supportsCompute(const QSurfaceFormat &f)
{
#if !QT_CONFIG(opengles2)
if (!isFormatGLES(f))
return f.version() >= qMakePair(4, 3);
return f.version() >= std::pair(4, 3);
else
return f.version() >= qMakePair(3, 1);
return f.version() >= std::pair(3, 1);
#else
return f.version() >= qMakePair(3, 1);
return f.version() >= std::pair(3, 1);
#endif
}

static inline bool supportsTessellation(const QSurfaceFormat &f)
{
#if !QT_CONFIG(opengles2)
if (!isFormatGLES(f))
return f.version() >= qMakePair(4, 0);
return f.version() >= std::pair(4, 0);
else
return f.version() >= qMakePair(3, 2);
return f.version() >= std::pair(3, 2);
#else
return f.version() >= qMakePair(3, 2);
return f.version() >= std::pair(3, 2);
#endif
}

Expand Down Expand Up @@ -863,7 +863,7 @@ bool QOpenGLShaderProgram::init()
d->glfuncs->initializeOpenGLFunctions();

#if !QT_CONFIG(opengles2)
if (!context->isOpenGLES() && context->format().version() >= qMakePair(4, 0)) {
if (!context->isOpenGLES() && context->format().version() >= std::pair(4, 0)) {
d->tessellationFuncs = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_4_0_Core>(context);
d->tessellationFuncs->initializeOpenGLFunctions();
}
Expand Down
Loading

0 comments on commit 35022c1

Please sign in to comment.