diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-08-21 12:12:15 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2018-09-06 12:55:35 -0700 |
commit | e321b96e55ea3e7b1e3f128792a341d86636c806 (patch) | |
tree | 229fdb1af3cd29d651dad3dd653db9b8da3f5285 | |
parent | 8dab268ee0f29dcfcbd03bcabbe6cbdbc457f5e0 (diff) | |
download | qtlocation-mapboxgl-e321b96e55ea3e7b1e3f128792a341d86636c806.tar.gz |
[core] Mark allow-overlap symbols visible even outside of collision grid.
Fixes issue #12683.
-rw-r--r-- | src/mbgl/text/placement.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 0747133bd2..48c58a962e 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -117,6 +117,25 @@ void Placement::placeLayerBucket( avoidEdges = collisionIndex.projectTileBoundaries(posMatrix); } + const bool textAllowOverlap = bucket.layout.get<style::TextAllowOverlap>(); + const bool iconAllowOverlap = bucket.layout.get<style::IconAllowOverlap>(); + // This logic is similar to the "defaultOpacityState" logic below in updateBucketOpacities + // If we know a symbol is always supposed to show, force it to be marked visible even if + // it wasn't placed into the collision index (because some or all of it was outside the range + // of the collision grid). + // There is a subtle edge case here we're accepting: + // Symbol A has text-allow-overlap: true, icon-allow-overlap: true, icon-optional: false + // A's icon is outside the grid, so doesn't get placed + // A's text would be inside grid, but doesn't get placed because of icon-optional: false + // We still show A because of the allow-overlap settings. + // Symbol B has allow-overlap: false, and gets placed where A's text would be + // On panning in, there is a short period when Symbol B and Symbol A will overlap + // This is the reverse of our normal policy of "fade in on pan", but should look like any other + // collision and hopefully not be too noticeable. + // See https://github.com/mapbox/mapbox-gl-native/issues/12683 + const bool alwaysShowText = textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || bucket.layout.get<style::IconOptional>()); + const bool alwaysShowIcon = iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || bucket.layout.get<style::TextOptional>()); + for (auto& symbolInstance : bucket.symbolInstances) { if (seenCrossTileIDs.count(symbolInstance.crossTileID) == 0) { @@ -187,7 +206,7 @@ void Placement::placeLayerBucket( placements.erase(symbolInstance.crossTileID); } - placements.emplace(symbolInstance.crossTileID, JointPlacement(placeText, placeIcon, offscreen || bucket.justReloaded)); + placements.emplace(symbolInstance.crossTileID, JointPlacement(placeText || alwaysShowText, placeIcon || alwaysShowIcon, offscreen || bucket.justReloaded)); seenCrossTileIDs.insert(symbolInstance.crossTileID); } } |