summaryrefslogtreecommitdiff
path: root/src/mbgl/map/transform.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-03 14:53:03 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-05 08:56:36 -0700
commit66da7594263b657b78aff54a16905184505e275e (patch)
tree3f940c3852ff7a7d4f2b885c742e4fac06c84abc /src/mbgl/map/transform.cpp
parentfd104dd3c229ce42d149a143260407cd259b716c (diff)
downloadqtlocation-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/map/transform.cpp')
-rw-r--r--src/mbgl/map/transform.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 0480ce4d9d..9f3a2a83d2 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -122,8 +122,6 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
const double scale = state.zoomScale(zoom);
pitch = util::clamp(pitch, state.min_pitch, state.max_pitch);
- Update update = state.getZoom() == zoom ? Update::Repaint : Update::RecalculateStyle;
-
// Minimize rotation by taking the shorter path around the circle.
angle = _normalizeAngle(angle, state.angle);
state.angle = _normalizeAngle(state.angle, angle);
@@ -153,7 +151,6 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
if (!padding.isFlush()) {
state.moveLatLng(frameLatLng, center);
}
- return update;
}, duration);
}
@@ -313,7 +310,6 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
if (!padding.isFlush()) {
state.moveLatLng(frameLatLng, center);
}
- return Update::RecalculateStyle;
}, duration);
}
@@ -533,7 +529,7 @@ ViewportMode Transform::getViewportMode() const {
void Transform::startTransition(const CameraOptions& camera,
const AnimationOptions& animation,
- std::function<Update(double)> frame,
+ std::function<void(double)> frame,
const Duration& duration) {
if (transitionFinishFn) {
transitionFinishFn();
@@ -555,12 +551,11 @@ void Transform::startTransition(const CameraOptions& camera,
transitionFrameFn = [isAnimated, animation, frame, anchor, anchorLatLng, this](const TimePoint now) {
float t = isAnimated ? (std::chrono::duration<float>(now - transitionStart) / transitionDuration) : 1.0;
- Update result;
if (t >= 1.0) {
- result = frame(1.0);
+ frame(1.0);
} else {
util::UnitBezier ease = animation.easing ? *animation.easing : util::DEFAULT_TRANSITION_EASE;
- result = frame(ease.solve(t, 0.001));
+ frame(ease.solve(t, 0.001));
}
if (anchor) state.moveLatLng(anchorLatLng, *anchor);
@@ -579,7 +574,6 @@ void Transform::startTransition(const CameraOptions& camera,
// we can only return after this point.
transitionFrameFn = nullptr;
}
- return result;
};
transitionFinishFn = [isAnimated, animation, this] {
@@ -601,8 +595,10 @@ bool Transform::inTransition() const {
return transitionFrameFn != nullptr;
}
-Update Transform::updateTransitions(const TimePoint& now) {
- return transitionFrameFn ? transitionFrameFn(now) : Update::Nothing;
+void Transform::updateTransitions(const TimePoint& now) {
+ if (transitionFrameFn) {
+ transitionFrameFn(now);
+ }
}
void Transform::cancelTransitions() {