summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-10 17:51:55 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-11 11:21:31 -0700
commitdb370a02b13f39ce79b8df11e784b3543f2908cb (patch)
treee5326621561d152802ad7ed2c88a4b70bc972953 /src/mbgl
parent08916f2d5f63a6ef746e0560e3a56784db81e3dc (diff)
downloadqtlocation-mapboxgl-db370a02b13f39ce79b8df11e784b3543f2908cb.tar.gz
[core] When a layer is added, reload its source's tiles
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/style/style.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 4b694917c3..f083ca47b8 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -52,6 +52,21 @@ namespace style {
static Observer nullObserver;
+struct QueueSourceReloadVisitor {
+ UpdateBatch& updateBatch;
+
+ // No need to reload sources for these types; their visibility can change but
+ // they don't participate in layout.
+ void operator()(CustomLayer&) {}
+ void operator()(RasterLayer&) {}
+ void operator()(BackgroundLayer&) {}
+
+ template <class VectorLayer>
+ void operator()(VectorLayer& layer) {
+ updateBatch.sourceIDs.insert(layer.getSourceID());
+ }
+};
+
Style::Style(Scheduler& scheduler_, FileSource& fileSource_, float pixelRatio)
: scheduler(scheduler_),
fileSource(fileSource_),
@@ -248,6 +263,7 @@ Layer* Style::addLayer(std::unique_ptr<Layer> layer, optional<std::string> befor
}
layer->baseImpl->setObserver(this);
+ layer->accept(QueueSourceReloadVisitor { updateBatch });
auto added = layers.emplace(before ? findLayer(*before) : layers.end(), std::move(layer))->get();
renderLayers.emplace(before ? findRenderLayer(*before) : renderLayers.end(), added->baseImpl->createRenderLayer());
@@ -726,21 +742,6 @@ void Style::onSpriteError(std::exception_ptr error) {
observer->onResourceError(error);
}
-struct QueueSourceReloadVisitor {
- UpdateBatch& updateBatch;
-
- // No need to reload sources for these types; their visibility can change but
- // they don't participate in layout.
- void operator()(CustomLayer&) {}
- void operator()(RasterLayer&) {}
- void operator()(BackgroundLayer&) {}
-
- template <class VectorLayer>
- void operator()(VectorLayer& layer) {
- updateBatch.sourceIDs.insert(layer.getSourceID());
- }
-};
-
void Style::onLayerFilterChanged(Layer& layer) {
layer.accept(QueueSourceReloadVisitor { updateBatch });
observer->onUpdate(Update::Repaint);