summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-03-06 21:23:12 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-03-18 01:27:47 +0200
commitc6ba05bbc3860d310e04faad93de1e82cb4b42fc (patch)
tree61bedf81da1a89052072d9a26f3ea8bc5589a1db
parent8f96dea8220074059438e9d732d9ce89bddd7fd9 (diff)
downloadqtlocation-mapboxgl-c6ba05bbc3860d310e04faad93de1e82cb4b42fc.tar.gz
[core] Default fade duration is now a constant
-rw-r--r--include/mbgl/map/map.hpp3
-rw-r--r--include/mbgl/util/constants.hpp1
-rw-r--r--src/mbgl/map/map.cpp9
-rw-r--r--src/mbgl/map/map_data.hpp16
-rw-r--r--src/mbgl/renderer/painter.cpp2
-rw-r--r--src/mbgl/renderer/painter_symbol.cpp2
-rw-r--r--src/mbgl/style/style.cpp10
7 files changed, 10 insertions, 33 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 3de9dc8891..c85e7eae38 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -72,9 +72,6 @@ public:
bool hasClass(const std::string&) const;
std::vector<std::string> getClasses() const;
- void setDefaultFadeDuration(const Duration&);
- Duration getDefaultFadeDuration() const;
-
void setStyleURL(const std::string& url);
void setStyleJSON(const std::string& json, const std::string& base = "");
std::string getStyleURL() const;
diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp
index c49b1ab9df..58f4143766 100644
--- a/include/mbgl/util/constants.hpp
+++ b/include/mbgl/util/constants.hpp
@@ -38,6 +38,7 @@ constexpr double MAX_ZOOM = 25.5;
constexpr uint64_t DEFAULT_MAX_CACHE_SIZE = 50 * 1024 * 1024;;
+constexpr Duration DEFAULT_FADE_DURATION = Milliseconds(300);
constexpr SystemDuration CLOCK_SKEW_RETRY_TIMEOUT = Seconds(30);
} // namespace util
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index b531643ed3..495dc06e3b 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -540,15 +540,6 @@ std::vector<std::string> Map::getClasses() const {
return context->invokeSync<std::vector<std::string>>(&MapContext::getClasses);
}
-void Map::setDefaultFadeDuration(const Duration& duration) {
- data->setDefaultFadeDuration(duration);
- update(Update::Classes);
-}
-
-Duration Map::getDefaultFadeDuration() const {
- return data->getDefaultFadeDuration();
-}
-
void Map::setSourceTileCacheSize(size_t size) {
context->invoke(&MapContext::setSourceTileCacheSize, size);
}
diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp
index 0c3c97ff7a..da41a28035 100644
--- a/src/mbgl/map/map_data.hpp
+++ b/src/mbgl/map/map_data.hpp
@@ -24,8 +24,7 @@ public:
, contextMode(contextMode_)
, pixelRatio(pixelRatio_)
, annotationManager(pixelRatio)
- , animationTime(Duration::zero())
- , defaultFadeDuration(mode_ == MapMode::Continuous ? Milliseconds(300) : Duration::zero()) {
+ , animationTime(Duration::zero()) {
assert(pixelRatio > 0);
}
@@ -63,18 +62,6 @@ public:
animationTime = timePoint.time_since_epoch();
};
- inline Duration getDefaultFadeDuration() const {
- return defaultFadeDuration;
- }
-
- inline void setDefaultFadeDuration(const Duration& duration) {
- if (mode == MapMode::Still) {
- return;
- }
-
- defaultFadeDuration = duration;
- }
-
util::exclusive<AnnotationManager> getAnnotationManager() {
return util::exclusive<AnnotationManager>(
&annotationManager,
@@ -92,7 +79,6 @@ private:
std::atomic<MapDebugOptions> debugOptions { MapDebugOptions::NoDebug };
std::atomic<Duration> animationTime;
- std::atomic<Duration> defaultFadeDuration;
// TODO: make private
public:
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index ebadee35db..ab35d173ae 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -72,7 +72,7 @@ Painter::Painter(MapData& data_, TransformState& state_, gl::GLObjectStore& glOb
Painter::~Painter() = default;
bool Painter::needsAnimation() const {
- return frameHistory.needsAnimation(data.getDefaultFadeDuration());
+ return frameHistory.needsAnimation(util::DEFAULT_FADE_DURATION);
}
void Painter::prepareTile(const Tile& tile) {
diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp
index 7bd4e4ee34..66f51543ea 100644
--- a/src/mbgl/renderer/painter_symbol.cpp
+++ b/src/mbgl/renderer/painter_symbol.cpp
@@ -62,7 +62,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
sdfShader.u_zoom = (state.getZoom() - zoomAdjust) * 10; // current zoom level
if (data.mode == MapMode::Continuous) {
- FadeProperties f = frameHistory.getFadeProperties(data.getAnimationTime(), data.getDefaultFadeDuration());
+ FadeProperties f = frameHistory.getFadeProperties(data.getAnimationTime(), util::DEFAULT_FADE_DURATION);
sdfShader.u_fadedist = f.fadedist * 10;
sdfShader.u_minfadezoom = std::floor(f.minfadezoom * 10);
sdfShader.u_maxfadezoom = std::floor(f.maxfadezoom * 10);
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 4478285bae..724810a70c 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -207,10 +207,12 @@ void Style::recalculate(float z) {
zoomHistory.update(z, data.getAnimationTime());
- StyleCalculationParameters parameters(z,
- data.getAnimationTime(),
- zoomHistory,
- data.getDefaultFadeDuration());
+ const StyleCalculationParameters parameters {
+ z,
+ data.getAnimationTime(),
+ zoomHistory,
+ data.mode == MapMode::Continuous ? util::DEFAULT_FADE_DURATION : Duration::zero()
+ };
hasPendingTransitions = false;
for (const auto& layer : layers) {