[core] mutate style on annotation mutations immediately
This commit is contained in:
committed by
Ivo van Dongen
parent
8ae7010546
commit
e35cbbae55
@@ -87,11 +87,12 @@ public:
|
||||
|
||||
Update updateFlags = Update::Nothing;
|
||||
|
||||
AnnotationManager annotationManager;
|
||||
std::unique_ptr<Painter> painter;
|
||||
std::unique_ptr<Style> style;
|
||||
std::unique_ptr<RenderStyle> renderStyle;
|
||||
|
||||
AnnotationManager annotationManager;
|
||||
|
||||
bool cameraMutated = false;
|
||||
|
||||
uint8_t prefetchZoomDelta = util::DEFAULT_PREFETCH_ZOOM_DELTA;
|
||||
@@ -147,6 +148,8 @@ Map::Impl::Impl(Map& map_,
|
||||
contextMode(contextMode_),
|
||||
pixelRatio(pixelRatio_),
|
||||
programCacheDir(std::move(programCacheDir_)),
|
||||
style(std::make_unique<Style>(scheduler, fileSource, pixelRatio)),
|
||||
annotationManager(*style),
|
||||
asyncInvalidate([this] {
|
||||
if (mode == MapMode::Continuous) {
|
||||
backend.invalidate();
|
||||
@@ -154,7 +157,6 @@ Map::Impl::Impl(Map& map_,
|
||||
renderStill();
|
||||
}
|
||||
}) {
|
||||
style = std::make_unique<Style>(scheduler, fileSource, pixelRatio);
|
||||
style->impl->setObserver(this);
|
||||
}
|
||||
|
||||
@@ -217,10 +219,6 @@ void Map::Impl::render(View& view) {
|
||||
|
||||
transform.updateTransitions(timePoint);
|
||||
|
||||
if (style->impl->loaded && updateFlags & Update::AnnotationStyle) {
|
||||
annotationManager.updateStyle(*style->impl);
|
||||
}
|
||||
|
||||
if (updateFlags & Update::AnnotationData) {
|
||||
annotationManager.updateData();
|
||||
}
|
||||
@@ -327,8 +325,10 @@ const style::Style& Map::getStyle() const {
|
||||
}
|
||||
|
||||
void Map::setStyle(std::unique_ptr<Style> style) {
|
||||
assert(style);
|
||||
impl->onStyleLoading();
|
||||
impl->style = std::move(style);
|
||||
impl->annotationManager.setStyle(*impl->style);
|
||||
}
|
||||
|
||||
#pragma mark - Transitions
|
||||
@@ -708,12 +708,10 @@ LatLng Map::latLngForPixel(const ScreenCoordinate& pixel) const {
|
||||
|
||||
void Map::addAnnotationImage(std::unique_ptr<style::Image> image) {
|
||||
impl->annotationManager.addImage(std::move(image));
|
||||
impl->onUpdate(Update::AnnotationStyle);
|
||||
}
|
||||
|
||||
void Map::removeAnnotationImage(const std::string& id) {
|
||||
impl->annotationManager.removeImage(id);
|
||||
impl->onUpdate(Update::AnnotationStyle);
|
||||
}
|
||||
|
||||
double Map::getTopOffsetPixelsForAnnotationImage(const std::string& id) {
|
||||
@@ -722,7 +720,7 @@ double Map::getTopOffsetPixelsForAnnotationImage(const std::string& id) {
|
||||
|
||||
AnnotationID Map::addAnnotation(const Annotation& annotation) {
|
||||
auto result = impl->annotationManager.addAnnotation(annotation, getMaxZoom());
|
||||
impl->onUpdate(Update::AnnotationStyle | Update::AnnotationData);
|
||||
impl->onUpdate(Update::AnnotationData);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -732,7 +730,7 @@ void Map::updateAnnotation(AnnotationID id, const Annotation& annotation) {
|
||||
|
||||
void Map::removeAnnotation(AnnotationID annotation) {
|
||||
impl->annotationManager.removeAnnotation(annotation);
|
||||
impl->onUpdate(Update::AnnotationStyle | Update::AnnotationData);
|
||||
impl->onUpdate(Update::AnnotationData);
|
||||
}
|
||||
|
||||
#pragma mark - Feature query api
|
||||
@@ -874,7 +872,7 @@ void Map::Impl::onStyleLoaded() {
|
||||
map.setPitch(style->getDefaultPitch());
|
||||
}
|
||||
|
||||
onUpdate(Update::AnnotationStyle);
|
||||
annotationManager.onStyleLoaded();
|
||||
observer.onDidFinishLoadingStyle();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user