summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/annotation_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/annotation/annotation_manager.cpp')
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp
index b5dfea8e1a..a2b26aabff 100644
--- a/src/mbgl/annotation/annotation_manager.cpp
+++ b/src/mbgl/annotation/annotation_manager.cpp
@@ -31,17 +31,12 @@ const std::string AnnotationManager::SourceID = "com.mapbox.annotations";
const std::string AnnotationManager::PointLayerID = "com.mapbox.annotations.points";
const std::string AnnotationManager::ShapeLayerID = "com.mapbox.annotations.shape.";
-AnnotationManager::AnnotationManager(Style& style_)
+AnnotationManager::AnnotationManager(StyleImpl& style_)
: style(style_) {
};
AnnotationManager::~AnnotationManager() = default;
-void AnnotationManager::setStyle(Style& style_) {
- CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
- style = style_;
-}
-
void AnnotationManager::onStyleLoaded() {
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
updateStyle();
@@ -83,13 +78,13 @@ void AnnotationManager::add(const AnnotationID& id, const SymbolAnnotation& anno
void AnnotationManager::add(const AnnotationID& id, const LineAnnotation& annotation) {
ShapeAnnotationImpl& impl = *shapeAnnotations.emplace(id,
std::make_unique<LineAnnotationImpl>(id, annotation)).first->second;
- impl.updateStyle(*style.get().impl);
+ impl.updateStyle(style);
}
void AnnotationManager::add(const AnnotationID& id, const FillAnnotation& annotation) {
ShapeAnnotationImpl& impl = *shapeAnnotations.emplace(id,
std::make_unique<FillAnnotationImpl>(id, annotation)).first->second;
- impl.updateStyle(*style.get().impl);
+ impl.updateStyle(style);
}
void AnnotationManager::update(const AnnotationID& id, const SymbolAnnotation& annotation) {
@@ -140,7 +135,7 @@ void AnnotationManager::remove(const AnnotationID& id) {
symbolAnnotations.erase(id);
} else if (shapeAnnotations.find(id) != shapeAnnotations.end()) {
auto it = shapeAnnotations.find(id);
- *style.get().impl->removeLayer(it->second->layerID);
+ style.removeLayer(it->second->layerID);
shapeAnnotations.erase(it);
} else {
assert(false); // Should never happen
@@ -178,8 +173,8 @@ std::unique_ptr<AnnotationTileData> AnnotationManager::getTileData(const Canonic
void AnnotationManager::updateStyle() {
// Create annotation source, point layer, and point bucket. We do everything via Style::Impl
// because we don't want annotation mutations to trigger Style::Impl::styleMutated to be set.
- if (!style.get().impl->getSource(SourceID)) {
- style.get().impl->addSource(std::make_unique<AnnotationSource>());
+ if (!style.getSource(SourceID)) {
+ style.addSource(std::make_unique<AnnotationSource>());
std::unique_ptr<SymbolLayer> layer = std::make_unique<SymbolLayer>(PointLayerID, SourceID);
@@ -190,13 +185,13 @@ void AnnotationManager::updateStyle() {
layer->setIconAllowOverlap(true);
layer->setIconIgnorePlacement(true);
- style.get().impl->addLayer(std::move(layer));
+ style.addLayer(std::move(layer));
}
std::lock_guard<std::mutex> lock(mutex);
for (const auto& shape : shapeAnnotations) {
- shape.second->updateStyle(*style.get().impl);
+ shape.second->updateStyle(style);
}
for (const auto& image : images) {
@@ -206,7 +201,7 @@ void AnnotationManager::updateStyle() {
// of which images need to be added because we don't know if the style is the same
// instance as in the last updateStyle call. If it's a new style, we need to add all
// images.)
- style.get().impl->addImage(std::make_unique<style::Image>(image.second));
+ style.addImage(std::make_unique<style::Image>(image.second));
}
}
@@ -247,7 +242,7 @@ void AnnotationManager::addImage(std::unique_ptr<style::Image> image) {
images.erase(id);
auto inserted = images.emplace(id, style::Image(id, image->getImage().clone(),
image->getPixelRatio(), image->isSdf()));
- style.get().impl->addImage(std::make_unique<style::Image>(inserted.first->second));
+ style.addImage(std::make_unique<style::Image>(inserted.first->second));
}
void AnnotationManager::removeImage(const std::string& id_) {
@@ -255,7 +250,7 @@ void AnnotationManager::removeImage(const std::string& id_) {
std::lock_guard<std::mutex> lock(mutex);
const std::string id = prefixedImageID(id_);
images.erase(id);
- style.get().impl->removeImage(id);
+ style.removeImage(id);
}
double AnnotationManager::getTopOffsetPixelsForImage(const std::string& id_) {