Fix for style properties transition updates

This commit is contained in:
Bruno de Oliveira Abinader
2015-10-06 11:14:25 -07:00
parent 71be6923a8
commit 402819e1ad
3 changed files with 15 additions and 2 deletions

View File

@@ -243,7 +243,12 @@ bool MapContext::renderSync(const TransformState& state, const FrameData& frame)
view.afterRender();
if (style->hasTransitions() || painter->needsAnimation()) {
if (style->hasTransitions()) {
updateFlags |= Update::Classes;
asyncUpdate->send();
}
if (painter->needsAnimation()) {
updateFlags |= Update::Repaint;
asyncUpdate->send();
}

View File

@@ -172,6 +172,7 @@ void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, cons
// We overwrite the current property partially with the new value.
float progress = std::chrono::duration<float>(now - property.begin) / (property.end - property.begin);
target = util::interpolate(target, mapbox::util::apply_visitor(evaluator, property.value), progress);
hasPendingTransitions = true;
} else {
// Do not apply this property because its transition hasn't begun yet.
}
@@ -280,6 +281,9 @@ void StyleLayer::applyStyleProperties<BackgroundProperties>(const float z, const
void StyleLayer::updateProperties(float z, const TimePoint& now, ZoomHistory &zoomHistory) {
cleanupAppliedStyleProperties(now);
// Clear the pending transitions flag upon each update.
hasPendingTransitions = false;
switch (type) {
case StyleLayerType::Fill: applyStyleProperties<FillProperties>(z, now, zoomHistory); break;
case StyleLayerType::Line: applyStyleProperties<LineProperties>(z, now, zoomHistory); break;
@@ -317,7 +321,7 @@ bool StyleLayer::hasTransitions() const {
return true;
}
}
return false;
return hasPendingTransitions;
}
void StyleLayer::cleanupAppliedStyleProperties(const TimePoint& now) {

View File

@@ -94,6 +94,10 @@ public:
// Stores the evaluated, and cascaded styling information, specific to this
// layer's type.
StyleProperties properties;
private:
// Stores whether there are pending transitions to be done on each update.
bool hasPendingTransitions = false;
};
}