summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-10-12 14:46:47 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-10-12 14:46:47 +0200
commite3d9fb171543c060aea53679dc1d298a156e656a (patch)
tree929e6e3eef0c8382b614b8f400b5463f461ec6d7
parent3f6422ea641c3f9d1ea2eeb3c95e7589b36bd5c0 (diff)
downloadqtlocation-mapboxgl-e3d9fb171543c060aea53679dc1d298a156e656a.tar.gz
[core] only show parent XOR child tiles
Since label rendering isn't clipped, having a parent tile, and only a handful of child tiles loaded may result in some labels being rendered twice (from the parent tile, and the up to three child tiles that necessitate the parent tile remaining in the list). This patch makes sure that in one location, it only ever renders one set of labels, by favoring the parent tile until all required child tiles have been loaded.
-rw-r--r--src/mbgl/renderer/painter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 0adf3b42b3..fc380c2f67 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -352,6 +352,25 @@ std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
continue;
}
+ // We're not clipping symbol layers, so when we have both parents and children of symbol
+ // layers, we drop all children in favor of their parent to avoid duplicate labels.
+ // See https://github.com/mapbox/mapbox-gl-native/issues/2482
+ if (layer.type == StyleLayerType::Symbol) {
+ bool skip = false;
+ // Look back through the buckets we decided to render to find out whether there is
+ // already a bucket from this layer that is a parent of this tile. Tiles are ordered
+ // by zoom level when we obtain them from getTiles().
+ for (auto it = order.rbegin(); it != order.rend() && (&it->layer == &layer); ++it) {
+ if (tile->id.isChildOf(it->tile->id)) {
+ skip = true;
+ break;
+ }
+ }
+ if (skip) {
+ continue;
+ }
+ }
+
auto bucket = tile->data->getBucket(layer);
if (bucket) {
order.emplace_back(layer, tile, bucket);