From ead71325489b16b8b256d3e9c826394c5dbc9bbb Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 1 Aug 2019 16:36:14 +0300 Subject: [core] Simplifications to variable text placement code path --- src/mbgl/text/placement.cpp | 18 ++++++++---------- src/mbgl/text/placement.hpp | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index de282acf79..320cc0fbfa 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -584,15 +584,13 @@ bool Placement::updateBucketDynamicVertices(SymbolBucket& bucket, const Transfor if (pitchWithMap) { shiftedAnchor = project(Point(tileAnchor.x + shift.x, tileAnchor.y + shift.y), labelPlaneMatrix).first; + } else if (rotateWithMap) { + auto rotated = util::rotate(shift, -state.getPitch()); + shiftedAnchor = Point(projectedAnchor.first.x + rotated.x, + projectedAnchor.first.y + rotated.y); } else { - if (rotateWithMap) { - auto rotated = util::rotate(shift, -state.getPitch()); - shiftedAnchor = Point(projectedAnchor.first.x + rotated.x, - projectedAnchor.first.y + rotated.y); - } else { - shiftedAnchor = Point(projectedAnchor.first.x + shift.x, - projectedAnchor.first.y + shift.y); - } + shiftedAnchor = Point(projectedAnchor.first.x + shift.x, + projectedAnchor.first.y + shift.y); } for (std::size_t i = 0; i < symbol.glyphOffsets.size(); ++i) { @@ -806,7 +804,7 @@ const style::TextJustifyType justifyTypes[] = {style::TextJustifyType::Right, st } // namespace -void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableAnchorType placedAnchor, SymbolInstance& symbolInstance, style::TextWritingModeType orientation) { +void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableAnchorType placedAnchor, const SymbolInstance& symbolInstance, style::TextWritingModeType orientation) { style::TextJustifyType anchorJustify = getAnchorJustification(placedAnchor); assert(anchorJustify != style::TextJustifyType::Auto); const optional& autoIndex = justificationToIndex(anchorJustify, symbolInstance, orientation); @@ -826,7 +824,7 @@ void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableA } } -void Placement::markUsedOrientation(SymbolBucket& bucket, style::TextWritingModeType orientation, SymbolInstance& symbolInstance) { +void Placement::markUsedOrientation(SymbolBucket& bucket, style::TextWritingModeType orientation, const SymbolInstance& symbolInstance) { auto horizontal = orientation == style::TextWritingModeType::Horizontal ? optional(orientation) : nullopt; auto vertical = orientation == style::TextWritingModeType::Vertical ? diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp index 33bfbd6527..722a4a0926 100644 --- a/src/mbgl/text/placement.hpp +++ b/src/mbgl/text/placement.hpp @@ -123,8 +123,8 @@ private: // Returns `true` if bucket vertices were updated; returns `false` otherwise. bool updateBucketDynamicVertices(SymbolBucket&, const TransformState&, const RenderTile& tile) const; void updateBucketOpacities(SymbolBucket&, const TransformState&, std::set&); - void markUsedJustification(SymbolBucket&, style::TextVariableAnchorType, SymbolInstance&, style::TextWritingModeType orientation); - void markUsedOrientation(SymbolBucket&, style::TextWritingModeType, SymbolInstance&); + void markUsedJustification(SymbolBucket&, style::TextVariableAnchorType, const SymbolInstance&, style::TextWritingModeType orientation); + void markUsedOrientation(SymbolBucket&, style::TextWritingModeType, const SymbolInstance&); CollisionIndex collisionIndex; -- cgit v1.2.1