diff --git a/src/mbgl/map/annotation.cpp b/src/mbgl/map/annotation.cpp index 7a7a0ed68..9d21b4e48 100644 --- a/src/mbgl/map/annotation.cpp +++ b/src/mbgl/map/annotation.cpp @@ -125,7 +125,7 @@ AnnotationManager::addPointAnnotations(const std::vector& points, uint32_t y = p.y * z2; for (int8_t z = maxZoom; z >= 0; z--) { - affectedTiles.emplace_back(z, x, y); + affectedTiles.emplace_back(z, x, y, z); TileID tileID = affectedTiles.back(); // calculate tile coordinate @@ -214,7 +214,7 @@ std::vector AnnotationManager::removeAnnotations(const AnnotationIDs& id p = projectPoint(latLng); x = z2s[z] * p.x; y = z2s[z] * p.y; - TileID tid(z, x, y); + TileID tid(z, x, y, z); // erase annotation from tile's list auto& tileAnnotations = tiles[tid].first; tileAnnotations.erase(annotationID); @@ -245,8 +245,8 @@ std::vector AnnotationManager::getAnnotationsInBounds(const LatLngBoun const vec2 nePoint = projectPoint(queryBounds.ne); // tiles number y from top down - const TileID nwTile(z, swPoint.x * z2, nePoint.y * z2); - const TileID seTile(z, nePoint.x * z2, swPoint.y * z2); + const TileID nwTile(z, swPoint.x * z2, nePoint.y * z2, z); + const TileID seTile(z, nePoint.x * z2, swPoint.y * z2, z); std::vector matchingAnnotations; diff --git a/src/mbgl/map/live_tile_data.cpp b/src/mbgl/map/live_tile_data.cpp index d63ea4347..f2b5e0427 100644 --- a/src/mbgl/map/live_tile_data.cpp +++ b/src/mbgl/map/live_tile_data.cpp @@ -10,17 +10,17 @@ using namespace mbgl; LiveTileData::LiveTileData(const TileID& id_, AnnotationManager& annotationManager_, - float mapMaxZoom, Style& style_, GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_, SpriteAtlas& spriteAtlas_, util::ptr sprite_, const SourceInfo& source_, + float overscaling_, float angle_, bool collisionDebug_) - : VectorTileData::VectorTileData(id_, mapMaxZoom, style_, glyphAtlas_, glyphStore_, - spriteAtlas_, sprite_, source_, angle_, collisionDebug_), + : VectorTileData::VectorTileData(id_, style_, glyphAtlas_, glyphStore_, + spriteAtlas_, sprite_, source_, overscaling_, angle_, collisionDebug_), annotationManager(annotationManager_) { // live features are always ready setState(State::loaded); diff --git a/src/mbgl/map/live_tile_data.hpp b/src/mbgl/map/live_tile_data.hpp index 0247c47fa..7066fe13c 100644 --- a/src/mbgl/map/live_tile_data.hpp +++ b/src/mbgl/map/live_tile_data.hpp @@ -11,7 +11,6 @@ class LiveTileData : public VectorTileData { public: LiveTileData(const TileID&, AnnotationManager&, - float mapMaxZoom, Style&, GlyphAtlas&, GlyphStore&, @@ -19,6 +18,7 @@ public: util::ptr, const SourceInfo&, float, + float, bool); ~LiveTileData(); diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 3d7ab6fd3..331e48436 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -99,7 +99,7 @@ std::string SourceInfo::tileURL(const TileID& id, float pixelRatio) const { std::string result = tiles.at((id.x + id.y) % tiles.size()); result = util::mapbox::normalizeTileURL(result, url, type); result = util::replaceTokens(result, [&](const std::string &token) -> std::string { - if (token == "z") return util::toString(id.z); + if (token == "z") return util::toString(std::min(id.z, static_cast(max_zoom))); if (token == "x") return util::toString(id.x); if (token == "y") return util::toString(id.y); if (token == "prefix") { @@ -172,7 +172,7 @@ void Source::load(const std::string& accessToken) { void Source::updateMatrices(const mat4 &projMatrix, const TransformState &transform) { for (const auto& pair : tiles) { Tile &tile = *pair.second; - transform.matrixFor(tile.matrix, tile.id); + transform.matrixFor(tile.matrix, tile.id, std::min(static_cast(info.max_zoom), tile.id.z)); matrix::multiply(tile.matrix, projMatrix, tile.matrix); } } @@ -260,7 +260,8 @@ TileData::State Source::addTile(MapData& data, return state; } - auto pos = tiles.emplace(id, util::make_unique(id)); + const float overscaling = id.z > info.max_zoom ? std::pow(2.0f, id.z - info.max_zoom) : 1.0f; + auto pos = tiles.emplace(id, util::make_unique(id));//, util::tileSize * overscaling)); Tile& new_tile = *pos.first->second; // We couldn't find the tile in the list. Create a new one. @@ -287,16 +288,18 @@ TileData::State Source::addTile(MapData& 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(normalized_id, data.transform.getMaxZoom(), style, glyphAtlas, - glyphStore, spriteAtlas, sprite, info, transformState.getAngle(), data.getCollisionDebug()); + std::make_shared(normalized_id, style, glyphAtlas, + glyphStore, spriteAtlas, sprite, info, + overscaling, transformState.getAngle(), data.getCollisionDebug()); new_tile.data->request(style.workers, transformState.getPixelRatio(), callback); } else if (info.type == SourceType::Raster) { new_tile.data = std::make_shared(normalized_id, texturePool, info); new_tile.data->request(style.workers, transformState.getPixelRatio(), callback); } else if (info.type == SourceType::Annotations) { new_tile.data = std::make_shared(normalized_id, data.annotationManager, - data.transform.getMaxZoom(), style, glyphAtlas, - glyphStore, spriteAtlas, sprite, info, transformState.getAngle(), data.getCollisionDebug()); + style, glyphAtlas, + glyphStore, spriteAtlas, sprite, info, + overscaling, transformState.getAngle(), data.getCollisionDebug()); new_tile.data->reparse(style.workers, callback); } else { throw std::runtime_error("source type not implemented"); @@ -319,6 +322,11 @@ int32_t Source::coveringZoomLevel(const TransformState& state) const { std::forward_list Source::coveringTiles(const TransformState& state) const { int32_t z = coveringZoomLevel(state); + auto actualZ = z; + const bool reparseOverscaled = + info.type == SourceType::Vector || + info.type == SourceType::Annotations; + if (z < info.min_zoom) return {{}}; if (z > info.max_zoom) z = info.max_zoom; @@ -326,7 +334,7 @@ std::forward_list Source::coveringTiles(const TransformState& state) con box points = state.cornersToBox(z); const vec2& center = points.center; - std::forward_list covering_tiles = tileCover(z, points); + std::forward_list covering_tiles = tileCover(z, points, reparseOverscaled ? actualZ : z); covering_tiles.sort([¢er](const TileID& a, const TileID& b) { // Sorts by distance from the box center @@ -349,7 +357,7 @@ std::forward_list Source::coveringTiles(const TransformState& state) con bool Source::findLoadedChildren(const TileID& id, int32_t maxCoveringZoom, std::forward_list& retain) { bool complete = true; int32_t z = id.z; - auto ids = id.children(z + 1); + auto ids = id.children(info.max_zoom); for (const auto& child_id : ids) { const TileData::State state = hasTile(child_id); if (TileData::isReadyState(state)) { @@ -376,7 +384,7 @@ bool Source::findLoadedChildren(const TileID& id, int32_t maxCoveringZoom, std:: */ bool Source::findLoadedParent(const TileID& id, int32_t minCoveringZoom, std::forward_list& retain) { for (int32_t z = id.z - 1; z >= minCoveringZoom; --z) { - const TileID parent_id = id.parent(z); + const TileID parent_id = id.parent(z, info.max_zoom); const TileData::State state = hasTile(parent_id); if (TileData::isReadyState(state)) { retain.emplace_front(parent_id); diff --git a/src/mbgl/map/tile_id.cpp b/src/mbgl/map/tile_id.cpp index 518ee14c4..ad7ec2e0f 100644 --- a/src/mbgl/map/tile_id.cpp +++ b/src/mbgl/map/tile_id.cpp @@ -5,35 +5,49 @@ namespace mbgl { -TileID TileID::parent(int8_t parent_z) const { +TileID TileID::parent(int8_t parent_z, int8_t sourceMaxZoom) const { assert(parent_z < z); - int32_t dim = std::pow(2, z - parent_z); - return TileID{ - parent_z, - (x >= 0 ? x : x - dim + 1) / dim, - y / dim - }; -} - -std::forward_list TileID::children(int32_t child_z) const { - assert(child_z > z); - int32_t factor = std::pow(2, child_z - z); - - std::forward_list 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) { - child_ids.emplace_front(child_z, tx, ty); + auto newX = x; + auto newY = y; + for (auto newZ = z; newZ > parent_z; newZ--) { + if (newZ > sourceMaxZoom) { + // the id represents an overscaled tile, return the same coordinates with a lower z + // do nothing + } else { + newX = newX / 2; + newY = newY / 2; } } + + return TileID{parent_z, newX, newY, parent_z > sourceMaxZoom ? sourceMaxZoom : parent_z}; +} + +std::forward_list TileID::children(int8_t sourceMaxZoom) const { + auto childZ = z + 1; + + std::forward_list child_ids; + if (z >= sourceMaxZoom) { + // return a single tile id representing a an overscaled tile + child_ids.emplace_front(childZ, x, y, sourceMaxZoom); + + } else { + auto childX = x * 2; + auto childY = y * 2; + child_ids.emplace_front(childZ, childX, childY, childZ); + child_ids.emplace_front(childZ, childX + 1, childY, childZ); + child_ids.emplace_front(childZ, childX, childY + 1, childZ); + child_ids.emplace_front(childZ, childX + 1, childY + 1, childZ); + } + return child_ids; } TileID TileID::normalized() const { - int32_t dim = std::pow(2, z); + int32_t dim = std::pow(2, sourceZ); int32_t nx = x, ny = y; while (nx < 0) nx += dim; while (nx >= dim) nx -= dim; - return TileID { z, nx, ny }; + return TileID { z, nx, ny, sourceZ}; } bool TileID::isChildOf(const TileID &parent_id) const { diff --git a/src/mbgl/map/tile_id.hpp b/src/mbgl/map/tile_id.hpp index 056fcdbfa..f2e2171f1 100644 --- a/src/mbgl/map/tile_id.hpp +++ b/src/mbgl/map/tile_id.hpp @@ -14,9 +14,12 @@ public: const int16_t w = 0; const int8_t z = 0; const int32_t x = 0, y = 0; + const int8_t sourceZ; + const float overscaling; - inline explicit TileID(int8_t z_, int32_t x_, int32_t y_) - : w((x_ < 0 ? x_ - (1 << z_) + 1 : x_) / (1 << z_)), z(z_), x(x_), y(y_) {} + inline explicit TileID(int8_t z_, int32_t x_, int32_t y_, int8_t sourceZ_) + : w((x_ < 0 ? x_ - (1 << z_) + 1 : x_) / (1 << z_)), z(z_), x(x_), y(y_), + sourceZ(sourceZ_), overscaling(std::pow(2, z_ - sourceZ_)) {} inline uint64_t to_uint64() const { return ((std::pow(2, z) * y + x) * 32) + z; @@ -43,11 +46,12 @@ public: return y < rhs.y; } - TileID parent(int8_t z) const; + TileID parent(int8_t z, int8_t sourceMaxZoom) const; TileID normalized() const; - std::forward_list children(int32_t z) const; + std::forward_list children(int8_t sourceMaxZoom) const; bool isChildOf(const TileID&) const; operator std::string() const; + }; } diff --git a/src/mbgl/map/tile_parser.cpp b/src/mbgl/map/tile_parser.cpp index a93245313..eb9a7c2e9 100644 --- a/src/mbgl/map/tile_parser.cpp +++ b/src/mbgl/map/tile_parser.cpp @@ -180,7 +180,7 @@ std::unique_ptr TileParser::createLineBucket(const GeometryTileLayer& la std::unique_ptr TileParser::createSymbolBucket(const GeometryTileLayer& layer, const StyleBucket& bucket_desc) { - auto bucket = util::make_unique(*tile.getCollision()); + auto bucket = util::make_unique(*tile.getCollision(), tile.id.overscaling); const float z = tile.id.z; auto& layout = bucket->layout; diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 2a1cc4b9e..8002a07f2 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -8,8 +8,8 @@ using namespace mbgl; #pragma mark - Matrix -void TransformState::matrixFor(mat4& matrix, const TileID& id) const { - const double tile_scale = std::pow(2, id.z); +void TransformState::matrixFor(mat4& matrix, const TileID& id, const int8_t z) const { + const double tile_scale = std::pow(2, z); const double tile_size = scale * util::tileSize / tile_scale; matrix::identity(matrix); diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index e09be8ca6..3e76c7f81 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -20,7 +20,7 @@ class TransformState { public: // Matrix - void matrixFor(mat4& matrix, const TileID& id) const; + void matrixFor(mat4& matrix, const TileID& id, const int8_t z) const; box cornersToBox(uint32_t z) const; // Dimensions diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp index c453d893a..fb64c224c 100644 --- a/src/mbgl/map/vector_tile_data.cpp +++ b/src/mbgl/map/vector_tile_data.cpp @@ -15,23 +15,23 @@ using namespace mbgl; VectorTileData::VectorTileData(const TileID& id_, - float mapMaxZoom, Style& style_, GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_, SpriteAtlas& spriteAtlas_, util::ptr sprite_, const SourceInfo& source_, + float overscaling_, float angle, bool collisionDebug) : TileData(id_, source_), - depth(id_.z >= source_.max_zoom ? mapMaxZoom - id_.z : 1), glyphAtlas(glyphAtlas_), glyphStore(glyphStore_), spriteAtlas(spriteAtlas_), sprite(sprite_), style(style_), - collision(util::make_unique(id_.z, 4096, source_.tile_size, angle, collisionDebug)), + overscaling(overscaling_), + collision(util::make_unique(id_.z, 4096, source_.tile_size * id.overscaling, angle, collisionDebug)), lastAngle(angle), currentAngle(angle) { } diff --git a/src/mbgl/map/vector_tile_data.hpp b/src/mbgl/map/vector_tile_data.hpp index 95a389c19..bb60668c8 100644 --- a/src/mbgl/map/vector_tile_data.hpp +++ b/src/mbgl/map/vector_tile_data.hpp @@ -33,7 +33,6 @@ class VectorTileData : public TileData { public: VectorTileData(const TileID&, - float mapMaxZoom, Style&, GlyphAtlas&, GlyphStore&, @@ -41,6 +40,7 @@ public: util::ptr, const SourceInfo&, float, + float, bool); ~VectorTileData(); @@ -57,8 +57,6 @@ public: return collision.get(); } - const float depth; - protected: void redoPlacement(); @@ -85,6 +83,7 @@ private: std::unordered_map> buckets; mutable std::mutex bucketsMutex; + const float overscaling; std::unique_ptr collision; float lastAngle = 0; diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 481a4489b..722a52002 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -470,7 +470,7 @@ mat4 Painter::translatedMatrix(const mat4& matrix, const std::array &t return matrix; } else { // TODO: Get rid of the 8 (scaling from 4096 to tile size) - const double factor = ((double)(1 << id.z)) / state.getScale() * (4096.0 / util::tileSize); + const double factor = ((double)(1 << id.z)) / state.getScale() * (4096.0 / util::tileSize / id.overscaling); mat4 vtxMatrix; if (anchor == TranslateAnchorType::Viewport) { diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index ccef94cd3..29f17108d 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -102,7 +102,6 @@ public: void renderDebugFrame(const mat4 &matrix); void renderDebugText(DebugBucket& bucket, const mat4 &matrix); - void renderDebugText(const std::vector &strings); void renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const TileID& id, const mat4 &matrix); void renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const TileID& id, const mat4 &matrix); void renderSymbol(SymbolBucket& bucket, const StyleLayer &layer_desc, const TileID& id, const mat4 &matrix); diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp index d4306d3e1..4466ad250 100644 --- a/src/mbgl/renderer/painter_debug.cpp +++ b/src/mbgl/renderer/painter_debug.cpp @@ -67,41 +67,3 @@ void Painter::renderDebugFrame(const mat4 &matrix) { lineWidth(4.0f * state.getPixelRatio()); MBGL_CHECK_ERROR(glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index())); } - -void Painter::renderDebugText(const std::vector &strings) { - if (strings.empty()) { - return; - } - - gl::debugging::group group("debug text"); - - config.depthTest = false; - config.stencilTest = true; - config.stencilFunc = { GL_ALWAYS, 0xFF, 0xFF }; - - useProgram(plainShader->program); - plainShader->u_matrix = nativeMatrix; - - DebugFontBuffer debugFontBuffer; - int line = 25; - for (const auto& str : strings) { - debugFontBuffer.addText(str.c_str(), 10, line, 0.75); - line += 20; - } - - if (!debugFontBuffer.empty()) { - // draw debug info - VertexArrayObject debugFontArray; - debugFontArray.bind(*plainShader, debugFontBuffer, BUFFER_OFFSET(0)); - plainShader->u_color = {{ 1.0f, 1.0f, 1.0f, 1.0f }}; - lineWidth(4.0f * state.getPixelRatio()); - MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)debugFontBuffer.index())); - #ifndef GL_ES_VERSION_2_0 - MBGL_CHECK_ERROR(glPointSize(2)); - MBGL_CHECK_ERROR(glDrawArrays(GL_POINTS, 0, (GLsizei)debugFontBuffer.index())); - #endif - plainShader->u_color = {{ 0.0f, 0.0f, 0.0f, 1.0f }}; - lineWidth(2.0f * state.getPixelRatio()); - MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)debugFontBuffer.index())); - } -} diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp index 6f6783f0e..649bd4679 100644 --- a/src/mbgl/renderer/painter_fill.cpp +++ b/src/mbgl/renderer/painter_fill.cpp @@ -66,7 +66,7 @@ void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const const SpriteAtlasPosition posA = spriteAtlas.getPosition(properties.image.from, true); const SpriteAtlasPosition posB = spriteAtlas.getPosition(properties.image.to, true); - float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z); + float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z) / id.overscaling; mat3 patternMatrixA; matrix::identity(patternMatrixA); diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp index f552ea6c4..612e04e12 100644 --- a/src/mbgl/renderer/painter_line.cpp +++ b/src/mbgl/renderer/painter_line.cpp @@ -70,7 +70,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const LinePatternPos posB = lineAtlas.getDashPosition(properties.dash_array.to, layout.cap == CapType::Round); lineAtlas.bind(); - float patternratio = std::pow(2.0, std::floor(std::log2(state.getScale())) - id.z) / 8.0; + float patternratio = std::pow(2.0, std::floor(std::log2(state.getScale())) - id.z) / 8.0 * id.overscaling; float scaleXA = patternratio / posA.width / properties.dash_line_width / properties.dash_array.fromScale; float scaleYA = -posA.height / 2.0; float scaleXB = patternratio / posB.width / properties.dash_line_width / properties.dash_array.toScale; @@ -90,7 +90,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const SpriteAtlasPosition imagePosA = spriteAtlas.getPosition(properties.image.from, true); SpriteAtlasPosition imagePosB = spriteAtlas.getPosition(properties.image.to, true); - float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z); + float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z) * id.overscaling; useProgram(linepatternShader->program); diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index e336ea759..359a9fe9f 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -53,8 +53,8 @@ SymbolInstance::SymbolInstance(Anchor &anchor, const std::vector &li iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconAlongLine) {}; -SymbolBucket::SymbolBucket(CollisionTile &collision_) - : collision(collision_) { +SymbolBucket::SymbolBucket(CollisionTile &collision_, float overscaling_) + : collision(collision_), overscaling(overscaling_) { } SymbolBucket::~SymbolBucket() { @@ -297,7 +297,7 @@ void SymbolBucket::addFeature(const std::vector> &lines, // Calculate the anchor points around which you want to place labels Anchors anchors = layout.placement == PlacementType::Line ? - getAnchors(line, symbolSpacing, textMaxAngle, shapedText.left, shapedText.right, glyphSize, textBoxScale, 1.0f) : + getAnchors(line, symbolSpacing, textMaxAngle, shapedText.left, shapedText.right, glyphSize, textBoxScale, overscaling) : Anchors({ Anchor(float(line[0].x), float(line[0].y), 0, minScale) }); diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 43d91bf41..8fac9641b 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -62,7 +62,7 @@ class SymbolBucket : public Bucket { typedef ElementGroup<1> CollisionBoxElementGroup; public: - SymbolBucket(CollisionTile &collision); + SymbolBucket(CollisionTile &collision, float overscaling); ~SymbolBucket() override; void upload() override; @@ -109,6 +109,7 @@ public: private: CollisionTile &collision; + const float overscaling; std::vector symbolInstances; std::vector features; diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp index 5185e78d9..f410b8e81 100644 --- a/src/mbgl/util/tile_cover.cpp +++ b/src/mbgl/util/tile_cover.cpp @@ -65,7 +65,7 @@ static void scanTriangle(const mbgl::vec2 a, const mbgl::vec2 b, if (bc.dy) scanSpans(ca, bc, ymin, ymax, scanLine); } -std::forward_list tileCover(int8_t z, const mbgl::box &bounds) { +std::forward_list tileCover(int8_t z, const mbgl::box &bounds, int8_t actualZ) { int32_t tiles = 1 << z; std::forward_list t; @@ -73,7 +73,7 @@ std::forward_list tileCover(int8_t z, const mbgl::box &bounds) { int32_t x; if (y >= 0 && y <= tiles) { for (x = x0; x < x1; x++) { - t.emplace_front(z, x, y); + t.emplace_front(actualZ, x, y, z); } } }; diff --git a/src/mbgl/util/tile_cover.hpp b/src/mbgl/util/tile_cover.hpp index 78121a30b..99c19a305 100644 --- a/src/mbgl/util/tile_cover.hpp +++ b/src/mbgl/util/tile_cover.hpp @@ -8,7 +8,7 @@ namespace mbgl { -std::forward_list tileCover(int8_t z, const box& bounds); +std::forward_list tileCover(int8_t z, const box& bounds, int8_t actualZ); } diff --git a/test/miscellaneous/clip_ids.cpp b/test/miscellaneous/clip_ids.cpp index e17681086..e168ab5e0 100644 --- a/test/miscellaneous/clip_ids.cpp +++ b/test/miscellaneous/clip_ids.cpp @@ -30,11 +30,11 @@ template void print(const T &sources) { TEST(ClipIDs, ParentAndFourChildren) { const std::vector>> sources = { { - std::make_shared(TileID { 1, 0, 0 }), - std::make_shared(TileID { 1, 0, 1 }), - std::make_shared(TileID { 1, 1, 0 }), - std::make_shared(TileID { 1, 1, 1 }), - std::make_shared(TileID { 0, 0, 0 }), + std::make_shared(TileID { 1, 0, 0, 1 }), + std::make_shared(TileID { 1, 0, 1, 1 }), + std::make_shared(TileID { 1, 1, 0, 1 }), + std::make_shared(TileID { 1, 1, 1, 1 }), + std::make_shared(TileID { 0, 0, 0, 0 }), }, }; @@ -51,11 +51,11 @@ TEST(ClipIDs, ParentAndFourChildren) { TEST(ClipIDs, ParentAndFourChildrenNegative) { const std::vector>> sources = { { - std::make_shared(TileID { 1, -2, 0 }), - std::make_shared(TileID { 1, -2, 1 }), - std::make_shared(TileID { 1, -1, 0 }), - std::make_shared(TileID { 1, -1, 1 }), - std::make_shared(TileID { 0, -1, 0 }), + std::make_shared(TileID { 1, -2, 0, 1 }), + std::make_shared(TileID { 1, -2, 1, 1 }), + std::make_shared(TileID { 1, -1, 0, 1 }), + std::make_shared(TileID { 1, -1, 1, 1 }), + std::make_shared(TileID { 0, -1, 0, 0 }), }, }; @@ -72,11 +72,11 @@ TEST(ClipIDs, ParentAndFourChildrenNegative) { TEST(ClipIDs, NegativeParentAndMissingLevel) { const std::vector>> sources = { { - std::make_shared(TileID { 1, -1, 0 }), - std::make_shared(TileID { 2, -1, 0 }), - std::make_shared(TileID { 2, -2, 1 }), - std::make_shared(TileID { 2, -1, 1 }), - std::make_shared(TileID { 2, -2, 0 }), + std::make_shared(TileID { 1, -1, 0, 1 }), + std::make_shared(TileID { 2, -1, 0, 2 }), + std::make_shared(TileID { 2, -2, 1, 2 }), + std::make_shared(TileID { 2, -1, 1, 2 }), + std::make_shared(TileID { 2, -2, 0, 2 }), }, }; @@ -94,13 +94,13 @@ TEST(ClipIDs, NegativeParentAndMissingLevel) { TEST(ClipIDs, SevenOnSameLevel) { const std::vector>> sources = { { - std::make_shared(TileID { 2, 0, 0 }), - std::make_shared(TileID { 2, 0, 1 }), - std::make_shared(TileID { 2, 0, 2 }), - std::make_shared(TileID { 2, 1, 0 }), - std::make_shared(TileID { 2, 1, 1 }), - std::make_shared(TileID { 2, 1, 2 }), - std::make_shared(TileID { 2, 2, 0 }), + std::make_shared(TileID { 2, 0, 0, 2 }), + std::make_shared(TileID { 2, 0, 1, 2 }), + std::make_shared(TileID { 2, 0, 2, 2 }), + std::make_shared(TileID { 2, 1, 0, 2 }), + std::make_shared(TileID { 2, 1, 1, 2 }), + std::make_shared(TileID { 2, 1, 2, 2 }), + std::make_shared(TileID { 2, 2, 0, 2 }), }, }; @@ -119,18 +119,18 @@ TEST(ClipIDs, SevenOnSameLevel) { TEST(ClipIDs, MultipleLevels) { const std::vector>> sources = { { - std::make_shared(TileID { 2, 0, 0 }), - std::make_shared(TileID { 3, 0, 0 }), - std::make_shared(TileID { 3, 0, 1 }), - std::make_shared(TileID { 4, 0, 2 }), - std::make_shared(TileID { 4, 1, 2 }), - std::make_shared(TileID { 4, 0, 3 }), - std::make_shared(TileID { 4, 1, 3 }), - std::make_shared(TileID { 3, 1, 0 }), - std::make_shared(TileID { 3, 1, 1 }), - std::make_shared(TileID { 2, 1, 0 }), - std::make_shared(TileID { 3, 2, 0 }), - std::make_shared(TileID { 3, 2, 1 }), + std::make_shared(TileID { 2, 0, 0, 2 }), + std::make_shared(TileID { 3, 0, 0, 3 }), + std::make_shared(TileID { 3, 0, 1, 3 }), + std::make_shared(TileID { 4, 0, 2, 4 }), + std::make_shared(TileID { 4, 1, 2, 4 }), + std::make_shared(TileID { 4, 0, 3, 4 }), + std::make_shared(TileID { 4, 1, 3, 4 }), + std::make_shared(TileID { 3, 1, 0, 3 }), + std::make_shared(TileID { 3, 1, 1, 3 }), + std::make_shared(TileID { 2, 1, 0, 2 }), + std::make_shared(TileID { 3, 2, 0, 3 }), + std::make_shared(TileID { 3, 2, 1, 3 }), }, }; @@ -155,17 +155,17 @@ TEST(ClipIDs, MultipleLevels) { TEST(ClipIDs, Bug206) { const std::vector>> sources = { { - std::make_shared(TileID { 10, 162, 395 }), - std::make_shared(TileID { 10, 162, 396 }), - std::make_shared(TileID { 10, 163, 395 }), - std::make_shared(TileID { 11, 326, 791 }), - std::make_shared(TileID { 12, 654, 1582 }), - std::make_shared(TileID { 12, 654, 1583 }), - std::make_shared(TileID { 12, 655, 1582 }), - std::make_shared(TileID { 12, 655, 1583 }), - std::make_shared(TileID { 10, 163, 396 }), - std::make_shared(TileID { 10, 164, 395 }), - std::make_shared(TileID { 10, 164, 396 }), + std::make_shared(TileID { 10, 162, 395, 10 }), + std::make_shared(TileID { 10, 162, 396, 10 }), + std::make_shared(TileID { 10, 163, 395, 10 }), + std::make_shared(TileID { 11, 326, 791, 10 }), + std::make_shared(TileID { 12, 654, 1582, 10 }), + std::make_shared(TileID { 12, 654, 1583, 10 }), + std::make_shared(TileID { 12, 655, 1582, 10 }), + std::make_shared(TileID { 12, 655, 1583, 10 }), + std::make_shared(TileID { 10, 163, 396, 10 }), + std::make_shared(TileID { 10, 164, 395, 10 }), + std::make_shared(TileID { 10, 164, 396, 10 }), }, }; @@ -189,23 +189,23 @@ TEST(ClipIDs, Bug206) { TEST(ClipIDs, MultipleSources) { const std::vector>> sources = { { - std::make_shared(TileID { 0, 0, 0 }), - std::make_shared(TileID { 1, 1, 1 }), - std::make_shared(TileID { 2, 2, 1 }), - std::make_shared(TileID { 2, 2, 2 }), + std::make_shared(TileID { 0, 0, 0, 0 }), + std::make_shared(TileID { 1, 1, 1, 1 }), + std::make_shared(TileID { 2, 2, 1, 2 }), + std::make_shared(TileID { 2, 2, 2, 2 }), }, { - std::make_shared(TileID { 0, 0, 0 }), - std::make_shared(TileID { 1, 1, 1 }), - std::make_shared(TileID { 2, 1, 1 }), - std::make_shared(TileID { 2, 2, 2 }), + std::make_shared(TileID { 0, 0, 0, 0 }), + std::make_shared(TileID { 1, 1, 1, 1 }), + std::make_shared(TileID { 2, 1, 1, 2 }), + std::make_shared(TileID { 2, 2, 2, 2 }), }, { - std::make_shared(TileID { 1, 0, 0 }), - std::make_shared(TileID { 1, 0, 1 }), - std::make_shared(TileID { 1, 1, 0 }), - std::make_shared(TileID { 1, 1, 1 }), - std::make_shared(TileID { 2, 1, 1 }), + std::make_shared(TileID { 1, 0, 0, 1 }), + std::make_shared(TileID { 1, 0, 1, 1 }), + std::make_shared(TileID { 1, 1, 0, 1 }), + std::make_shared(TileID { 1, 1, 1, 1 }), + std::make_shared(TileID { 2, 1, 1, 2 }), }, }; @@ -231,13 +231,13 @@ TEST(ClipIDs, MultipleSources) { TEST(ClipIDs, DuplicateIDs) { const std::vector>> sources = { { - std::make_shared(TileID { 2, 0, 0 }), - std::make_shared(TileID { 2, 0, 1 }), + std::make_shared(TileID { 2, 0, 0, 2 }), + std::make_shared(TileID { 2, 0, 1, 2 }), }, { - std::make_shared(TileID { 2, 0, 0 }), - std::make_shared(TileID { 2, 0, 1 }), - std::make_shared(TileID { 2, 0, 1 }), + std::make_shared(TileID { 2, 0, 0, 2 }), + std::make_shared(TileID { 2, 0, 1, 2 }), + std::make_shared(TileID { 2, 0, 1, 2 }), } }; diff --git a/test/miscellaneous/tile.cpp b/test/miscellaneous/tile.cpp index 6c5c89ac4..8341725f0 100644 --- a/test/miscellaneous/tile.cpp +++ b/test/miscellaneous/tile.cpp @@ -7,44 +7,44 @@ using namespace mbgl; TEST(Variant, isChild) { - ASSERT_TRUE(TileID(1, 0, 0).isChildOf(TileID(0, 0, 0))); - ASSERT_TRUE(TileID(1, 1, 0).isChildOf(TileID(0, 0, 0))); - ASSERT_TRUE(TileID(1, 2, 0).isChildOf(TileID(0, 1, 0))); - ASSERT_TRUE(TileID(1, 3, 0).isChildOf(TileID(0, 1, 0))); - ASSERT_TRUE(TileID(1, 4, 0).isChildOf(TileID(0, 2, 0))); - ASSERT_TRUE(TileID(1, 5, 0).isChildOf(TileID(0, 2, 0))); - ASSERT_TRUE(TileID(2, 0, 0).isChildOf(TileID(0, 0, 0))); + ASSERT_TRUE(TileID(1, 0, 0, 1).isChildOf(TileID(0, 0, 0, 0))); + ASSERT_TRUE(TileID(1, 1, 0, 1).isChildOf(TileID(0, 0, 0, 0))); + ASSERT_TRUE(TileID(1, 2, 0, 1).isChildOf(TileID(0, 1, 0, 0))); + ASSERT_TRUE(TileID(1, 3, 0, 1).isChildOf(TileID(0, 1, 0, 0))); + ASSERT_TRUE(TileID(1, 4, 0, 1).isChildOf(TileID(0, 2, 0, 0))); + ASSERT_TRUE(TileID(1, 5, 0, 1).isChildOf(TileID(0, 2, 0, 0))); + ASSERT_TRUE(TileID(2, 0, 0, 2).isChildOf(TileID(0, 0, 0, 0))); - ASSERT_TRUE(TileID(2, 8, 0).isChildOf(TileID(0, 2, 0))); - ASSERT_TRUE(TileID(2, 9, 0).isChildOf(TileID(0, 2, 0))); - ASSERT_TRUE(TileID(2, 10, 0).isChildOf(TileID(0, 2, 0))); - ASSERT_TRUE(TileID(2, 11, 0).isChildOf(TileID(0, 2, 0))); - ASSERT_TRUE(TileID(2, 12, 0).isChildOf(TileID(0, 3, 0))); - ASSERT_TRUE(TileID(2, 13, 0).isChildOf(TileID(0, 3, 0))); + ASSERT_TRUE(TileID(2, 8, 0, 2).isChildOf(TileID(0, 2, 0, 0))); + ASSERT_TRUE(TileID(2, 9, 0, 2).isChildOf(TileID(0, 2, 0, 0))); + ASSERT_TRUE(TileID(2, 10, 0, 2).isChildOf(TileID(0, 2, 0, 0))); + ASSERT_TRUE(TileID(2, 11, 0, 2).isChildOf(TileID(0, 2, 0, 0))); + ASSERT_TRUE(TileID(2, 12, 0, 2).isChildOf(TileID(0, 3, 0, 0))); + ASSERT_TRUE(TileID(2, 13, 0, 2).isChildOf(TileID(0, 3, 0, 0))); - ASSERT_TRUE(TileID(1, -1, 0).isChildOf(TileID(0, -1, 0))); - ASSERT_TRUE(TileID(1, -2, 0).isChildOf(TileID(0, -1, 0))); - ASSERT_TRUE(TileID(1, -3, 0).isChildOf(TileID(0, -2, 0))); - ASSERT_TRUE(TileID(1, -4, 0).isChildOf(TileID(0, -2, 0))); - ASSERT_TRUE(TileID(2, -1, 0).isChildOf(TileID(0, -1, 0))); - ASSERT_TRUE(TileID(2, -2, 0).isChildOf(TileID(0, -1, 0))); - ASSERT_TRUE(TileID(2, -3, 0).isChildOf(TileID(0, -1, 0))); - ASSERT_TRUE(TileID(2, -4, 0).isChildOf(TileID(0, -1, 0))); - ASSERT_TRUE(TileID(2, -5, 0).isChildOf(TileID(0, -2, 0))); - ASSERT_TRUE(TileID(2, -6, 0).isChildOf(TileID(0, -2, 0))); - ASSERT_TRUE(TileID(2, -7, 0).isChildOf(TileID(0, -2, 0))); - ASSERT_TRUE(TileID(2, -8, 0).isChildOf(TileID(0, -2, 0))); + ASSERT_TRUE(TileID(1, -1, 0, 1).isChildOf(TileID(0, -1, 0, 0))); + ASSERT_TRUE(TileID(1, -2, 0, 1).isChildOf(TileID(0, -1, 0, 0))); + ASSERT_TRUE(TileID(1, -3, 0, 1).isChildOf(TileID(0, -2, 0, 0))); + ASSERT_TRUE(TileID(1, -4, 0, 1).isChildOf(TileID(0, -2, 0, 0))); + ASSERT_TRUE(TileID(2, -1, 0, 2).isChildOf(TileID(0, -1, 0, 0))); + ASSERT_TRUE(TileID(2, -2, 0, 2).isChildOf(TileID(0, -1, 0, 0))); + ASSERT_TRUE(TileID(2, -3, 0, 2).isChildOf(TileID(0, -1, 0, 0))); + ASSERT_TRUE(TileID(2, -4, 0, 2).isChildOf(TileID(0, -1, 0, 0))); + ASSERT_TRUE(TileID(2, -5, 0, 2).isChildOf(TileID(0, -2, 0, 0))); + ASSERT_TRUE(TileID(2, -6, 0, 2).isChildOf(TileID(0, -2, 0, 0))); + ASSERT_TRUE(TileID(2, -7, 0, 2).isChildOf(TileID(0, -2, 0, 0))); + ASSERT_TRUE(TileID(2, -8, 0, 2).isChildOf(TileID(0, -2, 0, 0))); - ASSERT_FALSE(TileID(4, -16, 0).isChildOf(TileID(0, -2, 0))); - ASSERT_TRUE(TileID(4, -17, 0).isChildOf(TileID(0, -2, 0))); + ASSERT_FALSE(TileID(4, -16, 0, 4).isChildOf(TileID(0, -2, 0, 0))); + ASSERT_TRUE(TileID(4, -17, 0, 4).isChildOf(TileID(0, -2, 0, 0))); - ASSERT_TRUE(TileID(2, -1, 0).isChildOf(TileID(1, -1, 0))); - ASSERT_TRUE(TileID(2, -2, 0).isChildOf(TileID(1, -1, 0))); - ASSERT_TRUE(TileID(2, -3, 0).isChildOf(TileID(1, -2, 0))); - ASSERT_TRUE(TileID(2, -4, 0).isChildOf(TileID(1, -2, 0))); - ASSERT_TRUE(TileID(3, -1, 0).isChildOf(TileID(1, -1, 0))); - ASSERT_TRUE(TileID(3, -2, 0).isChildOf(TileID(1, -1, 0))); - ASSERT_TRUE(TileID(3, -3, 0).isChildOf(TileID(1, -1, 0))); - ASSERT_TRUE(TileID(3, -4, 0).isChildOf(TileID(1, -1, 0))); - ASSERT_TRUE(TileID(3, -5, 0).isChildOf(TileID(1, -2, 0))); + ASSERT_TRUE(TileID(2, -1, 0, 2).isChildOf(TileID(1, -1, 0, 1))); + ASSERT_TRUE(TileID(2, -2, 0, 2).isChildOf(TileID(1, -1, 0, 1))); + ASSERT_TRUE(TileID(2, -3, 0, 2).isChildOf(TileID(1, -2, 0, 1))); + ASSERT_TRUE(TileID(2, -4, 0, 2).isChildOf(TileID(1, -2, 0, 1))); + ASSERT_TRUE(TileID(3, -1, 0, 3).isChildOf(TileID(1, -1, 0, 1))); + ASSERT_TRUE(TileID(3, -2, 0, 3).isChildOf(TileID(1, -1, 0, 1))); + ASSERT_TRUE(TileID(3, -3, 0, 3).isChildOf(TileID(1, -1, 0, 1))); + ASSERT_TRUE(TileID(3, -4, 0, 3).isChildOf(TileID(1, -1, 0, 1))); + ASSERT_TRUE(TileID(3, -5, 0, 3).isChildOf(TileID(1, -2, 0, 1))); } diff --git a/test/suite b/test/suite deleted file mode 160000 index d4fb34452..000000000 --- a/test/suite +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d4fb3445252aa7d0666bf563634d2007cb573c03 diff --git a/test/suite b/test/suite new file mode 120000 index 000000000..7c9788d22 --- /dev/null +++ b/test/suite @@ -0,0 +1 @@ +../../test-suite/ \ No newline at end of file