Fix loaded being reset to false for KTX resources

This commit is contained in:
Ryan Huffman 2017-05-03 10:26:51 -07:00
parent 5d1abe4499
commit 0263021c0c
3 changed files with 14 additions and 7 deletions

View file

@ -421,7 +421,7 @@ void NetworkTexture::startRequestForNextMipLevel() {
_ktxResourceState = PENDING_MIP_REQUEST;
init();
init(false);
float priority = -(float)_originalKtxDescriptor->header.numberOfMipmapLevels + (float)_lowestKnownPopulatedMip;
setLoadPriority(this, priority);
_url.setFragment(QString::number(_lowestKnownPopulatedMip - 1));

View file

@ -533,13 +533,13 @@ void Resource::ensureLoading() {
}
void Resource::setLoadPriority(const QPointer<QObject>& owner, float priority) {
if (!(_failedToLoad || _loaded)) {
if (!(_failedToLoad)) {
_loadPriorities.insert(owner, priority);
}
}
void Resource::setLoadPriorities(const QHash<QPointer<QObject>, float>& priorities) {
if (_failedToLoad || _loaded) {
if (_failedToLoad) {
return;
}
for (QHash<QPointer<QObject>, float>::const_iterator it = priorities.constBegin();
@ -549,7 +549,7 @@ void Resource::setLoadPriorities(const QHash<QPointer<QObject>, float>& prioriti
}
void Resource::clearLoadPriority(const QPointer<QObject>& owner) {
if (!(_failedToLoad || _loaded)) {
if (!(_failedToLoad)) {
_loadPriorities.remove(owner);
}
}
@ -612,10 +612,12 @@ void Resource::allReferencesCleared() {
}
}
void Resource::init() {
void Resource::init(bool resetLoaded) {
_startedLoading = false;
_failedToLoad = false;
_loaded = false;
if (resetLoaded) {
_loaded = false;
}
_attempts = 0;
_activeUrl = _url;

View file

@ -425,7 +425,7 @@ protected slots:
void attemptRequest();
protected:
virtual void init();
virtual void init(bool resetLoaded = true);
/// Called by ResourceCache to begin loading this Resource.
/// This method can be overriden to provide custom request functionality. If this is done,
@ -454,9 +454,14 @@ protected:
QUrl _url;
QUrl _activeUrl;
ByteRange _requestByteRange;
// _loaded == true means we are in a loaded and usable state. It is possible that there may still be
// active requests/loading while in this state. Example: Progressive KTX downloads, where higher resolution
// mips are being download.
bool _startedLoading = false;
bool _failedToLoad = false;
bool _loaded = false;
QHash<QPointer<QObject>, float> _loadPriorities;
QWeakPointer<Resource> _self;
QPointer<ResourceCache> _cache;