diff options
Diffstat (limited to 'src/mbgl/style/style_layer.cpp')
-rw-r--r-- | src/mbgl/style/style_layer.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp index 262ca23af8..3b82d7f94a 100644 --- a/src/mbgl/style/style_layer.cpp +++ b/src/mbgl/style/style_layer.cpp @@ -14,7 +14,7 @@ bool StyleLayer::isBackground() const { return type == StyleLayerType::Background; } -void StyleLayer::setClasses(const std::vector<std::string> &class_names, const timestamp now, +void StyleLayer::setClasses(const std::vector<std::string> &class_names, const std::chrono::steady_clock::time_point now, const PropertyTransition &defaultTransition) { // Stores all keys that we have already added transitions for. std::set<PropertyKey> already_applied; @@ -45,8 +45,8 @@ void StyleLayer::setClasses(const std::vector<std::string> &class_names, const t if (appliedProperties.mostRecent() != ClassID::Fallback) { // This property key hasn't been set by a previous class, so we need to add a transition // to the fallback value for that key. - const timestamp begin = now + defaultTransition.delay * 1_millisecond; - const timestamp end = begin + defaultTransition.duration * 1_millisecond; + const std::chrono::steady_clock::time_point begin = now + defaultTransition.delay; + const std::chrono::steady_clock::time_point end = begin + defaultTransition.duration; const PropertyValue &value = PropertyFallbackValue::Get(key); appliedProperties.add(ClassID::Fallback, begin, end, value); } @@ -55,7 +55,7 @@ void StyleLayer::setClasses(const std::vector<std::string> &class_names, const t // Helper function for applying all properties of a a single class that haven't been applied yet. void StyleLayer::applyClassProperties(const ClassID class_id, - std::set<PropertyKey> &already_applied, timestamp now, + std::set<PropertyKey> &already_applied, std::chrono::steady_clock::time_point now, const PropertyTransition &defaultTransition) { auto style_it = styles.find(class_id); if (style_it == styles.end()) { @@ -83,8 +83,8 @@ void StyleLayer::applyClassProperties(const ClassID class_id, if (appliedProperties.mostRecent() != class_id) { const PropertyTransition &transition = class_properties.getTransition(key, defaultTransition); - const timestamp begin = now + transition.delay * 1_millisecond; - const timestamp end = begin + transition.duration * 1_millisecond; + const std::chrono::steady_clock::time_point begin = now + transition.delay; + const std::chrono::steady_clock::time_point end = begin + transition.duration; const PropertyValue &value = property_pair.second; appliedProperties.add(class_id, begin, end, value); } @@ -115,7 +115,7 @@ private: }; template <typename T> -void StyleLayer::applyStyleProperty(PropertyKey key, T &target, const float z, const timestamp now) { +void StyleLayer::applyStyleProperty(PropertyKey key, T &target, const float z, const std::chrono::steady_clock::time_point now) { auto it = appliedStyle.find(key); if (it != appliedStyle.end()) { AppliedClassProperties &applied = it->second; @@ -133,7 +133,7 @@ void StyleLayer::applyStyleProperty(PropertyKey key, T &target, const float z, c } template <typename T> -void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, const float z, const timestamp now) { +void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, const float z, const std::chrono::steady_clock::time_point now) { auto it = appliedStyle.find(key); if (it != appliedStyle.end()) { AppliedClassProperties &applied = it->second; @@ -145,7 +145,7 @@ void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, cons target = mapbox::util::apply_visitor(evaluator, property.value); } else if (now >= property.begin) { // We overwrite the current property partially with the new value. - float progress = float(now - property.begin) / float(property.end - property.begin); + 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); } else { // Do not apply this property because its transition hasn't begun yet. @@ -155,7 +155,7 @@ void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, cons } template <> -void StyleLayer::applyStyleProperties<FillProperties>(const float z, const timestamp now) { +void StyleLayer::applyStyleProperties<FillProperties>(const float z, const std::chrono::steady_clock::time_point now) { properties.set<FillProperties>(); FillProperties &fill = properties.get<FillProperties>(); applyStyleProperty(PropertyKey::FillAntialias, fill.antialias, z, now); @@ -169,7 +169,7 @@ void StyleLayer::applyStyleProperties<FillProperties>(const float z, const times } template <> -void StyleLayer::applyStyleProperties<LineProperties>(const float z, const timestamp now) { +void StyleLayer::applyStyleProperties<LineProperties>(const float z, const std::chrono::steady_clock::time_point now) { properties.set<LineProperties>(); LineProperties &line = properties.get<LineProperties>(); applyTransitionedStyleProperty(PropertyKey::LineOpacity, line.opacity, z, now); @@ -184,11 +184,11 @@ void StyleLayer::applyStyleProperties<LineProperties>(const float z, const times applyStyleProperty(PropertyKey::LineImage, line.image, z, now); // for scaling dasharrays - applyStyleProperty(PropertyKey::LineWidth, line.dash_line_width, std::floor(z), now + 10000); + applyStyleProperty(PropertyKey::LineWidth, line.dash_line_width, std::floor(z), std::chrono::steady_clock::time_point::max()); } template <> -void StyleLayer::applyStyleProperties<SymbolProperties>(const float z, const timestamp now) { +void StyleLayer::applyStyleProperties<SymbolProperties>(const float z, const std::chrono::steady_clock::time_point now) { properties.set<SymbolProperties>(); SymbolProperties &symbol = properties.get<SymbolProperties>(); applyTransitionedStyleProperty(PropertyKey::IconOpacity, symbol.icon.opacity, z, now); @@ -214,7 +214,7 @@ void StyleLayer::applyStyleProperties<SymbolProperties>(const float z, const tim } template <> -void StyleLayer::applyStyleProperties<RasterProperties>(const float z, const timestamp now) { +void StyleLayer::applyStyleProperties<RasterProperties>(const float z, const std::chrono::steady_clock::time_point now) { properties.set<RasterProperties>(); RasterProperties &raster = properties.get<RasterProperties>(); applyTransitionedStyleProperty(PropertyKey::RasterOpacity, raster.opacity, z, now); @@ -227,7 +227,7 @@ void StyleLayer::applyStyleProperties<RasterProperties>(const float z, const tim } template <> -void StyleLayer::applyStyleProperties<BackgroundProperties>(const float z, const timestamp now) { +void StyleLayer::applyStyleProperties<BackgroundProperties>(const float z, const std::chrono::steady_clock::time_point now) { properties.set<BackgroundProperties>(); BackgroundProperties &background = properties.get<BackgroundProperties>(); applyTransitionedStyleProperty(PropertyKey::BackgroundOpacity, background.opacity, z, now); @@ -235,7 +235,7 @@ void StyleLayer::applyStyleProperties<BackgroundProperties>(const float z, const applyStyleProperty(PropertyKey::BackgroundImage, background.image, z, now); } -void StyleLayer::updateProperties(float z, const timestamp now) { +void StyleLayer::updateProperties(float z, const std::chrono::steady_clock::time_point now) { cleanupAppliedStyleProperties(now); switch (type) { @@ -258,7 +258,7 @@ bool StyleLayer::hasTransitions() const { } -void StyleLayer::cleanupAppliedStyleProperties(timestamp now) { +void StyleLayer::cleanupAppliedStyleProperties(std::chrono::steady_clock::time_point now) { auto it = appliedStyle.begin(); const auto end = appliedStyle.end(); while (it != end) { |