summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-01-15 15:27:09 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-01-22 14:30:26 +0200
commit5af128f205a404128e804f5c82ecf748a52dac9c (patch)
tree1e1c6c0b697ebbffd590f807b3f17b3beef5bdad
parent4735845a6ee4baad9306b8d5150b093fccdd11a2 (diff)
downloadqtlocation-mapboxgl-5af128f205a404128e804f5c82ecf748a52dac9c.tar.gz
[core] Pass placement commit parameters in constructor
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp8
-rw-r--r--src/mbgl/text/placement.cpp10
-rw-r--r--src/mbgl/text/placement.hpp5
3 files changed, 14 insertions, 9 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index 2462ee6986..aa32acc04a 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -400,6 +400,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
updateParameters.mode,
updateParameters.transitionOptions,
updateParameters.crossSourceCollisions,
+ updateParameters.timePoint,
placementController.getPlacement());
for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
@@ -408,7 +409,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
placement->placeLayer(layer, renderTreeParameters->transformParams.projMatrix, updateParameters.debugOptions & MapDebugOptions::Collision);
}
- placement->commit(updateParameters.timePoint, updateParameters.transformState.getZoom());
+ placement->commit();
crossTileSymbolIndex.pruneUnusedLayers(usedSymbolLayers);
for (const auto& entry : renderSources) {
entry.second->updateFadingTiles();
@@ -427,7 +428,8 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
Mutable<Placement> placement = makeMutable<Placement>(updateParameters.transformState,
updateParameters.mode,
updateParameters.transitionOptions,
- updateParameters.crossSourceCollisions);
+ updateParameters.crossSourceCollisions,
+ updateParameters.timePoint);
for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
const RenderLayer& layer = *it;
crossTileSymbolIndex.addLayer(layer, updateParameters.transformState.getLatLng().longitude());
@@ -435,7 +437,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
renderTreeParameters->transformParams.projMatrix,
updateParameters.debugOptions & MapDebugOptions::Collision);
}
- placement->commit(updateParameters.timePoint, updateParameters.transformState.getZoom());
+ placement->commit();
placementController.setPlacement(std::move(placement));
}
renderTreeParameters->symbolFadeChange = 1.0f;
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index d6a78082fa..f3917a8fdb 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -61,7 +61,8 @@ const CollisionGroups::CollisionGroup& CollisionGroups::get(const std::string& s
// PlacementController implemenation
PlacementController::PlacementController()
- : placement(makeMutable<Placement>(TransformState{}, MapMode::Static, style::TransitionOptions{}, true, nullopt)) {}
+ : placement(makeMutable<Placement>(
+ TransformState{}, MapMode::Static, style::TransitionOptions{}, true, TimePoint(), nullopt)) {}
void PlacementController::setPlacement(Immutable<Placement> placement_) {
placement = std::move(placement_);
@@ -94,10 +95,12 @@ Placement::Placement(const TransformState& state_,
MapMode mapMode_,
style::TransitionOptions transitionOptions_,
const bool crossSourceCollisions,
+ TimePoint commitTime_,
optional<Immutable<Placement>> prevPlacement_)
: collisionIndex(state_, mapMode_),
mapMode(mapMode_),
transitionOptions(std::move(transitionOptions_)),
+ commitTime(commitTime_),
placementZoom(state_.getZoom()),
collisionGroups(crossSourceCollisions),
prevPlacement(std::move(prevPlacement_)) {
@@ -622,8 +625,7 @@ void Placement::placeBucket(const SymbolBucket& bucket,
std::forward_as_tuple(bucket.bucketInstanceId, params.featureIndex, overscaledID));
}
-void Placement::commit(TimePoint now, const double zoom) {
- commitTime = now;
+void Placement::commit() {
if (!getPrevPlacement()) {
assert(mapMode != MapMode::Continuous);
fadeStartTime = commitTime;
@@ -638,7 +640,7 @@ void Placement::commit(TimePoint now, const double zoom) {
bool placementChanged = false;
- prevZoomAdjustment = getPrevPlacement()->zoomAdjustment(zoom);
+ prevZoomAdjustment = getPrevPlacement()->zoomAdjustment(placementZoom);
float increment = getPrevPlacement()->symbolFadeChange(commitTime);
// add the opacities from the current placement, and copy their current values from the previous placement
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 4dd9011da4..dd46970780 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -116,9 +116,10 @@ public:
MapMode,
style::TransitionOptions,
const bool crossSourceCollisions,
+ TimePoint commitTime,
optional<Immutable<Placement>> prevPlacement = nullopt);
void placeLayer(const RenderLayer&, const mat4&, bool showCollisionBoxes);
- void commit(TimePoint, const double zoom);
+ void commit();
void updateLayerBuckets(const RenderLayer&, const TransformState&, bool updateOpacities) const;
float symbolFadeChange(TimePoint now) const;
bool hasTransitions(TimePoint now) const;
@@ -151,7 +152,7 @@ private:
TimePoint fadeStartTime;
TimePoint commitTime;
- float placementZoom;
+ const float placementZoom;
float prevZoomAdjustment = 0;
std::unordered_map<uint32_t, JointPlacement> placements;