From 674e767513a1086c052d77acee36cab14eba1cb2 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 26 Apr 2017 08:42:21 -0700 Subject: [PATCH] Remove MipInterestListener --- libraries/gpu/src/gpu/Texture.cpp | 22 ------------------- libraries/gpu/src/gpu/Texture.h | 11 ---------- .../src/model-networking/TextureCache.cpp | 18 --------------- .../src/model-networking/TextureCache.h | 5 +---- 4 files changed, 1 insertion(+), 55 deletions(-) diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index 1dbe9db2b4..0ede0406c3 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -476,32 +476,10 @@ void Texture::assignStoredMipFace(uint16 level, uint8 face, storage::StoragePoin } } -void Texture::requestInterestInMip(uint16 level) { - if (!_storage->isMipAvailable(level, 0)) { - std::lock_guard lock(_mipInterestListenersMutex); - for (auto& callback : _mipInterestListeners) { - callback->handleMipInterestCallback(level); - } - } -} - bool Texture::isStoredMipFaceAvailable(uint16 level, uint8 face) const { return _storage->isMipAvailable(level, face); } -void Texture::registerMipInterestListener(MipInterestListener* listener) { - std::lock_guard lock(_mipInterestListenersMutex); - _mipInterestListeners.push_back(listener); -} - -void Texture::unregisterMipInterestListener(MipInterestListener* listener) { - std::lock_guard lock(_mipInterestListenersMutex); - auto it = find(_mipInterestListeners.begin(), _mipInterestListeners.end(), listener); - if (it != _mipInterestListeners.end()) { - _mipInterestListeners.erase(it); - } -} - void Texture::setAutoGenerateMips(bool enable) { bool changed = false; if (!_autoGenerateMips) { diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 3c82f67c86..a79e679f15 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -488,17 +488,6 @@ public: void setStorage(std::unique_ptr& newStorage); void setKtxBacking(const std::string& filename); - class MipInterestListener { - public: - virtual void handleMipInterestCallback(uint16 level) = 0; - }; - void registerMipInterestListener(MipInterestListener* listener); - void unregisterMipInterestListener(MipInterestListener* listener); - std::vector _mipInterestListeners; - std::mutex _mipInterestListenersMutex; - - void requestInterestInMip(uint16 level); - // Usage is a a set of flags providing Semantic about the usage of the Texture. void setUsage(const Usage& usage) { _usage = usage; } Usage getUsage() const { return _usage; } diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 0e9ce46912..1d37a26f37 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -245,13 +245,6 @@ gpu::TexturePointer getFallbackTextureForType(image::TextureUsage::Type type) { return result; } -NetworkTexture::~NetworkTexture() { - auto texture = _textureSource->getGPUTexture(); - if (texture) { - texture->unregisterMipInterestListener(this); - } -} - /// Returns a texture version of an image file gpu::TexturePointer TextureCache::getImageTexture(const QString& path, image::TextureUsage::Type type, QVariantMap options) { QImage image = QImage(path); @@ -381,15 +374,6 @@ void NetworkTexture::makeRequest() { } -void NetworkTexture::handleMipInterestCallback(uint16_t level) { - QMetaObject::invokeMethod(this, "handleMipInterestLevel", Qt::QueuedConnection, Q_ARG(int, level)); -} - -void NetworkTexture::handleMipInterestLevel(int level) { - _lowestRequestedMipLevel = std::min((uint16_t)level, _lowestRequestedMipLevel); - startRequestForNextMipLevel(); -} - void NetworkTexture::startRequestForNextMipLevel() { if (_lowestKnownPopulatedMip == 0) { qWarning(networking) << "Requesting next mip level but all have been fulfilled: " << _lowestKnownPopulatedMip @@ -647,8 +631,6 @@ void NetworkTexture::maybeHandleFinishedInitialLoad() { _lowestKnownPopulatedMip = texture->minAvailableMipLevel(); - - texture->registerMipInterestListener(this); _ktxResourceState = WAITING_FOR_MIP_REQUEST; setImage(texture, header->getPixelWidth(), header->getPixelHeight()); qDebug() << "Loaded KTX: " << QString::fromStdString(hash) << " : " << _url; diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index 5fb23c0d2d..c7a7799216 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -41,7 +41,7 @@ public: }; /// A texture loaded from the network. -class NetworkTexture : public Resource, public Texture, public gpu::Texture::MipInterestListener { +class NetworkTexture : public Resource, public Texture { Q_OBJECT public: @@ -58,9 +58,6 @@ public: gpu::TexturePointer getFallbackTexture() const; - void handleMipInterestCallback(uint16_t level) override; - Q_INVOKABLE void handleMipInterestLevel(int level); - signals: void networkTextureCreated(const QWeakPointer& self);