diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/map.cpp | 23 | ||||
-rw-r--r-- | src/map/raster_tile_data.cpp | 4 | ||||
-rw-r--r-- | src/map/source.cpp | 12 | ||||
-rw-r--r-- | src/map/sprite.cpp | 28 | ||||
-rw-r--r-- | src/map/tile.cpp | 20 | ||||
-rw-r--r-- | src/map/tile_data.cpp | 10 | ||||
-rw-r--r-- | src/map/tile_parser.cpp | 4 | ||||
-rw-r--r-- | src/map/transform.cpp | 2 | ||||
-rw-r--r-- | src/map/transform_state.cpp | 4 | ||||
-rw-r--r-- | src/map/vector_tile.cpp | 12 | ||||
-rw-r--r-- | src/map/vector_tile_data.cpp | 4 |
11 files changed, 63 insertions, 60 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index f255c3ff65..a7520b2517 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -30,17 +30,17 @@ using namespace mbgl; -Map::Map(View& view) +Map::Map(View& view_) : loop(std::make_shared<uv::loop>()), thread(std::make_unique<uv::thread>()), async_terminate(new uv_async_t()), async_render(new uv_async_t()), async_cleanup(new uv_async_t()), - view(view), + view(view_), #ifndef NDEBUG main_thread(uv_thread_self()), #endif - transform(view), + transform(view_), glyphAtlas(std::make_shared<GlyphAtlas>(1024, 1024)), spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)), texturepool(std::make_shared<Texturepool>()), @@ -163,7 +163,6 @@ void Map::run() { // If the map rendering wasn't started asynchronously, we perform one render // *after* all events have been processed. if (!async) { - prepare(); render(); #ifndef NDEBUG map_thread = -1; @@ -206,10 +205,13 @@ void Map::cleanup(uv_async_t *async) { #endif Map *map = static_cast<Map *>(async->data); - map->view.make_active(); map->painter.cleanup(); } +void Map::terminate() { + painter.terminate(); +} + void Map::setReachability(bool reachable) { // Note: This function may be called from *any* thread. if (reachable) { @@ -271,8 +273,8 @@ void Map::terminate(uv_async_t *async) { void Map::setup() { assert(uv_thread_self() == map_thread); view.make_active(); - painter.setup(); + view.make_inactive(); } void Map::setStyleURL(const std::string &url) { @@ -605,8 +607,6 @@ void Map::updateRenderState() { } void Map::prepare() { - view.make_active(); - if (!fileSource) { fileSource = std::make_shared<FileSource>(**loop, platform::defaultCacheDatabase()); glyphStore = std::make_shared<GlyphStore>(fileSource); @@ -651,9 +651,8 @@ void Map::prepare() { } void Map::render() { -#if defined(DEBUG) - std::vector<std::string> debug; -#endif + view.make_active(); + painter.clear(); painter.resize(); @@ -685,6 +684,8 @@ void Map::render() { } glFlush(); + + view.make_inactive(); } void Map::renderLayers(util::ptr<StyleLayerGroup> group) { diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp index e7725b7abd..99ca327fe7 100644 --- a/src/map/raster_tile_data.cpp +++ b/src/map/raster_tile_data.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -RasterTileData::RasterTileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source) - : TileData(id, map, source), +RasterTileData::RasterTileData(Tile::ID id_, Map &map_, const util::ptr<SourceInfo> &source_) + : TileData(id_, map_, source_), bucket(map.getTexturepool(), properties) { } diff --git a/src/map/source.cpp b/src/map/source.cpp index 36f1a71c84..9c0f7caf28 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -18,10 +18,12 @@ #include <mbgl/map/vector_tile_data.hpp> #include <mbgl/map/raster_tile_data.hpp> +#include <algorithm> + namespace mbgl { -Source::Source(const util::ptr<SourceInfo>& info) - : info(info) +Source::Source(const util::ptr<SourceInfo>& info_) + : info(info_) { } @@ -219,15 +221,15 @@ std::forward_list<Tile::ID> Source::coveringTiles(const TransformState& state) c box points = state.cornersToBox(z); const vec2<double>& center = points.center; - std::forward_list<Tile::ID> tiles = Tile::cover(z, points); + std::forward_list<Tile::ID> covering_tiles = Tile::cover(z, points); - tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { + covering_tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { // Sorts by distance from the box center return std::fabs(a.x - center.x) + std::fabs(a.y - center.y) < std::fabs(b.x - center.x) + std::fabs(b.y - center.y); }); - return tiles; + return covering_tiles; } /** diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index c069ece45a..876586e4b0 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -13,13 +13,13 @@ using namespace mbgl; -SpritePosition::SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio, bool sdf) - : x(x), - y(y), - width(width), - height(height), - pixelRatio(pixelRatio), - sdf(sdf) { +SpritePosition::SpritePosition(uint16_t x_, uint16_t y_, uint16_t width_, uint16_t height_, float pixelRatio_, bool sdf_) + : x(x_), + y(y_), + width(width_), + height(height_), + pixelRatio(pixelRatio_), + sdf(sdf_) { } util::ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, const util::ptr<FileSource> &fileSource) { @@ -28,11 +28,11 @@ util::ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, return sprite; } -Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio) +Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio_) : valid(base_url.length() > 0), - pixelRatio(pixelRatio), - spriteURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".png"), - jsonURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".json"), + pixelRatio(pixelRatio_), + spriteURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".png"), + jsonURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".json"), raster(), loadedImage(false), loadedJSON(false), @@ -123,16 +123,16 @@ void Sprite::parseJSON() { uint16_t y = 0; uint16_t width = 0; uint16_t height = 0; - float pixelRatio = 1.0f; + float spritePixelRatio = 1.0f; bool sdf = false; if (value.HasMember("x")) x = value["x"].GetInt(); if (value.HasMember("y")) y = value["y"].GetInt(); if (value.HasMember("width")) width = value["width"].GetInt(); if (value.HasMember("height")) height = value["height"].GetInt(); - if (value.HasMember("pixelRatio")) pixelRatio = value["pixelRatio"].GetInt(); + if (value.HasMember("pixelRatio")) spritePixelRatio = value["pixelRatio"].GetInt(); if (value.HasMember("sdf")) sdf = value["sdf"].GetBool(); - pos.emplace(name, SpritePosition { x, y, width, height, pixelRatio, sdf }); + pos.emplace(name, SpritePosition { x, y, width, height, spritePixelRatio, sdf }); } } } else { diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 863fbfbece..3070d3fd96 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -7,8 +7,8 @@ using namespace mbgl; #include <iostream> -Tile::Tile(const ID& id) - : id(id) { +Tile::Tile(const ID& id_) + : id(id_) { } Tile::ID Tile::ID::parent(int8_t parent_z) const { @@ -25,13 +25,13 @@ std::forward_list<Tile::ID> Tile::ID::children(int32_t child_z) const { assert(child_z > z); int32_t factor = std::pow(2, child_z - z); - std::forward_list<ID> children; + std::forward_list<ID> child_ids; for (int32_t ty = y * factor, y_max = (y + 1) * factor; ty < y_max; ++ty) { for (int32_t tx = x * factor, x_max = (x + 1) * factor; tx < x_max; ++tx) { - children.emplace_front(child_z, tx, ty); + child_ids.emplace_front(child_z, tx, ty); } } - return children; + return child_ids; } Tile::ID Tile::ID::normalized() const { @@ -42,13 +42,13 @@ Tile::ID Tile::ID::normalized() const { return ID { z, nx, ny }; } -bool Tile::ID::isChildOf(const Tile::ID &parent) const { - if (parent.z >= z || parent.w != w) { +bool Tile::ID::isChildOf(const Tile::ID &parent_id) const { + if (parent_id.z >= z || parent_id.w != w) { return false; } - int32_t scale = std::pow(2, z - parent.z); - return parent.x == ((x < 0 ? x - scale + 1 : x) / scale) && - parent.y == y / scale; + int32_t scale = std::pow(2, z - parent_id.z); + return parent_id.x == ((x < 0 ? x - scale + 1 : x) / scale) && + parent_id.y == y / scale; } diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 44e3826bf5..7e4d1a1de1 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -9,14 +9,14 @@ using namespace mbgl; -TileData::TileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source) - : id(id), +TileData::TileData(Tile::ID id_, Map &map_, const util::ptr<SourceInfo> &source_) + : id(id_), state(State::initial), - map(map), - source(source), + map(map_), + source(source_), debugBucket(debugFontBuffer) { // Initialize tile debug coordinates - const std::string str = util::sprintf<32>("%d/%d/%d", id.z, id.x, id.y); + const std::string str = util::sprintf<32>("%d/%d/%d", id_.z, id_.x, id_.y); debugFontBuffer.addText(str.c_str(), 50, 200, 5); } diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 3dc5cb9cef..235151cd47 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -37,14 +37,14 @@ namespace mbgl { // its header file. TileParser::~TileParser() = default; -TileParser::TileParser(const std::string &data, VectorTileData &tile, +TileParser::TileParser(const std::string &data, VectorTileData &tile_, const util::ptr<const Style> &style_, const util::ptr<GlyphAtlas> &glyphAtlas_, const util::ptr<GlyphStore> &glyphStore_, const util::ptr<SpriteAtlas> &spriteAtlas_, const util::ptr<Sprite> &sprite_) : vector_data(pbf((const uint8_t *)data.data(), data.size())), - tile(tile), + tile(tile_), style(style_), glyphAtlas(glyphAtlas_), glyphStore(glyphStore_), diff --git a/src/map/transform.cpp b/src/map/transform.cpp index baa615b94a..b42f24a83d 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -17,7 +17,7 @@ const double R2D = 180.0 / M_PI; const double M2PI = 2 * M_PI; const double MIN_ROTATE_SCALE = 8; -Transform::Transform(View &view) : view(view), mtx(std::make_unique<uv::rwlock>()) { +Transform::Transform(View &view_) : view(view_), mtx(std::make_unique<uv::rwlock>()) { setScale(current.scale); setAngle(current.angle); } diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index 4b1bc4161e..0a858bce6a 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -96,8 +96,8 @@ float TransformState::lngX(float lon) const { } float TransformState::latY(float lat) const { - float y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); - return (180 - y) * worldSize() / 360; + float lat_y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); + return (180 - lat_y) * worldSize() / 360; } std::array<float, 2> TransformState::locationCoordinate(float lon, float lat) const { diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index 4ec25d6cf6..8f097c8292 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -103,9 +103,9 @@ VectorTileLayer::VectorTileLayer(pbf layer) : data(layer) { } } -FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer, const FilterExpression &filterExpression) - : layer(layer), - filterExpression(filterExpression) { +FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer_, const FilterExpression &filterExpression_) + : layer(layer_), + filterExpression(filterExpression_) { } FilteredVectorTileLayer::iterator FilteredVectorTileLayer::begin() const { @@ -116,10 +116,10 @@ FilteredVectorTileLayer::iterator FilteredVectorTileLayer::end() const { return iterator(*this, pbf(layer.data.end, 0)); } -FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent, const pbf& data) - : parent(parent), +FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent_, const pbf& data_) + : parent(parent_), feature(pbf()), - data(data) { + data(data_) { operator++(); } diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index 48b46059a5..b94bc66dea 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -8,8 +8,8 @@ using namespace mbgl; -VectorTileData::VectorTileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source) - : TileData(id, map, source), +VectorTileData::VectorTileData(Tile::ID id_, Map &map_, const util::ptr<SourceInfo> &source_) + : TileData(id_, map_, source_), depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) { } |