From e3d9fb171543c060aea53679dc1d298a156e656a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 12 Oct 2015 14:46:47 +0200 Subject: [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. --- src/mbgl/renderer/painter.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 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); -- cgit v1.2.1