summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-12-10 14:01:25 -0800
committerChris Loer <chris.loer@mapbox.com>2018-12-11 14:03:34 -0800
commitd812babecd8cfa31e6198bdd83d28e2f80fd240f (patch)
tree3526cfe0822777ea40a70af47de4d962c0bc2c1e
parent662a4955615d201f6d1525dcbf3cc08da3d546b4 (diff)
downloadqtlocation-mapboxgl-d812babecd8cfa31e6198bdd83d28e2f80fd240f.tar.gz
[core] Avoid divide-by-zero when transition duration is 0..
Fixes issue #13506 -- transition duration of 0 would cause symbol flickering.
-rw-r--r--src/mbgl/text/placement.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 3b2cf20b7e..a39106a43d 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -245,7 +245,9 @@ void Placement::commit(const Placement& prevPlacement, TimePoint now) {
bool placementChanged = false;
- float increment = mapMode == MapMode::Continuous && transitionOptions.enablePlacementTransitions ?
+ float increment = mapMode == MapMode::Continuous &&
+ transitionOptions.enablePlacementTransitions &&
+ transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION) > Milliseconds(0) ?
std::chrono::duration<float>(commitTime - prevPlacement.commitTime) / transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION) :
1.0;
@@ -405,7 +407,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>&
}
float Placement::symbolFadeChange(TimePoint now) const {
- if (mapMode == MapMode::Continuous && transitionOptions.enablePlacementTransitions) {
+ if (mapMode == MapMode::Continuous && transitionOptions.enablePlacementTransitions &&
+ transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION) > Milliseconds(0)) {
return std::chrono::duration<float>(now - commitTime) / transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION);
} else {
return 1.0;