Remove duration argument from View::notifyMapChange

Fixes #1026
This commit is contained in:
John Firebaugh
2015-06-24 14:50:54 -07:00
parent e6a576f6eb
commit d193083513
6 changed files with 28 additions and 49 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -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;

View File

@@ -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

View File

@@ -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 {

View File

@@ -19,7 +19,7 @@ std::unique_ptr<StillImage> View::readStillImage() {
return nullptr;
}
void View::notifyMapChange(MapChange, Duration) {
void View::notifyMapChange(MapChange) {
// no-op
}