Fix for style properties transition updates
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user