summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-01-23 20:11:24 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-01-23 20:53:35 +0200
commit95c7bbab46c477df4884368044fe27e71c4acbdc (patch)
tree348ea058a2ab05bb9329a4afbc4f176b6075aefb
parent9e1bcc4fdc6cb3bb1710a6e2cefd7e642159b2f3 (diff)
downloadqtlocation-mapboxgl-upstream/mikhail_tile_mode_variable_placement_fix.tar.gz
[tile mode] Fix variable symbols placementupstream/mikhail_tile_mode_variable_placement_fix
This commit allows the variable symbols to cross the tile border only if their anchor is the first anchor from the `text-variable-anchor` list.
-rw-r--r--metrics/expectations/platform-all/render-tests/text-variable-anchor/all-anchors-tile-map-mode/expected.pngbin162269 -> 158810 bytes
-rw-r--r--src/mbgl/text/placement.cpp13
2 files changed, 4 insertions, 9 deletions
diff --git a/metrics/expectations/platform-all/render-tests/text-variable-anchor/all-anchors-tile-map-mode/expected.png b/metrics/expectations/platform-all/render-tests/text-variable-anchor/all-anchors-tile-map-mode/expected.png
index 4a7089b1be..8b02991f2f 100644
--- a/metrics/expectations/platform-all/render-tests/text-variable-anchor/all-anchors-tile-map-mode/expected.png
+++ b/metrics/expectations/platform-all/render-tests/text-variable-anchor/all-anchors-tile-map-mode/expected.png
Binary files differ
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 32edf679e8..8740e4b021 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -331,9 +331,6 @@ void Placement::placeBucket(const SymbolBucket& bucket,
const bool doVariableIconPlacement =
hasIconTextFit && !iconAllowOverlap && symbolInstance.placedIconIndex;
-
- bool stickToFirstAnchor = false;
-
const auto placeFeatureForVariableAnchors = [&](const CollisionFeature& textCollisionFeature,
style::TextWritingModeType orientation,
const CollisionFeature& iconCollisionFeature) {
@@ -347,8 +344,6 @@ void Placement::placeBucket(const SymbolBucket& bucket,
for (size_t i = 0u; i < placementAttempts; ++i) {
auto anchor = variableTextAnchors[i % anchorsSize];
const bool isFirstAnchor = (anchor == variableTextAnchors.front());
- if (stickToFirstAnchor && !isFirstAnchor) continue;
-
const bool allowOverlap = (i >= anchorsSize);
shift = calculateVariableLayoutOffset(anchor,
width,
@@ -360,10 +355,10 @@ void Placement::placeBucket(const SymbolBucket& bucket,
state.getBearing());
textBoxes.clear();
- if (mapMode == MapMode::Tile && isFirstAnchor) {
- assert(tileBorders);
- stickToFirstAnchor = collisionIndex.featureIntersectsTileBorders(
- textCollisionFeature, shift, posMatrix, pixelRatio, *tileBorders);
+ if (mapMode == MapMode::Tile && !isFirstAnchor &&
+ collisionIndex.featureIntersectsTileBorders(
+ textCollisionFeature, shift, posMatrix, pixelRatio, *tileBorders)) {
+ continue;
}
placedFeature = collisionIndex.placeFeature(textCollisionFeature,