diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-08-08 13:56:22 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-08-20 12:31:02 +0300 |
commit | 9ba700fd47cccb3b615afae0b4b309c1e69da2f7 (patch) | |
tree | 3f788876e2a2be9d4787d81a961b660125b5546e /src/mbgl/renderer | |
parent | 073a243862ce9634cd7db2a06aebbd3ac60a7402 (diff) | |
download | qtlocation-mapboxgl-9ba700fd47cccb3b615afae0b4b309c1e69da2f7.tar.gz |
[core] Fix combination of icon-text-fit with text-variable-anchors and text-writing-mode
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.hpp | 7 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_symbol_layer.cpp | 7 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 21a7870473..681a492e73 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -228,6 +228,10 @@ void SymbolBucket::sortFeatures(const float angle) { if (symbolInstance.placedIconIndex) { addPlacedSymbol(icon.triangles, icon.placedSymbols[*symbolInstance.placedIconIndex]); } + + if (symbolInstance.placedVerticalIconIndex) { + addPlacedSymbol(icon.triangles, icon.placedSymbols[*symbolInstance.placedVerticalIconIndex]); + } } } diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index f47ced8331..20c0c5b790 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -21,9 +21,9 @@ class CrossTileSymbolLayerIndex; class PlacedSymbol { public: PlacedSymbol(Point<float> anchorPoint_, uint16_t segment_, float lowerSize_, float upperSize_, - std::array<float, 2> lineOffset_, WritingModeType writingModes_, GeometryCoordinates line_, std::vector<float> tileDistances_) : + std::array<float, 2> lineOffset_, WritingModeType writingModes_, GeometryCoordinates line_, std::vector<float> tileDistances_, optional<size_t> placedIconIndex_ = nullopt) : anchorPoint(anchorPoint_), segment(segment_), lowerSize(lowerSize_), upperSize(upperSize_), - lineOffset(lineOffset_), writingModes(writingModes_), line(std::move(line_)), tileDistances(std::move(tileDistances_)), hidden(false), vertexStartIndex(0) + lineOffset(lineOffset_), writingModes(writingModes_), line(std::move(line_)), tileDistances(std::move(tileDistances_)), hidden(false), vertexStartIndex(0), placedIconIndex(std::move(placedIconIndex_)) { } Point<float> anchorPoint; @@ -43,6 +43,9 @@ public: // placement for orientation variants. optional<style::TextWritingModeType> placedOrientation; float angle = 0; + + // Reference to placed icon, only applicable for text symbols. + optional<size_t> placedIconIndex; }; class SymbolBucket final : public Bucket { diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 9733241393..ffb32b9746 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -131,11 +131,12 @@ void drawIcon(const DrawFn& draw, : gfx::TextureFilterType::Nearest }; const Size& iconSize = tile.getIconAtlasTexture().size; + const bool variablePlacedIcon = bucket.hasVariablePlacement && layout.get<IconTextFit>() != IconTextFitType::None; if (bucket.sdfIcons) { if (values.hasHalo) { draw(parameters.programs.getSymbolLayerPrograms().symbolIconSDF, - SymbolSDFIconProgram::layoutUniformValues(false, false, values, iconSize, parameters.pixelsToGLUnits, parameters.pixelRatio, alongLine, tile, parameters.state, parameters.symbolFadeChange, SymbolSDFPart::Halo), + SymbolSDFIconProgram::layoutUniformValues(false, variablePlacedIcon, values, iconSize, parameters.pixelsToGLUnits, parameters.pixelRatio, alongLine, tile, parameters.state, parameters.symbolFadeChange, SymbolSDFPart::Halo), bucket.icon, iconSegments, bucket.iconSizeBinder, @@ -149,7 +150,7 @@ void drawIcon(const DrawFn& draw, if (values.hasFill) { draw(parameters.programs.getSymbolLayerPrograms().symbolIconSDF, - SymbolSDFIconProgram::layoutUniformValues(false, false, values, iconSize, parameters.pixelsToGLUnits, parameters.pixelRatio, alongLine, tile, parameters.state, parameters.symbolFadeChange, SymbolSDFPart::Fill), + SymbolSDFIconProgram::layoutUniformValues(false, variablePlacedIcon, values, iconSize, parameters.pixelsToGLUnits, parameters.pixelRatio, alongLine, tile, parameters.state, parameters.symbolFadeChange, SymbolSDFPart::Fill), bucket.icon, iconSegments, bucket.iconSizeBinder, @@ -162,7 +163,7 @@ void drawIcon(const DrawFn& draw, } } else { draw(parameters.programs.getSymbolLayerPrograms().symbolIcon, - SymbolIconProgram::layoutUniformValues(false, false, values, iconSize, parameters.pixelsToGLUnits, alongLine, tile, parameters.state, parameters.symbolFadeChange), + SymbolIconProgram::layoutUniformValues(false, variablePlacedIcon, values, iconSize, parameters.pixelsToGLUnits, alongLine, tile, parameters.state, parameters.symbolFadeChange), bucket.icon, iconSegments, bucket.iconSizeBinder, |