diff options
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/renderer/symbol_bucket.cpp | 52 | ||||
-rw-r--r-- | src/mbgl/renderer/symbol_bucket.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/text/collision_feature.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/text/collision_feature.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/text/quads.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/text/quads.hpp | 5 |
6 files changed, 44 insertions, 41 deletions
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 420ca27f01..9d0cb14609 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -36,8 +36,8 @@ using namespace style; SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, const Shaping& shapedText, const PositionedIcon& shapedIcon, const SymbolLayoutProperties& layout, const bool addToBuffers, const uint32_t index_, - const float textBoxScale, const float textPadding, const float textAlongLine, - const float iconBoxScale, const float iconPadding, const float iconAlongLine, + const float textBoxScale, const float textPadding, const SymbolPlacementType textPlacement, + const float iconBoxScale, const float iconPadding, const SymbolPlacementType iconPlacement, const GlyphPositions& face, const IndexedSubfeature& indexedFeature) : point(anchor.point), index(index_), @@ -46,17 +46,17 @@ SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, // Create the quads used for rendering the glyphs. glyphQuads(addToBuffers && shapedText ? - getGlyphQuads(anchor, shapedText, textBoxScale, line, layout, textAlongLine, face) : + getGlyphQuads(anchor, shapedText, textBoxScale, line, layout, textPlacement, face) : SymbolQuads()), // Create the quad used for rendering the icon. iconQuads(addToBuffers && shapedIcon ? - getIconQuads(anchor, shapedIcon, line, layout, iconAlongLine, shapedText) : + getIconQuads(anchor, shapedIcon, line, layout, iconPlacement, shapedText) : SymbolQuads()), // Create the collision features that will be used to check whether this symbol instance can be placed - textCollisionFeature(line, anchor, shapedText, textBoxScale, textPadding, textAlongLine, indexedFeature), - iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconAlongLine, indexedFeature) + textCollisionFeature(line, anchor, shapedText, textBoxScale, textPadding, textPlacement, indexedFeature), + iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature) {} @@ -313,12 +313,12 @@ void SymbolBucket::addFeature(const GeometryCollection &lines, const float textPadding = layout.textPadding * tilePixelRatio; const float iconPadding = layout.iconPadding * tilePixelRatio; const float textMaxAngle = layout.textMaxAngle * util::DEG2RAD; - const bool textAlongLine = - layout.textRotationAlignment == AlignmentType::Map && - layout.symbolPlacement == SymbolPlacementType::Line; - const bool iconAlongLine = - layout.iconRotationAlignment == AlignmentType::Map && - layout.symbolPlacement == SymbolPlacementType::Line; + const SymbolPlacementType textPlacement = layout.textRotationAlignment != AlignmentType::Map + ? SymbolPlacementType::Point + : layout.symbolPlacement; + const SymbolPlacementType iconPlacement = layout.iconRotationAlignment != AlignmentType::Map + ? SymbolPlacementType::Point + : layout.symbolPlacement; const bool mayOverlap = layout.textAllowOverlap || layout.iconAllowOverlap || layout.textIgnorePlacement || layout.iconIgnorePlacement; const bool isLine = layout.symbolPlacement == SymbolPlacementType::Line; @@ -364,8 +364,8 @@ void SymbolBucket::addFeature(const GeometryCollection &lines, const bool addToBuffers = (mode == MapMode::Still) || inside || (mayOverlap && false); symbolInstances.emplace_back(anchor, line, shapedText, shapedIcon, layout, addToBuffers, symbolInstances.size(), - textBoxScale, textPadding, textAlongLine, - iconBoxScale, iconPadding, iconAlongLine, + textBoxScale, textPadding, textPlacement, + iconBoxScale, iconPadding, iconPlacement, face, indexedFeature); } } @@ -393,12 +393,12 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) { // Calculate which labels can be shown and when they can be shown and // create the bufers used for rendering. - const bool textAlongLine = - layout.textRotationAlignment == AlignmentType::Map && - layout.symbolPlacement == SymbolPlacementType::Line; - const bool iconAlongLine = - layout.iconRotationAlignment == AlignmentType::Map && - layout.symbolPlacement == SymbolPlacementType::Line; + const SymbolPlacementType textPlacement = layout.textRotationAlignment != AlignmentType::Map + ? SymbolPlacementType::Point + : layout.symbolPlacement; + const SymbolPlacementType iconPlacement = layout.iconRotationAlignment != AlignmentType::Map + ? SymbolPlacementType::Point + : layout.symbolPlacement; const bool mayOverlap = layout.textAllowOverlap || layout.iconAllowOverlap || layout.textIgnorePlacement || layout.iconIgnorePlacement; @@ -458,7 +458,7 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) { if (glyphScale < collisionTile.maxScale) { addSymbols<SymbolRenderData::TextBuffer, TextElementGroup>( renderDataInProgress->text, symbolInstance.glyphQuads, glyphScale, - layout.textKeepUpright, textAlongLine, collisionTile.config.angle); + layout.textKeepUpright, textPlacement, collisionTile.config.angle); } } @@ -467,7 +467,7 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) { if (iconScale < collisionTile.maxScale) { addSymbols<SymbolRenderData::IconBuffer, IconElementGroup>( renderDataInProgress->icon, symbolInstance.iconQuads, iconScale, - layout.iconKeepUpright, iconAlongLine, collisionTile.config.angle); + layout.iconKeepUpright, iconPlacement, collisionTile.config.angle); } } } @@ -478,7 +478,7 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) { } template <typename Buffer, typename GroupType> -void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const bool alongLine, const float placementAngle) { +void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const style::SymbolPlacementType placement, const float placementAngle) { const float placementZoom = ::fmax(std::log(scale) / std::log(2) + zoom, 0); @@ -496,8 +496,10 @@ void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float // drop upside down versions of glyphs const float a = std::fmod(symbol.anchorAngle + placementAngle + M_PI, M_PI * 2); - if (keepUpright && alongLine && (a <= M_PI / 2 || a > M_PI * 3 / 2)) continue; - + if (keepUpright && placement == style::SymbolPlacementType::Line && + (a <= M_PI / 2 || a > M_PI * 3 / 2)) { + continue; + } if (maxZoom <= minZoom) continue; diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 0b95dd8b4d..8c76bd8045 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -47,8 +47,8 @@ class SymbolInstance { explicit SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, const Shaping& shapedText, const PositionedIcon& shapedIcon, const style::SymbolLayoutProperties&, const bool inside, const uint32_t index, - const float textBoxScale, const float textPadding, const float textAlongLine, - const float iconBoxScale, const float iconPadding, const float iconAlongLine, + const float textBoxScale, const float textPadding, style::SymbolPlacementType textPlacement, + const float iconBoxScale, const float iconPadding, style::SymbolPlacementType iconPlacement, const GlyphPositions& face, const IndexedSubfeature& indexedfeature); Point<float> point; uint32_t index; @@ -106,7 +106,7 @@ private: // Adds placed items to the buffer. template <typename Buffer, typename GroupType> void addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, - const bool keepUpright, const bool alongLine, const float placementAngle); + const bool keepUpright, const style::SymbolPlacementType placement, const float placementAngle); public: style::SymbolLayoutProperties layout; diff --git a/src/mbgl/text/collision_feature.cpp b/src/mbgl/text/collision_feature.cpp index 74a41099ff..661c44891f 100644 --- a/src/mbgl/text/collision_feature.cpp +++ b/src/mbgl/text/collision_feature.cpp @@ -5,7 +5,7 @@ namespace mbgl { CollisionFeature::CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const float top, const float bottom, const float left, const float right, - const float boxScale, const float padding, const bool alongLine, IndexedSubfeature indexedFeature_, + const float boxScale, const float padding, const style::SymbolPlacementType placement, IndexedSubfeature indexedFeature_, const bool straight) : indexedFeature(std::move(indexedFeature_)) { @@ -16,7 +16,7 @@ CollisionFeature::CollisionFeature(const GeometryCoordinates &line, const Anchor const float x1 = left * boxScale - padding; const float x2 = right * boxScale + padding; - if (alongLine) { + if (placement == style::SymbolPlacementType::Line) { float height = y2 - y1; const double length = x2 - x1; diff --git a/src/mbgl/text/collision_feature.hpp b/src/mbgl/text/collision_feature.hpp index 5c0095bc6d..12c14fe0c1 100644 --- a/src/mbgl/text/collision_feature.hpp +++ b/src/mbgl/text/collision_feature.hpp @@ -35,22 +35,22 @@ namespace mbgl { // for text explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const Shaping &shapedText, - const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_) + const float boxScale, const float padding, const style::SymbolPlacementType placement, const IndexedSubfeature& indexedFeature_) : CollisionFeature(line, anchor, shapedText.top, shapedText.bottom, shapedText.left, shapedText.right, - boxScale, padding, alongLine, indexedFeature_, false) {} + boxScale, padding, placement, indexedFeature_, false) {} // for icons explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const PositionedIcon &shapedIcon, - const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_) + const float boxScale, const float padding, const style::SymbolPlacementType placement, const IndexedSubfeature& indexedFeature_) : CollisionFeature(line, anchor, shapedIcon.top, shapedIcon.bottom, shapedIcon.left, shapedIcon.right, - boxScale, padding, alongLine, indexedFeature_, true) {} + boxScale, padding, placement, indexedFeature_, true) {} explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const float top, const float bottom, const float left, const float right, - const float boxScale, const float padding, const bool alongLine, + const float boxScale, const float padding, const style::SymbolPlacementType placement, IndexedSubfeature, const bool straight); diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 727b86f610..3f142cd908 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -15,7 +15,7 @@ const float globalMinScale = 0.5f; // underscale by 1 zoom level SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, const GeometryCoordinates& line, const SymbolLayoutProperties& layout, - const bool alongLine, const Shaping& shapedText) { + const style::SymbolPlacementType placement, const Shaping& shapedText) { auto image = *(shapedIcon.image); @@ -63,7 +63,7 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, } float angle = layout.iconRotate * util::DEG2RAD; - if (alongLine) { + if (placement == style::SymbolPlacementType::Line) { assert(static_cast<unsigned int>(anchor.segment) < line.size()); const GeometryCoordinate &prev= line[anchor.segment]; if (anchor.point.y == prev.y && anchor.point.x == prev.x && @@ -166,7 +166,7 @@ void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> glyphs, Anchor & SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText, const float boxScale, const GeometryCoordinates& line, const SymbolLayoutProperties& layout, - const bool alongLine, const GlyphPositions& face) { + const style::SymbolPlacementType placement, const GlyphPositions& face) { const float textRotate = layout.textRotate * util::DEG2RAD; const bool keepUpright = layout.textKeepUpright; @@ -189,7 +189,7 @@ SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText, const float centerX = (positionedGlyph.x + glyph.metrics.advance / 2.0f) * boxScale; GlyphInstances glyphInstances; - if (alongLine) { + if (placement == style::SymbolPlacementType::Line) { getSegmentGlyphs(std::back_inserter(glyphInstances), anchor, centerX, line, anchor.segment, true); if (keepUpright) getSegmentGlyphs(std::back_inserter(glyphInstances), anchor, centerX, line, anchor.segment, false); diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp index dd64af682a..d4edbf9493 100644 --- a/src/mbgl/text/quads.hpp +++ b/src/mbgl/text/quads.hpp @@ -1,6 +1,7 @@ #pragma once #include <mbgl/text/glyph.hpp> +#include <mbgl/style/types.hpp> #include <mbgl/tile/geometry_tile_data.hpp> #include <vector> @@ -40,10 +41,10 @@ typedef std::vector<SymbolQuad> SymbolQuads; SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, const GeometryCoordinates& line, const style::SymbolLayoutProperties&, - const bool alongLine, const Shaping& shapedText); + style::SymbolPlacementType placement, const Shaping& shapedText); SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText, const float boxScale, const GeometryCoordinates& line, const style::SymbolLayoutProperties&, - const bool alongLine, const GlyphPositions& face); + style::SymbolPlacementType placement, const GlyphPositions& face); } // namespace mbgl |