diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-11-13 18:04:47 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-12-02 17:11:49 +0200 |
commit | 2bb2a40b6d13d4fe44e8879003a3e53416033a34 (patch) | |
tree | 19b184fc5faef7a2bfaba579f61c59e8e3e1db7b /src/mbgl/layout | |
parent | f4f652063d9a9903d96bf6f32257a5e6fd6dbfe2 (diff) | |
download | qtlocation-mapboxgl-2bb2a40b6d13d4fe44e8879003a3e53416033a34.tar.gz |
[core] Shape images in labels and create image quads
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r-- | src/mbgl/layout/layout.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_instance.cpp | 13 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_instance.hpp | 16 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 27 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.hpp | 8 |
5 files changed, 40 insertions, 27 deletions
diff --git a/src/mbgl/layout/layout.hpp b/src/mbgl/layout/layout.hpp index 91d3e3f596..4e7c0c7aca 100644 --- a/src/mbgl/layout/layout.hpp +++ b/src/mbgl/layout/layout.hpp @@ -23,8 +23,7 @@ public: const bool, const bool) = 0; - virtual void prepareSymbols(const GlyphMap&, const GlyphPositions&, - const ImageMap&, const ImagePositions&) {}; + virtual void prepareSymbols(const GlyphMap&, const GlyphPositions&, const ImageMap&, const ImagePositions&){}; virtual bool hasSymbolInstances() const { return true; diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp index 41a00e0131..d48a3af388 100644 --- a/src/mbgl/layout/symbol_instance.cpp +++ b/src/mbgl/layout/symbol_instance.cpp @@ -25,8 +25,9 @@ SymbolInstanceSharedData::SymbolInstanceSharedData(GeometryCoordinates line_, const style::SymbolLayoutProperties::Evaluated& layout, const style::SymbolPlacementType textPlacement, const std::array<float, 2>& textOffset, - const GlyphPositions& positions, - bool allowVerticalPlacement) : line(std::move(line_)) { + const ImageMap& imageMap, + bool allowVerticalPlacement) + : line(std::move(line_)) { // Create the quads used for rendering the icon and glyphs. if (shapedIcon) { iconQuad = getIconQuad(*shapedIcon, getAnyShaping(shapedTextOrientations).writingMode); @@ -38,11 +39,12 @@ SymbolInstanceSharedData::SymbolInstanceSharedData(GeometryCoordinates line_, bool singleLineInitialized = false; const auto initHorizontalGlyphQuads = [&] (SymbolQuads& quads, const Shaping& shaping) { if (!shapedTextOrientations.singleLine) { - quads = getGlyphQuads(shaping, textOffset, layout, textPlacement, positions, allowVerticalPlacement); + quads = getGlyphQuads(shaping, textOffset, layout, textPlacement, imageMap, allowVerticalPlacement); return; } if (!singleLineInitialized) { - rightJustifiedGlyphQuads = getGlyphQuads(shaping, textOffset, layout, textPlacement, positions, allowVerticalPlacement); + rightJustifiedGlyphQuads = + getGlyphQuads(shaping, textOffset, layout, textPlacement, imageMap, allowVerticalPlacement); singleLineInitialized = true; } }; @@ -60,7 +62,8 @@ SymbolInstanceSharedData::SymbolInstanceSharedData(GeometryCoordinates line_, } if (shapedTextOrientations.vertical) { - verticalGlyphQuads = getGlyphQuads(shapedTextOrientations.vertical, textOffset, layout, textPlacement, positions, allowVerticalPlacement); + verticalGlyphQuads = getGlyphQuads( + shapedTextOrientations.vertical, textOffset, layout, textPlacement, imageMap, allowVerticalPlacement); } } diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp index 4a57b527f7..bc2ff48d33 100644 --- a/src/mbgl/layout/symbol_instance.hpp +++ b/src/mbgl/layout/symbol_instance.hpp @@ -23,14 +23,14 @@ struct ShapedTextOrientations { struct SymbolInstanceSharedData { SymbolInstanceSharedData(GeometryCoordinates line, - const ShapedTextOrientations& shapedTextOrientations, - const optional<PositionedIcon>& shapedIcon, - const optional<PositionedIcon>& verticallyShapedIcon, - const style::SymbolLayoutProperties::Evaluated& layout, - const style::SymbolPlacementType textPlacement, - const std::array<float, 2>& textOffset, - const GlyphPositions& positions, - bool allowVerticalPlacement); + const ShapedTextOrientations& shapedTextOrientations, + const optional<PositionedIcon>& shapedIcon, + const optional<PositionedIcon>& verticallyShapedIcon, + const style::SymbolLayoutProperties::Evaluated& layout, + const style::SymbolPlacementType textPlacement, + const std::array<float, 2>& textOffset, + const ImageMap& imageMap, + bool allowVerticalPlacement); bool empty() const; GeometryCoordinates line; // Note: When singleLine == true, only `rightJustifiedGlyphQuads` is populated. diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 55de0d2a2b..1207c1c668 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -340,8 +340,10 @@ std::array<float, 2> SymbolLayout::evaluateVariableOffset(style::SymbolAnchorTyp return result; } -void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions, - const ImageMap& imageMap, const ImagePositions& imagePositions) { +void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, + const GlyphPositions& glyphPositions, + const ImageMap& imageMap, + const ImagePositions& imagePositions) { const bool isPointPlacement = layout->get<SymbolPlacement>() == SymbolPlacementType::Point; const bool textAlongLine = layout->get<TextRotationAlignment>() == AlignmentType::Map && !isPointPlacement; @@ -375,7 +377,8 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions /* translate */ textOffset, /* writingMode */ writingMode, /* bidirectional algorithm object */ bidi, - /* glyphs */ glyphMap, + glyphMap, + /* glyphs */ glyphPositions, /* images */ imagePositions, layoutTextSize, allowVerticalPlacement); @@ -430,7 +433,7 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions Shaping shaping = applyShaping(*feature.formattedText, WritingModeType::Horizontal, SymbolAnchorType::Center, justification); if (shaping) { shapingForJustification = std::move(shaping); - if (shapingForJustification.lineCount == 1u) { + if (shapingForJustification.positionedLines.size() == 1u) { shapedTextOrientations.singleLine = true; break; } @@ -488,7 +491,7 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions feature, shapedTextOrientations, std::move(shapedIcon), - glyphPositions, + imageMap, textOffset, layoutTextSize, layoutIconSize, @@ -505,7 +508,7 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, const SymbolFeature& feature, const ShapedTextOrientations& shapedTextOrientations, optional<PositionedIcon> shapedIcon, - const GlyphPositions& glyphPositions, + const ImageMap& imageMap, std::array<float, 2> textOffset, float layoutTextSize, float layoutIconSize, @@ -585,10 +588,16 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, } }; - const auto createSymbolInstanceSharedData = [&] (GeometryCoordinates line) { + const auto createSymbolInstanceSharedData = [&](GeometryCoordinates line) { return std::make_shared<SymbolInstanceSharedData>(std::move(line), - shapedTextOrientations, shapedIcon, verticallyShapedIcon, evaluatedLayoutProperties, - textPlacement, textOffset, glyphPositions, allowVerticalPlacement); + shapedTextOrientations, + shapedIcon, + verticallyShapedIcon, + evaluatedLayoutProperties, + textPlacement, + textOffset, + imageMap, + allowVerticalPlacement); }; const auto& type = feature.getType(); diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index 804bc39741..86bfd46a31 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -31,8 +31,10 @@ public: ~SymbolLayout() final = default; - void prepareSymbols(const GlyphMap&, const GlyphPositions&, - const ImageMap&, const ImagePositions&) override; + void prepareSymbols(const GlyphMap& glyphMap, + const GlyphPositions&, + const ImageMap&, + const ImagePositions&) override; void createBucket(const ImagePositions&, std::unique_ptr<FeatureIndex>&, std::unordered_map<std::string, LayerRenderData>&, const bool firstLoad, const bool showCollisionBoxes) override; @@ -60,7 +62,7 @@ private: const SymbolFeature&, const ShapedTextOrientations& shapedTextOrientations, optional<PositionedIcon> shapedIcon, - const GlyphPositions&, + const ImageMap&, std::array<float, 2> textOffset, float layoutTextSize, float layoutIconSize, |