Enable resetting tile providers from GUI, i.e. reloading tiles

This commit is contained in:
Erik Broberg
2016-07-12 11:19:57 -04:00
parent 1b37a78fa5
commit edf114cda2
10 changed files with 64 additions and 10 deletions
+24 -8
View File
@@ -51,14 +51,10 @@ namespace openspace {
const Tile Tile::TileUnavailable = {nullptr, nullptr, Tile::Status::Unavailable };
SingleImagePrivoder::SingleImagePrivoder(const std::string& imagePath) {
_tile = Tile();
_tile.texture = std::shared_ptr<Texture>(ghoul::io::TextureReader::ref().loadTexture(imagePath).release());
_tile.status = _tile.texture != nullptr ? Tile::Status::OK : Tile::Status::IOError;
_tile.preprocessData = nullptr;
_tile.texture->uploadTexture();
_tile.texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
SingleImagePrivoder::SingleImagePrivoder(const std::string& imagePath)
: _imagePath(imagePath)
{
reset();
}
Tile SingleImagePrivoder::getTile(const ChunkIndex& chunkIndex) {
@@ -85,6 +81,16 @@ namespace openspace {
// nothing to be done
}
void SingleImagePrivoder::reset() {
_tile = Tile();
_tile.texture = std::shared_ptr<Texture>(ghoul::io::TextureReader::ref().loadTexture(_imagePath).release());
_tile.status = _tile.texture != nullptr ? Tile::Status::OK : Tile::Status::IOError;
_tile.preprocessData = nullptr;
_tile.texture->uploadTexture();
_tile.texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
int SingleImagePrivoder::maxLevel() {
return 1337; // unlimited
}
@@ -120,6 +126,16 @@ namespace openspace {
}
}
void CachingTileProvider::reset() {
_tileCache->clear();
_asyncTextureDataProvider->clearRequestQueue();
// also clear tiles that has just been finished loading
while (_asyncTextureDataProvider->hasLoadedTextureData()) {
_asyncTextureDataProvider->nextTileIOResult(); // get it and throw it away
}
}
int CachingTileProvider::maxLevel() {
return _asyncTextureDataProvider->getTextureDataProvider()->maxChunkLevel();
}