From 6c23a6a095097c457c896dfeb1a3005a4f618f41 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 31 Aug 2016 16:13:37 -0700 Subject: [core] Avoid triggering re-layout of fill annotation source --- src/mbgl/annotation/fill_annotation_impl.cpp | 11 +++++------ src/mbgl/annotation/line_annotation_impl.cpp | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src') 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() : nullptr; - if (!fillLayer) { - fillLayer = style.addLayer( - std::make_unique(layerID, AnnotationManager::SourceID), - AnnotationManager::PointLayerID)->as(); - fillLayer->setSourceLayer(layerID); + if (!layer) { + auto newLayer = std::make_unique(layerID, AnnotationManager::SourceID); + newLayer->setSourceLayer(layerID); + layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID); } + FillLayer* fillLayer = layer->as(); 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() : nullptr; - if (!lineLayer) { - lineLayer = style.addLayer( - std::make_unique(layerID, AnnotationManager::SourceID), - AnnotationManager::PointLayerID)->as(); - lineLayer->setSourceLayer(layerID); + if (!layer) { + auto newLayer = std::make_unique(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->setLineOpacity(annotation.opacity); lineLayer->setLineWidth(annotation.width); lineLayer->setLineColor(annotation.color); -- cgit v1.2.1