move worker to MapContext
This commit is contained in:
committed by
John Firebaugh
parent
67fa80f5e9
commit
f272d13dea
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user