mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 21:02:17 +02:00
Remove MipInterestListener
This commit is contained in:
parent
9505bf746c
commit
674e767513
4 changed files with 1 additions and 55 deletions
|
@ -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<std::mutex> 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<std::mutex> lock(_mipInterestListenersMutex);
|
||||
_mipInterestListeners.push_back(listener);
|
||||
}
|
||||
|
||||
void Texture::unregisterMipInterestListener(MipInterestListener* listener) {
|
||||
std::lock_guard<std::mutex> 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) {
|
||||
|
|
|
@ -488,17 +488,6 @@ public:
|
|||
void setStorage(std::unique_ptr<Storage>& 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<MipInterestListener*> _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; }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<NetworkTexture>& self);
|
||||
|
||||
|
|
Loading…
Reference in a new issue