[core] Avoid unnecessary work when a symbol annotation is updated

In particular, if only the geometry changes, don't cascade and recalculate the style.
This commit is contained in:
John Firebaugh
2016-06-16 17:31:52 -07:00
parent e2f52a1dd8
commit 2921127bdb
9 changed files with 94 additions and 35 deletions

View File

@@ -211,11 +211,15 @@ void Map::Impl::update() {
// - Hint style sources to notify when all its tiles are loaded;
timePoint = Clock::now();
if (style->loaded && updateFlags & Update::Annotations) {
if (style->loaded && updateFlags & Update::AnnotationStyle) {
annotationManager->updateStyle(*style);
updateFlags |= Update::Classes;
}
if (updateFlags & Update::AnnotationData) {
annotationManager->updateData();
}
if (updateFlags & Update::Classes) {
style->cascade(timePoint, mode);
}
@@ -338,7 +342,7 @@ void Map::Impl::loadStyleJSON(const std::string& json) {
// force style cascade, causing all pending transitions to complete.
style->cascade(Clock::now(), mode);
updateFlags |= Update::Classes | Update::RecalculateStyle | Update::Annotations;
updateFlags |= Update::Classes | Update::RecalculateStyle | Update::AnnotationStyle;
asyncUpdate.send();
}
@@ -689,18 +693,17 @@ double Map::getTopOffsetPixelsForAnnotationIcon(const std::string& name) {
AnnotationID Map::addAnnotation(const Annotation& annotation) {
auto result = impl->annotationManager->addAnnotation(annotation, getMaxZoom());
update(Update::Annotations);
update(Update::AnnotationStyle | Update::AnnotationData);
return result;
}
void Map::updateAnnotation(AnnotationID id, const Annotation& annotation) {
impl->annotationManager->updateAnnotation(id, annotation, getMaxZoom());
update(Update::Annotations);
update(impl->annotationManager->updateAnnotation(id, annotation, getMaxZoom()));
}
void Map::removeAnnotation(AnnotationID annotation) {
impl->annotationManager->removeAnnotation(annotation);
update(Update::Annotations);
update(Update::AnnotationStyle | Update::AnnotationData);
}
AnnotationIDs Map::getPointAnnotationsInBounds(const LatLngBounds& bounds) {