diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-11 14:57:12 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-18 01:27:48 +0200 |
commit | cd1a06c2dc209da81b3d745c088e568b3b14809f (patch) | |
tree | 0a30b411984b5926e6bd11dd933614317ae359bb /src | |
parent | c6ba05bbc3860d310e04faad93de1e82cb4b42fc (diff) | |
download | qtlocation-mapboxgl-cd1a06c2dc209da81b3d745c088e568b3b14809f.tar.gz |
[core] Get rid of MapData::{get,set}animationTime
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/map_context.cpp | 19 | ||||
-rw-r--r-- | src/mbgl/map/map_context.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/map/map_data.hpp | 19 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/painter_symbol.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/style.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/style.hpp | 6 |
8 files changed, 27 insertions, 40 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 495dc06e3b..1d9cb1ac74 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -56,7 +56,7 @@ void Map::resume() { void Map::renderStill(StillImageCallback callback) { context->invoke(&MapContext::renderStill, transform->getState(), - FrameData{ view.getFramebufferSize() }, callback); + FrameData { view.getFramebufferSize(), Clock::now() }, callback); } void Map::renderSync() { @@ -68,7 +68,7 @@ void Map::renderSync() { const Update flags = transform->updateTransitions(Clock::now()); const bool fullyLoaded = context->invokeSync<bool>( - &MapContext::renderSync, transform->getState(), FrameData { view.getFramebufferSize() }); + &MapContext::renderSync, transform->getState(), FrameData { view.getFramebufferSize(), Clock::now() }); view.notifyMapChange(fullyLoaded ? MapChangeDidFinishRenderingFrameFullyRendered : diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index b03218da1f..ecb3503e23 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -144,7 +144,7 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base) styleJSON = json; // force style cascade, causing all pending transitions to complete. - style->cascade(); + style->cascade(Clock::now()); // set loading here so we don't get a false loaded event as soon as map is // created but before a style is loaded @@ -164,27 +164,29 @@ void MapContext::update() { return; } - data.setAnimationTime(Clock::now()); - if (style->loaded && updateFlags & Update::Annotations) { data.getAnnotationManager()->updateStyle(*style); updateFlags |= Update::Classes; } if (updateFlags & Update::Classes) { - style->cascade(); + style->cascade(frameData.timePoint); } if (updateFlags & Update::Classes || updateFlags & Update::RecalculateStyle) { - style->recalculate(transformState.getZoom()); + style->recalculate(transformState.getZoom(), frameData.timePoint); } - style->update(transformState, *texturePool); + style->update(transformState, frameData.timePoint, *texturePool); if (data.mode == MapMode::Continuous) { asyncInvalidate.send(); - } else if (callback && style->isLoaded()) { - renderSync(transformState, frameData); + } else { + // Update time point so style sources can check they are loaded. + frameData.timePoint = Clock::now(); + if (callback && style->isLoaded()) { + renderSync(transformState, frameData); + } } updateFlags = Update::Nothing; @@ -234,6 +236,7 @@ bool MapContext::renderSync(const TransformState& state, const FrameData& frame) view.beforeRender(); transformState = state; + frameData = frame; if (!painter) painter = std::make_unique<Painter>(data, transformState, glObjectStore); painter->render(*style, frame, data.getAnnotationManager()->getSpriteAtlas()); diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index 55278131ad..8570a40935 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -27,6 +27,7 @@ namespace gl { class TexturePool; } struct FrameData { std::array<uint16_t, 2> framebufferSize; + TimePoint timePoint; }; class MapContext : public Style::Observer { diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp index da41a28035..4cf3140e91 100644 --- a/src/mbgl/map/map_data.hpp +++ b/src/mbgl/map/map_data.hpp @@ -1,8 +1,6 @@ #ifndef MBGL_MAP_MAP_DATA #define MBGL_MAP_MAP_DATA -#include <mbgl/util/chrono.hpp> - #include <mutex> #include <atomic> #include <vector> @@ -23,8 +21,7 @@ public: : mode(mode_) , contextMode(contextMode_) , pixelRatio(pixelRatio_) - , annotationManager(pixelRatio) - , animationTime(Duration::zero()) { + , annotationManager(pixelRatio) { assert(pixelRatio > 0); } @@ -49,19 +46,6 @@ public: debugOptions = debugOptions_; } - 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 mode == MapMode::Continuous ? TimePoint(animationTime) : Clock::now(); - } - inline void setAnimationTime(const TimePoint& timePoint) { - if (mode == MapMode::Still) { - return; - } - - animationTime = timePoint.time_since_epoch(); - }; - util::exclusive<AnnotationManager> getAnnotationManager() { return util::exclusive<AnnotationManager>( &annotationManager, @@ -78,7 +62,6 @@ private: AnnotationManager annotationManager; std::atomic<MapDebugOptions> debugOptions { MapDebugOptions::NoDebug }; - std::atomic<Duration> animationTime; // TODO: make private public: diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index ab35d173ae..c6b8bdbc3b 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -155,7 +155,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a drawClippingMasks(generator.getStencils()); } - frameHistory.record(data.getAnimationTime(), state.getZoom()); + frameHistory.record(frame.timePoint, state.getZoom()); // Actually render the layers if (debug::renderTree) { Log::Info(Event::Render, "{"); indent++; } diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 66f51543ea..ea7a0463d4 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(), util::DEFAULT_FADE_DURATION); + FadeProperties f = frameHistory.getFadeProperties(frame.timePoint, 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 724810a70c..6342dabc45 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -147,12 +147,12 @@ void Style::removeLayer(const std::string& id) { layers.erase(it); } -void Style::update(const TransformState& transform, +void Style::update(const TransformState& transform, const TimePoint& timePoint, gl::TexturePool& texturePool) { bool allTilesUpdated = true; StyleUpdateParameters parameters(data.pixelRatio, data.getDebug(), - data.getAnimationTime(), + timePoint, transform, workers, fileSource, @@ -175,7 +175,7 @@ void Style::update(const TransformState& transform, } } -void Style::cascade() { +void Style::cascade(const TimePoint& timePoint) { // When in continuous mode, we can either have user- or style-defined // transitions. Still mode is always immediate. static const PropertyTransition immediateTransition; @@ -189,7 +189,7 @@ void Style::cascade() { const StyleCascadeParameters parameters { classIDs, - data.getAnimationTime(), + timePoint, data.mode == MapMode::Continuous ? transitionProperties.value_or(immediateTransition) : immediateTransition }; @@ -200,16 +200,16 @@ void Style::cascade() { } } -void Style::recalculate(float z) { +void Style::recalculate(float z, const TimePoint& timePoint) { for (const auto& source : sources) { source->enabled = false; } - zoomHistory.update(z, data.getAnimationTime()); + zoomHistory.update(z, timePoint); const StyleCalculationParameters parameters { z, - data.getAnimationTime(), + timePoint, zoomHistory, data.mode == MapMode::Continuous ? util::DEFAULT_FADE_DURATION : Duration::zero() }; diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index 6321a04c3f..e4ed7435b0 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -81,10 +81,10 @@ public: // Fetch the tiles needed by the current viewport and emit a signal when // a tile is ready so observers can render the tile. - void update(const TransformState&, gl::TexturePool&); + void update(const TransformState&, const TimePoint&, gl::TexturePool&); - void cascade(); - void recalculate(float z); + void cascade(const TimePoint&); + void recalculate(float z, const TimePoint&); bool hasTransitions() const; |