[core] Avoid triggering re-layout of fill annotation source

This commit is contained in:
John Firebaugh
2016-08-31 16:13:37 -07:00
parent b4864ca9d5
commit 6c23a6a095
2 changed files with 11 additions and 13 deletions

View File

@@ -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);

View File

@@ -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);