diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-10-02 11:10:21 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-10-07 09:30:48 +0200 |
commit | 74c898d5f5891553500426592a16419bd83776da (patch) | |
tree | 5103af45b0a4621dc88db07ce5c3419e8b472c7e /src | |
parent | ce94b847c87e2606c5f189d2ad3715c1d025b9cf (diff) |
Follow QRhi improvements and drop QVectors where applicable
Task-number: QTBUG-78883
Change-Id: Ifcf5af843b5101a35ecc762a6a3b0196b6d97782
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src')
6 files changed, 16 insertions, 12 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 29923b5d20..c8f1ebd986 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -187,7 +187,7 @@ static QRhiVertexInputLayout calculateVertexInputLayout(const QSGMaterialRhiShad } const int attrCount = geometry->attributeCount(); - QVector<QRhiVertexInputAttribute> inputAttributes; + QVarLengthArray<QRhiVertexInputAttribute, 8> inputAttributes; inputAttributes.reserve(attrCount + 1); int offset = 0; for (int i = 0; i < attrCount; ++i) { @@ -205,15 +205,14 @@ static QRhiVertexInputLayout calculateVertexInputLayout(const QSGMaterialRhiShad } Q_ASSERT(VERTEX_BUFFER_BINDING == 0 && ZORDER_BUFFER_BINDING == 1); // not very flexible - QVector<QRhiVertexInputBinding> inputBindings; - inputBindings.reserve(2); + QVarLengthArray<QRhiVertexInputBinding, 2> inputBindings; inputBindings.append(QRhiVertexInputBinding(geometry->sizeOfVertex())); if (batchable) inputBindings.append(QRhiVertexInputBinding(sizeof(float))); QRhiVertexInputLayout inputLayout; - inputLayout.setBindings(inputBindings); - inputLayout.setAttributes(inputAttributes); + inputLayout.setBindings(inputBindings.cbegin(), inputBindings.cend()); + inputLayout.setAttributes(inputAttributes.cbegin(), inputAttributes.cend()); return inputLayout; } diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp index 28fc10e413..53b6fe117f 100644 --- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp @@ -182,7 +182,9 @@ void QSGRhiDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &gly for (int i = 0; i < glyphs.size(); ++i) { TextureInfo *texInfo = m_glyphsTexture.value(glyphs.at(i).glyph()); if (!texInfo->uploads.isEmpty()) { - m_resourceUpdates->uploadTexture(texInfo->texture, texInfo->uploads); + QRhiTextureUploadDescription desc; + desc.setEntries(texInfo->uploads.cbegin(), texInfo->uploads.cend()); + m_resourceUpdates->uploadTexture(texInfo->texture, desc); texInfo->uploads.clear(); } } diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h index ddd3d92ba7..d43b0aa5d4 100644 --- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h @@ -88,7 +88,7 @@ private: QRect allocatedArea; QDistanceField image; int padding = -1; - QVector<QRhiTextureUploadEntry> uploads; + QVarLengthArray<QRhiTextureUploadEntry, 16> uploads; TextureInfo(const QRect &preallocRect = QRect()) : texture(nullptr), allocatedArea(preallocRect) { } }; diff --git a/src/quick/scenegraph/qsgrhitextureglyphcache.cpp b/src/quick/scenegraph/qsgrhitextureglyphcache.cpp index 99761302e2..d0108bc56e 100644 --- a/src/quick/scenegraph/qsgrhitextureglyphcache.cpp +++ b/src/quick/scenegraph/qsgrhitextureglyphcache.cpp @@ -223,7 +223,9 @@ void QSGRhiTextureGlyphCache::endFillTexture() if (!m_resourceUpdates) m_resourceUpdates = m_rhi->nextResourceUpdateBatch(); - m_resourceUpdates->uploadTexture(m_texture, m_uploads); + QRhiTextureUploadDescription desc; + desc.setEntries(m_uploads.cbegin(), m_uploads.cend()); + m_resourceUpdates->uploadTexture(m_texture, desc); m_uploads.clear(); } diff --git a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h index 75d82de90d..a7374d91a4 100644 --- a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h +++ b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h @@ -90,7 +90,7 @@ private: QRhiTexture *m_texture = nullptr; QSize m_size; bool m_bgra = false; - QVector<QRhiTextureUploadEntry> m_uploads; + QVarLengthArray<QRhiTextureUploadEntry, 16> m_uploads; QSet<QRhiTexture *> m_pendingDispose; }; diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp index 665e9bb412..3dc1f5f526 100644 --- a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp @@ -295,8 +295,7 @@ void Atlas::enqueueTextureUpload(TextureBase *t, QRhiResourceUpdateBatch *resour const int tmpBitsSize = tmpBits.size() * 4; const quint32 *src = reinterpret_cast<const quint32 *>(image.constBits()); quint32 *dst = tmpBits.data(); - QVector<QRhiTextureUploadEntry> entries; - entries.reserve(5); + QVarLengthArray<QRhiTextureUploadEntry, 5> entries; // top row, padding corners dst[0] = src[0]; @@ -361,7 +360,9 @@ void Atlas::enqueueTextureUpload(TextureBase *t, QRhiResourceUpdateBatch *resour entries.append(QRhiTextureUploadEntry(0, 0, subresDesc)); } - resourceUpdates->uploadTexture(m_texture, QRhiTextureUploadDescription(entries)); + QRhiTextureUploadDescription desc; + desc.setEntries(entries.cbegin(), entries.cend()); + resourceUpdates->uploadTexture(m_texture, desc); const QSize textureSize = t->textureSize(); if (textureSize.width() > m_atlas_transient_image_threshold || textureSize.height() > m_atlas_transient_image_threshold) |