summaryrefslogtreecommitdiff
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
parentb4864ca9d5a18dda4476baa31e33fe8547d55b40 (diff)
downloadqtlocation-mapboxgl-6c23a6a095097c457c896dfeb1a3005a4f618f41.tar.gz
[core] Avoid triggering re-layout of fill annotation source
-rw-r--r--src/mbgl/annotation/fill_annotation_impl.cpp11
-rw-r--r--src/mbgl/annotation/line_annotation_impl.cpp13
2 files changed, 11 insertions, 13 deletions
diff --git a/src/mbgl/annotation/fill_annotation_impl.cpp b/src/mbgl/annotation/fill_annotation_impl.cpp
index 0c69bc4fe5..3e91524e86 100644
--- a/src/mbgl/annotation/fill_annotation_impl.cpp
+++ b/src/mbgl/annotation/fill_annotation_impl.cpp
@@ -14,15 +14,14 @@ FillAnnotationImpl::FillAnnotationImpl(AnnotationID id_, FillAnnotation annotati
void FillAnnotationImpl::updateStyle(Style& style) const {
Layer* layer = style.getLayer(layerID);
- FillLayer* fillLayer = layer ? layer->as<FillLayer>() : nullptr;
- if (!fillLayer) {
- fillLayer = style.addLayer(
- std::make_unique<FillLayer>(layerID, AnnotationManager::SourceID),
- AnnotationManager::PointLayerID)->as<FillLayer>();
- fillLayer->setSourceLayer(layerID);
+ if (!layer) {
+ auto newLayer = std::make_unique<FillLayer>(layerID, AnnotationManager::SourceID);
+ newLayer->setSourceLayer(layerID);
+ layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
}
+ FillLayer* fillLayer = layer->as<FillLayer>();
fillLayer->setFillOpacity(annotation.opacity);
fillLayer->setFillColor(annotation.color);
fillLayer->setFillOutlineColor(annotation.outlineColor);
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);