summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-19 17:59:50 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-20 08:58:50 -0700
commitb43e1ae12328e8a36a9a36c03e49e1db0a395189 (patch)
treedf0cb8d9a44406578107fb9c07d5c34324160f45
parentd3628449460a0918e9e89c81e1baba31c4acffe0 (diff)
downloadqtlocation-mapboxgl-b43e1ae12328e8a36a9a36c03e49e1db0a395189.tar.gz
[core] Correctly track sprite loaded state through smart setStyle
m---------mapbox-gl-js0
-rw-r--r--src/mbgl/renderer/image_manager.cpp21
-rw-r--r--src/mbgl/renderer/image_manager.hpp7
-rw-r--r--src/mbgl/renderer/render_style.cpp4
-rw-r--r--src/mbgl/style/style_impl.cpp1
-rw-r--r--test/renderer/image_manager.test.cpp2
6 files changed, 21 insertions, 14 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject f27666813dd8e3d738a3962b3d86d0ec799b6fc
+Subproject 31444a72c2dafdd7dba99dc3bf5428c155e07cf
diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp
index d0a106ede6..692747bca4 100644
--- a/src/mbgl/renderer/image_manager.cpp
+++ b/src/mbgl/renderer/image_manager.cpp
@@ -4,12 +4,23 @@
namespace mbgl {
-void ImageManager::onSpriteLoaded() {
- loaded = true;
- for (const auto& entry : requestors) {
- notify(*entry.first, entry.second);
+void ImageManager::setLoaded(bool loaded_) {
+ if (loaded == loaded_) {
+ return;
}
- requestors.clear();
+
+ loaded = loaded_;
+
+ if (loaded) {
+ for (const auto& entry : requestors) {
+ notify(*entry.first, entry.second);
+ }
+ requestors.clear();
+ }
+}
+
+bool ImageManager::isLoaded() const {
+ return loaded;
}
void ImageManager::addImage(Immutable<style::Image::Impl> image_) {
diff --git a/src/mbgl/renderer/image_manager.hpp b/src/mbgl/renderer/image_manager.hpp
index 9a9a4ce997..1c9d67f47d 100644
--- a/src/mbgl/renderer/image_manager.hpp
+++ b/src/mbgl/renderer/image_manager.hpp
@@ -39,11 +39,8 @@ public:
ImageManager();
~ImageManager();
- void onSpriteLoaded();
-
- bool isLoaded() const {
- return loaded;
- }
+ void setLoaded(bool);
+ bool isLoaded() const;
void dumpDebugLogs() const;
diff --git a/src/mbgl/renderer/render_style.cpp b/src/mbgl/renderer/render_style.cpp
index 2bf903fe5f..3d95b12bc4 100644
--- a/src/mbgl/renderer/render_style.cpp
+++ b/src/mbgl/renderer/render_style.cpp
@@ -143,9 +143,7 @@ void RenderStyle::update(const UpdateParameters& parameters) {
imageManager->updateImage(entry.second.after);
}
- if (parameters.spriteLoaded && !imageManager->isLoaded()) {
- imageManager->onSpriteLoaded();
- }
+ imageManager->setLoaded(parameters.spriteLoaded);
const LayerDifference layerDiff = diffLayers(layerImpls, parameters.layers);
diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp
index 2d42afd086..9cc2588ca7 100644
--- a/src/mbgl/style/style_impl.cpp
+++ b/src/mbgl/style/style_impl.cpp
@@ -111,6 +111,7 @@ void Style::Impl::parse(const std::string& json_) {
defaultPitch = parser.pitch;
setLight(std::make_unique<Light>(parser.light));
+ spriteLoaded = false;
spriteLoader->load(parser.spriteURL, scheduler, fileSource);
glyphURL = parser.glyphURL;
diff --git a/test/renderer/image_manager.test.cpp b/test/renderer/image_manager.test.cpp
index 203e05d492..5e6da5c005 100644
--- a/test/renderer/image_manager.test.cpp
+++ b/test/renderer/image_manager.test.cpp
@@ -127,7 +127,7 @@ TEST(ImageManager, NotifiesRequestorWhenSpriteIsLoaded) {
imageManager.getImages(requestor, {"one"});
ASSERT_FALSE(notified);
- imageManager.onSpriteLoaded();
+ imageManager.setLoaded(true);
ASSERT_TRUE(notified);
}