diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-06-22 14:33:21 -0700 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-07-18 10:45:12 +0200 |
commit | e35cbbae55ab01f33690b1bb2e918c5f8393b854 (patch) | |
tree | 9c4a1d27c7ef3e8e0edf5076ee1404f2a3c2aa29 /src/mbgl/map | |
parent | 8ae70105463db78699ef3743fb24503ed8feb054 (diff) | |
download | qtlocation-mapboxgl-e35cbbae55ab01f33690b1bb2e918c5f8393b854.tar.gz |
[core] mutate style on annotation mutations immediately
Diffstat (limited to 'src/mbgl/map')
-rw-r--r-- | src/mbgl/map/map.cpp | 20 | ||||
-rw-r--r-- | src/mbgl/map/update.hpp | 1 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 26795f7814..e644f91c4f 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -87,11 +87,12 @@ public: Update updateFlags = Update::Nothing; - AnnotationManager annotationManager; std::unique_ptr<Painter> painter; std::unique_ptr<Style> style; std::unique_ptr<RenderStyle> renderStyle; + AnnotationManager annotationManager; + bool cameraMutated = false; uint8_t prefetchZoomDelta = util::DEFAULT_PREFETCH_ZOOM_DELTA; @@ -147,6 +148,8 @@ Map::Impl::Impl(Map& map_, contextMode(contextMode_), pixelRatio(pixelRatio_), programCacheDir(std::move(programCacheDir_)), + style(std::make_unique<Style>(scheduler, fileSource, pixelRatio)), + annotationManager(*style), asyncInvalidate([this] { if (mode == MapMode::Continuous) { backend.invalidate(); @@ -154,7 +157,6 @@ Map::Impl::Impl(Map& map_, renderStill(); } }) { - style = std::make_unique<Style>(scheduler, fileSource, pixelRatio); style->impl->setObserver(this); } @@ -217,10 +219,6 @@ void Map::Impl::render(View& view) { transform.updateTransitions(timePoint); - if (style->impl->loaded && updateFlags & Update::AnnotationStyle) { - annotationManager.updateStyle(*style->impl); - } - if (updateFlags & Update::AnnotationData) { annotationManager.updateData(); } @@ -327,8 +325,10 @@ const style::Style& Map::getStyle() const { } void Map::setStyle(std::unique_ptr<Style> style) { + assert(style); impl->onStyleLoading(); impl->style = std::move(style); + impl->annotationManager.setStyle(*impl->style); } #pragma mark - Transitions @@ -708,12 +708,10 @@ LatLng Map::latLngForPixel(const ScreenCoordinate& pixel) const { void Map::addAnnotationImage(std::unique_ptr<style::Image> image) { impl->annotationManager.addImage(std::move(image)); - impl->onUpdate(Update::AnnotationStyle); } void Map::removeAnnotationImage(const std::string& id) { impl->annotationManager.removeImage(id); - impl->onUpdate(Update::AnnotationStyle); } double Map::getTopOffsetPixelsForAnnotationImage(const std::string& id) { @@ -722,7 +720,7 @@ double Map::getTopOffsetPixelsForAnnotationImage(const std::string& id) { AnnotationID Map::addAnnotation(const Annotation& annotation) { auto result = impl->annotationManager.addAnnotation(annotation, getMaxZoom()); - impl->onUpdate(Update::AnnotationStyle | Update::AnnotationData); + impl->onUpdate(Update::AnnotationData); return result; } @@ -732,7 +730,7 @@ void Map::updateAnnotation(AnnotationID id, const Annotation& annotation) { void Map::removeAnnotation(AnnotationID annotation) { impl->annotationManager.removeAnnotation(annotation); - impl->onUpdate(Update::AnnotationStyle | Update::AnnotationData); + impl->onUpdate(Update::AnnotationData); } #pragma mark - Feature query api @@ -874,7 +872,7 @@ void Map::Impl::onStyleLoaded() { map.setPitch(style->getDefaultPitch()); } - onUpdate(Update::AnnotationStyle); + annotationManager.onStyleLoaded(); observer.onDidFinishLoadingStyle(); } diff --git a/src/mbgl/map/update.hpp b/src/mbgl/map/update.hpp index ab8b10c651..057720a5c9 100644 --- a/src/mbgl/map/update.hpp +++ b/src/mbgl/map/update.hpp @@ -8,7 +8,6 @@ namespace mbgl { enum class Update { Nothing = 0, Repaint = 1 << 0, - AnnotationStyle = 1 << 6, AnnotationData = 1 << 7 }; |