diff options
-rw-r--r-- | include/mbgl/map/map.hpp | 22 | ||||
-rw-r--r-- | src/map/map.cpp | 92 |
2 files changed, 57 insertions, 57 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 5fe2ea07eb..1f4715339d 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -74,11 +74,11 @@ public: void setAppliedClasses(const std::vector<std::string> &classes); void toggleClass(const std::string &name); const std::vector<std::string> &getAppliedClasses() const; - void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0); + void setDefaultTransitionDuration(uint64_t milliseconds = 0); void setStyleURL(const std::string &url); void setStyleJSON(std::string newStyleJSON, const std::string &base = ""); std::string getStyleJSON() const; - void setAccessToken(std::string access_token); + void setAccessToken(std::string accessToken); std::string getAccessToken() const; // Transition @@ -148,30 +148,30 @@ private: std::unique_ptr<uv::loop> loop; std::unique_ptr<uv::worker> workers; std::unique_ptr<uv::thread> thread; - std::unique_ptr<uv::async> async_terminate; - std::unique_ptr<uv::async> async_render; - std::unique_ptr<uv::async> async_cleanup; + std::unique_ptr<uv::async> asyncTerminate; + std::unique_ptr<uv::async> asyncRender; + std::unique_ptr<uv::async> asyncCleanup; // If cleared, the next time the render thread attempts to render the map, it will *actually* // render the map. - std::atomic_flag is_clean = ATOMIC_FLAG_INIT; + std::atomic_flag isClean = ATOMIC_FLAG_INIT; // If this flag is cleared, the current back buffer is ready for being swapped with the front // buffer (i.e. it has rendered data). - std::atomic_flag is_swapped = ATOMIC_FLAG_INIT; + std::atomic_flag isSwapped = ATOMIC_FLAG_INIT; // This is cleared once the current front buffer has been presented and the back buffer is // ready for rendering. - std::atomic_flag is_rendered = ATOMIC_FLAG_INIT; + std::atomic_flag isRendered = ATOMIC_FLAG_INIT; // Stores whether the map thread has been stopped already. - std::atomic_bool is_stopped; + std::atomic_bool isStopped; View &view; #ifndef NDEBUG - const unsigned long main_thread; - unsigned long map_thread = -1; + const unsigned long mainThread; + unsigned long mapThread = -1; #endif Transform transform; diff --git a/src/map/map.cpp b/src/map/map.cpp index 4e588943da..259e212423 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -89,7 +89,7 @@ Map::Map(View& view_) : loop(std::make_unique<uv::loop>()), view(view_), #ifndef NDEBUG - main_thread(uv_thread_self()), + mainThread(uv_thread_self()), #endif transform(view_), glyphAtlas(1024, 1024), @@ -99,9 +99,9 @@ Map::Map(View& view_) { view.initialize(this); // Make sure that we're doing an initial drawing in all cases. - is_clean.clear(); - is_rendered.clear(); - is_swapped.test_and_set(); + isClean.clear(); + isRendered.clear(); + isSwapped.test_and_set(); } Map::~Map() { @@ -129,7 +129,7 @@ uv::worker &Map::getWorker() { } void Map::start() { - assert(uv_thread_self() == main_thread); + assert(uv_thread_self() == mainThread); assert(!async); // When starting map rendering in another thread, we perform async/continuously @@ -137,11 +137,11 @@ void Map::start() { async = true; // Reset the flag. - is_stopped = false; + isStopped = false; // Setup async notifications - async_terminate = std::make_unique<uv::async>(**loop, [this]() { - assert(uv_thread_self() == map_thread); + asyncTerminate = std::make_unique<uv::async>(**loop, [this]() { + assert(uv_thread_self() == mapThread); // Remove all of these to make sure they are destructed in the correct thread. glyphStore.reset(); @@ -151,37 +151,37 @@ void Map::start() { activeSources.clear(); // Closes all open handles on the loop. This means that the loop will automatically terminate. - async_cleanup.reset(); - async_render.reset(); - async_terminate.reset(); + asyncCleanup.reset(); + asyncRender.reset(); + asyncTerminate.reset(); }); - async_render = std::make_unique<uv::async>(**loop, [this]() { - assert(uv_thread_self() == map_thread); + asyncRender = std::make_unique<uv::async>(**loop, [this]() { + assert(uv_thread_self() == mapThread); if (state.hasSize()) { - if (is_rendered.test_and_set() == false) { + if (isRendered.test_and_set() == false) { prepare(); - if (is_clean.test_and_set() == false) { + if (isClean.test_and_set() == false) { render(); - is_swapped.clear(); + isSwapped.clear(); view.swap(); } else { // We set the rendered flag in the test above, so we have to reset it // now that we're not actually rendering because the map is clean. - is_rendered.clear(); + isRendered.clear(); } } } }); - async_cleanup = std::make_unique<uv::async>(**loop, [this]() { + asyncCleanup = std::make_unique<uv::async>(**loop, [this]() { painter.cleanup(); }); thread = std::make_unique<uv::thread>([this]() { #ifndef NDEBUG - map_thread = uv_thread_self(); + mapThread = uv_thread_self(); #endif #ifdef __APPLE__ @@ -191,21 +191,21 @@ void Map::start() { run(); #ifndef NDEBUG - map_thread = -1; + mapThread = -1; #endif // Make sure that the stop() function knows when to stop invoking the callback function. - is_stopped = true; + isStopped = true; view.notify(); }); } void Map::stop(stop_callback cb, void *data) { - assert(uv_thread_self() == main_thread); - assert(main_thread != map_thread); + assert(uv_thread_self() == mainThread); + assert(mainThread != mapThread); assert(async); - async_terminate->send(); + asyncTerminate->send(); if (cb) { // Wait until the render thread stopped. We are using this construct instead of plainly @@ -214,7 +214,7 @@ void Map::stop(stop_callback cb, void *data) { // the case with Cocoa's NSURLRequest. Otherwise, we will eventually deadlock because this // thread (== main thread) is blocked. The callback function should use an efficient waiting // function to avoid a busy waiting loop. - while (!is_stopped) { + while (!isStopped) { cb(data); } } @@ -229,10 +229,10 @@ void Map::stop(stop_callback cb, void *data) { void Map::run() { #ifndef NDEBUG if (!async) { - map_thread = main_thread; + mapThread = mainThread; } #endif - assert(uv_thread_self() == map_thread); + assert(uv_thread_self() == mapThread); setup(); prepare(); @@ -246,7 +246,7 @@ void Map::run() { if (!async) { render(); #ifndef NDEBUG - map_thread = -1; + mapThread = -1; #endif } } @@ -255,27 +255,27 @@ void Map::rerender() { // We only send render events if we want to continuously update the map // (== async rendering). if (async) { - async_render->send(); + asyncRender->send(); } } void Map::update() { - is_clean.clear(); + isClean.clear(); rerender(); } bool Map::needsSwap() { - return is_swapped.test_and_set() == false; + return isSwapped.test_and_set() == false; } void Map::swapped() { - is_rendered.clear(); + isRendered.clear(); rerender(); } void Map::cleanup() { - if (async_cleanup != nullptr) { - async_cleanup->send(); + if (asyncCleanup != nullptr) { + asyncCleanup->send(); } } @@ -297,7 +297,7 @@ void Map::setReachability(bool reachable) { #pragma mark - Setup void Map::setup() { - assert(uv_thread_self() == map_thread); + assert(uv_thread_self() == mapThread); view.make_active(); painter.setup(); view.make_inactive(); @@ -330,9 +330,9 @@ std::string Map::getStyleJSON() const { return styleJSON; } -void Map::setAccessToken(std::string access_token) { +void Map::setAccessToken(std::string accessToken_) { // TODO: Make threadsafe. - accessToken.swap(access_token); + accessToken.swap(accessToken_); } std::string Map::getAccessToken() const { @@ -534,12 +534,12 @@ const std::vector<std::string> &Map::getAppliedClasses() const { return style->getAppliedClasses(); } -void Map::setDefaultTransitionDuration(uint64_t duration_milliseconds) { - style->setDefaultTransitionDuration(duration_milliseconds); +void Map::setDefaultTransitionDuration(uint64_t milliseconds) { + style->setDefaultTransitionDuration(milliseconds); } void Map::updateSources() { - assert(uv_thread_self() == map_thread); + assert(uv_thread_self() == mapThread); // First, disable all existing sources. for (const auto& source : activeSources) { @@ -550,14 +550,14 @@ void Map::updateSources() { updateSources(style->layers); // Then, construct or destroy the actual source object, depending on enabled state. - for (const auto& style_source : activeSources) { - if (style_source->enabled) { - if (!style_source->source) { - style_source->source = std::make_shared<Source>(style_source->info); - style_source->source->load(*this, *fileSource); + for (const auto& source : activeSources) { + if (source->enabled) { + if (!source->source) { + source->source = std::make_shared<Source>(source->info); + source->source->load(*this, *fileSource); } } else { - style_source->source.reset(); + source->source.reset(); } } |