diff options
-rw-r--r-- | include/mbgl/map/map.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/map/map_context.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/map/map_context.hpp | 4 |
4 files changed, 13 insertions, 11 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 582eb430ac..1ec12eb255 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -175,7 +175,6 @@ private: void resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight); util::ptr<Sprite> getSprite(); - Worker& getWorker(); // Checks if render thread needs to pause void checkForPause(); @@ -215,7 +214,6 @@ private: std::unique_ptr<MapContext> context; private: - std::unique_ptr<Worker> workers; std::thread thread; std::unique_ptr<uv::async> asyncTerminate; std::unique_ptr<uv::async> asyncUpdate; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 62ed60f3bd..da16f2d8da 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -86,7 +86,6 @@ Map::~Map() { // Explicitly reset all pointers. style.reset(); - workers.reset(); context.reset(); uv_run(env->loop, UV_RUN_DEFAULT); @@ -94,11 +93,6 @@ Map::~Map() { env->performCleanup(); } -Worker& Map::getWorker() { - assert(workers); - return *workers; -} - void Map::start(bool startPaused, Mode renderMode) { assert(Environment::currentlyOn(ThreadType::Main)); assert(mode == Mode::None); @@ -119,7 +113,7 @@ void Map::start(bool startPaused, Mode renderMode) { // It's now safe to destroy/join the workers since there won't be any more callbacks that // could dispatch to the worker pool. - workers.reset(); + context->workers.reset(); terminating = true; @@ -263,7 +257,7 @@ void Map::run() { view.activate(); view.discard(); - workers = util::make_unique<Worker>(env->loop, 4); + context->workers = util::make_unique<Worker>(env->loop, 4); setup(); prepare(); @@ -744,7 +738,7 @@ void Map::updateTiles() { assert(Environment::currentlyOn(ThreadType::Map)); if (!style) return; for (const auto& source : style->sources) { - source->update(*data, getWorker(), style, *context->glyphAtlas, *context->glyphStore, + source->update(*data, context->getWorker(), style, *context->glyphAtlas, *context->glyphStore, *context->spriteAtlas, getSprite(), *context->texturePool, [this]() { assert(Environment::currentlyOn(ThreadType::Map)); triggerUpdate(); diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 258c4ab4c4..cad2bd8991 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -11,6 +11,7 @@ #include <mbgl/util/std.hpp> #include <mbgl/util/uv_detail.hpp> +#include <mbgl/util/worker.hpp> #include <mbgl/util/texture_pool.hpp> namespace mbgl { @@ -24,4 +25,9 @@ MapContext::MapContext(Environment& env) painter(util::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas)) { } +Worker& MapContext::getWorker() { + assert(workers); + return *workers; +} + }
\ No newline at end of file diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index 694b82f43f..cbe5994aed 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -17,12 +17,16 @@ class Painter; class Sprite; class StyleSource; class StyleLayerGroup; +class Worker; class MapContext { public: MapContext(Environment&); + Worker& getWorker(); + public: + std::unique_ptr<Worker> workers; const std::unique_ptr<GlyphStore> glyphStore; const std::unique_ptr<GlyphAtlas> glyphAtlas; const std::unique_ptr<SpriteAtlas> spriteAtlas; |