diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-03 14:53:03 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-05 08:56:36 -0700 |
commit | 66da7594263b657b78aff54a16905184505e275e (patch) | |
tree | 3f940c3852ff7a7d4f2b885c742e4fac06c84abc /src/mbgl/style | |
parent | fd104dd3c229ce42d149a143260407cd259b716c (diff) | |
download | qtlocation-mapboxgl-66da7594263b657b78aff54a16905184505e275e.tar.gz |
[core] Reduce use of RecalculateStyle
* Don't use it to track zoom changes. Instead, Style::update can use the zoom history to check for a change in zoom from the previous frame.
* Don't use it to track active property transitions. Style already knows which layers/light have an active transition, and can re-evaluate only those that do.
This leaves layer property changes as the only use of RecalculateStyle.
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/style.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 1fc738cb84..d2821751be 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -329,7 +329,7 @@ double Style::getDefaultPitch() const { } void Style::update(const UpdateParameters& parameters) { - zoomHistory.update(parameters.transformState.getZoom(), parameters.timePoint); + bool zoomChanged = zoomHistory.update(parameters.transformState.getZoom(), parameters.timePoint); std::vector<ClassID> classIDs; for (const auto& className : classes) { @@ -358,11 +358,14 @@ void Style::update(const UpdateParameters& parameters) { parameters.annotationManager, *this); - if (parameters.updateFlags & Update::Classes) { + const bool cascade = parameters.updateFlags & Update::Classes; + const bool evaluate = cascade || zoomChanged || parameters.updateFlags & Update::RecalculateStyle; + + if (cascade) { transitioningLight = TransitioningLight(*light, std::move(transitioningLight), cascadeParameters); } - if (parameters.updateFlags & Update::RecalculateStyle) { + if (evaluate || transitioningLight.hasTransition()) { evaluatedLight = EvaluatedLight(transitioningLight, evaluationParameters); } @@ -371,11 +374,11 @@ void Style::update(const UpdateParameters& parameters) { } for (const auto& layer : renderLayers) { - if (parameters.updateFlags & Update::Classes) { + if (cascade) { layer->cascade(cascadeParameters); } - if (parameters.updateFlags & Update::Classes || parameters.updateFlags & Update::RecalculateStyle) { + if (evaluate || layer->hasTransition()) { layer->evaluate(evaluationParameters); } |