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>
This commit is contained in:
parent
89b2b60e63
commit
162a859045
@ -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) {
|
||||
|
@ -84,6 +84,8 @@ public:
|
||||
int dataLength(int level = 0) const;
|
||||
void setDataLength(int length, int level = 0);
|
||||
|
||||
QByteArrayView getDataView(int level = 0) const;
|
||||
|
||||
int numLevels() const;
|
||||
void setNumLevels(int num);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user