From 09d4a7497bffbf1c637eac3c6d5d5e2cfb84b9d5 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 10 May 2017 17:51:55 -0700 Subject: [PATCH] [core] When a layer is added, reload its source's tiles --- mapbox-gl-js | 2 +- src/mbgl/style/style.cpp | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/mapbox-gl-js b/mapbox-gl-js index 44641e917ed..8b085a21157 160000 --- a/mapbox-gl-js +++ b/mapbox-gl-js @@ -1 +1 @@ -Subproject commit 44641e917ed0e37a1c1622ab154f068b22927b03 +Subproject commit 8b085a211579d417ad8b3d58bc502c4ffbdfc2e9 diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 4b694917c3f..f083ca47b88 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 + 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, optional 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 - void operator()(VectorLayer& layer) { - updateBatch.sourceIDs.insert(layer.getSourceID()); - } -}; - void Style::onLayerFilterChanged(Layer& layer) { layer.accept(QueueSourceReloadVisitor { updateBatch }); observer->onUpdate(Update::Repaint);