Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Set fade/transition duration to 0 if map mode is still
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Oct 14, 2015
1 parent 071dbcf commit 9a97333
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
20 changes: 18 additions & 2 deletions src/mbgl/map/map_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MapData {
: mode(mode_)
, pixelRatio(pixelRatio_)
, animationTime(Duration::zero())
, defaultFadeDuration(std::chrono::milliseconds(300))
, defaultFadeDuration(mode_ == MapMode::Continuous ? std::chrono::milliseconds(300) : Duration::zero())
, defaultTransitionDuration(Duration::zero())
, defaultTransitionDelay(Duration::zero()) {
assert(pixelRatio > 0);
Expand Down Expand Up @@ -71,9 +71,13 @@ class MapData {
inline TimePoint getAnimationTime() const {
// We're casting the TimePoint to and from a Duration because libstdc++
// has a bug that doesn't allow TimePoints to be atomic.
return TimePoint(animationTime);
return mode == MapMode::Continuous ? TimePoint(animationTime) : Clock::now();
}
inline void setAnimationTime(const TimePoint& timePoint) {
if (mode == MapMode::Still) {
return;
}

animationTime = timePoint.time_since_epoch();
};

Expand All @@ -82,6 +86,10 @@ class MapData {
}

inline void setDefaultFadeDuration(const Duration& duration) {
if (mode == MapMode::Still) {
return;
}

defaultFadeDuration = duration;
}

Expand All @@ -90,6 +98,10 @@ class MapData {
}

inline void setDefaultTransitionDuration(const Duration& duration) {
if (mode == MapMode::Still) {
return;
}

defaultTransitionDuration = duration;
}

Expand All @@ -98,6 +110,10 @@ class MapData {
}

inline void setDefaultTransitionDelay(const Duration& delay) {
if (mode == MapMode::Still) {
return;
}

defaultTransitionDelay = delay;
}

Expand Down
8 changes: 4 additions & 4 deletions src/mbgl/style/style_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,11 @@ template<> StyleParser::Result<PropertyTransition> StyleParser::parseProperty(JS
PropertyTransition transition { data.getDefaultTransitionDuration(), data.getDefaultTransitionDelay() };
if (value.IsObject()) {
bool parsed = false;
if (value.HasMember("duration") && value["duration"].IsNumber()) {
if (value.HasMember("duration") && value["duration"].IsNumber() && data.mode == MapMode::Continuous) {
transition.duration = std::chrono::milliseconds(value["duration"].GetUint());
parsed = true;
}
if (value.HasMember("delay") && value["delay"].IsNumber()) {
if (value.HasMember("delay") && value["delay"].IsNumber() && data.mode == MapMode::Continuous) {
transition.delay = std::chrono::milliseconds(value["delay"].GetUint());
parsed = true;
}
Expand Down Expand Up @@ -594,7 +594,7 @@ template<> StyleParser::Result<Function<Color>> StyleParser::parseProperty(JSVal

template<> StyleParser::Result<PiecewiseConstantFunction<Faded<std::vector<float>>>> StyleParser::parseProperty(JSVal value, const char *property_name, JSVal transition) {
Duration duration = data.getDefaultFadeDuration();
if (transition.HasMember("duration")) {
if (transition.HasMember("duration") && data.mode == MapMode::Continuous) {
duration = std::chrono::milliseconds(transition["duration"].GetUint());
}

Expand All @@ -613,7 +613,7 @@ template<> StyleParser::Result<PiecewiseConstantFunction<Faded<std::vector<float

template<> StyleParser::Result<PiecewiseConstantFunction<Faded<std::string>>> StyleParser::parseProperty(JSVal value, const char *property_name, JSVal transition) {
Duration duration = data.getDefaultFadeDuration();
if (transition.HasMember("duration")) {
if (transition.HasMember("duration") && data.mode == MapMode::Continuous) {
duration = std::chrono::milliseconds(transition["duration"].GetUint());
}

Expand Down

0 comments on commit 9a97333

Please sign in to comment.