From b043871d2b1ee9c57d75fe8a3f8cb22e35a4fe4d Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 22 Jun 2020 12:36:03 +0200 Subject: Use QList instead of QVector in opengl Task-number: QTBUG-84469 Change-Id: I26c1cfab7f2d9aa5c71847ae02bfe0cf15c04a1b Reviewed-by: Laszlo Agocs --- src/opengl/qopengldebug.cpp | 31 +++++++--------------- src/opengl/qopengldebug.h | 5 ++-- src/opengl/qopenglengineshadermanager.cpp | 2 +- src/opengl/qopenglengineshadermanager_p.h | 2 +- src/opengl/qopenglframebufferobject.cpp | 8 +++--- src/opengl/qopenglframebufferobject.h | 4 +-- src/opengl/qopenglframebufferobject_p.h | 2 +- src/opengl/qopenglpaintengine_p.h | 6 ++--- src/opengl/qopenglshaderprogram.cpp | 32 +++++++++++------------ src/opengl/qopenglshaderprogram.h | 8 +++--- src/opengl/qopengltimerquery.cpp | 28 ++++++++++---------- src/opengl/qopengltimerquery.h | 6 ++--- src/opengl/qplatformbackingstoreopenglsupport.cpp | 2 +- 13 files changed, 62 insertions(+), 74 deletions(-) diff --git a/src/opengl/qopengldebug.cpp b/src/opengl/qopengldebug.cpp index a69f6069dc..ef3b955f90 100644 --- a/src/opengl/qopengldebug.cpp +++ b/src/opengl/qopengldebug.cpp @@ -1079,10 +1079,8 @@ public: void handleMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *rawMessage); void controlDebugMessages(QOpenGLDebugMessage::Sources sources, QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities, - const QVector &ids, - const QByteArray &callerName, - bool enable); + QOpenGLDebugMessage::Severities severities, const QList &ids, + const QByteArray &callerName, bool enable); void _q_contextAboutToBeDestroyed(); qt_glDebugMessageControl_t glDebugMessageControl; @@ -1159,9 +1157,8 @@ void QOpenGLDebugLoggerPrivate::handleMessage(GLenum source, void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Sources sources, QOpenGLDebugMessage::Types types, QOpenGLDebugMessage::Severities severities, - const QVector &ids, - const QByteArray &callerName, - bool enable) + const QList &ids, + const QByteArray &callerName, bool enable) { if (!initialized) { qWarning("QOpenGLDebugLogger::%s(): object must be initialized before enabling/disabling messages", callerName.constData()); @@ -1644,12 +1641,8 @@ void QOpenGLDebugLogger::enableMessages(QOpenGLDebugMessage::Sources sources, QOpenGLDebugMessage::Severities severities) { Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - severities, - QVector(), - QByteArrayLiteral("enableMessages"), - true); + d->controlDebugMessages(sources, types, severities, QList(), + QByteArrayLiteral("enableMessages"), true); } /*! @@ -1660,7 +1653,7 @@ void QOpenGLDebugLogger::enableMessages(QOpenGLDebugMessage::Sources sources, \sa disableMessages(), pushGroup(), popGroup() */ -void QOpenGLDebugLogger::enableMessages(const QVector &ids, +void QOpenGLDebugLogger::enableMessages(const QList &ids, QOpenGLDebugMessage::Sources sources, QOpenGLDebugMessage::Types types) { @@ -1686,12 +1679,8 @@ void QOpenGLDebugLogger::disableMessages(QOpenGLDebugMessage::Sources sources, QOpenGLDebugMessage::Severities severities) { Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - severities, - QVector(), - QByteArrayLiteral("disableMessages"), - false); + d->controlDebugMessages(sources, types, severities, QList(), + QByteArrayLiteral("disableMessages"), false); } /*! @@ -1702,7 +1691,7 @@ void QOpenGLDebugLogger::disableMessages(QOpenGLDebugMessage::Sources sources, \sa enableMessages(), pushGroup(), popGroup() */ -void QOpenGLDebugLogger::disableMessages(const QVector &ids, +void QOpenGLDebugLogger::disableMessages(const QList &ids, QOpenGLDebugMessage::Sources sources, QOpenGLDebugMessage::Types types) { diff --git a/src/opengl/qopengldebug.h b/src/opengl/qopengldebug.h index fef2782302..c12d996493 100644 --- a/src/opengl/qopengldebug.h +++ b/src/opengl/qopengldebug.h @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -184,7 +183,7 @@ public: QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); - void enableMessages(const QVector &ids, + void enableMessages(const QList &ids, QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); @@ -192,7 +191,7 @@ public: QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); - void disableMessages(const QVector &ids, + void disableMessages(const QList &ids, QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); diff --git a/src/opengl/qopenglengineshadermanager.cpp b/src/opengl/qopenglengineshadermanager.cpp index 09bd9ff096..dc52b326bb 100644 --- a/src/opengl/qopenglengineshadermanager.cpp +++ b/src/opengl/qopenglengineshadermanager.cpp @@ -524,7 +524,7 @@ GLuint QOpenGLEngineShaderManager::getUniformLocation(Uniform id) if (!currentShaderProg) return 0; - QVector &uniformLocations = currentShaderProg->uniformLocations; + QList &uniformLocations = currentShaderProg->uniformLocations; if (uniformLocations.isEmpty()) uniformLocations.fill(GLuint(-1), NumUniforms); diff --git a/src/opengl/qopenglengineshadermanager_p.h b/src/opengl/qopenglengineshadermanager_p.h index 71e6214278..5aaa1903a1 100644 --- a/src/opengl/qopenglengineshadermanager_p.h +++ b/src/opengl/qopenglengineshadermanager_p.h @@ -386,7 +386,7 @@ public: QByteArray customStageSource; //TODO: Decent cache key for custom stages QOpenGLShaderProgram* program; - QVector uniformLocations; + QList uniformLocations; bool useTextureCoords; bool useOpacityAttribute; diff --git a/src/opengl/qopenglframebufferobject.cpp b/src/opengl/qopenglframebufferobject.cpp index 813c01b0a5..588ddd6535 100644 --- a/src/opengl/qopenglframebufferobject.cpp +++ b/src/opengl/qopenglframebufferobject.cpp @@ -1223,10 +1223,10 @@ GLuint QOpenGLFramebufferObject::texture() const \sa takeTexture(), texture() */ -QVector QOpenGLFramebufferObject::textures() const +QList QOpenGLFramebufferObject::textures() const { Q_D(const QOpenGLFramebufferObject); - QVector ids; + QList ids; if (d->format.samples() != 0) return ids; ids.reserve(d->colorAttachments.count()); @@ -1310,10 +1310,10 @@ QSize QOpenGLFramebufferObject::size() const \since 5.6 */ -QVector QOpenGLFramebufferObject::sizes() const +QList QOpenGLFramebufferObject::sizes() const { Q_D(const QOpenGLFramebufferObject); - QVector sz; + QList sz; sz.reserve(d->colorAttachments.size()); for (const auto &color : d->colorAttachments) sz.append(color.size); diff --git a/src/opengl/qopenglframebufferobject.h b/src/opengl/qopenglframebufferobject.h index da3347eaec..9351f6f1a6 100644 --- a/src/opengl/qopenglframebufferobject.h +++ b/src/opengl/qopenglframebufferobject.h @@ -100,13 +100,13 @@ public: int height() const { return size().height(); } GLuint texture() const; - QVector textures() const; + QList textures() const; GLuint takeTexture(); GLuint takeTexture(int colorAttachmentIndex); QSize size() const; - QVector sizes() const; + QList sizes() const; QImage toImage() const; QImage toImage(bool flipped) const; diff --git a/src/opengl/qopenglframebufferobject_p.h b/src/opengl/qopenglframebufferobject_p.h index 3721e2affa..2eb5936cb4 100644 --- a/src/opengl/qopenglframebufferobject_p.h +++ b/src/opengl/qopenglframebufferobject_p.h @@ -141,7 +141,7 @@ public: GLenum internalFormat; QOpenGLSharedResourceGuard *guard; }; - QVector colorAttachments; + QList colorAttachments; inline GLuint fbo() const { return fbo_guard ? fbo_guard->id() : 0; } }; diff --git a/src/opengl/qopenglpaintengine_p.h b/src/opengl/qopenglpaintengine_p.h index 9dc92e3810..1a5f82b313 100644 --- a/src/opengl/qopenglpaintengine_p.h +++ b/src/opengl/qopenglpaintengine_p.h @@ -306,7 +306,7 @@ public: QOpenGL2PEXVertexArray vertexCoordinateArray; QOpenGL2PEXVertexArray textureCoordinateArray; - QVector elementIndices; + QList elementIndices; GLuint elementIndicesVBOId; QDataBuffer opacityArray; GLfloat staticVertexCoordinateArray[8]; @@ -332,8 +332,8 @@ public: QTriangulatingStroker stroker; QDashedStrokeProcessor dasher; - QVector unusedVBOSToClean; - QVector unusedIBOSToClean; + QList unusedVBOSToClean; + QList unusedIBOSToClean; const GLfloat *vertexAttribPointers[3]; }; diff --git a/src/opengl/qopenglshaderprogram.cpp b/src/opengl/qopenglshaderprogram.cpp index 968163fd4d..b786c82516 100644 --- a/src/opengl/qopenglshaderprogram.cpp +++ b/src/opengl/qopenglshaderprogram.cpp @@ -44,9 +44,9 @@ #include #include #include -#include -#include +#include #include +#include #include #include #include @@ -3552,7 +3552,7 @@ int QOpenGLShaderProgram::patchVertexCount() const does not output them to \a levels. For more details on OpenGL and Tessellation shaders see \l{OpenGL Tessellation Shaders}. - The \a levels argument should be a QVector consisting of 4 floats. Not all + The \a levels argument should be a QList consisting of 4 floats. Not all of the values make sense for all tessellation modes. If you specify a vector with fewer than 4 elements, the remaining elements will be given a default value of 1. @@ -3566,12 +3566,12 @@ int QOpenGLShaderProgram::patchVertexCount() const \sa defaultOuterTessellationLevels(), setDefaultInnerTessellationLevels() */ -void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QVector &levels) +void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QList &levels) { #if !QT_CONFIG(opengles2) Q_D(QOpenGLShaderProgram); if (d->tessellationFuncs) { - QVector tessLevels = levels; + QList tessLevels = levels; // Ensure we have the required 4 outer tessellation levels // Use default of 1 for missing entries (same as spec) @@ -3594,7 +3594,7 @@ void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QVector QOpenGLShaderProgram::defaultOuterTessellationLevels() const +QList QOpenGLShaderProgram::defaultOuterTessellationLevels() const { #if !QT_CONFIG(opengles2) - QVector tessLevels(4, 1.0f); + QList tessLevels(4, 1.0f); Q_D(const QOpenGLShaderProgram); if (d->tessellationFuncs) d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_OUTER_LEVEL, tessLevels.data()); return tessLevels; #else - return QVector(); + return QList(); #endif } @@ -3625,7 +3625,7 @@ QVector QOpenGLShaderProgram::defaultOuterTessellationLevels() const does not output them to \a levels. For more details on OpenGL and Tessellation shaders see \l{OpenGL Tessellation Shaders}. - The \a levels argument should be a QVector consisting of 2 floats. Not all + The \a levels argument should be a QList consisting of 2 floats. Not all of the values make sense for all tessellation modes. If you specify a vector with fewer than 2 elements, the remaining elements will be given a default value of 1. @@ -3639,12 +3639,12 @@ QVector QOpenGLShaderProgram::defaultOuterTessellationLevels() const \sa defaultInnerTessellationLevels(), setDefaultOuterTessellationLevels() */ -void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QVector &levels) +void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QList &levels) { #if !QT_CONFIG(opengles2) Q_D(QOpenGLShaderProgram); if (d->tessellationFuncs) { - QVector tessLevels = levels; + QList tessLevels = levels; // Ensure we have the required 2 inner tessellation levels // Use default of 1 for missing entries (same as spec) @@ -3667,7 +3667,7 @@ void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QVector QOpenGLShaderProgram::defaultInnerTessellationLevels() const +QList QOpenGLShaderProgram::defaultInnerTessellationLevels() const { #if !QT_CONFIG(opengles2) - QVector tessLevels(2, 1.0f); + QList tessLevels(2, 1.0f); Q_D(const QOpenGLShaderProgram); if (d->tessellationFuncs) d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_INNER_LEVEL, tessLevels.data()); return tessLevels; #else - return QVector(); + return QList(); #endif } diff --git a/src/opengl/qopenglshaderprogram.h b/src/opengl/qopenglshaderprogram.h index 87da4fc072..4cbf7e0d3b 100644 --- a/src/opengl/qopenglshaderprogram.h +++ b/src/opengl/qopenglshaderprogram.h @@ -140,11 +140,11 @@ public: void setPatchVertexCount(int count); int patchVertexCount() const; - void setDefaultOuterTessellationLevels(const QVector &levels); - QVector defaultOuterTessellationLevels() const; + void setDefaultOuterTessellationLevels(const QList &levels); + QList defaultOuterTessellationLevels() const; - void setDefaultInnerTessellationLevels(const QVector &levels); - QVector defaultInnerTessellationLevels() const; + void setDefaultInnerTessellationLevels(const QList &levels); + QList defaultInnerTessellationLevels() const; void bindAttributeLocation(const char *name, int location); void bindAttributeLocation(const QByteArray& name, int location); diff --git a/src/opengl/qopengltimerquery.cpp b/src/opengl/qopengltimerquery.cpp index d5ef875efa..921a9f759f 100644 --- a/src/opengl/qopengltimerquery.cpp +++ b/src/opengl/qopengltimerquery.cpp @@ -487,12 +487,12 @@ public: void destroy(); void recordSample(); bool isResultAvailable() const; - QVector samples() const; - QVector intervals() const; + QList samples() const; + QList intervals() const; void reset(); - QVector timers; - mutable QVector timeSamples; + QList timers; + mutable QList timeSamples; QOpenGLContext *context; QOpenGLQueryHelper *core; @@ -596,7 +596,7 @@ bool QOpenGLTimeMonitorPrivate::isResultAvailable() const return available; } -QVector QOpenGLTimeMonitorPrivate::samples() const +QList QOpenGLTimeMonitorPrivate::samples() const { // For the Core and ARB options just ask for the timestamp for each timer query. // For the EXT implementation we cannot obtain timestamps so we defer any result @@ -611,12 +611,12 @@ QVector QOpenGLTimeMonitorPrivate::samples() const return timeSamples; } -QVector QOpenGLTimeMonitorPrivate::intervals() const +QList QOpenGLTimeMonitorPrivate::intervals() const { - QVector intervals(timers.size() - 1); + QList intervals(timers.size() - 1); if (!ext) { // Obtain the timestamp samples and calculate the interval durations - const QVector timeStamps = samples(); + const QList timeStamps = samples(); for (int i = 0; i < intervals.size(); ++i) intervals[i] = timeStamps[i+1] - timeStamps[i]; } else { @@ -794,9 +794,9 @@ bool QOpenGLTimeMonitor::isCreated() const } /*! - Returns a QVector containing the object Ids of the OpenGL timer query objects. + Returns a QList containing the object Ids of the OpenGL timer query objects. */ -QVector QOpenGLTimeMonitor::objectIds() const +QList QOpenGLTimeMonitor::objectIds() const { Q_D(const QOpenGLTimeMonitor); return d->timers; @@ -829,7 +829,7 @@ bool QOpenGLTimeMonitor::isResultAvailable() const } /*! - Returns a QVector containing the GPU timestamps taken with recordSample(). + Returns a QList containing the GPU timestamps taken with recordSample(). This function will block until OpenGL indicates the results are available. It is recommended to check the availability of the result prior to calling this @@ -840,14 +840,14 @@ bool QOpenGLTimeMonitor::isResultAvailable() const \sa waitForIntervals(), isResultAvailable() */ -QVector QOpenGLTimeMonitor::waitForSamples() const +QList QOpenGLTimeMonitor::waitForSamples() const { Q_D(const QOpenGLTimeMonitor); return d->samples(); } /*! - Returns a QVector containing the time intervals delimited by the calls to + Returns a QList containing the time intervals delimited by the calls to recordSample(). The resulting vector will contain one fewer element as this represents the intervening intervals rather than the actual timestamp samples. @@ -858,7 +858,7 @@ QVector QOpenGLTimeMonitor::waitForSamples() const \sa waitForSamples(), isResultAvailable() */ -QVector QOpenGLTimeMonitor::waitForIntervals() const +QList QOpenGLTimeMonitor::waitForIntervals() const { Q_D(const QOpenGLTimeMonitor); return d->intervals(); diff --git a/src/opengl/qopengltimerquery.h b/src/opengl/qopengltimerquery.h index fa0e5b3203..a81c181b51 100644 --- a/src/opengl/qopengltimerquery.h +++ b/src/opengl/qopengltimerquery.h @@ -93,14 +93,14 @@ public: bool create(); void destroy(); bool isCreated() const; - QVector objectIds() const; + QList objectIds() const; int recordSample(); bool isResultAvailable() const; - QVector waitForSamples() const; - QVector waitForIntervals() const; + QList waitForSamples() const; + QList waitForIntervals() const; void reset(); diff --git a/src/opengl/qplatformbackingstoreopenglsupport.cpp b/src/opengl/qplatformbackingstoreopenglsupport.cpp index a188d25db5..5a9b41dd29 100644 --- a/src/opengl/qplatformbackingstoreopenglsupport.cpp +++ b/src/opengl/qplatformbackingstoreopenglsupport.cpp @@ -94,7 +94,7 @@ static QRegion deviceRegion(const QRegion ®ion, QWindow *window, const QPoint if (offset.isNull() && window->devicePixelRatio() <= 1) return region; - QVector rects; + QList rects; rects.reserve(region.rectCount()); for (const QRect &rect : region) rects.append(deviceRect(rect.translated(offset), window)); -- cgit v1.2.3