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

[core] always commit placement to fix #11795 #12100

Merged
merged 1 commit into from
Jun 11, 2018
Merged
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
10 changes: 4 additions & 6 deletions src/mbgl/renderer/renderer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {

bool placementChanged = false;
if (!placement->stillRecent(parameters.timePoint)) {
placementChanged = true;

auto newPlacement = std::make_unique<Placement>(parameters.state, parameters.mapMode);
std::set<std::string> usedSymbolLayers;
for (auto it = order.rbegin(); it != order.rend(); ++it) {
Expand All @@ -396,13 +398,9 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
}
}

placementChanged = newPlacement->commit(*placement, parameters.timePoint);
newPlacement->commit(*placement, parameters.timePoint);
crossTileSymbolIndex.pruneUnusedLayers(usedSymbolLayers);
if (placementChanged || symbolBucketsChanged) {
placement = std::move(newPlacement);
}

placement->setRecent(parameters.timePoint);
placement = std::move(newPlacement);

updateFadingTiles();
} else {
Expand Down
20 changes: 8 additions & 12 deletions src/mbgl/text/placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Placement::Placement(const TransformState& state_, MapMode mapMode_)
: collisionIndex(state_)
, state(state_)
, mapMode(mapMode_)
, recentUntil(TimePoint::min())
{}

void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatrix, bool showCollisionBoxes) {
Expand Down Expand Up @@ -188,7 +187,7 @@ void Placement::placeLayerBucket(
bucket.justReloaded = false;
}

bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
void Placement::commit(const Placement& prevPlacement, TimePoint now) {
commitTime = now;

bool placementChanged = false;
Expand Down Expand Up @@ -222,7 +221,7 @@ bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
}
}

return placementChanged;
fadeStartTime = placementChanged ? commitTime : prevPlacement.fadeStartTime;
}

void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
Expand Down Expand Up @@ -339,18 +338,15 @@ float Placement::symbolFadeChange(TimePoint now) const {
}

bool Placement::hasTransitions(TimePoint now) const {
return symbolFadeChange(now) < 1.0 || stale;
if (mapMode == MapMode::Continuous) {
return stale || std::chrono::duration<float>(now - fadeStartTime) < Duration(std::chrono::milliseconds(300));
} else {
return false;
}
}

bool Placement::stillRecent(TimePoint now) const {
return mapMode == MapMode::Continuous && recentUntil > now;
}
void Placement::setRecent(TimePoint now) {
stale = false;
if (mapMode == MapMode::Continuous) {
// Only set in continuous mode because "now" isn't defined in still mode
recentUntil = now + Duration(std::chrono::milliseconds(300));
}
return mapMode == MapMode::Continuous && commitTime + Duration(std::chrono::milliseconds(300)) > now;
}

void Placement::setStale() {
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/text/placement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Placement {
public:
Placement(const TransformState&, MapMode mapMode);
void placeLayer(RenderSymbolLayer&, const mat4&, bool showCollisionBoxes);
bool commit(const Placement& prevPlacement, TimePoint);
void commit(const Placement& prevPlacement, TimePoint);
void updateLayerOpacities(RenderSymbolLayer&);
float symbolFadeChange(TimePoint now) const;
bool hasTransitions(TimePoint now) const;
Expand Down Expand Up @@ -94,12 +94,12 @@ class Placement {

TransformState state;
MapMode mapMode;
TimePoint fadeStartTime;
TimePoint commitTime;

std::unordered_map<uint32_t, JointPlacement> placements;
std::unordered_map<uint32_t, JointOpacityState> opacities;

TimePoint recentUntil;
bool stale = false;

std::unordered_map<uint32_t, RetainedQueryData> retainedQueryData;
Expand Down