diff options
-rw-r--r-- | .clang-format | 4 | ||||
-rw-r--r-- | src/mbgl/map/environment.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/map/environment.hpp | 13 | ||||
-rw-r--r-- | src/mbgl/map/live_tile_data.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/map/live_tile_data.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/raster_tile_data.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/raster_tile_data.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/source.cpp | 23 | ||||
-rw-r--r-- | src/mbgl/map/source.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/tile_data.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/map/tile_data.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/vector_tile_data.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/map/vector_tile_data.hpp | 3 |
14 files changed, 43 insertions, 48 deletions
diff --git a/.clang-format b/.clang-format index 109b562b59..ff0f39e73b 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,7 @@ Standard: Cpp11 IndentWidth: 4 AccessModifierOffset: -4 UseTab: Never -BinPackParameters: true +BinPackParameters: false AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AllowShortBlocksOnASingleLine: false @@ -10,7 +10,7 @@ AllowShortFunctionsOnASingleLine: false ConstructorInitializerAllOnOneLineOrOnePerLine: true AlwaysBreakTemplateDeclarations: true NamespaceIndentation: None -PointerBindsToType: false +PointerBindsToType: true SpacesInParentheses: false BreakBeforeBraces: Attach ColumnLimit: 100 diff --git a/src/mbgl/map/environment.cpp b/src/mbgl/map/environment.cpp index 98cf2d353e..07bfab089c 100644 --- a/src/mbgl/map/environment.cpp +++ b/src/mbgl/map/environment.cpp @@ -35,7 +35,7 @@ public: // FIXME: We should never need to overwrite a thread here and we only allow // this today because on the Static mode, the Map thread and the Main thread // are same. Replace this with emplace() when this gets fixed. - threadSet[std::this_thread::get_id()] = ThreadInfo{env, type, name}; + threadSet[std::this_thread::get_id()] = ThreadInfo{ env, type, name }; } void unregisterThread() { @@ -80,7 +80,7 @@ Environment::Scope::~Scope() { threadInfoStore.unregisterThread(); } -Environment::Environment(FileSource &fs) : fileSource(fs), loop(uv_loop_new()) { +Environment::Environment(FileSource& fs) : fileSource(fs), loop(uv_loop_new()) { } Environment& Environment::Get() { @@ -102,16 +102,18 @@ std::string Environment::threadName() { return threadInfoStore.getThreadInfo().name; } -void Environment::requestAsync(const Resource &resource, std::function<void(const Response &)> callback) { +void Environment::requestAsync(const Resource& resource, + std::function<void(const Response&)> callback) { fileSource.request(resource, *this, std::move(callback)); } -Request *Environment::request(const Resource &resource, std::function<void(const Response &)> callback) { +Request* Environment::request(const Resource& resource, + std::function<void(const Response&)> callback) { assert(currentlyOn(ThreadType::Map)); return fileSource.request(resource, loop, *this, std::move(callback)); } -void Environment::cancelRequest(Request *req) { +void Environment::cancelRequest(Request* req) { assert(currentlyOn(ThreadType::Map)); fileSource.cancel(req); } diff --git a/src/mbgl/map/environment.hpp b/src/mbgl/map/environment.hpp index 97813d3589..e5d5f6e8b8 100644 --- a/src/mbgl/map/environment.hpp +++ b/src/mbgl/map/environment.hpp @@ -20,6 +20,7 @@ enum class ThreadType : uint8_t { Unknown = 0, Main = 1 << 0, Map = 1 << 1, + TileWorker = 1 << 2, }; class Environment final : private util::noncopyable { @@ -33,25 +34,25 @@ public: std::thread::id id; }; - Environment(FileSource &); + Environment(FileSource&); static Environment& Get(); static bool inScope(); static bool currentlyOn(ThreadType); static std::string threadName(); - void requestAsync(const Resource &, std::function<void(const Response &)>); - Request *request(const Resource &, std::function<void(const Response &)>); - void cancelRequest(Request *); + void requestAsync(const Resource&, std::function<void(const Response&)>); + Request* request(const Resource&, std::function<void(const Response&)>); + void cancelRequest(Request*); // Request to terminate the environment. void terminate(); private: - FileSource &fileSource; + FileSource& fileSource; public: - uv_loop_t *const loop; + uv_loop_t* const loop; }; } diff --git a/src/mbgl/map/live_tile_data.cpp b/src/mbgl/map/live_tile_data.cpp index 92777f67f0..192efb7dcf 100644 --- a/src/mbgl/map/live_tile_data.cpp +++ b/src/mbgl/map/live_tile_data.cpp @@ -15,10 +15,9 @@ LiveTileData::LiveTileData(Tile::ID const& id_, GlyphStore& glyphStore_, SpriteAtlas& spriteAtlas_, util::ptr<Sprite> sprite_, - const SourceInfo& source_, - Environment& env_) + const SourceInfo& source_) : VectorTileData::VectorTileData(id_, mapMaxZoom, style_, glyphAtlas_, glyphStore_, - spriteAtlas_, sprite_, source_, env_), + spriteAtlas_, sprite_, source_), annotationManager(annotationManager_) { // live features are always ready state = State::loaded; diff --git a/src/mbgl/map/live_tile_data.hpp b/src/mbgl/map/live_tile_data.hpp index 6b9d0a047a..7874d6ff55 100644 --- a/src/mbgl/map/live_tile_data.hpp +++ b/src/mbgl/map/live_tile_data.hpp @@ -17,8 +17,7 @@ public: GlyphStore&, SpriteAtlas&, util::ptr<Sprite>, - const SourceInfo&, - Environment&); + const SourceInfo&); ~LiveTileData(); void parse() override; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 7af3b54ded..22e6cbcebb 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -694,7 +694,7 @@ void Map::updateSources(const util::ptr<StyleLayerGroup> &group) { void Map::updateTiles() { assert(Environment::currentlyOn(ThreadType::Map)); for (const auto &source : activeSources) { - source->source->update(*this, *env, getWorker(), style, *glyphAtlas, *glyphStore, + source->source->update(*this, getWorker(), style, *glyphAtlas, *glyphStore, *spriteAtlas, getSprite(), *texturePool, [this]() { assert(Environment::currentlyOn(ThreadType::Map)); triggerUpdate(); diff --git a/src/mbgl/map/raster_tile_data.cpp b/src/mbgl/map/raster_tile_data.cpp index 4cd7fc2b5e..b8862e6dd8 100644 --- a/src/mbgl/map/raster_tile_data.cpp +++ b/src/mbgl/map/raster_tile_data.cpp @@ -5,8 +5,8 @@ using namespace mbgl; RasterTileData::RasterTileData(Tile::ID const &id_, TexturePool &texturePool, - const SourceInfo &source_, Environment &env_) - : TileData(id_, source_, env_), bucket(texturePool, layout) { + const SourceInfo &source_) + : TileData(id_, source_), bucket(texturePool, layout) { } RasterTileData::~RasterTileData() { diff --git a/src/mbgl/map/raster_tile_data.hpp b/src/mbgl/map/raster_tile_data.hpp index 2413e13fb0..76bc1bb5aa 100644 --- a/src/mbgl/map/raster_tile_data.hpp +++ b/src/mbgl/map/raster_tile_data.hpp @@ -17,7 +17,7 @@ class RasterTileData : public TileData { friend class TileParser; public: - RasterTileData(Tile::ID const &id, TexturePool &, const SourceInfo &, Environment &); + RasterTileData(Tile::ID const &id, TexturePool &, const SourceInfo &); ~RasterTileData(); void parse() override; diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index b13a76c205..3036342d78 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -155,7 +155,7 @@ TileData::State Source::hasTile(const Tile::ID& id) { return TileData::State::invalid; } -TileData::State Source::addTile(Map &map, Environment &env, uv::worker &worker, +TileData::State Source::addTile(Map &map, uv::worker &worker, util::ptr<Style> style, GlyphAtlas &glyphAtlas, GlyphStore &glyphStore, SpriteAtlas &spriteAtlas, util::ptr<Sprite> sprite, TexturePool &texturePool, @@ -187,22 +187,18 @@ TileData::State Source::addTile(Map &map, Environment &env, uv::worker &worker, if (!new_tile.data) { // If we don't find working tile data, we're just going to load it. if (info.type == SourceType::Vector) { - new_tile.data = std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style, - glyphAtlas, glyphStore, - spriteAtlas, sprite, - info, env); + new_tile.data = + std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style, glyphAtlas, + glyphStore, spriteAtlas, sprite, info); new_tile.data->request(worker, map.getState().getPixelRatio(), callback); } else if (info.type == SourceType::Raster) { - new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info, env); + new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info); new_tile.data->request(worker, map.getState().getPixelRatio(), callback); } else if (info.type == SourceType::Annotations) { AnnotationManager& annotationManager = map.getAnnotationManager(); - new_tile.data = std::make_shared<LiveTileData>(normalized_id, - annotationManager, - map.getMaxZoom(), style, - glyphAtlas, glyphStore, - spriteAtlas, sprite, - info, env); + new_tile.data = std::make_shared<LiveTileData>(normalized_id, annotationManager, + map.getMaxZoom(), style, glyphAtlas, + glyphStore, spriteAtlas, sprite, info); new_tile.data->reparse(worker, callback); } else { throw std::runtime_error("source type not implemented"); @@ -293,7 +289,6 @@ bool Source::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std:: } void Source::update(Map &map, - Environment &env, uv::worker &worker, util::ptr<Style> style, GlyphAtlas &glyphAtlas, @@ -322,7 +317,7 @@ void Source::update(Map &map, // Add existing child/parent tiles if the actual tile is not yet loaded for (const Tile::ID& id : required) { - const TileData::State state = addTile(map, env, worker, style, glyphAtlas, glyphStore, + const TileData::State state = addTile(map, worker, style, glyphAtlas, glyphStore, spriteAtlas, sprite, texturePool, id, callback); if (state != TileData::State::parsed) { diff --git a/src/mbgl/map/source.hpp b/src/mbgl/map/source.hpp index 211713015c..f5ffd29adc 100644 --- a/src/mbgl/map/source.hpp +++ b/src/mbgl/map/source.hpp @@ -35,7 +35,7 @@ public: Source(SourceInfo&); void load(Map &, Environment &); - void update(Map &, Environment &, uv::worker &, util::ptr<Style>, GlyphAtlas &, GlyphStore &, + void update(Map &, uv::worker &, util::ptr<Style>, GlyphAtlas &, GlyphStore &, SpriteAtlas &, util::ptr<Sprite>, TexturePool &, std::function<void()> callback); void invalidateTiles(Map&, std::vector<Tile::ID>&); @@ -56,7 +56,7 @@ private: int32_t coveringZoomLevel(const TransformState&) const; std::forward_list<Tile::ID> coveringTiles(const TransformState&) const; - TileData::State addTile(Map &, Environment &, uv::worker &, util::ptr<Style>, GlyphAtlas &, + TileData::State addTile(Map &, uv::worker &, util::ptr<Style>, GlyphAtlas &, GlyphStore &, SpriteAtlas &, util::ptr<Sprite>, TexturePool &, const Tile::ID &, std::function<void()> callback); diff --git a/src/mbgl/map/tile_data.cpp b/src/mbgl/map/tile_data.cpp index 7b379e9fe3..aed182671b 100644 --- a/src/mbgl/map/tile_data.cpp +++ b/src/mbgl/map/tile_data.cpp @@ -12,12 +12,12 @@ using namespace mbgl; -TileData::TileData(Tile::ID const& id_, const SourceInfo& source_, Environment& env_) +TileData::TileData(Tile::ID const& id_, const SourceInfo& source_) : id(id_), name(id), state(State::initial), source(source_), - env(env_), + env(Environment::Get()), debugBucket(debugFontBuffer) { // Initialize tile debug coordinates debugFontBuffer.addText(name.c_str(), 50, 200, 5); @@ -96,7 +96,8 @@ void TileData::reparse(uv::worker& worker, std::function<void()> callback) // the after work handler new uv::work<util::ptr<TileData>>( worker, - [](util::ptr<TileData>& tile) { + [this](util::ptr<TileData>& tile) { + Environment::Scope scope(env, ThreadType::TileWorker, "TileWorker_" + tile->name); tile->parse(); }, [callback](util::ptr<TileData>&) { diff --git a/src/mbgl/map/tile_data.hpp b/src/mbgl/map/tile_data.hpp index 66c0fbba2e..cce346d835 100644 --- a/src/mbgl/map/tile_data.hpp +++ b/src/mbgl/map/tile_data.hpp @@ -48,7 +48,7 @@ public: }; public: - TileData(Tile::ID const &id, const SourceInfo &, Environment &); + TileData(Tile::ID const &id, const SourceInfo &); ~TileData(); void request(uv::worker&, float pixelRatio, std::function<void ()> callback); @@ -72,7 +72,7 @@ public: public: const SourceInfo& source; - Environment &env; + Environment& env; protected: Request *req = nullptr; diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp index 3e318b0856..3bed7a1c32 100644 --- a/src/mbgl/map/vector_tile_data.cpp +++ b/src/mbgl/map/vector_tile_data.cpp @@ -17,9 +17,8 @@ VectorTileData::VectorTileData(Tile::ID const& id_, GlyphStore& glyphStore_, SpriteAtlas& spriteAtlas_, util::ptr<Sprite> sprite_, - const SourceInfo& source_, - Environment& env_) - : TileData(id_, source_, env_), + const SourceInfo& source_) + : TileData(id_, source_), glyphAtlas(glyphAtlas_), glyphStore(glyphStore_), spriteAtlas(spriteAtlas_), diff --git a/src/mbgl/map/vector_tile_data.hpp b/src/mbgl/map/vector_tile_data.hpp index e097c9bc59..7f43d824ac 100644 --- a/src/mbgl/map/vector_tile_data.hpp +++ b/src/mbgl/map/vector_tile_data.hpp @@ -37,8 +37,7 @@ public: GlyphStore&, SpriteAtlas&, util::ptr<Sprite>, - const SourceInfo&, - Environment&); + const SourceInfo&); ~VectorTileData(); void parse() override; |