diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-09-24 12:32:23 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-09-26 11:47:34 +0200 |
commit | 2ed81bbaaeecab12ea50813275269a3b1778f8ea (patch) | |
tree | 38b2ad27135371878140e48aa85f5e6dd81dcad1 | |
parent | ae3a02babe557867b115ad69bb83ae3da2cfe43f (diff) | |
download | qtlocation-mapboxgl-2ed81bbaaeecab12ea50813275269a3b1778f8ea.tar.gz |
[core] Trigger Update::RecalculateStyle when toggling layer visibility
-rw-r--r-- | src/mbgl/style/style.cpp | 2 | ||||
-rw-r--r-- | test/style/style.cpp | 17 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index a82cdec572..a684db62d5 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -520,7 +520,7 @@ void Style::onLayerFilterChanged(Layer& layer) { void Style::onLayerVisibilityChanged(Layer& layer) { layer.accept(QueueSourceReloadVisitor { updateBatch }); - observer->onUpdate(Update::Layout); + observer->onUpdate(Update::RecalculateStyle | Update::Layout); } void Style::onLayerPaintPropertyChanged(Layer&) { diff --git a/test/style/style.cpp b/test/style/style.cpp index ff03e3c2cc..41f12f6ff7 100644 --- a/test/style/style.cpp +++ b/test/style/style.cpp @@ -3,6 +3,7 @@ #include <mbgl/style/style.hpp> #include <mbgl/style/source_impl.hpp> +#include <mbgl/style/layer.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> @@ -25,13 +26,25 @@ TEST(Style, UnusedSource) { style.cascade(now, MapMode::Still); style.recalculate(0, now, MapMode::Still); - Source *usedSource = style.getSource("usedsource"); + Source* usedSource = style.getSource("usedsource"); EXPECT_TRUE(usedSource); EXPECT_TRUE(usedSource->baseImpl->isLoaded()); - Source *unusedSource = style.getSource("unusedsource"); + Source* unusedSource = style.getSource("unusedsource"); EXPECT_TRUE(unusedSource); EXPECT_FALSE(unusedSource->baseImpl->isLoaded()); + + Layer* unusedLayer = style.getLayer("unusedlayervisibility"); + EXPECT_TRUE(unusedLayer); + + unusedLayer->setVisibility(mbgl::style::VisibilityType::Visible); + + style.relayout(); + EXPECT_FALSE(unusedSource->baseImpl->isLoaded()); + + // Style loads sources upon request when recalculating style. + style.recalculate(0, now, MapMode::Still); + EXPECT_TRUE(unusedSource->baseImpl->isLoaded()); } TEST(Style, UnusedSourceActiveViaClassUpdate) { |