diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-06-24 14:50:54 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-06-26 10:32:07 -0700 |
commit | d19308351322ea8314137d531a9935e19b6f235f (patch) | |
tree | a785ef5841eda34ba133201a8c399d683b65ab78 | |
parent | e6a576f6eb2fb0124b7cbfbc975398ded5e812f9 (diff) | |
download | qtlocation-mapboxgl-d19308351322ea8314137d531a9935e19b6f235f.tar.gz |
Remove duration argument from View::notifyMapChange
Fixes #1026
-rw-r--r-- | android/cpp/native_map_view.cpp | 2 | ||||
-rw-r--r-- | include/mbgl/android/native_map_view.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/map/view.hpp | 4 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 19 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 48 | ||||
-rw-r--r-- | src/mbgl/map/view.cpp | 2 |
6 files changed, 28 insertions, 49 deletions
diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index 48f75865e6..983797767a 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -640,7 +640,7 @@ void NativeMapView::resume() { } } -void NativeMapView::notifyMapChange(mbgl::MapChange, std::chrono::steady_clock::duration) { +void NativeMapView::notifyMapChange(mbgl::MapChange) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::notifyMapChange()"); assert(vm != nullptr); diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp index 9b89e7305c..af8f76bd74 100644 --- a/include/mbgl/android/native_map_view.hpp +++ b/include/mbgl/android/native_map_view.hpp @@ -26,7 +26,7 @@ public: void invalidate() override; void swap() override; - void notifyMapChange(mbgl::MapChange change, Duration delay = Duration::zero()) override; + void notifyMapChange(mbgl::MapChange) override; mbgl::Map &getMap(); mbgl::DefaultFileSource &getFileSource(); diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index 84ccc89679..e3b0810c45 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -57,9 +57,7 @@ public: // Notifies a watcher of map x/y/scale/rotation changes. // Must only be called from the same thread that caused the change. // Must not be called from the render thread. - virtual void notifyMapChange( - MapChange change, - Duration delay = Duration::zero()); + virtual void notifyMapChange(MapChange change); protected: mbgl::Map *map = nullptr; diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index e70f6c7c60..8f279870e7 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -2726,23 +2726,10 @@ class MBGLView : public mbgl::View // no-op } - void notifyMapChange(mbgl::MapChange change, std::chrono::steady_clock::duration delay = std::chrono::steady_clock::duration::zero()) override + void notifyMapChange(mbgl::MapChange change) override { - if (delay != std::chrono::steady_clock::duration::zero()) - { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, std::chrono::duration_cast<std::chrono::nanoseconds>(delay).count()), dispatch_get_main_queue(), ^ - { - [nativeView performSelector:@selector(notifyMapChange:) - withObject:@(change) - afterDelay:0]; - }); - } - else - { - assert([[NSThread currentThread] isMainThread]); - - [nativeView notifyMapChange:@(change)]; - } + assert([[NSThread currentThread] isMainThread]); + [nativeView notifyMapChange:@(change)]; } void activate() override diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index ed442260bb..b716916318 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -66,19 +66,21 @@ void Transform::moveBy(const double dx, const double dy, const Duration duration } void Transform::_moveBy(const double dx, const double dy, const Duration duration) { - view.notifyMapChange(duration != Duration::zero() ? - MapChangeRegionWillChangeAnimated : - MapChangeRegionWillChange); - double x = state.x + std::cos(state.angle) * dx + std::sin( state.angle) * dy; double y = state.y + std::cos(state.angle) * dy + std::sin(-state.angle) * dx; state.constrain(state.scale, y); if (duration == Duration::zero()) { + view.notifyMapChange(MapChangeRegionWillChange); + state.x = x; state.y = y; + + view.notifyMapChange(MapChangeRegionDidChange); } else { + view.notifyMapChange(MapChangeRegionWillChangeAnimated); + const double startX = state.x; const double startY = state.y; state.panning = true; @@ -91,13 +93,9 @@ void Transform::_moveBy(const double dx, const double dy, const Duration duratio }, [=] { state.panning = false; + view.notifyMapChange(MapChangeRegionDidChangeAnimated); }, duration); } - - view.notifyMapChange(duration != Duration::zero() ? - MapChangeRegionDidChangeAnimated : - MapChangeRegionDidChange, - duration); } void Transform::setLatLng(const LatLng latLng, const Duration duration) { @@ -211,10 +209,6 @@ void Transform::_setScale(double new_scale, double cx, double cy, const Duration void Transform::_setScaleXY(const double new_scale, const double xn, const double yn, const Duration duration) { - view.notifyMapChange(duration != Duration::zero() ? - MapChangeRegionWillChangeAnimated : - MapChangeRegionWillChange); - double scale = new_scale; double x = xn; double y = yn; @@ -222,13 +216,19 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl state.constrain(scale, y); if (duration == Duration::zero()) { + view.notifyMapChange(MapChangeRegionWillChange); + state.scale = scale; state.x = x; state.y = y; const double s = state.scale * util::tileSize; state.Bc = s / 360; state.Cc = s / util::M2PI; + + view.notifyMapChange(MapChangeRegionDidChange); } else { + view.notifyMapChange(MapChangeRegionWillChangeAnimated); + const double startS = state.scale; const double startX = state.x; const double startY = state.y; @@ -248,13 +248,9 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl [=] { state.panning = false; state.scaling = false; + view.notifyMapChange(MapChangeRegionDidChangeAnimated); }, duration); } - - view.notifyMapChange(duration != Duration::zero() ? - MapChangeRegionDidChangeAnimated : - MapChangeRegionDidChange, - duration); } #pragma mark - Angle @@ -321,16 +317,18 @@ void Transform::setAngle(const double new_angle, const double cx, const double c } void Transform::_setAngle(double new_angle, const Duration duration) { - view.notifyMapChange(duration != Duration::zero() ? - MapChangeRegionWillChangeAnimated : - MapChangeRegionWillChange); - double angle = _normalizeAngle(new_angle, state.angle); state.angle = _normalizeAngle(state.angle, angle); if (duration == Duration::zero()) { + view.notifyMapChange(MapChangeRegionWillChange); + state.angle = angle; + + view.notifyMapChange(MapChangeRegionDidChange); } else { + view.notifyMapChange(MapChangeRegionWillChangeAnimated); + const double startA = state.angle; state.rotating = true; @@ -341,13 +339,9 @@ void Transform::_setAngle(double new_angle, const Duration duration) { }, [=] { state.rotating = false; + view.notifyMapChange(MapChangeRegionDidChangeAnimated); }, duration); } - - view.notifyMapChange(duration != Duration::zero() ? - MapChangeRegionDidChangeAnimated : - MapChangeRegionDidChange, - duration); } double Transform::getAngle() const { diff --git a/src/mbgl/map/view.cpp b/src/mbgl/map/view.cpp index fb771a8c49..7d507d87a5 100644 --- a/src/mbgl/map/view.cpp +++ b/src/mbgl/map/view.cpp @@ -19,7 +19,7 @@ std::unique_ptr<StillImage> View::readStillImage() { return nullptr; } -void View::notifyMapChange(MapChange, Duration) { +void View::notifyMapChange(MapChange) { // no-op } |