diff --git a/.clang-format b/.clang-format index 109b562b5..ff0f39e73 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 98cf2d353..07bfab089 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 callback) { +void Environment::requestAsync(const Resource& resource, + std::function callback) { fileSource.request(resource, *this, std::move(callback)); } -Request *Environment::request(const Resource &resource, std::function callback) { +Request* Environment::request(const Resource& resource, + std::function 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 97813d358..e5d5f6e8b 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); - Request *request(const Resource &, std::function); - void cancelRequest(Request *); + void requestAsync(const Resource&, std::function); + Request* request(const Resource&, std::function); + 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 92777f67f..192efb7dc 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_, - 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 6b9d0a047..7874d6ff5 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, - const SourceInfo&, - Environment&); + const SourceInfo&); ~LiveTileData(); void parse() override; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 7af3b54de..22e6cbceb 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -694,7 +694,7 @@ void Map::updateSources(const util::ptr &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 4cd7fc2b5..b8862e6dd 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 2413e13fb..76bc1bb5a 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 b13a76c20..3036342d7 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