summaryrefslogtreecommitdiff
path: root/src/mbgl/layout/symbol_layout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/layout/symbol_layout.cpp')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index e0475f0acb..61c3b4ad66 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -106,7 +106,7 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters,
const bool hasSymbolSortKey = !leader.layout.get<SymbolSortKey>().isUndefined();
const auto symbolZOrder = layout->get<SymbolZOrder>();
- const bool sortFeaturesByKey = symbolZOrder != SymbolZOrderType::ViewportY && hasSymbolSortKey;
+ sortFeaturesByKey = symbolZOrder != SymbolZOrderType::ViewportY && hasSymbolSortKey;
const bool zOrderByViewportY = symbolZOrder == SymbolZOrderType::ViewportY || (symbolZOrder == SymbolZOrderType::Auto && !sortFeaturesByKey);
sortFeaturesByY = zOrderByViewportY && (layout->get<TextAllowOverlap>() || layout->get<IconAllowOverlap>() ||
layout->get<TextIgnorePlacement>() || layout->get<IconIgnorePlacement>());
@@ -572,9 +572,10 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex,
}
}
- auto addSymbolInstance = [&] (Anchor& anchor, std::shared_ptr<SymbolInstanceSharedData> sharedData) {
+ auto addSymbolInstance = [&](Anchor& anchor, std::shared_ptr<SymbolInstanceSharedData> sharedData) {
assert(sharedData);
- const bool anchorInsideTile = anchor.point.x >= 0 && anchor.point.x < util::EXTENT && anchor.point.y >= 0 && anchor.point.y < util::EXTENT;
+ const bool anchorInsideTile = anchor.point.x >= 0 && anchor.point.x < util::EXTENT && anchor.point.y >= 0 &&
+ anchor.point.y < util::EXTENT;
if (mode == MapMode::Tile || anchorInsideTile) {
// For static/continuous rendering, only add symbols anchored within this tile:
@@ -582,13 +583,36 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex,
// In tiled rendering mode, add all symbols in the buffers so that we can:
// (1) render symbols that overlap into this tile
// (2) approximate collision detection effects from neighboring symbols
- symbolInstances.emplace_back(anchor, std::move(sharedData), shapedTextOrientations,
- shapedIcon, verticallyShapedIcon,
- textBoxScale, textPadding, textPlacement, textOffset,
- iconBoxScale, iconPadding, iconOffset, indexedFeature,
- layoutFeatureIndex, feature.index,
- feature.formattedText ? feature.formattedText->rawText() : std::u16string(),
- overscaling, iconRotation, textRotation, variableTextOffset, allowVerticalPlacement, iconType);
+ symbolInstances.emplace_back(anchor,
+ std::move(sharedData),
+ shapedTextOrientations,
+ shapedIcon,
+ verticallyShapedIcon,
+ textBoxScale,
+ textPadding,
+ textPlacement,
+ textOffset,
+ iconBoxScale,
+ iconPadding,
+ iconOffset,
+ indexedFeature,
+ layoutFeatureIndex,
+ feature.index,
+ feature.formattedText ? feature.formattedText->rawText() : std::u16string(),
+ overscaling,
+ iconRotation,
+ textRotation,
+ variableTextOffset,
+ allowVerticalPlacement,
+ iconType);
+
+ if (sortFeaturesByKey) {
+ if (sortKeyRanges.size() && sortKeyRanges.back().sortKey == feature.sortKey) {
+ sortKeyRanges.back().symbolInstanceEnd = symbolInstances.size();
+ } else {
+ sortKeyRanges.push_back({feature.sortKey, symbolInstances.size() - 1, symbolInstances.size()});
+ }
+ }
}
};
@@ -728,6 +752,7 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn
sortFeaturesByY,
bucketLeaderID,
std::move(symbolInstances),
+ std::move(sortKeyRanges),
tilePixelRatio,
allowVerticalPlacement,
std::move(placementModes),