summaryrefslogtreecommitdiffstats
path: root/src/plugins/renderers/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/renderers/opengl')
-rw-r--r--src/plugins/renderers/opengl/renderer/renderer.cpp4
-rw-r--r--src/plugins/renderers/opengl/textures/gltexture.cpp22
-rw-r--r--src/plugins/renderers/opengl/textures/gltexture_p.h16
3 files changed, 17 insertions, 25 deletions
diff --git a/src/plugins/renderers/opengl/renderer/renderer.cpp b/src/plugins/renderers/opengl/renderer/renderer.cpp
index e6ebadf90..51681d16e 100644
--- a/src/plugins/renderers/opengl/renderer/renderer.cpp
+++ b/src/plugins/renderers/opengl/renderer/renderer.cpp
@@ -1342,7 +1342,7 @@ void Renderer::updateTexture(Texture *texture)
// Will make the texture requestUpload
if (dirtyFlags.testFlag(Texture::DirtyImageGenerators)) {
const QNodeIdVector textureImageIds = texture->textureImageIds();
- QVector<GLTexture::Image> images;
+ std::vector<GLTexture::Image> images;
images.reserve(textureImageIds.size());
// TODO: Move this into GLTexture directly
for (const QNodeId textureImageId : textureImageIds) {
@@ -1354,7 +1354,7 @@ void Renderer::updateTexture(Texture *texture)
images.push_back(glImg);
}
}
- glTexture->setImages(images);
+ glTexture->setImages(std::move(images));
}
// Will make the texture requestUpload
diff --git a/src/plugins/renderers/opengl/textures/gltexture.cpp b/src/plugins/renderers/opengl/textures/gltexture.cpp
index a44ef6877..f0cd34de1 100644
--- a/src/plugins/renderers/opengl/textures/gltexture.cpp
+++ b/src/plugins/renderers/opengl/textures/gltexture.cpp
@@ -55,6 +55,7 @@
#include <Qt3DRender/private/qabstracttexture_p.h>
#include <Qt3DRender/private/qtextureimagedata_p.h>
#include <renderbuffer_p.h>
+#include <Qt3DCore/private/vector_helper_p.h>
#if !QT_CONFIG(opengles2)
#include <QOpenGLFunctions_3_1>
@@ -404,19 +405,10 @@ void GLTexture::setProperties(const TextureProperties &props)
}
}
-void GLTexture::setImages(const QVector<Image> &images)
+void GLTexture::setImages(const std::vector<Image> &images)
{
// check if something has changed at all
- bool same = (images.size() == m_images.size());
- if (same) {
- for (int i = 0; i < images.size(); i++) {
- if (images[i] != m_images[i]) {
- same = false;
- break;
- }
- }
- }
-
+ const bool same = (images == m_images);
if (!same) {
m_images = images;
@@ -440,9 +432,9 @@ void GLTexture::setSharedTextureId(int textureId)
}
}
-void GLTexture::addTextureDataUpdates(const QVector<QTextureDataUpdate> &updates)
+void GLTexture::addTextureDataUpdates(const std::vector<QTextureDataUpdate> &updates)
{
- m_pendingTextureDataUpdates += updates;
+ Qt3DCore::append(m_pendingTextureDataUpdates, updates);
requestUpload();
}
@@ -560,7 +552,7 @@ void GLTexture::uploadGLTextureData()
}
// Upload all QTexImageData references by the TextureImages
- for (int i = 0; i < std::min(m_images.size(), m_imageData.size()); i++) {
+ for (size_t i = 0; i < std::min(m_images.size(), m_imageData.size()); i++) {
const QTextureImageDataPtr &imgData = m_imageData.at(i);
// Here the bytes in the QTextureImageData contain data for a single
// layer, face or mip level, unlike the QTextureGenerator case where
@@ -575,7 +567,7 @@ void GLTexture::uploadGLTextureData()
m_imageData.clear();
// Update data from TextureUpdates
- const QVector<QTextureDataUpdate> textureDataUpdates = std::move(m_pendingTextureDataUpdates);
+ const std::vector<QTextureDataUpdate> textureDataUpdates = std::move(m_pendingTextureDataUpdates);
for (const QTextureDataUpdate &update : textureDataUpdates) {
const QTextureImageDataPtr imgData = update.data();
diff --git a/src/plugins/renderers/opengl/textures/gltexture_p.h b/src/plugins/renderers/opengl/textures/gltexture_p.h
index da85ff386..7a6564831 100644
--- a/src/plugins/renderers/opengl/textures/gltexture_p.h
+++ b/src/plugins/renderers/opengl/textures/gltexture_p.h
@@ -134,7 +134,7 @@ public:
inline TextureParameters parameters() const { return m_parameters; }
inline QTextureGeneratorPtr textureGenerator() const { return m_dataFunctor; }
inline int sharedTextureId() const { return m_sharedTextureId; }
- inline QVector<Image> images() const { return m_images; }
+ inline const std::vector<Image> &images() const { return m_images; }
inline QSize size() const { return QSize(m_properties.width, m_properties.height); }
inline QOpenGLTexture *getGLTexture() const { return m_gl; }
@@ -176,7 +176,7 @@ public:
}
bool hasTextureData() const { return !m_textureData.isNull(); }
- bool hasImagesData() const { return !m_imageData.isEmpty(); }
+ bool hasImagesData() const { return !m_imageData.empty(); }
QFlags<DirtyFlag> dirtyFlags() const { return m_dirtyFlags; }
@@ -203,12 +203,12 @@ public:
void setParameters(const TextureParameters &params);
void setProperties(const TextureProperties &props);
- void setImages(const QVector<Image> &images);
+ void setImages(const std::vector<Image> &images);
void setGenerator(const QTextureGeneratorPtr &generator);
void setSharedTextureId(int textureId);
- void addTextureDataUpdates(const QVector<QTextureDataUpdate> &updates);
+ void addTextureDataUpdates(const std::vector<QTextureDataUpdate> &updates);
- QVector<QTextureDataUpdate> textureDataUpdates() const { return m_pendingTextureDataUpdates; }
+ const std::vector<QTextureDataUpdate> &textureDataUpdates() const { return m_pendingTextureDataUpdates; }
QTextureGeneratorPtr dataGenerator() const { return m_dataFunctor; }
private:
@@ -251,12 +251,12 @@ private:
QTextureGeneratorPtr m_dataFunctor;
QTextureGenerator *m_pendingDataFunctor;
- QVector<Image> m_images;
+ std::vector<Image> m_images;
// cache actual image data generated by the functors
QTextureDataPtr m_textureData;
- QVector<QTextureImageDataPtr> m_imageData;
- QVector<QTextureDataUpdate> m_pendingTextureDataUpdates;
+ std::vector<QTextureImageDataPtr> m_imageData;
+ std::vector<QTextureDataUpdate> m_pendingTextureDataUpdates;
int m_sharedTextureId;
bool m_externalRendering;