summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/line_annotation_impl.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-08-31 16:13:37 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-06 14:29:22 -0700
commit6c23a6a095097c457c896dfeb1a3005a4f618f41 (patch)
treea2ec700fa536bafa4bf84f1b4a334507965d8873 /src/mbgl/annotation/line_annotation_impl.cpp
parentb4864ca9d5a18dda4476baa31e33fe8547d55b40 (diff)
downloadqtlocation-mapboxgl-6c23a6a095097c457c896dfeb1a3005a4f618f41.tar.gz
[core] Avoid triggering re-layout of fill annotation source
Diffstat (limited to 'src/mbgl/annotation/line_annotation_impl.cpp')
-rw-r--r--src/mbgl/annotation/line_annotation_impl.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp
index 5ec5a2a49f..15fa2c67f3 100644
--- a/src/mbgl/annotation/line_annotation_impl.cpp
+++ b/src/mbgl/annotation/line_annotation_impl.cpp
@@ -14,16 +14,15 @@ LineAnnotationImpl::LineAnnotationImpl(AnnotationID id_, LineAnnotation annotati
void LineAnnotationImpl::updateStyle(Style& style) const {
Layer* layer = style.getLayer(layerID);
- LineLayer* lineLayer = layer ? layer->as<LineLayer>() : nullptr;
- if (!lineLayer) {
- lineLayer = style.addLayer(
- std::make_unique<LineLayer>(layerID, AnnotationManager::SourceID),
- AnnotationManager::PointLayerID)->as<LineLayer>();
- lineLayer->setSourceLayer(layerID);
+ if (!layer) {
+ auto newLayer = std::make_unique<LineLayer>(layerID, AnnotationManager::SourceID);
+ newLayer->setSourceLayer(layerID);
+ newLayer->setLineJoin(LineJoinType::Round);
+ layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
}
- lineLayer->setLineJoin(LineJoinType::Round);
+ LineLayer* lineLayer = layer->as<LineLayer>();
lineLayer->setLineOpacity(annotation.opacity);
lineLayer->setLineWidth(annotation.width);
lineLayer->setLineColor(annotation.color);