From 0c280adebcb9b1dd050aacb1dda1ad3715128ced Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 23 Apr 2015 17:05:37 -0700 Subject: [PATCH] Move Worker to Style This ensures that worker tasks are entirely complete by the time the style is destructed, and enables us to pass Style& rather than a shared pointer. --- src/mbgl/map/map_context.cpp | 3 +-- src/mbgl/map/map_context.hpp | 1 - src/mbgl/map/source.cpp | 11 +++++------ src/mbgl/map/source.hpp | 3 --- src/mbgl/map/tile_parser.cpp | 2 +- src/mbgl/style/style.cpp | 3 ++- src/mbgl/style/style.hpp | 4 ++++ 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index ccd239253..15541a84d 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -37,7 +37,6 @@ MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, Map envScope(env, ThreadType::Map, "Map"), updated(static_cast(Update::Nothing)), asyncUpdate(util::make_unique(loop, [this] { update(); })), - workers(util::make_unique(4)), glyphStore(util::make_unique(env)), glyphAtlas(util::make_unique(1024, 1024)), spriteAtlas(util::make_unique(512, 512)), @@ -163,7 +162,7 @@ void MapContext::updateTiles() { assert(Environment::currentlyOn(ThreadType::Map)); if (!style) return; for (const auto& source : style->sources) { - source->update(data, transformState, *workers, style, *glyphAtlas, *glyphStore, *spriteAtlas, + source->update(data, transformState, style, *glyphAtlas, *glyphStore, *spriteAtlas, getSprite(), *texturePool, [this]() { assert(Environment::currentlyOn(ThreadType::Map)); triggerUpdate(); diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index 2c9f28708..ba8a4db9d 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -77,7 +77,6 @@ private: UpdateType updated { static_cast(Update::Nothing) }; std::unique_ptr asyncUpdate; - std::unique_ptr workers; std::unique_ptr glyphStore; std::unique_ptr glyphAtlas; std::unique_ptr spriteAtlas; diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 93761255b..2d4c4ec50 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -226,7 +227,6 @@ TileData::State Source::hasTile(const TileID& id) { TileData::State Source::addTile(MapData& data, const TransformState& transformState, - Worker& worker, util::ptr