diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-03-20 18:08:01 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-03-29 16:18:41 +0200 |
commit | b39c71eea805d0551608f97ad1f35525d0586b14 (patch) | |
tree | aec6480c147f560dd3e50025b283e0f705ee2ac2 /src/mbgl/renderer | |
parent | 9fc42b9c3ceef09a51686a29985ce70dd0a78f6d (diff) | |
download | qtlocation-mapboxgl-b39c71eea805d0551608f97ad1f35525d0586b14.tar.gz |
[core] Introduce variable text placement for point labels - Layout part
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.cpp | 20 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.hpp | 6 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 9220235f1d..38342b44ee 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -17,7 +17,8 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo bool iconsNeedLinear_, bool sortFeaturesByY_, const std::string bucketName_, - const std::vector<SymbolInstance>&& symbolInstances_) + const std::vector<SymbolInstance>&& symbolInstances_, + float tilePixelRatio_) : layout(std::move(layout_)), sdfIcons(sdfIcons_), iconsNeedLinear(iconsNeedLinear_ || iconSize.isDataDriven() || !iconSize.isZoomConstant()), @@ -25,7 +26,8 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo bucketLeaderID(std::move(bucketName_)), symbolInstances(std::move(symbolInstances_)), textSizeBinder(SymbolSizeBinder::create(zoom, textSize, TextSize::defaultValue())), - iconSizeBinder(SymbolSizeBinder::create(zoom, iconSize, IconSize::defaultValue())) { + iconSizeBinder(SymbolSizeBinder::create(zoom, iconSize, IconSize::defaultValue())), + tilePixelRatio(tilePixelRatio_) { for (const auto& pair : paintProperties_) { auto layerPaintProperties = pair.second; @@ -218,12 +220,22 @@ void SymbolBucket::sortFeatures(const float angle) { const SymbolInstance& symbolInstance = symbolInstances[i]; featureSortOrder->push_back(symbolInstance.dataFeatureIndex); - if (symbolInstance.placedTextIndex) { - addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.placedTextIndex]); + if (symbolInstance.placedRightTextIndex) { + addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.placedRightTextIndex]); } + + if (symbolInstance.placedCenterTextIndex) { + addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.placedCenterTextIndex]); + } + + if (symbolInstance.placedLeftTextIndex) { + addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.placedLeftTextIndex]); + } + if (symbolInstance.placedVerticalTextIndex) { addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.placedVerticalTextIndex]); } + if (symbolInstance.placedIconIndex) { addPlacedSymbol(icon.triangles, icon.placedSymbols[*symbolInstance.placedIconIndex]); } diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index fafa2592fe..f8ffc1a8eb 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -35,6 +35,8 @@ public: std::vector<float> glyphOffsets; bool hidden; size_t vertexStartIndex; + // The crossTileID is only filled/used on the foreground for variable text anchors + uint32_t crossTileID = 0u; }; class SymbolBucket final : public Bucket { @@ -48,7 +50,8 @@ public: bool iconsNeedLinear, bool sortFeaturesByY, const std::string bucketLeaderID, - const std::vector<SymbolInstance>&&); + const std::vector<SymbolInstance>&&, + const float tilePixelRatio); ~SymbolBucket() override; void upload(gfx::Context&) override; @@ -130,6 +133,7 @@ public: optional<gfx::IndexBuffer> indexBuffer; } collisionCircle; + const float tilePixelRatio; uint32_t bucketInstanceId = 0; bool justReloaded = false; optional<bool> hasFormatSectionOverrides_; |