summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-04-23 12:30:15 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-05-04 17:33:05 +0200
commitc43016ce6c73c7305d259e7858efc0228d726660 (patch)
tree9c594b543cf8b02b733a808f9695e9be2931740e /src
parent97a22b6f5fea5666025189231f5fecc4946ceb0b (diff)
downloadqtlocation-mapboxgl-c43016ce6c73c7305d259e7858efc0228d726660.tar.gz
make sure we always to a full upload after sprite atlas resizes
We always need to do a full upload to adjust the image buffer size when we adjust the size of our sprite atlas. This can happen when we change the pixelRatio of the map we're rendering.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/geometry/sprite_atlas.cpp7
-rw-r--r--src/mbgl/geometry/sprite_atlas.hpp1
2 files changed, 5 insertions, 3 deletions
diff --git a/src/mbgl/geometry/sprite_atlas.cpp b/src/mbgl/geometry/sprite_atlas.cpp
index a6156febbc..9d0aeac8b7 100644
--- a/src/mbgl/geometry/sprite_atlas.cpp
+++ b/src/mbgl/geometry/sprite_atlas.cpp
@@ -58,6 +58,7 @@ bool SpriteAtlas::resize(const float newRatio) {
::operator delete(old_data);
dirty = true;
+ fullUploadRequired = true;
// Mark all sprite images as in need of update
for (const auto &pair : images) {
@@ -237,7 +238,6 @@ void SpriteAtlas::upload() {
}
void SpriteAtlas::bind(bool linear) {
- bool first = false;
if (!texture) {
MBGL_CHECK_ERROR(glGenTextures(1, &texture));
MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture));
@@ -248,7 +248,7 @@ void SpriteAtlas::bind(bool linear) {
// We use those when the pixelRatio isn't a power of two, e.g. on iPhone 6 Plus.
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
- first = true;
+ fullUploadRequired = true;
} else {
MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture));
}
@@ -264,7 +264,7 @@ void SpriteAtlas::bind(bool linear) {
std::lock_guard<std::recursive_mutex> lock(mtx);
allocate();
- if (first) {
+ if (fullUploadRequired) {
MBGL_CHECK_ERROR(glTexImage2D(
GL_TEXTURE_2D, // GLenum target
0, // GLint level
@@ -276,6 +276,7 @@ void SpriteAtlas::bind(bool linear) {
GL_UNSIGNED_BYTE, // GLenum type
data // const GLvoid * data
));
+ fullUploadRequired = false;
} else {
MBGL_CHECK_ERROR(glTexSubImage2D(
GL_TEXTURE_2D, // GLenum target
diff --git a/src/mbgl/geometry/sprite_atlas.hpp b/src/mbgl/geometry/sprite_atlas.hpp
index 5605143104..6c4a381aa1 100644
--- a/src/mbgl/geometry/sprite_atlas.hpp
+++ b/src/mbgl/geometry/sprite_atlas.hpp
@@ -79,6 +79,7 @@ private:
std::set<std::string> uninitialized;
uint32_t *data = nullptr;
std::atomic<bool> dirty;
+ bool fullUploadRequired = true;
uint32_t texture = 0;
uint32_t filter = 0;
static const int buffer = 1;