diff options
Diffstat (limited to 'src/mbgl/text/placement.cpp')
-rw-r--r-- | src/mbgl/text/placement.cpp | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index bea2b3f1eb..d81d3779cf 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -61,8 +61,7 @@ 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, nullopt)) {} bool PlacementController::placementIsRecent(TimePoint now, const float zoom, optional<Duration> maximumDuration) const { if (!placement->transitionsEnabled()) return false; @@ -76,7 +75,6 @@ bool PlacementController::placementIsRecent(TimePoint now, const float zoom, opt return placement->getCommitTime() + updatePeriod > now; } - bool PlacementController::hasTransitions(TimePoint now) const { if (!placement->transitionsEnabled()) return false; @@ -87,13 +85,17 @@ bool PlacementController::hasTransitions(TimePoint now) const { // Placement implementation -Placement::Placement(const TransformState& state_, MapMode mapMode_, style::TransitionOptions transitionOptions_, const bool crossSourceCollisions, optional<Immutable<Placement>> prevPlacement_) - : collisionIndex(state_) - , mapMode(mapMode_) - , transitionOptions(std::move(transitionOptions_)) - , placementZoom(state_.getZoom()) - , collisionGroups(crossSourceCollisions) - , prevPlacement(std::move(prevPlacement_)) { +Placement::Placement(const TransformState& state_, + MapMode mapMode_, + style::TransitionOptions transitionOptions_, + const bool crossSourceCollisions, + optional<Immutable<Placement>> prevPlacement_) + : collisionIndex(state_), + mapMode(mapMode_), + transitionOptions(std::move(transitionOptions_)), + placementZoom(state_.getZoom()), + collisionGroups(crossSourceCollisions), + prevPlacement(std::move(prevPlacement_)) { if (prevPlacement) { prevPlacement->get()->prevPlacement = nullopt; // Only hold on to one placement back } @@ -216,12 +218,12 @@ void Placement::placeBucket( const CollisionFeature& textCollisionFeature = symbolInstance.textCollisionFeature; const auto updatePreviousOrientationIfNotPlaced = [&](bool isPlaced) { - if (bucket.allowVerticalPlacement && !isPlaced && getPrevPlacement()) { - auto prevOrientation = getPrevPlacement()->placedOrientations.find(symbolInstance.crossTileID); - if (prevOrientation != getPrevPlacement()->placedOrientations.end()) { - placedOrientations[symbolInstance.crossTileID] = prevOrientation->second; - } + if (bucket.allowVerticalPlacement && !isPlaced && getPrevPlacement()) { + auto prevOrientation = getPrevPlacement()->placedOrientations.find(symbolInstance.crossTileID); + if (prevOrientation != getPrevPlacement()->placedOrientations.end()) { + placedOrientations[symbolInstance.crossTileID] = prevOrientation->second; } + } }; const auto placeTextForPlacementModes = [&] (auto& placeHorizontalFn, auto& placeVerticalFn) { @@ -717,7 +719,9 @@ bool Placement::updateBucketDynamicVertices(SymbolBucket& bucket, const Transfor return result; } -void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState& state, std::set<uint32_t>& seenCrossTileIDs) const { +void Placement::updateBucketOpacities(SymbolBucket& bucket, + const TransformState& state, + std::set<uint32_t>& seenCrossTileIDs) const { if (bucket.hasTextData()) bucket.text.opacityVertices.clear(); if (bucket.hasIconData()) bucket.icon.opacityVertices.clear(); if (bucket.hasSdfIconData()) bucket.sdfIcon.opacityVertices.clear(); @@ -922,7 +926,10 @@ const style::TextJustifyType justifyTypes[] = {style::TextJustifyType::Right, st } // namespace -void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableAnchorType placedAnchor, const SymbolInstance& symbolInstance, style::TextWritingModeType orientation) const { +void Placement::markUsedJustification(SymbolBucket& bucket, + style::TextVariableAnchorType placedAnchor, + const SymbolInstance& symbolInstance, + style::TextWritingModeType orientation) const { style::TextJustifyType anchorJustify = getAnchorJustification(placedAnchor); assert(anchorJustify != style::TextJustifyType::Auto); const optional<size_t>& autoIndex = justificationToIndex(anchorJustify, symbolInstance, orientation); @@ -942,7 +949,9 @@ void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableA } } -void Placement::markUsedOrientation(SymbolBucket& bucket, style::TextWritingModeType orientation, const SymbolInstance& symbolInstance) const { +void Placement::markUsedOrientation(SymbolBucket& bucket, + style::TextWritingModeType orientation, + const SymbolInstance& symbolInstance) const { auto horizontal = orientation == style::TextWritingModeType::Horizontal ? optional<style::TextWritingModeType>(orientation) : nullopt; auto vertical = orientation == style::TextWritingModeType::Vertical ? @@ -1003,7 +1012,8 @@ bool Placement::transitionsEnabled() const { bool Placement::hasTransitions(TimePoint now) const { assert(transitionsEnabled()); - return std::chrono::duration<float>(now - fadeStartTime) < transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION); + return std::chrono::duration<float>(now - fadeStartTime) < + transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION); } const CollisionIndex& Placement::getCollisionIndex() const { |