diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index b6ca3b62c..46381cc90 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -374,7 +374,7 @@ const LatLng Map::latLngForPixel(const vec2 pixel) const { void Map::setDefaultPointAnnotationSymbol(const std::string& symbol) { assert(Environment::currentlyOn(ThreadType::Main)); context->invokeTask([=] { - data->annotationManager.setDefaultPointAnnotationSymbol(symbol); + context->setDefaultPointAnnotationSymbol(symbol); }); } @@ -392,9 +392,7 @@ uint32_t Map::addPointAnnotation(const LatLng& point, const std::string& symbol) std::vector Map::addPointAnnotations(const std::vector& points, const std::vector& symbols) { assert(Environment::currentlyOn(ThreadType::Main)); return context->invokeSyncTask([&] { - auto result = data->annotationManager.addPointAnnotations(points, symbols, *data); - context->updateAnnotationTiles(result.first); - return result.second; + return context->addPointAnnotations(points, symbols); }); } @@ -406,22 +404,21 @@ void Map::removeAnnotation(uint32_t annotation) { void Map::removeAnnotations(const std::vector& annotations) { assert(Environment::currentlyOn(ThreadType::Main)); context->invokeTask([=] { - auto result = data->annotationManager.removeAnnotations(annotations, *data); - context->updateAnnotationTiles(result); + context->removeAnnotations(annotations); }); } std::vector Map::getAnnotationsInBounds(const LatLngBounds& bounds) { assert(Environment::currentlyOn(ThreadType::Main)); return context->invokeSyncTask([&] { - return data->annotationManager.getAnnotationsInBounds(bounds, *data); + return context->getAnnotationsInBounds(bounds); }); } LatLngBounds Map::getBoundsForAnnotations(const std::vector& annotations) { assert(Environment::currentlyOn(ThreadType::Main)); return context->invokeSyncTask([&] { - return data->annotationManager.getBoundsForAnnotations(annotations); + return context->getBoundsForAnnotations(annotations); }); } diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 28f394d85..525425205 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -415,6 +415,10 @@ void MapContext::processTasks() { } } +void MapContext::setDefaultPointAnnotationSymbol(const std::string& symbol) { + data.annotationManager.setDefaultPointAnnotationSymbol(symbol); +} + double MapContext::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) { assert(Environment::currentlyOn(ThreadType::Map)); assert(sprite); @@ -422,6 +426,25 @@ double MapContext::getTopOffsetPixelsForAnnotationSymbol(const std::string& symb return -pos.height / pos.pixelRatio / 2; } +std::vector MapContext::addPointAnnotations(const std::vector& points, const std::vector& symbols) { + auto result = data.annotationManager.addPointAnnotations(points, symbols, data); + updateAnnotationTiles(result.first); + return result.second; +} + +void MapContext::removeAnnotations(const std::vector& annotations) { + auto result = data.annotationManager.removeAnnotations(annotations, data); + updateAnnotationTiles(result); +} + +std::vector MapContext::getAnnotationsInBounds(const LatLngBounds& bounds) { + return data.annotationManager.getAnnotationsInBounds(bounds, data); +} + +LatLngBounds MapContext::getBoundsForAnnotations(const std::vector& annotations) { + return data.annotationManager.getBoundsForAnnotations(annotations); +} + void MapContext::setSourceTileCacheSize(size_t size) { assert(Environment::currentlyOn(ThreadType::Map)); if (size != sourceCacheSize) { diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index fd9347e61..7a4e9123e 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -28,6 +28,8 @@ class Painter; class Sprite; class Style; class Worker; +struct LatLng; +struct LatLngBounds; class MapContext { public: @@ -57,8 +59,13 @@ public: return promise.get_future().get(); } - void updateAnnotationTiles(const std::vector& ids); + void setDefaultPointAnnotationSymbol(const std::string& symbol); double getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol); + std::vector addPointAnnotations(const std::vector& points, const std::vector& symbols); + void removeAnnotations(const std::vector& annotations); + std::vector getAnnotationsInBounds(const LatLngBounds&); + LatLngBounds getBoundsForAnnotations(const std::vector&); + void setSourceTileCacheSize(size_t size); void onLowMemory(); @@ -66,6 +73,7 @@ public: private: // Checks if render thread needs to pause void checkForPause(); + void updateAnnotationTiles(const std::vector& ids); Worker& getWorker(); util::ptr getSprite();