Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

split renderSync and transition nudging to allow client view syncing #1813

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/mbgl/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class Map : private util::noncopyable {
void renderStill(StillImageCallback callback);

// Triggers a synchronous or asynchronous render.
void renderSync();
bool renderSync();

// Nudges transitions one step, possibly notifying of the need for a rerender.
void nudgeTransitions(bool forceRerender);

// Notifies the Map thread that the state has changed and an update might be necessary.
void update(Update update = Update::Nothing);
Expand Down
3 changes: 2 additions & 1 deletion platform/ios/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect

_mbglMap->setSourceTileCacheSize(cacheSize);

_mbglMap->renderSync();
bool needsRerender = _mbglMap->renderSync();
_mbglMap->nudgeTransitions(needsRerender);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/mbgl/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void Map::renderStill(StillImageCallback callback) {
context->invoke(&MapContext::renderStill, transform->getState(), callback);
}

void Map::renderSync() {
bool Map::renderSync() {
if (renderState == RenderState::never) {
view.notifyMapChange(MapChangeWillStartRenderingMap);
}
Expand All @@ -67,9 +67,13 @@ void Map::renderSync() {
view.notifyMapChange(MapChangeDidFinishRenderingMapFullyRendered);
}

return result.needsRerender;
}

void Map::nudgeTransitions(bool forceRerender) {
if (transform->needsTransition()) {
update(Update(transform->updateTransitions(Clock::now())));
} else if (result.needsRerender) {
} else if (forceRerender) {
update();
}
}
Expand Down