summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2015-05-28 16:44:28 -0400
committerAnsis Brammanis <brammanis@gmail.com>2015-05-28 19:17:07 -0400
commit1e044a175cbb714182709b9929fe4a74bfa42322 (patch)
tree18f488db5b3909fbd35d458d73c273c2b4ff0772 /src
parent8962442b1b838445efaf8dc12003225facac2a06 (diff)
downloadqtlocation-mapboxgl-1e044a175cbb714182709b9929fe4a74bfa42322.tar.gz
Reparse tiles when zoom level > source maxzoom
so that layout property functions are applied correctly and so that label placement is redone js: https://github.com/mapbox/mapbox-gl-js/pull/1005 and https://github.com/mapbox/mapbox-gl-js/commit/440bc02505eb66f198a3d98708ddc3d9453f453f
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/annotation.cpp8
-rw-r--r--src/mbgl/map/live_tile_data.cpp6
-rw-r--r--src/mbgl/map/live_tile_data.hpp2
-rw-r--r--src/mbgl/map/source.cpp28
-rw-r--r--src/mbgl/map/tile_id.cpp46
-rw-r--r--src/mbgl/map/tile_id.hpp12
-rw-r--r--src/mbgl/map/tile_parser.cpp2
-rw-r--r--src/mbgl/map/transform_state.cpp4
-rw-r--r--src/mbgl/map/transform_state.hpp2
-rw-r--r--src/mbgl/map/vector_tile_data.cpp6
-rw-r--r--src/mbgl/map/vector_tile_data.hpp5
-rw-r--r--src/mbgl/renderer/painter.cpp2
-rw-r--r--src/mbgl/renderer/painter.hpp1
-rw-r--r--src/mbgl/renderer/painter_debug.cpp38
-rw-r--r--src/mbgl/renderer/painter_fill.cpp2
-rw-r--r--src/mbgl/renderer/painter_line.cpp4
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp6
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp3
-rw-r--r--src/mbgl/util/tile_cover.cpp4
-rw-r--r--src/mbgl/util/tile_cover.hpp2
20 files changed, 85 insertions, 98 deletions
diff --git a/src/mbgl/map/annotation.cpp b/src/mbgl/map/annotation.cpp
index 7a7a0ed683..9d21b4e48b 100644
--- a/src/mbgl/map/annotation.cpp
+++ b/src/mbgl/map/annotation.cpp
@@ -125,7 +125,7 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& 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<TileID> 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<uint32_t> AnnotationManager::getAnnotationsInBounds(const LatLngBoun
const vec2<double> 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<uint32_t> matchingAnnotations;
diff --git a/src/mbgl/map/live_tile_data.cpp b/src/mbgl/map/live_tile_data.cpp
index d63ea43470..f2b5e0427d 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> 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 0247c47fa7..7066fe13c9 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<Sprite>,
const SourceInfo&,
float,
+ float,
bool);
~LiveTileData();
diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp
index 3d7ab6fd32..331e48436f 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<int8_t>(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<int8_t>(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<Tile>(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<Tile>(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<VectorTileData>(normalized_id, data.transform.getMaxZoom(), style, glyphAtlas,
- glyphStore, spriteAtlas, sprite, info, transformState.getAngle(), data.getCollisionDebug());
+ std::make_shared<VectorTileData>(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<RasterTileData>(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<LiveTileData>(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<TileID> 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<TileID> Source::coveringTiles(const TransformState& state) con
box points = state.cornersToBox(z);
const vec2<double>& center = points.center;
- std::forward_list<TileID> covering_tiles = tileCover(z, points);
+ std::forward_list<TileID> covering_tiles = tileCover(z, points, reparseOverscaled ? actualZ : z);
covering_tiles.sort([&center](const TileID& a, const TileID& b) {
// Sorts by distance from the box center
@@ -349,7 +357,7 @@ std::forward_list<TileID> Source::coveringTiles(const TransformState& state) con
bool Source::findLoadedChildren(const TileID& id, int32_t maxCoveringZoom, std::forward_list<TileID>& 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<TileID>& 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 518ee14c42..ad7ec2e0f6 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
- };
+ 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> TileID::children(int32_t child_z) const {
- assert(child_z > z);
- int32_t factor = std::pow(2, child_z - z);
+std::forward_list<TileID> TileID::children(int8_t sourceMaxZoom) const {
+ auto childZ = z + 1;
std::forward_list<TileID> 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);
- }
+ 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 056fcdbfa5..f2e2171f1a 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<TileID> children(int32_t z) const;
+ std::forward_list<TileID> 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 a932453136..eb9a7c2e9f 100644
--- a/src/mbgl/map/tile_parser.cpp
+++ b/src/mbgl/map/tile_parser.cpp
@@ -180,7 +180,7 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const GeometryTileLayer& la
std::unique_ptr<Bucket> TileParser::createSymbolBucket(const GeometryTileLayer& layer,
const StyleBucket& bucket_desc) {
- auto bucket = util::make_unique<SymbolBucket>(*tile.getCollision());
+ auto bucket = util::make_unique<SymbolBucket>(*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 2a1cc4b9ea..8002a07f2b 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 e09be8ca63..3e76c7f817 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 c453d893a8..fb64c224cf 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> 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<CollisionTile>(id_.z, 4096, source_.tile_size, angle, collisionDebug)),
+ overscaling(overscaling_),
+ collision(util::make_unique<CollisionTile>(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 95a389c199..bb60668c8b 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<Sprite>,
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<std::string, std::unique_ptr<Bucket>> buckets;
mutable std::mutex bucketsMutex;
+ const float overscaling;
std::unique_ptr<CollisionTile> collision;
float lastAngle = 0;
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 481a4489b5..722a520027 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<float, 2> &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 ccef94cd32..29f17108d3 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<std::string> &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 d4306d3e1a..4466ad2503 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<std::string> &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 6f6783f0e2..649bd46794 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 f552ea6c43..612e04e121 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 e336ea7594..359a9fe9f8 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<Coordinate> &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<std::vector<Coordinate>> &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 43d91bf419..8fac9641b7 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<SymbolInstance> symbolInstances;
std::vector<SymbolFeature> features;
diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp
index 5185e78d92..f410b8e813 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<double> a, const mbgl::vec2<double> b,
if (bc.dy) scanSpans(ca, bc, ymin, ymax, scanLine);
}
-std::forward_list<TileID> tileCover(int8_t z, const mbgl::box &bounds) {
+std::forward_list<TileID> tileCover(int8_t z, const mbgl::box &bounds, int8_t actualZ) {
int32_t tiles = 1 << z;
std::forward_list<mbgl::TileID> t;
@@ -73,7 +73,7 @@ std::forward_list<TileID> 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 78121a30ba..99c19a3052 100644
--- a/src/mbgl/util/tile_cover.hpp
+++ b/src/mbgl/util/tile_cover.hpp
@@ -8,7 +8,7 @@
namespace mbgl {
-std::forward_list<TileID> tileCover(int8_t z, const box& bounds);
+std::forward_list<TileID> tileCover(int8_t z, const box& bounds, int8_t actualZ);
}