diff options
author | Jonas Karlsson <jonas.karlsson@qt.io> | 2020-12-22 13:52:29 +0100 |
---|---|---|
committer | Jonas Karlsson <jonas.karlsson@qt.io> | 2020-12-29 09:59:06 +0100 |
commit | 162a859045ec455321909af6aa03b99d9cbbda6e (patch) | |
tree | 6b691d1964590317e3979674094594f952a0b644 /src/gui/util/qtexturefiledata.cpp | |
parent | 89b2b60e6374c62d97b739b3351753e552cd16bb (diff) |
Add getDataView() method to QTextureFileData
This method will return a QByteArrayView of the data range corresponding
to the level. This avoids a leaky abstraction by moving the needed data
pointer arithmetic from the caller to the method. It will also make it
easier adding cubemap support in the future.
Change-Id: I2415bd88365d8d69ba14aefc77f5f1117f9e0033
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/util/qtexturefiledata.cpp')
-rw-r--r-- | src/gui/util/qtexturefiledata.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index d271541e51..29c6acaeca 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -167,6 +167,17 @@ int QTextureFileData::dataLength(int level) const return (d && d->lengths.size() > level) ? d->lengths.at(level) : 0; } +QByteArrayView QTextureFileData::getDataView(int level) const +{ + const int dataLength = this->dataLength(level); + const int dataOffset = this->dataOffset(level); + + if (d == nullptr || dataLength == 0) + return QByteArrayView(); + + return QByteArrayView(d->data.constData() + dataOffset, dataLength); +} + void QTextureFileData::setDataLength(int length, int level) { if (d.constData() && level >= 0) { |