Substitute nudgeTransitions with async view invalidation
This commit is contained in:
@@ -712,7 +712,6 @@ void NativeMapView::onInvalidate() {
|
||||
map.setSourceTileCacheSize(cacheSize);
|
||||
|
||||
map.renderSync();
|
||||
map.nudgeTransitions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +69,6 @@ public:
|
||||
// Triggers a synchronous render.
|
||||
void renderSync();
|
||||
|
||||
// Nudges transitions one step, possibly notifying of the need for a rerender, if any.
|
||||
void nudgeTransitions();
|
||||
|
||||
// Notifies the Map thread that the state has changed and an update might be necessary.
|
||||
void update(Update update);
|
||||
|
||||
|
||||
@@ -352,7 +352,6 @@ void GLFWView::run() {
|
||||
if (benchmark) {
|
||||
map->setNeedsRepaint();
|
||||
}
|
||||
map->nudgeTransitions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,8 +724,6 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
|
||||
_mbglMap->renderSync();
|
||||
|
||||
[self updateUserLocationAnnotationView];
|
||||
|
||||
_mbglMap->nudgeTransitions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ void Map::renderSync() {
|
||||
|
||||
view.notifyMapChange(MapChangeWillStartRenderingFrame);
|
||||
|
||||
const Update flags = transform->updateTransitions(Clock::now());
|
||||
const bool fullyLoaded = context->invokeSync<bool>(
|
||||
&MapContext::renderSync, transform->getState(), FrameData { view.getFramebufferSize() });
|
||||
|
||||
@@ -68,14 +69,12 @@ void Map::renderSync() {
|
||||
renderState = RenderState::fully;
|
||||
view.notifyMapChange(MapChangeDidFinishRenderingMapFullyRendered);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::nudgeTransitions() {
|
||||
Update flags = transform->updateTransitions(Clock::now());
|
||||
if (data->getNeedsRepaint()) {
|
||||
flags |= Update::Repaint;
|
||||
// Triggers an asynchronous update, that eventually triggers a view
|
||||
// invalidation, causing renderSync to be called again if in transition.
|
||||
if (transform->inTransition()) {
|
||||
update(flags);
|
||||
}
|
||||
update(flags);
|
||||
}
|
||||
|
||||
void Map::update(Update flags) {
|
||||
|
||||
@@ -256,6 +256,8 @@ void MapContext::update() {
|
||||
|
||||
if (!style) {
|
||||
updateFlags = Update::Nothing;
|
||||
} else if (data.getNeedsRepaint()) {
|
||||
updateFlags |= Update::Repaint;
|
||||
}
|
||||
|
||||
if (updateFlags == Update::Nothing || (data.mode == MapMode::Still && !callback)) {
|
||||
@@ -347,7 +349,12 @@ bool MapContext::renderSync(const TransformState& state, const FrameData& frame)
|
||||
|
||||
view.afterRender();
|
||||
|
||||
data.setNeedsRepaint(style->hasTransitions() || painter->needsAnimation());
|
||||
if (style->hasTransitions() || painter->needsAnimation()) {
|
||||
data.setNeedsRepaint(true);
|
||||
asyncUpdate->send();
|
||||
} else {
|
||||
data.setNeedsRepaint(false);
|
||||
}
|
||||
|
||||
return isLoaded();
|
||||
}
|
||||
|
||||
@@ -386,6 +386,10 @@ void Transform::startTransition(std::function<Update(double)> frame,
|
||||
transitionFinishFn = finish;
|
||||
}
|
||||
|
||||
bool Transform::inTransition() const {
|
||||
return transitionFrameFn != nullptr;
|
||||
}
|
||||
|
||||
Update Transform::updateTransitions(const TimePoint& now) {
|
||||
return transitionFrameFn ? transitionFrameFn(now) : Update::Nothing;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
double getPitch() const;
|
||||
|
||||
// Transitions
|
||||
bool inTransition() const;
|
||||
Update updateTransitions(const TimePoint& now);
|
||||
void cancelTransitions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user