diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-08-22 17:57:22 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-09-27 10:42:10 +0200 |
commit | 68ec9d3fd5725aa9bf0d2debf5f72551e8f4aef2 (patch) | |
tree | 7eeae50e1d6e6f7c617855593b81f0e7e49d9cb1 /src/mbgl | |
parent | 63e53de157e75e504a6bf1a678cebaea5acf72b9 (diff) | |
download | qtlocation-mapboxgl-68ec9d3fd5725aa9bf0d2debf5f72551e8f4aef2.tar.gz |
[core] Make sure textures have a scaling filter set after upload
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/util/raster.cpp | 30 | ||||
-rw-r--r-- | src/mbgl/util/raster.hpp | 3 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/mbgl/util/raster.cpp b/src/mbgl/util/raster.cpp index 498f6027b7..a7a56713b8 100644 --- a/src/mbgl/util/raster.cpp +++ b/src/mbgl/util/raster.cpp @@ -36,7 +36,7 @@ void Raster::bind(gl::ObjectStore& store, uint32_t unit, Scaling newFilter, MipMap newMipMap) { - bool updateFilter = false; + bool filterNeedsUpdate = false; if (!texture) { if (images.empty()) { @@ -44,35 +44,39 @@ void Raster::bind(gl::ObjectStore& store, return; } else { upload(store, config, unit); - updateFilter = true; + filterNeedsUpdate = true; } } else { if (config.texture[unit] != *texture) { config.activeTexture = unit; - config.texture[unit] = *texture; + config.texture[unit] = *texture; } - updateFilter = (filter != newFilter || mipmap != newMipMap); + filterNeedsUpdate = (filter != newFilter || mipmap != newMipMap); } - if (updateFilter) { + if (filterNeedsUpdate) { filter = newFilter; mipmap = newMipMap; - config.activeTexture = unit; - MBGL_CHECK_ERROR(glTexParameteri( - GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - filter == Scaling::Linear - ? (mipmap == MipMap::Yes ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR) - : (mipmap == MipMap::Yes ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST))); - MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - filter == Scaling::Linear ? GL_LINEAR : GL_NEAREST)); + updateFilter(); } } +void Raster::updateFilter() { + MBGL_CHECK_ERROR(glTexParameteri( + GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + filter == Scaling::Linear + ? (mipmap == MipMap::Yes ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR) + : (mipmap == MipMap::Yes ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST))); + MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + filter == Scaling::Linear ? GL_LINEAR : GL_NEAREST)); +} + void Raster::upload(gl::ObjectStore& store, gl::Config& config, uint32_t unit) { if (!images.empty() && !texture) { texture = store.createTexture(); config.activeTexture = unit; config.texture[unit] = *texture; + updateFilter(); #ifndef GL_ES_VERSION_2_0 MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, images.size())); #endif diff --git a/src/mbgl/util/raster.hpp b/src/mbgl/util/raster.hpp index 860c533086..ceb018c128 100644 --- a/src/mbgl/util/raster.hpp +++ b/src/mbgl/util/raster.hpp @@ -41,6 +41,9 @@ public: std::array<uint16_t, 2> getSize() const; private: + void updateFilter(); + +private: // raw pixels have been loaded std::atomic<bool> loaded { false }; std::array<uint16_t, 2> size = {{ 0, 0 }}; |