From b0a30943b45e6d8f28fac9407728d62dd7e33668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 24 Mar 2015 15:43:08 +0100 Subject: [PATCH] move most private Map code to MapContext --- android/cpp/jni.cpp | 10 +- android/cpp/native_map_view.cpp | 4 +- .../mapbox/mapboxgl/views/NativeMapView.java | 2 - include/mbgl/android/native_map_view.hpp | 2 +- include/mbgl/map/map.hpp | 45 +-- include/mbgl/map/view.hpp | 6 +- include/mbgl/platform/default/glfw_view.hpp | 2 +- .../mbgl/platform/default/headless_view.hpp | 2 +- platform/default/glfw_view.cpp | 8 +- platform/default/headless_view.cpp | 5 +- platform/ios/MGLMapView.mm | 4 +- src/mbgl/map/map.cpp | 375 +++--------------- src/mbgl/map/map_context.cpp | 274 ++++++++++++- src/mbgl/map/map_context.hpp | 105 ++++- src/mbgl/map/raster_tile_data.cpp | 1 - src/mbgl/renderer/painter.cpp | 18 - src/mbgl/renderer/painter.hpp | 6 - src/mbgl/util/signal.cpp | 21 + src/mbgl/util/signal.hpp | 24 ++ 19 files changed, 482 insertions(+), 432 deletions(-) create mode 100644 src/mbgl/util/signal.cpp create mode 100644 src/mbgl/util/signal.hpp diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index ac5188484..3f57b2df2 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -287,14 +287,7 @@ void JNICALL nativeUpdate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeUpdate"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->getMap().triggerUpdate(); -} - -void JNICALL nativeTerminate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeTerminate"); - assert(nativeMapViewPtr != 0); - NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->getMap().terminate(); + nativeMapView->getMap().update(); } void JNICALL nativeResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint width, jint height, @@ -943,7 +936,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { {"nativePause", "(J)V", reinterpret_cast(&nativePause)}, {"nativeResume", "(J)V", reinterpret_cast(&nativeResume)}, {"nativeUpdate", "(J)V", reinterpret_cast(&nativeUpdate)}, - {"nativeTerminate", "(J)V", reinterpret_cast(&nativeTerminate)}, {"nativeResize", "(JIIFII)V", reinterpret_cast(static_cast(&nativeResize))}, diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index 39a777bff..4e219bf52 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -121,11 +121,11 @@ void NativeMapView::deactivate() { } } -void NativeMapView::invalidate() { +void NativeMapView::invalidate(std::function render) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::invalidate"); if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)) { - map.render(); + render(); if (!eglSwapBuffers(display, surface)) { mbgl::Log::Error(mbgl::Event::OpenGL, "eglSwapBuffers() returned error %d", diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java index 4dcd5ef8e..c03306049 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java @@ -396,8 +396,6 @@ class NativeMapView { private native void nativeUpdate(long nativeMapViewPtr); - private native void nativeTerminate(long nativeMapViewPtr); - private native void nativeResize(long nativeMapViewPtr, int width, int height, float ratio, int fbWidth, int fbHeight); diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp index 14ccaba3f..a810ab189 100644 --- a/include/mbgl/android/native_map_view.hpp +++ b/include/mbgl/android/native_map_view.hpp @@ -23,7 +23,7 @@ public: void activate() override; void deactivate() override; void notify() override; - void invalidate() override; + void invalidate(std::function render) override; void notifyMapChange(mbgl::MapChange change, Duration delay = Duration::zero()) override; diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index bbf6dea92..5d719173d 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -25,7 +25,6 @@ namespace uv { class async; } namespace mbgl { -class Sprite; class FileSource; class View; class Environment; @@ -65,15 +64,8 @@ public: // Triggers a synchronous or asynchronous render. void renderSync(); - // Unconditionally performs a render with the current map state. May only be called from the Map - // thread. - void render(); - // Notifies the Map thread that the state has changed and an update might be necessary. - void triggerUpdate(Update = Update::Nothing); - - // Releases resources immediately - void terminate(); + void update(); // Styling void addClass(const std::string&); @@ -171,29 +163,7 @@ private: // Setup void setup(); - void updateTiles(); - - // Triggered by triggerUpdate(); - void update(); - - // Loads the style set in the data object. Called by Update::StyleInfo - void reloadStyle(); - void loadStyleJSON(const std::string& json, const std::string& base); - - // Prepares a map render by updating the tiles we need for the current view, as well as updating - // the stylesheet. - void prepare(); - - // Runs the function in the map thread. - void invokeTask(std::function&&); - template auto invokeSyncTask(const Fn& fn) -> decltype(fn()); - - void processTasks(); - - void updateAnnotationTiles(const std::vector&); - size_t sourceCacheSize; - const std::unique_ptr env; std::unique_ptr scope; View &view; @@ -202,11 +172,7 @@ private: private: std::thread thread; - std::unique_ptr asyncTerminate; - std::unique_ptr asyncUpdate; - std::unique_ptr asyncInvoke; - bool terminating = false; bool pausing = false; bool isPaused = false; std::mutex mutexRun; @@ -214,18 +180,9 @@ private: std::mutex mutexPause; std::condition_variable condPause; - // Used to signal that rendering completed. - bool rendered = false; - std::condition_variable condRendered; - std::mutex mutexRendered; - // Stores whether the map thread has been stopped already. std::atomic_bool isStopped; - std::atomic updated; - - std::mutex mutexTask; - std::queue> tasks; StillImageCallback callback; }; diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index 8e21233b7..9fdbd6278 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -2,6 +2,7 @@ #define MBGL_MAP_VIEW #include +#include #include @@ -40,8 +41,9 @@ public: virtual void notify() = 0; // Called from the render thread. The implementation must trigger a rerender. - // (i.e. map->renderSync() or map->renderAsync() must be called as a result of this) - virtual void invalidate() = 0; + // (i.e. either the passed render() function for rendering immediately on the map thread, + // or map->renderSync() from the main thread must be called as a result of this) + virtual void invalidate(std::function render) = 0; // Called from the render (=GL) thread. Signals that the contents of the contents // may be discarded. The default is a no-op. diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp index 234568e4b..0f37ec130 100644 --- a/include/mbgl/platform/default/glfw_view.hpp +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -17,7 +17,7 @@ public: void activate() override; void deactivate() override; void notify() override; - void invalidate() override; + void invalidate(std::function render) override; static void onKey(GLFWwindow *window, int key, int scancode, int action, int mods); static void onScroll(GLFWwindow *window, double xoffset, double yoffset); diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp index 3262afc46..44b891bf6 100644 --- a/include/mbgl/platform/default/headless_view.hpp +++ b/include/mbgl/platform/default/headless_view.hpp @@ -33,7 +33,7 @@ public: void activate() override; void deactivate() override; void notify() override; - void invalidate() override; + void invalidate(std::function render) override; void discard() override; std::unique_ptr readStillImage() override; diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 7cedd634c..e4f459053 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -275,9 +275,6 @@ int GLFWView::run() { glfwWaitEvents(); }); - // Terminate here to save binary shaders - map->terminate(); - return 0; } @@ -293,9 +290,8 @@ void GLFWView::notify() { glfwPostEmptyEvent(); } -void GLFWView::invalidate() { - assert(map); - map->render(); +void GLFWView::invalidate(std::function render) { + render(); glfwSwapBuffers(window); fps(); } diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index f8622604e..d84e223e4 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -328,9 +328,8 @@ void HeadlessView::deactivate() { #endif } -void HeadlessView::invalidate() { - assert(map); - map->render(); +void HeadlessView::invalidate(std::function render) { + render(); } } diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 0fe408d33..cac54355a 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -645,7 +645,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; if ( ! _isTargetingInterfaceBuilder) { - mbglMap->triggerUpdate(); + mbglMap->update(); } } @@ -2532,7 +2532,7 @@ class MBGLView : public mbgl::View View::resize(width, height, ratio, fbWidth, fbHeight); } - void invalidate() override + void invalidate(std::function) override { [nativeView performSelectorOnMainThread:@selector(invalidate) withObject:nil diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index c13cce73b..8b1b4efc4 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -66,8 +67,7 @@ Map::Map(View& view_, FileSource& fileSource_) scope(util::make_unique(*env, ThreadType::Main, "Main")), view(view_), data(util::make_unique(view_)), - context(util::make_unique(*env, *data)), - updated(static_cast(Update::Nothing)) + context(util::make_unique(*env, view, *data)) { view.initialize(this); } @@ -104,51 +104,7 @@ void Map::start(bool startPaused, MapMode renderMode) { // Reset the flag. isStopped = false; - // Setup async notifications - asyncTerminate = util::make_unique(env->loop, [this]() { - assert(Environment::currentlyOn(ThreadType::Map)); - - // Remove all of these to make sure they are destructed in the correct thread. - context->style.reset(); - - // It's now safe to destroy/join the workers since there won't be any more callbacks that - // could dispatch to the worker pool. - context->workers.reset(); - - terminating = true; - - // Closes all open handles on the loop. This means that the loop will automatically terminate. - context->asyncRender.reset(); - asyncUpdate.reset(); - asyncInvoke.reset(); - asyncTerminate.reset(); - }); - - asyncUpdate = util::make_unique(env->loop, [this] { - // Whenever we call triggerUpdate(), we ref() the asyncUpdate handle to make sure that all - // of the calls actually get triggered. - asyncUpdate->unref(); - - update(); - }); - - asyncInvoke = util::make_unique(env->loop, [this] { - processTasks(); - }); - - context->asyncRender = util::make_unique(env->loop, [this] { - // Must be called in Map thread. - assert(Environment::currentlyOn(ThreadType::Map)); - - render(); - - // Finally, notify all listeners that we have finished rendering this frame. - { - std::lock_guard lk(mutexRendered); - rendered = true; - } - condRendered.notify_all(); - }); + context->start(); // Do we need to pause first? if (startPaused) { @@ -167,14 +123,14 @@ void Map::start(bool startPaused, MapMode renderMode) { view.notify(); }); - triggerUpdate(); + context->triggerUpdate(); } void Map::stop(std::function cb) { assert(Environment::currentlyOn(ThreadType::Main)); assert(data->mode != MapMode::None); - asyncTerminate->send(); + context->terminate(); resume(); @@ -205,7 +161,7 @@ void Map::pause(bool waitForPause) { mutexRun.unlock(); uv_stop(env->loop); - triggerUpdate(); // Needed to ensure uv_stop is seen and uv_run exits, otherwise we deadlock on wait_for_pause + context->triggerUpdate(); // Needed to ensure uv_stop is seen and uv_run exits, otherwise we deadlock on wait_for_pause if (waitForPause) { std::unique_lock lockPause (mutexPause); @@ -240,7 +196,7 @@ void Map::renderStill(StillImageCallback fn) { callback = std::move(fn); - triggerUpdate(Update::RenderStill); + context->triggerUpdate(Update::RenderStill); } void Map::run() { @@ -258,25 +214,25 @@ void Map::run() { context->workers = util::make_unique(env->loop, 4); setup(); - prepare(); + context->prepare(); if (data->mode == MapMode::Continuous) { - terminating = false; - while (!terminating) { + context->terminating = false; + while (!context->terminating) { uv_run(env->loop, UV_RUN_DEFAULT); checkForPause(); } } else if (data->mode == MapMode::Still) { - terminating = false; - while (!terminating) { + context->terminating = false; + while (!context->terminating) { uv_run(env->loop, UV_RUN_DEFAULT); // After the loop terminated, these async handles may have been deleted if the terminate() // callback was fired. In this case, we are exiting the loop. - if (asyncTerminate && asyncUpdate) { + if (context->asyncTerminate && context->asyncUpdate) { // Otherwise, loop termination means that we have acquired and parsed all resources // required for this map image and we can now proceed to rendering. - render(); + context->render(); auto image = view.readStillImage(); // We are moving the callback out of the way and empty it in case the callback function @@ -290,9 +246,9 @@ void Map::run() { // To prepare for the next event loop run, we have to make sure the async handles keep // the loop alive. - asyncTerminate->ref(); - asyncUpdate->ref(); - asyncInvoke->ref(); + context->asyncTerminate->ref(); + context->asyncUpdate->ref(); + context->asyncInvoke->ref(); context->asyncRender->ref(); } } @@ -312,41 +268,7 @@ void Map::renderSync() { context->triggerRender(); - std::unique_lock lock(mutexRendered); - condRendered.wait(lock, [this] { return rendered; }); - rendered = false; -} - -// Runs the function in the map thread. -void Map::invokeTask(std::function&& fn) { - { - std::lock_guard lock(mutexTask); - tasks.emplace(::std::forward>(fn)); - } - - if (asyncInvoke) { - asyncInvoke->send(); - } -} - -template auto Map::invokeSyncTask(const Fn& fn) -> decltype(fn()) { - std::promise promise; - invokeTask([&fn, &promise] { promise.set_value(fn()); }); - return promise.get_future().get(); -} - -// Processes the functions that should be run in the map thread. -void Map::processTasks() { - std::queue> queue; - { - std::lock_guard lock(mutexTask); - queue.swap(tasks); - } - - while (!queue.empty()) { - queue.front()(); - queue.pop(); - } + context->rendered.wait(); } void Map::checkForPause() { @@ -369,10 +291,8 @@ void Map::checkForPause() { mutexPause.unlock(); } -void Map::terminate() { - assert(context->painter); - context->painter->terminate(); - view.deactivate(); +void Map::update() { + context->triggerUpdate(); } #pragma mark - Setup @@ -399,14 +319,14 @@ void Map::setStyleURL(const std::string &url) { } data->setStyleInfo({ styleURL, base, "" }); - triggerUpdate(Update::StyleInfo); + context->triggerUpdate(Update::StyleInfo); } void Map::setStyleJSON(const std::string& json, const std::string& base) { assert(Environment::currentlyOn(ThreadType::Main)); data->setStyleInfo({ "", base, json }); - triggerUpdate(Update::StyleInfo); + context->triggerUpdate(Update::StyleInfo); } std::string Map::getStyleJSON() const { @@ -421,7 +341,7 @@ void Map::resize(uint16_t width, uint16_t height, float ratio) { void Map::resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight) { if (data->transform.resize(width, height, ratio, fbWidth, fbHeight)) { - triggerUpdate(); + context->triggerUpdate(); } } @@ -429,24 +349,24 @@ void Map::resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, void Map::cancelTransitions() { data->transform.cancelTransitions(); - triggerUpdate(); + context->triggerUpdate(); } void Map::setGestureInProgress(bool inProgress) { data->transform.setGestureInProgress(inProgress); - triggerUpdate(); + context->triggerUpdate(); } #pragma mark - Position void Map::moveBy(double dx, double dy, Duration duration) { data->transform.moveBy(dx, dy, duration); - triggerUpdate(); + context->triggerUpdate(); } void Map::setLatLng(LatLng latLng, Duration duration) { data->transform.setLatLng(latLng, duration); - triggerUpdate(); + context->triggerUpdate(); } LatLng Map::getLatLng() const { @@ -457,7 +377,7 @@ void Map::resetPosition() { data->transform.setAngle(0); data->transform.setLatLng(LatLng(0, 0)); data->transform.setZoom(0); - triggerUpdate(Update::Zoom); + context->triggerUpdate(Update::Zoom); } @@ -465,12 +385,12 @@ void Map::resetPosition() { void Map::scaleBy(double ds, double cx, double cy, Duration duration) { data->transform.scaleBy(ds, cx, cy, duration); - triggerUpdate(Update::Zoom); + context->triggerUpdate(Update::Zoom); } void Map::setScale(double scale, double cx, double cy, Duration duration) { data->transform.setScale(scale, cx, cy, duration); - triggerUpdate(Update::Zoom); + context->triggerUpdate(Update::Zoom); } double Map::getScale() const { @@ -479,7 +399,7 @@ double Map::getScale() const { void Map::setZoom(double zoom, Duration duration) { data->transform.setZoom(zoom, duration); - triggerUpdate(Update::Zoom); + context->triggerUpdate(Update::Zoom); } double Map::getZoom() const { @@ -488,13 +408,24 @@ double Map::getZoom() const { void Map::setLatLngZoom(LatLng latLng, double zoom, Duration duration) { data->transform.setLatLngZoom(latLng, zoom, duration); - triggerUpdate(Update::Zoom); + context->triggerUpdate(Update::Zoom); } void Map::resetZoom() { setZoom(0); } +double Map::getMinZoom() const { + return data->transform.getMinZoom(); +} + +double Map::getMaxZoom() const { + return data->transform.getMaxZoom(); +} + + +#pragma mark - Size + uint16_t Map::getWidth() const { return data->getTransformState().getWidth(); } @@ -508,17 +439,17 @@ uint16_t Map::getHeight() const { void Map::rotateBy(double sx, double sy, double ex, double ey, Duration duration) { data->transform.rotateBy(sx, sy, ex, ey, duration); - triggerUpdate(); + context->triggerUpdate(); } void Map::setBearing(double degrees, Duration duration) { data->transform.setAngle(-degrees * M_PI / 180, duration); - triggerUpdate(); + context->triggerUpdate(); } void Map::setBearing(double degrees, double cx, double cy) { data->transform.setAngle(-degrees * M_PI / 180, cx, cy); - triggerUpdate(); + context->triggerUpdate(); } double Map::getBearing() const { @@ -527,22 +458,10 @@ double Map::getBearing() const { void Map::resetNorth() { data->transform.setAngle(0, std::chrono::milliseconds(500)); - triggerUpdate(); + context->triggerUpdate(); } -#pragma mark - Rotation - -double Map::getMinZoom() const { - return data->transform.getMinZoom(); -} - -double Map::getMaxZoom() const { - return data->transform.getMaxZoom(); -} - - - #pragma mark - Access Token void Map::setAccessToken(const std::string &token) { @@ -588,14 +507,14 @@ const LatLng Map::latLngForPixel(const vec2 pixel) const { void Map::setDefaultPointAnnotationSymbol(const std::string& symbol) { assert(Environment::currentlyOn(ThreadType::Main)); - invokeTask([=] { + context->invokeTask([=] { data->annotationManager.setDefaultPointAnnotationSymbol(symbol); }); } double Map::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) { assert(Environment::currentlyOn(ThreadType::Main)); - return invokeSyncTask([&] { + return context->invokeSyncTask([&] { assert(context->sprite); const SpritePosition pos = context->sprite->getSpritePosition(symbol); return -pos.height / pos.pixelRatio / 2; @@ -608,9 +527,9 @@ 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 invokeSyncTask([&] { + return context->invokeSyncTask([&] { auto result = data->annotationManager.addPointAnnotations(points, symbols, *data); - updateAnnotationTiles(result.first); + context->updateAnnotationTiles(result.first); return result.second; }); } @@ -622,22 +541,22 @@ void Map::removeAnnotation(uint32_t annotation) { void Map::removeAnnotations(const std::vector& annotations) { assert(Environment::currentlyOn(ThreadType::Main)); - invokeTask([=] { + context->invokeTask([=] { auto result = data->annotationManager.removeAnnotations(annotations, *data); - updateAnnotationTiles(result); + context->updateAnnotationTiles(result); }); } std::vector Map::getAnnotationsInBounds(const LatLngBounds& bounds) { assert(Environment::currentlyOn(ThreadType::Main)); - return invokeSyncTask([&] { + return context->invokeSyncTask([&] { return data->annotationManager.getAnnotationsInBounds(bounds, *data); }); } LatLngBounds Map::getBoundsForAnnotations(const std::vector& annotations) { assert(Environment::currentlyOn(ThreadType::Main)); - return invokeSyncTask([&] { + return context->invokeSyncTask([&] { return data->annotationManager.getBoundsForAnnotations(annotations); }); } @@ -647,12 +566,12 @@ LatLngBounds Map::getBoundsForAnnotations(const std::vector& annotatio void Map::setDebug(bool value) { data->setDebug(value); - triggerUpdate(Update::Debug); + context->triggerUpdate(Update::Debug); } void Map::toggleDebug() { data->toggleDebug(); - triggerUpdate(Update::Debug); + context->triggerUpdate(Update::Debug); } bool Map::getDebug() const { @@ -661,19 +580,19 @@ bool Map::getDebug() const { void Map::addClass(const std::string& klass) { if (data->addClass(klass)) { - triggerUpdate(Update::Classes); + context->triggerUpdate(Update::Classes); } } void Map::removeClass(const std::string& klass) { if (data->removeClass(klass)) { - triggerUpdate(Update::Classes); + context->triggerUpdate(Update::Classes); } } void Map::setClasses(const std::vector& classes) { data->setClasses(classes); - triggerUpdate(Update::Classes); + context->triggerUpdate(Update::Classes); } bool Map::hasClass(const std::string& klass) const { @@ -688,7 +607,7 @@ void Map::setDefaultTransitionDuration(Duration duration) { assert(Environment::currentlyOn(ThreadType::Main)); data->setDefaultTransitionDuration(duration); - triggerUpdate(Update::DefaultTransitionDuration); + context->triggerUpdate(Update::DefaultTransitionDuration); } Duration Map::getDefaultTransitionDuration() { @@ -698,178 +617,10 @@ Duration Map::getDefaultTransitionDuration() { #pragma mark - Private -void Map::triggerUpdate(const Update u) { - updated |= static_cast(u); - - if (asyncUpdate) { - asyncUpdate->ref(); - asyncUpdate->send(); - } -} - -void Map::updateAnnotationTiles(const std::vector& ids) { - assert(Environment::currentlyOn(ThreadType::Main)); - if (!context->style) return; - for (const auto &source : context->style->sources) { - if (source->info.type == SourceType::Annotations) { - source->invalidateTiles(ids); - } - } - triggerUpdate(); -} - -void Map::updateTiles() { - assert(Environment::currentlyOn(ThreadType::Map)); - if (!context->style) return; - for (const auto& source : context->style->sources) { - source->update(*data, context->getWorker(), context->style, *context->glyphAtlas, *context->glyphStore, - *context->spriteAtlas, context->getSprite(), *context->texturePool, [this]() { - assert(Environment::currentlyOn(ThreadType::Map)); - triggerUpdate(); - }); - } -} - -void Map::update() { - assert(Environment::currentlyOn(ThreadType::Map)); - - if (data->getTransformState().hasSize()) { - prepare(); - } -} - -void Map::reloadStyle() { - assert(Environment::currentlyOn(ThreadType::Map)); - - context->style = std::make_shared