From 2ed81bbaaeecab12ea50813275269a3b1778f8ea Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Sat, 24 Sep 2016 12:32:23 +0300 Subject: [PATCH] [core] Trigger Update::RecalculateStyle when toggling layer visibility --- src/mbgl/style/style.cpp | 2 +- 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 a82cdec57..a684db62d 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 ff03e3c2c..41f12f6ff 100644 --- a/test/style/style.cpp +++ b/test/style/style.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -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) {