diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-08-29 13:53:55 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-06 14:29:22 -0700 |
commit | b4864ca9d5a18dda4476baa31e33fe8547d55b40 (patch) | |
tree | 677e8a3876e7e3ab8b3c26b106a256ab235db48c /src/mbgl | |
parent | fe2a26225f3746381b36ad8b6c6a3ce7727bf655 (diff) | |
download | qtlocation-mapboxgl-b4864ca9d5a18dda4476baa31e33fe8547d55b40.tar.gz |
[core] Trigger Source::Impl::reload when a filter or layout property is modified
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/style/layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/style.cpp | 31 | ||||
-rw-r--r-- | src/mbgl/style/style.hpp | 1 |
3 files changed, 29 insertions, 5 deletions
diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp index 6eff64ae09..4d4e793ec0 100644 --- a/src/mbgl/style/layer.cpp +++ b/src/mbgl/style/layer.cpp @@ -5,7 +5,7 @@ namespace mbgl { namespace style { Layer::Layer(Type type_, std::unique_ptr<Impl> baseImpl_) - : baseImpl(std::move(baseImpl_)), type(type_) { + : type(type_), baseImpl(std::move(baseImpl_)) { } Layer::~Layer() = default; diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 99333b4a77..e797ec7a5b 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -7,6 +7,10 @@ #include <mbgl/style/layers/custom_layer_impl.hpp> #include <mbgl/style/layers/background_layer.hpp> #include <mbgl/style/layers/background_layer_impl.hpp> +#include <mbgl/style/layers/fill_layer.hpp> +#include <mbgl/style/layers/line_layer.hpp> +#include <mbgl/style/layers/circle_layer.hpp> +#include <mbgl/style/layers/raster_layer.hpp> #include <mbgl/style/layer_impl.hpp> #include <mbgl/style/parser.hpp> #include <mbgl/style/transition_options.hpp> @@ -483,17 +487,36 @@ void Style::onSpriteError(std::exception_ptr error) { observer->onResourceError(error); } -void Style::onLayerFilterChanged(Layer&) { - // TODO: reload source +struct LayerSourceReloadVisitor { + Style& style; + + void operator()(CustomLayer&) { assert(false); } + void operator()(RasterLayer&) { assert(false); } + void operator()(BackgroundLayer&) { assert(false); } + + template <class VectorLayer> + void operator()(VectorLayer& layer) { + Source* source = style.getSource(layer.getSourceID()); + if (!source) return; + source->baseImpl->reload(); + } +}; + +void Style::reloadLayerSource(Layer& layer) { + layer.accept(LayerSourceReloadVisitor { *this }); +} + +void Style::onLayerFilterChanged(Layer& layer) { + reloadLayerSource(layer); } void Style::onLayerPaintPropertyChanged(Layer&) { observer->onUpdate(Update::RecalculateStyle | Update::Classes); } -void Style::onLayerLayoutPropertyChanged(Layer&) { +void Style::onLayerLayoutPropertyChanged(Layer& layer) { observer->onUpdate(Update::RecalculateStyle); - // TODO: reload source + reloadLayerSource(layer); } void Style::dumpDebugLogs() const { diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index 9e9ec1a03c..26b96fba22 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -115,6 +115,7 @@ private: double defaultPitch; std::vector<std::unique_ptr<Layer>>::const_iterator findLayer(const std::string& layerID) const; + void reloadLayerSource(Layer&); // GlyphStoreObserver implementation. void onGlyphsLoaded(const FontStack&, const GlyphRange&) override; |