From 8fb459aa674df99d9268f1653072635866316f49 Mon Sep 17 00:00:00 2001 From: Tim Sylvester Date: Mon, 24 Jun 2024 08:39:12 -0700 Subject: [PATCH] Pass context through symbol instance accessor methods --- src/mbgl/layout/symbol_instance.hpp | 143 ++++++------ src/mbgl/layout/symbol_layout.cpp | 90 +++---- src/mbgl/renderer/buckets/symbol_bucket.cpp | 34 +-- src/mbgl/text/cross_tile_symbol_index.cpp | 28 +-- src/mbgl/text/placement.cpp | 246 ++++++++++---------- src/mbgl/tile/geometry_tile.cpp | 4 +- 6 files changed, 274 insertions(+), 271 deletions(-) diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp index e33ad0a7fce..341e42a4dc8 100644 --- a/src/mbgl/layout/symbol_instance.hpp +++ b/src/mbgl/layout/symbol_instance.hpp @@ -9,6 +9,7 @@ #define STRINGIZE(x) STRINGIZE2(x) #define STRINGIZE2(x) #x #define __LINE_STRING__ STRINGIZE(__LINE__) +#define __SOURCE_LOCATION__ __FILE__ ":" __LINE_STRING__ namespace mbgl { @@ -89,37 +90,39 @@ class SymbolInstance { const optional& verticalIconQuads() const; void releaseSharedData(); - bool check(std::string_view source = std::string_view()) const { - return !isFailed && - check(check01, 1, source) && - check(check02, 2, source) && - check(check03, 3, source) && - check(check04, 4, source) && - check(check05, 5, source) && - check(check06, 6, source) && - check(check07, 7, source) && - check(check08, 8, source) && - check(check09, 9, source) && - check(check10, 10, source) && - check(check11, 11, source) && - check(check12, 12, source) && - check(check13, 13, source) && - check(check14, 14, source) && - check(check15, 15, source) && - check(check16, 16, source) && - check(check17, 17, source) && - check(check18, 18, source) && - check(check19, 19, source) && - check(check20, 20, source) && - check(check21, 21, source) && - check(check22, 22, source) && - check(check23, 23, source) && - check(check24, 24, source) && - check(check25, 25, source) && - check(check26, 26, source) && - check(check27, 27, source) && - check(check28, 28, source) && - check(check29, 29, source); + bool check(std::string_view source) const { + if (isFailed) + return false; + check(check01, 1, source); + check(check02, 2, source); + check(check03, 3, source); + check(check04, 4, source); + check(check05, 5, source); + check(check06, 6, source); + check(check07, 7, source); + check(check08, 8, source); + check(check09, 9, source); + check(check10, 10, source); + check(check11, 11, source); + check(check12, 12, source); + check(check13, 13, source); + check(check14, 14, source); + check(check15, 15, source); + check(check16, 16, source); + check(check17, 17, source); + check(check18, 18, source); + check(check19, 19, source); + check(check20, 20, source); + check(check21, 21, source); + check(check22, 22, source); + check(check23, 23, source); + check(check24, 24, source); + check(check25, 25, source); + check(check26, 26, source); + check(check27, 27, source); + check(check28, 28, source); + check(check29, 29, source); + return !isFailed; } bool checkIndex(const optional& index, std::size_t size, std::string_view source) const; bool checkIndexes(std::size_t textCount, std::size_t iconSize, std::size_t sdfSize, std::string_view source) const { @@ -132,45 +135,45 @@ class SymbolInstance { checkIndex(placedVerticalIconIndex, hasSdfIcon() ? sdfSize : iconSize, source); } - const Anchor& getAnchor() const { check(); return anchor; } - std::size_t getRightJustifiedGlyphQuadsSize() const { check(); return rightJustifiedGlyphQuadsSize; } - std::size_t getCenterJustifiedGlyphQuadsSize() const { check(); return centerJustifiedGlyphQuadsSize; } - std::size_t getLeftJustifiedGlyphQuadsSize() const { check(); return leftJustifiedGlyphQuadsSize; } - std::size_t getVerticalGlyphQuadsSize() const { check(); return verticalGlyphQuadsSize; } - std::size_t getIconQuadsSize() const { check(); return iconQuadsSize; } - const CollisionFeature& getTextCollisionFeature() const { check(); return textCollisionFeature; } - const CollisionFeature& getIconCollisionFeature() const { check(); return iconCollisionFeature; } - const optional& getVerticalTextCollisionFeature() const { check(); return verticalTextCollisionFeature; } - const optional& getVerticalIconCollisionFeature() const { check(); return verticalIconCollisionFeature; } - WritingModeType getWritingModes() const { check(); return writingModes; } - std::size_t getLayoutFeatureIndex() const { check(); return layoutFeatureIndex; } - std::size_t getDataFeatureIndex() const { check(); return dataFeatureIndex; } - std::array getTextOffset() const { check(); return textOffset; } - std::array getIconOffset() const { check(); return iconOffset; } - const std::u16string& getKey() const { check(); checkKey(); return key; } - optional getPlacedRightTextIndex() const { check(); return placedRightTextIndex; } - optional getPlacedCenterTextIndex() const { check(); return placedCenterTextIndex; } - optional getPlacedLeftTextIndex() const { check(); return placedLeftTextIndex; } - optional getPlacedVerticalTextIndex() const { check(); return placedVerticalTextIndex; } - optional getPlacedIconIndex() const { check(); return placedIconIndex; } - optional getPlacedVerticalIconIndex() const { check(); return placedVerticalIconIndex; } - float getTextBoxScale() const { check(); return textBoxScale; } - std::array getVariableTextOffset() const { check(); return variableTextOffset; } - bool getSingleLine() const { check(); return singleLine; } - - uint32_t getCrossTileID() const { check(); return crossTileID; } - void setCrossTileID(uint32_t x) { check(); crossTileID = x; check(); } - - optional& refPlacedRightTextIndex() { check(); return placedRightTextIndex; } - optional& refPlacedCenterTextIndex() { check(); return placedCenterTextIndex; } - optional& refPlacedLeftTextIndex() { check(); return placedLeftTextIndex; } - optional& refPlacedVerticalTextIndex() { check(); return placedVerticalTextIndex; } - optional& refPlacedIconIndex() { check(); return placedIconIndex; } - optional& refPlacedVerticalIconIndex() { check(); return placedVerticalIconIndex; } - - void setPlacedRightTextIndex(optional x) { check(); placedRightTextIndex = x; check(); } - void setPlacedCenterTextIndex(optional x) { check(); placedCenterTextIndex = x; check(); } - void setPlacedLeftTextIndex(optional x) { check(); placedLeftTextIndex = x; check(); } + const Anchor& getAnchor(std::string_view source) const { check(source); return anchor; } + std::size_t getRightJustifiedGlyphQuadsSize(std::string_view source) const { check(source); return rightJustifiedGlyphQuadsSize; } + std::size_t getCenterJustifiedGlyphQuadsSize(std::string_view source) const { check(source); return centerJustifiedGlyphQuadsSize; } + std::size_t getLeftJustifiedGlyphQuadsSize(std::string_view source) const { check(source); return leftJustifiedGlyphQuadsSize; } + std::size_t getVerticalGlyphQuadsSize(std::string_view source) const { check(source); return verticalGlyphQuadsSize; } + std::size_t getIconQuadsSize(std::string_view source) const { check(source); return iconQuadsSize; } + const CollisionFeature& getTextCollisionFeature(std::string_view source) const { check(source); return textCollisionFeature; } + const CollisionFeature& getIconCollisionFeature(std::string_view source) const { check(source); return iconCollisionFeature; } + const optional& getVerticalTextCollisionFeature(std::string_view source) const { check(source); return verticalTextCollisionFeature; } + const optional& getVerticalIconCollisionFeature(std::string_view source) const { check(source); return verticalIconCollisionFeature; } + WritingModeType getWritingModes(std::string_view source) const { check(source); return writingModes; } + std::size_t getLayoutFeatureIndex(std::string_view source) const { check(source); return layoutFeatureIndex; } + std::size_t getDataFeatureIndex(std::string_view source) const { check(source); return dataFeatureIndex; } + std::array getTextOffset(std::string_view source) const { check(source); return textOffset; } + std::array getIconOffset(std::string_view source) const { check(source); return iconOffset; } + const std::u16string& getKey(std::string_view source) const { check(source); checkKey(); return key; } + optional getPlacedRightTextIndex(std::string_view source) const { check(source); return placedRightTextIndex; } + optional getPlacedCenterTextIndex(std::string_view source) const { check(source); return placedCenterTextIndex; } + optional getPlacedLeftTextIndex(std::string_view source) const { check(source); return placedLeftTextIndex; } + optional getPlacedVerticalTextIndex(std::string_view source) const { check(source); return placedVerticalTextIndex; } + optional getPlacedIconIndex(std::string_view source) const { check(source); return placedIconIndex; } + optional getPlacedVerticalIconIndex(std::string_view source) const { check(source); return placedVerticalIconIndex; } + float getTextBoxScale(std::string_view source) const { check(source); return textBoxScale; } + std::array getVariableTextOffset(std::string_view source) const { check(source); return variableTextOffset; } + bool getSingleLine(std::string_view source) const { check(source); return singleLine; } + + uint32_t getCrossTileID(std::string_view source) const { check(source); return crossTileID; } + void setCrossTileID(uint32_t x, std::string_view source) { check(source); crossTileID = x; } + + optional& refPlacedRightTextIndex(std::string_view source) { check(source); return placedRightTextIndex; } + optional& refPlacedCenterTextIndex(std::string_view source) { check(source); return placedCenterTextIndex; } + optional& refPlacedLeftTextIndex(std::string_view source) { check(source); return placedLeftTextIndex; } + optional& refPlacedVerticalTextIndex(std::string_view source) { check(source); return placedVerticalTextIndex; } + optional& refPlacedIconIndex(std::string_view source) { check(source); return placedIconIndex; } + optional& refPlacedVerticalIconIndex(std::string_view source) { check(source); return placedVerticalIconIndex; } + + void setPlacedRightTextIndex(optional x, std::string_view source) { check(source); placedRightTextIndex = x; } + void setPlacedCenterTextIndex(optional x, std::string_view source) { check(source); placedCenterTextIndex = x; } + void setPlacedLeftTextIndex(optional x, std::string_view source) { check(source); placedLeftTextIndex = x; } static constexpr uint32_t invalidCrossTileID() { return std::numeric_limits::max(); } diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 1b371ddafe1..a3cfbed3ca3 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -775,13 +775,13 @@ void SymbolLayout::createBucket(const ImagePositions&, iconsInText); for (SymbolInstance &symbolInstance : bucket->symbolInstances) { - if (!symbolInstance.check("createBucket 1")) continue; + if (!symbolInstance.check(__SOURCE_LOCATION__)) continue; const bool hasText = symbolInstance.hasText(); const bool hasIcon = symbolInstance.hasIcon(); - const bool singleLine = symbolInstance.getSingleLine(); + const bool singleLine = symbolInstance.getSingleLine(__SOURCE_LOCATION__); - const auto& feature = features.at(symbolInstance.getLayoutFeatureIndex()); + const auto& feature = features.at(symbolInstance.getLayoutFeatureIndex(__SOURCE_LOCATION__)); // Insert final placement into collision tree and add glyphs/icons to buffers @@ -791,11 +791,11 @@ void SymbolLayout::createBucket(const ImagePositions&, const Range sizeData = bucket->iconSizeBinder->getVertexSizeData(feature); auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket->sdfIcon : bucket->icon; const auto placeIcon = [&](const SymbolQuads& iconQuads, auto& index, const WritingModeType writingMode) { - iconBuffer.placedSymbols.emplace_back(symbolInstance.getAnchor().point, - symbolInstance.getAnchor().segment.value_or(0u), + iconBuffer.placedSymbols.emplace_back(symbolInstance.getAnchor(__SOURCE_LOCATION__).point, + symbolInstance.getAnchor(__SOURCE_LOCATION__).segment.value_or(0u), sizeData.min, sizeData.max, - symbolInstance.getIconOffset(), + symbolInstance.getIconOffset(__SOURCE_LOCATION__), writingMode, symbolInstance.line(), std::vector()); @@ -803,21 +803,21 @@ void SymbolLayout::createBucket(const ImagePositions&, PlacedSymbol& iconSymbol = iconBuffer.placedSymbols.back(); iconSymbol.angle = (allowVerticalPlacement && writingMode == WritingModeType::Vertical) ? static_cast(M_PI_2) : 0.0f; iconSymbol.vertexStartIndex = - addSymbols(iconBuffer, sizeData, iconQuads, symbolInstance.getAnchor(), iconSymbol, feature.sortKey); + addSymbols(iconBuffer, sizeData, iconQuads, symbolInstance.getAnchor(__SOURCE_LOCATION__), iconSymbol, feature.sortKey); }; - placeIcon(*symbolInstance.iconQuads(), symbolInstance.refPlacedIconIndex(), WritingModeType::None); - symbolInstance.check(); + placeIcon(*symbolInstance.iconQuads(), symbolInstance.refPlacedIconIndex(__SOURCE_LOCATION__), WritingModeType::None); + symbolInstance.check(__SOURCE_LOCATION__); if (symbolInstance.verticalIconQuads()) { placeIcon(*symbolInstance.verticalIconQuads(), - symbolInstance.refPlacedVerticalIconIndex(), + symbolInstance.refPlacedVerticalIconIndex(__SOURCE_LOCATION__), WritingModeType::Vertical); - symbolInstance.check(); + symbolInstance.check(__SOURCE_LOCATION__); } for (auto& pair : bucket->paintProperties) { pair.second.iconBinders.populateVertexVectors( - feature, iconBuffer.vertices.elements(), symbolInstance.getDataFeatureIndex(), {}, {}, canonical); + feature, iconBuffer.vertices.elements(), symbolInstance.getDataFeatureIndex(__SOURCE_LOCATION__), {}, {}, canonical); } } @@ -828,57 +828,57 @@ void SymbolLayout::createBucket(const ImagePositions&, lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, - symbolInstance.getWritingModes(), + symbolInstance.getWritingModes(__SOURCE_LOCATION__), placedTextIndex, symbolInstance.rightJustifiedGlyphQuads(), canonical, lastAddedSection); - symbolInstance.setPlacedRightTextIndex(placedTextIndex); - symbolInstance.setPlacedCenterTextIndex(placedTextIndex); - symbolInstance.setPlacedLeftTextIndex(placedTextIndex); + symbolInstance.setPlacedRightTextIndex(placedTextIndex, __SOURCE_LOCATION__); + symbolInstance.setPlacedCenterTextIndex(placedTextIndex, __SOURCE_LOCATION__); + symbolInstance.setPlacedLeftTextIndex(placedTextIndex, __SOURCE_LOCATION__); } else { - if (symbolInstance.getRightJustifiedGlyphQuadsSize()) { + if (symbolInstance.getRightJustifiedGlyphQuadsSize(__SOURCE_LOCATION__)) { lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, - symbolInstance.getWritingModes(), - symbolInstance.refPlacedRightTextIndex(), + symbolInstance.getWritingModes(__SOURCE_LOCATION__), + symbolInstance.refPlacedRightTextIndex(__SOURCE_LOCATION__), symbolInstance.rightJustifiedGlyphQuads(), canonical, lastAddedSection); } - if (symbolInstance.getCenterJustifiedGlyphQuadsSize()) { + if (symbolInstance.getCenterJustifiedGlyphQuadsSize(__SOURCE_LOCATION__)) { lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, - symbolInstance.getWritingModes(), - symbolInstance.refPlacedCenterTextIndex(), + symbolInstance.getWritingModes(__SOURCE_LOCATION__), + symbolInstance.refPlacedCenterTextIndex(__SOURCE_LOCATION__), symbolInstance.centerJustifiedGlyphQuads(), canonical, lastAddedSection); } - if (symbolInstance.getLeftJustifiedGlyphQuadsSize()) { + if (symbolInstance.getLeftJustifiedGlyphQuadsSize(__SOURCE_LOCATION__)) { lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, - symbolInstance.getWritingModes(), - symbolInstance.refPlacedLeftTextIndex(), + symbolInstance.getWritingModes(__SOURCE_LOCATION__), + symbolInstance.refPlacedLeftTextIndex(__SOURCE_LOCATION__), symbolInstance.leftJustifiedGlyphQuads(), canonical, lastAddedSection); } } - if ((symbolInstance.getWritingModes() & WritingModeType::Vertical) && symbolInstance.getVerticalGlyphQuadsSize()) { + if ((symbolInstance.getWritingModes(__SOURCE_LOCATION__) & WritingModeType::Vertical) && symbolInstance.getVerticalGlyphQuadsSize(__SOURCE_LOCATION__)) { lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, WritingModeType::Vertical, - symbolInstance.refPlacedVerticalTextIndex(), + symbolInstance.refPlacedVerticalTextIndex(__SOURCE_LOCATION__), symbolInstance.verticalGlyphQuads(), canonical, lastAddedSection); } - symbolInstance.check("createBucket loop"); + symbolInstance.check(__SOURCE_LOCATION__); assert(lastAddedSection); // True, as hasText == true; updatePaintPropertiesForSection(*bucket, feature, *lastAddedSection, canonical); } @@ -896,7 +896,7 @@ void SymbolLayout::createBucket(const ImagePositions&, } renderData.emplace(pair.first, LayerRenderData{bucket, pair.second}); } - bucket->check("SymbolLayout::createBucket"); + bucket->check(__SOURCE_LOCATION__); } } @@ -921,15 +921,15 @@ std::size_t SymbolLayout::addSymbolGlyphQuads(SymbolBucket& bucket, optional lastAddedSection) { const Range sizeData = bucket.textSizeBinder->getVertexSizeData(feature); const bool hasFormatSectionOverrides = bucket.hasFormatSectionOverrides(); - const auto& placedIconIndex = writingMode == WritingModeType::Vertical ? symbolInstance.getPlacedVerticalIconIndex() : symbolInstance.getPlacedIconIndex(); - bucket.text.placedSymbols.emplace_back(symbolInstance.getAnchor().point, - symbolInstance.getAnchor().segment.value_or(0u), + const auto& placedIconIndex = writingMode == WritingModeType::Vertical ? symbolInstance.getPlacedVerticalIconIndex(__SOURCE_LOCATION__) : symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__); + bucket.text.placedSymbols.emplace_back(symbolInstance.getAnchor(__SOURCE_LOCATION__).point, + symbolInstance.getAnchor(__SOURCE_LOCATION__).segment.value_or(0u), sizeData.min, sizeData.max, - symbolInstance.getTextOffset(), + symbolInstance.getTextOffset(__SOURCE_LOCATION__), writingMode, symbolInstance.line(), - calculateTileDistances(symbolInstance.line(), symbolInstance.getAnchor()), + calculateTileDistances(symbolInstance.line(), symbolInstance.getAnchor(__SOURCE_LOCATION__)), placedIconIndex); placedIndex = bucket.text.placedSymbols.size() - 1; PlacedSymbol& placedSymbol = bucket.text.placedSymbols.back(); @@ -943,7 +943,7 @@ std::size_t SymbolLayout::addSymbolGlyphQuads(SymbolBucket& bucket, } lastAddedSection = symbolQuad.sectionIndex; } - size_t index = addSymbol(bucket.text, sizeData, symbolQuad, symbolInstance.getAnchor(), placedSymbol, feature.sortKey); + size_t index = addSymbol(bucket.text, sizeData, symbolQuad, symbolInstance.getAnchor(__SOURCE_LOCATION__), placedSymbol, feature.sortKey); if (firstSymbol) { placedSymbol.vertexStartIndex = index; firstSymbol = false; @@ -1100,10 +1100,10 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) { auto& segment = collisionBuffer.segments.back(); auto index = static_cast(segment.vertexLength); - collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, tl)); - collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, tr)); - collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, br)); - collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, bl)); + collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor(__SOURCE_LOCATION__).point, tl)); + collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor(__SOURCE_LOCATION__).point, tr)); + collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor(__SOURCE_LOCATION__).point, br)); + collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor(__SOURCE_LOCATION__).point, bl)); // Dynamic vertices are initialized so that the vertex count always agrees with // the layout vertex buffer, but they will always be updated before rendering happens @@ -1129,14 +1129,14 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) { segment.indexLength += indexLength; } }; - populateCollisionBox(symbolInstance.getTextCollisionFeature(), true /*isText*/); - if (symbolInstance.getVerticalTextCollisionFeature()) { - populateCollisionBox(*symbolInstance.getVerticalTextCollisionFeature(), true /*isText*/); + populateCollisionBox(symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__), true /*isText*/); + if (symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__)) { + populateCollisionBox(*symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__), true /*isText*/); } - if (symbolInstance.getVerticalIconCollisionFeature()) { - populateCollisionBox(*symbolInstance.getVerticalIconCollisionFeature(), false /*isText*/); + if (symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__)) { + populateCollisionBox(*symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__), false /*isText*/); } - populateCollisionBox(symbolInstance.getIconCollisionFeature(), false /*isText*/); + populateCollisionBox(symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__), false /*isText*/); } } diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 574f0779a83..509a05e3df5 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -246,33 +246,33 @@ void SymbolBucket::sortFeatures(const float angle) { // The index array buffer is rewritten to reference the (unchanged) vertices in the // sorted order. for (const SymbolInstance& symbolInstance : getSortedSymbols(angle)) { - if (!symbolInstance.check("sortFeatures")) continue; + if (!symbolInstance.check(__SOURCE_LOCATION__)) continue; if (!symbolInstance.checkIndexes(text.placedSymbols.size(), icon.placedSymbols.size(), sdfIcon.placedSymbols.size(), "sortFeatures")) continue; - symbolsSortOrder->push_back(symbolInstance.getDataFeatureIndex()); + symbolsSortOrder->push_back(symbolInstance.getDataFeatureIndex(__SOURCE_LOCATION__)); - if (symbolInstance.getPlacedRightTextIndex()) { - addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedRightTextIndex()]); + if (symbolInstance.getPlacedRightTextIndex(__SOURCE_LOCATION__)) { + addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedRightTextIndex(__SOURCE_LOCATION__)]); } - if (symbolInstance.getPlacedCenterTextIndex() && !symbolInstance.getSingleLine()) { - addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedCenterTextIndex()]); + if (symbolInstance.getPlacedCenterTextIndex(__SOURCE_LOCATION__) && !symbolInstance.getSingleLine(__SOURCE_LOCATION__)) { + addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedCenterTextIndex(__SOURCE_LOCATION__)]); } - if (symbolInstance.getPlacedLeftTextIndex() && !symbolInstance.getSingleLine()) { - addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedLeftTextIndex()]); + if (symbolInstance.getPlacedLeftTextIndex(__SOURCE_LOCATION__) && !symbolInstance.getSingleLine(__SOURCE_LOCATION__)) { + addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedLeftTextIndex(__SOURCE_LOCATION__)]); } - if (symbolInstance.getPlacedVerticalTextIndex()) { - addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedVerticalTextIndex()]); + if (symbolInstance.getPlacedVerticalTextIndex(__SOURCE_LOCATION__)) { + addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.getPlacedVerticalTextIndex(__SOURCE_LOCATION__)]); } auto& iconBuffer = symbolInstance.hasSdfIcon() ? sdfIcon : icon; - if (symbolInstance.getPlacedIconIndex()) { - addPlacedSymbol(iconBuffer.triangles, iconBuffer.placedSymbols[*symbolInstance.getPlacedIconIndex()]); + if (symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)) { + addPlacedSymbol(iconBuffer.triangles, iconBuffer.placedSymbols[*symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)]); } - if (symbolInstance.getPlacedVerticalIconIndex()) { - addPlacedSymbol(iconBuffer.triangles, iconBuffer.placedSymbols[*symbolInstance.getPlacedVerticalIconIndex()]); + if (symbolInstance.getPlacedVerticalIconIndex(__SOURCE_LOCATION__)) { + addPlacedSymbol(iconBuffer.triangles, iconBuffer.placedSymbols[*symbolInstance.getPlacedVerticalIconIndex(__SOURCE_LOCATION__)]); } } @@ -285,12 +285,12 @@ SymbolInstanceReferences SymbolBucket::getSortedSymbols(const float angle) const const float cos = std::cos(angle); std::sort(result.begin(), result.end(), [sin, cos](const SymbolInstance& a, const SymbolInstance& b) { - const auto aRotated = std::lround(sin * a.getAnchor().point.x + cos * a.getAnchor().point.y); - const auto bRotated = std::lround(sin * b.getAnchor().point.x + cos * b.getAnchor().point.y); + const auto aRotated = std::lround(sin * a.getAnchor(__SOURCE_LOCATION__).point.x + cos * a.getAnchor(__SOURCE_LOCATION__).point.y); + const auto bRotated = std::lround(sin * b.getAnchor(__SOURCE_LOCATION__).point.x + cos * b.getAnchor(__SOURCE_LOCATION__).point.y); if (aRotated != bRotated) { return aRotated < bRotated; } - return a.getDataFeatureIndex() > b.getDataFeatureIndex(); // aRotated == bRotated + return a.getDataFeatureIndex(__SOURCE_LOCATION__) > b.getDataFeatureIndex(__SOURCE_LOCATION__); // aRotated == bRotated }); return result; diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp index a904b6dde74..a744372c8e8 100644 --- a/src/mbgl/text/cross_tile_symbol_index.cpp +++ b/src/mbgl/text/cross_tile_symbol_index.cpp @@ -12,8 +12,8 @@ TileLayerIndex::TileLayerIndex(OverscaledTileID coord_, std::string bucketLeaderId_) : coord(coord_), bucketInstanceId(bucketInstanceId_), bucketLeaderId(std::move(bucketLeaderId_)) { for (SymbolInstance& symbolInstance : symbolInstances) { - if (symbolInstance.getCrossTileID() == SymbolInstance::invalidCrossTileID()) continue; - indexedSymbolInstances[symbolInstance.getKey()].emplace_back(symbolInstance.getCrossTileID(), + if (symbolInstance.getCrossTileID(__SOURCE_LOCATION__) == SymbolInstance::invalidCrossTileID()) continue; + indexedSymbolInstances[symbolInstance.getKey(__SOURCE_LOCATION__)].emplace_back(symbolInstance.getCrossTileID(__SOURCE_LOCATION__), getScaledCoordinates(symbolInstance, coord)); } } @@ -24,8 +24,8 @@ Point TileLayerIndex::getScaledCoordinates(SymbolInstance& symbolInstan const double roundingFactor = 512.0 / util::EXTENT / 2.0; const double scale = roundingFactor / std::pow(2, childTileCoord.canonical.z - coord.canonical.z); return { - static_cast(std::floor((childTileCoord.canonical.x * util::EXTENT + symbolInstance.getAnchor().point.x) * scale)), - static_cast(std::floor((childTileCoord.canonical.y * util::EXTENT + symbolInstance.getAnchor().point.y) * scale)) + static_cast(std::floor((childTileCoord.canonical.x * util::EXTENT + symbolInstance.getAnchor(__SOURCE_LOCATION__).point.x) * scale)), + static_cast(std::floor((childTileCoord.canonical.y * util::EXTENT + symbolInstance.getAnchor(__SOURCE_LOCATION__).point.y) * scale)) }; } @@ -38,12 +38,12 @@ void TileLayerIndex::findMatches(SymbolBucket& bucket, if (bucket.bucketLeaderID != bucketLeaderId) return; for (auto& symbolInstance : symbolInstances) { - if (symbolInstance.getCrossTileID()) { + if (symbolInstance.getCrossTileID(__SOURCE_LOCATION__)) { // already has a match, skip continue; } - auto it = indexedSymbolInstances.find(symbolInstance.getKey()); + auto it = indexedSymbolInstances.find(symbolInstance.getKey(__SOURCE_LOCATION__)); if (it == indexedSymbolInstances.end()) { // No symbol with this key in this bucket continue; @@ -61,7 +61,7 @@ void TileLayerIndex::findMatches(SymbolBucket& bucket, // don't let any other symbols at the same zoom level duplicate against // the same parent (see issue #10844) zoomCrossTileIDs.insert(thisTileSymbol.crossTileID); - symbolInstance.setCrossTileID(thisTileSymbol.crossTileID); + symbolInstance.setCrossTileID(thisTileSymbol.crossTileID, __SOURCE_LOCATION__); break; } } @@ -134,16 +134,16 @@ bool CrossTileSymbolLayerIndex::addBucket(const OverscaledTileID& tileID, // For overscaled tiles the viewport might be showing only a small part of the tile, // so we filter out the off-screen symbols to improve the performance. for (auto& symbolInstance : bucket.symbolInstances) { - if (isInVewport(tileMatrix, symbolInstance.getAnchor().point)) { - symbolInstance.setCrossTileID(0u); + if (isInVewport(tileMatrix, symbolInstance.getAnchor(__SOURCE_LOCATION__).point)) { + symbolInstance.setCrossTileID(0u, __SOURCE_LOCATION__); } else { - symbolInstance.setCrossTileID(SymbolInstance::invalidCrossTileID()); + symbolInstance.setCrossTileID(SymbolInstance::invalidCrossTileID(), __SOURCE_LOCATION__); bucket.hasUninitializedSymbols = true; } } } else { for (auto& symbolInstance : bucket.symbolInstances) { - symbolInstance.setCrossTileID(0u); + symbolInstance.setCrossTileID(0u, __SOURCE_LOCATION__); } } @@ -168,10 +168,10 @@ bool CrossTileSymbolLayerIndex::addBucket(const OverscaledTileID& tileID, } for (auto& symbolInstance : bucket.symbolInstances) { - if (!symbolInstance.getCrossTileID()) { + if (!symbolInstance.getCrossTileID(__SOURCE_LOCATION__)) { // symbol did not match any known symbol, assign a new id - symbolInstance.setCrossTileID(++maxCrossTileID); - thisZoomUsedCrossTileIDs.insert(symbolInstance.getCrossTileID()); + symbolInstance.setCrossTileID(++maxCrossTileID, __SOURCE_LOCATION__); + thisZoomUsedCrossTileIDs.insert(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); } } diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 68ef525d111..9d841e7923b 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -239,13 +239,13 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::setplacedOrientations.find(symbolInstance.getCrossTileID()); + auto prevOrientation = getPrevPlacement()->placedOrientations.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (prevOrientation != getPrevPlacement()->placedOrientations.end()) { - placedOrientations[symbolInstance.getCrossTileID()] = prevOrientation->second; + placedOrientations[symbolInstance.getCrossTileID(__SOURCE_LOCATION__)] = prevOrientation->second; } } }; const auto placeTextForPlacementModes = [&](auto& placeHorizontalFn, auto& placeVerticalFn) { - if (bucket.allowVerticalPlacement && symbolInstance.getWritingModes() & WritingModeType::Vertical) { + if (bucket.allowVerticalPlacement && symbolInstance.getWritingModes(__SOURCE_LOCATION__) & WritingModeType::Vertical) { assert(!bucket.placementModes.empty()); for (auto& placementMode : bucket.placementModes) { if (placementMode == TextWritingModeType::Vertical) { @@ -337,18 +337,18 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons collisionGroup.second, textBoxes); if (placedFeature.first) { - placedOrientations.emplace(symbolInstance.getCrossTileID(), orientation); + placedOrientations.emplace(symbolInstance.getCrossTileID(__SOURCE_LOCATION__), orientation); } return placedFeature; }; const auto placeHorizontal = [&] { - return placeFeature(symbolInstance.getTextCollisionFeature(), style::TextWritingModeType::Horizontal); + return placeFeature(symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__), style::TextWritingModeType::Horizontal); }; const auto placeVertical = [&] { - if (bucket.allowVerticalPlacement && symbolInstance.getVerticalTextCollisionFeature()) { - return placeFeature(*symbolInstance.getVerticalTextCollisionFeature(), + if (bucket.allowVerticalPlacement && symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__)) { + return placeFeature(*symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__), style::TextWritingModeType::Vertical); } return std::pair{false, false}; @@ -359,13 +359,13 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons placeText = placed.first; offscreen &= placed.second; - } else if (!symbolInstance.getTextCollisionFeature().alongLine && - !symbolInstance.getTextCollisionFeature().boxes.empty()) { + } else if (!symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__).alongLine && + !symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__).boxes.empty()) { // If this symbol was in the last placement, shift the previously used // anchor to the front of the anchor list, only if the previous anchor // is still in the anchor list. if (getPrevPlacement()) { - auto prevOffset = getPrevPlacement()->variableOffsets.find(symbolInstance.getCrossTileID()); + auto prevOffset = getPrevPlacement()->variableOffsets.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (prevOffset != getPrevPlacement()->variableOffsets.end()) { const auto prevAnchor = prevOffset->second.anchor; auto found = std::find(variableTextAnchors.begin(), variableTextAnchors.end(), prevAnchor); @@ -384,14 +384,14 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons } const bool doVariableIconPlacement = - ctx.hasIconTextFit && !ctx.iconAllowOverlap && symbolInstance.getPlacedIconIndex(); + ctx.hasIconTextFit && !ctx.iconAllowOverlap && symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__); const auto placeFeatureForVariableAnchors = [&](const CollisionFeature& textCollisionFeature, style::TextWritingModeType orientation, const CollisionFeature& iconCollisionFeature) { const CollisionBox& textBox = textCollisionFeature.boxes[0]; const float width = textBox.x2 - textBox.x1; const float height = textBox.y2 - textBox.y1; - const float textBoxScale = symbolInstance.getTextBoxScale(); + const float textBoxScale = symbolInstance.getTextBoxScale(__SOURCE_LOCATION__); std::pair placedFeature = {false, false}; const size_t anchorsSize = variableTextAnchors.size(); const size_t placementAttempts = ctx.textAllowOverlap ? anchorsSize * 2 : anchorsSize; @@ -401,7 +401,7 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons shift = calculateVariableLayoutOffset(anchor, width, height, - symbolInstance.getVariableTextOffset(), + symbolInstance.getVariableTextOffset(__SOURCE_LOCATION__), textBoxScale, ctx.rotateTextWithMap, ctx.pitchTextWithMap, @@ -448,14 +448,14 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons } if (placedFeature.first) { - assert(symbolInstance.getCrossTileID() != 0u); + assert(symbolInstance.getCrossTileID(__SOURCE_LOCATION__) != 0u); optional prevAnchor; // If this label was placed in the previous placement, record the anchor position // to allow us to animate the transition if (getPrevPlacement()) { - auto prevOffset = getPrevPlacement()->variableOffsets.find(symbolInstance.getCrossTileID()); - auto prevPlacements = getPrevPlacement()->placements.find(symbolInstance.getCrossTileID()); + auto prevOffset = getPrevPlacement()->variableOffsets.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); + auto prevPlacements = getPrevPlacement()->placements.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (prevOffset != getPrevPlacement()->variableOffsets.end() && prevPlacements != getPrevPlacement()->placements.end() && prevPlacements->second.text) { // TODO: The prevAnchor seems to be unused, needs to be fixed. @@ -464,12 +464,12 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons } variableOffsets.insert(std::make_pair( - symbolInstance.getCrossTileID(), + symbolInstance.getCrossTileID(__SOURCE_LOCATION__), VariableOffset{ - symbolInstance.getVariableTextOffset(), width, height, anchor, textBoxScale, prevAnchor})); + symbolInstance.getVariableTextOffset(__SOURCE_LOCATION__), width, height, anchor, textBoxScale, prevAnchor})); if (bucket.allowVerticalPlacement) { - placedOrientations.emplace(symbolInstance.getCrossTileID(), orientation); + placedOrientations.emplace(symbolInstance.getCrossTileID(__SOURCE_LOCATION__), orientation); } break; } @@ -479,18 +479,18 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons }; const auto placeHorizontal = [&] { - return placeFeatureForVariableAnchors(symbolInstance.getTextCollisionFeature(), + return placeFeatureForVariableAnchors(symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__), style::TextWritingModeType::Horizontal, - symbolInstance.getIconCollisionFeature()); + symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__)); }; const auto placeVertical = [&] { - if (bucket.allowVerticalPlacement && !placed.first && symbolInstance.getVerticalTextCollisionFeature()) { - return placeFeatureForVariableAnchors(*symbolInstance.getVerticalTextCollisionFeature(), + if (bucket.allowVerticalPlacement && !placed.first && symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__)) { + return placeFeatureForVariableAnchors(*symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__), style::TextWritingModeType::Vertical, - symbolInstance.getVerticalTextCollisionFeature() - ? *symbolInstance.getVerticalTextCollisionFeature() - : symbolInstance.getIconCollisionFeature()); + symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__) + ? *symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__) + : symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__)); } return std::pair{false, false}; }; @@ -505,21 +505,21 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons // If we didn't get placed, we still need to copy our position from the last placement for // fade animations if (!placeText && getPrevPlacement()) { - auto prevOffset = getPrevPlacement()->variableOffsets.find(symbolInstance.getCrossTileID()); + auto prevOffset = getPrevPlacement()->variableOffsets.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (prevOffset != getPrevPlacement()->variableOffsets.end()) { - variableOffsets[symbolInstance.getCrossTileID()] = prevOffset->second; + variableOffsets[symbolInstance.getCrossTileID(__SOURCE_LOCATION__)] = prevOffset->second; } } } } - if (symbolInstance.getPlacedIconIndex()) { + if (symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)) { if (!ctx.hasIconTextFit || !placeText || variableTextAnchors.empty()) { shift = {0.0f, 0.0f}; } const auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket.sdfIcon : bucket.icon; - const PlacedSymbol& placedSymbol = iconBuffer.placedSymbols.at(*symbolInstance.getPlacedIconIndex()); + const PlacedSymbol& placedSymbol = iconBuffer.placedSymbols.at(*symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)); const float fontSize = evaluateSizeForFeature(ctx.partiallyEvaluatedIconSize, placedSymbol); const auto& placeIconFeature = [&](const CollisionFeature& collisionFeature) { return collisionIndex.placeFeature(collisionFeature, @@ -539,10 +539,10 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons }; std::pair placedIcon; - if (placedVerticalText.first && symbolInstance.getVerticalIconCollisionFeature()) { - placedIcon = placedVerticalIcon = placeIconFeature(*symbolInstance.getVerticalIconCollisionFeature()); + if (placedVerticalText.first && symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__)) { + placedIcon = placedVerticalIcon = placeIconFeature(*symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__)); } else { - placedIcon = placeIconFeature(symbolInstance.getIconCollisionFeature()); + placedIcon = placeIconFeature(symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__)); } placeIcon = placedIcon.first; offscreen &= placedIcon.second; @@ -561,14 +561,14 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons } if (placeText) { - if (placedVerticalText.first && symbolInstance.getVerticalTextCollisionFeature()) { - collisionIndex.insertFeature(*symbolInstance.getVerticalTextCollisionFeature(), + if (placedVerticalText.first && symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__)) { + collisionIndex.insertFeature(*symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__), textBoxes, ctx.getLayout().get(), bucket.bucketInstanceId, collisionGroup.first); } else { - collisionIndex.insertFeature(symbolInstance.getTextCollisionFeature(), + collisionIndex.insertFeature(symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__), textBoxes, ctx.getLayout().get(), bucket.bucketInstanceId, @@ -577,14 +577,14 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons } if (placeIcon) { - if (placedVerticalIcon.first && symbolInstance.getVerticalIconCollisionFeature()) { - collisionIndex.insertFeature(*symbolInstance.getVerticalIconCollisionFeature(), + if (placedVerticalIcon.first && symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__)) { + collisionIndex.insertFeature(*symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__), iconBoxes, ctx.getLayout().get(), bucket.bucketInstanceId, collisionGroup.first); } else { - collisionIndex.insertFeature(symbolInstance.getIconCollisionFeature(), + collisionIndex.insertFeature(symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__), iconBoxes, ctx.getLayout().get(), bucket.bucketInstanceId, @@ -595,26 +595,26 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons const bool hasIconCollisionCircleData = bucket.hasIconCollisionCircleData(); const bool hasTextCollisionCircleData = bucket.hasTextCollisionCircleData(); - if (hasIconCollisionCircleData && symbolInstance.getIconCollisionFeature().alongLine && !iconBoxes.empty()) { - collisionCircles[&symbolInstance.getIconCollisionFeature()] = iconBoxes; + if (hasIconCollisionCircleData && symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__).alongLine && !iconBoxes.empty()) { + collisionCircles[&symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__)] = iconBoxes; } - if (hasTextCollisionCircleData && symbolInstance.getTextCollisionFeature().alongLine && !textBoxes.empty()) { - collisionCircles[&symbolInstance.getTextCollisionFeature()] = textBoxes; + if (hasTextCollisionCircleData && symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__).alongLine && !textBoxes.empty()) { + collisionCircles[&symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__)] = textBoxes; } - assert(symbolInstance.getCrossTileID() != 0); + assert(symbolInstance.getCrossTileID(__SOURCE_LOCATION__) != 0); - if (placements.find(symbolInstance.getCrossTileID()) != placements.end()) { + if (placements.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)) != placements.end()) { // If there's a previous placement with this ID, it comes from a tile that's fading out // Erase it so that the placement result from the non-fading tile supersedes it - placements.erase(symbolInstance.getCrossTileID()); + placements.erase(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); } - if (!symbolInstance.check("/placeSymbol")) return kUnplaced; + if (!symbolInstance.check(__SOURCE_LOCATION__)) return kUnplaced; JointPlacement result( placeText || ctx.alwaysShowText, placeIcon || ctx.alwaysShowIcon, offscreen || bucket.justReloaded); - placements.emplace(symbolInstance.getCrossTileID(), result); + placements.emplace(symbolInstance.getCrossTileID(__SOURCE_LOCATION__), result); newSymbolPlaced(symbolInstance, ctx, result, ctx.placementType, textBoxes, iconBoxes); return result; } @@ -923,10 +923,10 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, true); for (SymbolInstance& symbolInstance : bucket.symbolInstances) { - if (!symbolInstance.check("updateBucketOpacities")) continue; - bool isDuplicate = seenCrossTileIDs.count(symbolInstance.getCrossTileID()) > 0; + if (!symbolInstance.check(__SOURCE_LOCATION__)) continue; + bool isDuplicate = seenCrossTileIDs.count(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)) > 0; - auto it = opacities.find(symbolInstance.getCrossTileID()); + auto it = opacities.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); auto opacityState = defaultOpacityState; if (isDuplicate) { opacityState = duplicateOpacityState; @@ -934,7 +934,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, opacityState = it->second; } - seenCrossTileIDs.insert(symbolInstance.getCrossTileID()); + seenCrossTileIDs.insert(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (symbolInstance.hasText() || symbolInstance.hasIcon()) { if (!symbolInstance.checkIndexes(bucket.text.placedSymbols.size(), bucket.icon.placedSymbols.size(), bucket.sdfIcon.placedSymbols.size(), "Placement::updateBucketOpacities")) return; @@ -942,38 +942,38 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, if (symbolInstance.hasText()) { size_t textOpacityVerticesSize = 0u; const auto& opacityVertex = SymbolSDFTextProgram::opacityVertex(opacityState.text.placed, opacityState.text.opacity); - if (symbolInstance.getPlacedRightTextIndex()) { - textOpacityVerticesSize += symbolInstance.getRightJustifiedGlyphQuadsSize() * 4; - PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedRightTextIndex()]; + if (symbolInstance.getPlacedRightTextIndex(__SOURCE_LOCATION__)) { + textOpacityVerticesSize += symbolInstance.getRightJustifiedGlyphQuadsSize(__SOURCE_LOCATION__) * 4; + PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedRightTextIndex(__SOURCE_LOCATION__)]; placed.hidden = opacityState.isHidden(); } - if (symbolInstance.getPlacedCenterTextIndex() && !symbolInstance.getSingleLine()) { - textOpacityVerticesSize += symbolInstance.getCenterJustifiedGlyphQuadsSize() * 4; - PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedCenterTextIndex()]; + if (symbolInstance.getPlacedCenterTextIndex(__SOURCE_LOCATION__) && !symbolInstance.getSingleLine(__SOURCE_LOCATION__)) { + textOpacityVerticesSize += symbolInstance.getCenterJustifiedGlyphQuadsSize(__SOURCE_LOCATION__) * 4; + PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedCenterTextIndex(__SOURCE_LOCATION__)]; placed.hidden = opacityState.isHidden(); } - if (symbolInstance.getPlacedLeftTextIndex() && !symbolInstance.getSingleLine()) { - textOpacityVerticesSize += symbolInstance.getLeftJustifiedGlyphQuadsSize() * 4; - PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedLeftTextIndex()]; + if (symbolInstance.getPlacedLeftTextIndex(__SOURCE_LOCATION__) && !symbolInstance.getSingleLine(__SOURCE_LOCATION__)) { + textOpacityVerticesSize += symbolInstance.getLeftJustifiedGlyphQuadsSize(__SOURCE_LOCATION__) * 4; + PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedLeftTextIndex(__SOURCE_LOCATION__)]; placed.hidden = opacityState.isHidden(); } - if (symbolInstance.getPlacedVerticalTextIndex()) { - textOpacityVerticesSize += symbolInstance.getVerticalGlyphQuadsSize() * 4; - bucket.text.placedSymbols[*symbolInstance.getPlacedVerticalTextIndex()].hidden = opacityState.isHidden(); + if (symbolInstance.getPlacedVerticalTextIndex(__SOURCE_LOCATION__)) { + textOpacityVerticesSize += symbolInstance.getVerticalGlyphQuadsSize(__SOURCE_LOCATION__) * 4; + bucket.text.placedSymbols[*symbolInstance.getPlacedVerticalTextIndex(__SOURCE_LOCATION__)].hidden = opacityState.isHidden(); } bucket.text.opacityVertices.extend(textOpacityVerticesSize, opacityVertex); style::TextWritingModeType previousOrientation = style::TextWritingModeType::Horizontal; if (bucket.allowVerticalPlacement) { - auto prevOrientation = placedOrientations.find(symbolInstance.getCrossTileID()); + auto prevOrientation = placedOrientations.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (prevOrientation != placedOrientations.end()) { previousOrientation = prevOrientation->second; markUsedOrientation(bucket, prevOrientation->second, symbolInstance); } } - auto prevOffset = variableOffsets.find(symbolInstance.getCrossTileID()); + auto prevOffset = variableOffsets.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (prevOffset != variableOffsets.end()) { markUsedJustification(bucket, prevOffset->second.anchor, symbolInstance, previousOrientation); } @@ -984,14 +984,14 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, SymbolIconProgram::opacityVertex(opacityState.icon.placed, opacityState.icon.opacity); auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket.sdfIcon : bucket.icon; - if (symbolInstance.getPlacedIconIndex()) { - iconOpacityVerticesSize += symbolInstance.getIconQuadsSize() * 4; - iconBuffer.placedSymbols[*symbolInstance.getPlacedIconIndex()].hidden = opacityState.isHidden(); + if (symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)) { + iconOpacityVerticesSize += symbolInstance.getIconQuadsSize(__SOURCE_LOCATION__) * 4; + iconBuffer.placedSymbols[*symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)].hidden = opacityState.isHidden(); } - if (symbolInstance.getPlacedVerticalIconIndex()) { - iconOpacityVerticesSize += symbolInstance.getIconQuadsSize() * 4; - iconBuffer.placedSymbols[*symbolInstance.getPlacedVerticalIconIndex()].hidden = opacityState.isHidden(); + if (symbolInstance.getPlacedVerticalIconIndex(__SOURCE_LOCATION__)) { + iconOpacityVerticesSize += symbolInstance.getIconQuadsSize(__SOURCE_LOCATION__) * 4; + iconBuffer.placedSymbols[*symbolInstance.getPlacedVerticalIconIndex(__SOURCE_LOCATION__)].hidden = opacityState.isHidden(); } iconBuffer.opacityVertices.extend(iconOpacityVerticesSize, opacityVertex); @@ -1014,7 +1014,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, } bool used = true; if (variablePlacement) { - auto foundOffset = variableOffsets.find(symbolInstance.getCrossTileID()); + auto foundOffset = variableOffsets.find(symbolInstance.getCrossTileID(__SOURCE_LOCATION__)); if (foundOffset != variableOffsets.end()) { const VariableOffset& variableOffset = foundOffset->second; // This will show either the currently placed position or the last @@ -1062,23 +1062,23 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, Point textShift{0.0f, 0.0f}; Point verticalTextShift{0.0f, 0.0f}; if (bucket.hasTextCollisionBoxData()) { - textShift = updateTextCollisionBox(symbolInstance.getTextCollisionFeature(), opacityState.text.placed); - if (bucket.allowVerticalPlacement && symbolInstance.getVerticalTextCollisionFeature()) { - verticalTextShift = updateTextCollisionBox(*symbolInstance.getVerticalTextCollisionFeature(), opacityState.text.placed); + textShift = updateTextCollisionBox(symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__), opacityState.text.placed); + if (bucket.allowVerticalPlacement && symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__)) { + verticalTextShift = updateTextCollisionBox(*symbolInstance.getVerticalTextCollisionFeature(__SOURCE_LOCATION__), opacityState.text.placed); } } if (bucket.hasIconCollisionBoxData()) { - updateIconCollisionBox(symbolInstance.getIconCollisionFeature(), opacityState.icon.placed, hasIconTextFit ? textShift : Point{0.0f, 0.0f}); - if (bucket.allowVerticalPlacement && symbolInstance.getVerticalIconCollisionFeature()) { - updateIconCollisionBox(*symbolInstance.getVerticalIconCollisionFeature(), opacityState.text.placed, hasIconTextFit ? verticalTextShift : Point{0.0f, 0.0f}); + updateIconCollisionBox(symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__), opacityState.icon.placed, hasIconTextFit ? textShift : Point{0.0f, 0.0f}); + if (bucket.allowVerticalPlacement && symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__)) { + updateIconCollisionBox(*symbolInstance.getVerticalIconCollisionFeature(__SOURCE_LOCATION__), opacityState.text.placed, hasIconTextFit ? verticalTextShift : Point{0.0f, 0.0f}); } } if (bucket.hasIconCollisionCircleData()) { - updateCollisionCircles(symbolInstance.getIconCollisionFeature(), opacityState.icon.placed, false); + updateCollisionCircles(symbolInstance.getIconCollisionFeature(__SOURCE_LOCATION__), opacityState.icon.placed, false); } if (bucket.hasTextCollisionCircleData()) { - updateCollisionCircles(symbolInstance.getTextCollisionFeature(), opacityState.text.placed, true); + updateCollisionCircles(symbolInstance.getTextCollisionFeature(__SOURCE_LOCATION__), opacityState.text.placed, true); } } @@ -1093,13 +1093,13 @@ namespace { optional justificationToIndex(style::TextJustifyType justify, const SymbolInstance& symbolInstance, style::TextWritingModeType orientation) { // Vertical symbol has just one justification, style::TextJustifyType::Left. if (orientation == style::TextWritingModeType::Vertical) { - return symbolInstance.getPlacedVerticalTextIndex(); + return symbolInstance.getPlacedVerticalTextIndex(__SOURCE_LOCATION__); } switch(justify) { - case style::TextJustifyType::Right: return symbolInstance.getPlacedRightTextIndex(); - case style::TextJustifyType::Center: return symbolInstance.getPlacedCenterTextIndex(); - case style::TextJustifyType::Left: return symbolInstance.getPlacedLeftTextIndex(); + case style::TextJustifyType::Right: return symbolInstance.getPlacedRightTextIndex(__SOURCE_LOCATION__); + case style::TextJustifyType::Center: return symbolInstance.getPlacedCenterTextIndex(__SOURCE_LOCATION__); + case style::TextJustifyType::Left: return symbolInstance.getPlacedLeftTextIndex(__SOURCE_LOCATION__); case style::TextJustifyType::Auto: break; } assert(false); @@ -1129,7 +1129,7 @@ void Placement::markUsedJustification(SymbolBucket& bucket, bucket.text.placedSymbols.at(*index).crossTileID = 0u; } else { // Either this is the chosen justification or the justification is hardwired: use this one - bucket.text.placedSymbols.at(*index).crossTileID = symbolInstance.getCrossTileID(); + bucket.text.placedSymbols.at(*index).crossTileID = symbolInstance.getCrossTileID(__SOURCE_LOCATION__); } } } @@ -1145,29 +1145,29 @@ void Placement::markUsedOrientation(SymbolBucket& bucket, if (!symbolInstance.checkIndexes(bucket.text.placedSymbols.size(), bucket.icon.placedSymbols.size(), bucket.sdfIcon.placedSymbols.size(), "markUsedOrientation")) return; - if (symbolInstance.getPlacedRightTextIndex()) { - bucket.text.placedSymbols.at(*symbolInstance.getPlacedRightTextIndex()).placedOrientation = horizontal; + if (symbolInstance.getPlacedRightTextIndex(__SOURCE_LOCATION__)) { + bucket.text.placedSymbols.at(*symbolInstance.getPlacedRightTextIndex(__SOURCE_LOCATION__)).placedOrientation = horizontal; } - if (symbolInstance.getPlacedCenterTextIndex() && !symbolInstance.getSingleLine()) { - bucket.text.placedSymbols.at(*symbolInstance.getPlacedCenterTextIndex()).placedOrientation = horizontal; + if (symbolInstance.getPlacedCenterTextIndex(__SOURCE_LOCATION__) && !symbolInstance.getSingleLine(__SOURCE_LOCATION__)) { + bucket.text.placedSymbols.at(*symbolInstance.getPlacedCenterTextIndex(__SOURCE_LOCATION__)).placedOrientation = horizontal; } - if (symbolInstance.getPlacedLeftTextIndex() && !symbolInstance.getSingleLine()) { - bucket.text.placedSymbols.at(*symbolInstance.getPlacedLeftTextIndex()).placedOrientation = horizontal; + if (symbolInstance.getPlacedLeftTextIndex(__SOURCE_LOCATION__) && !symbolInstance.getSingleLine(__SOURCE_LOCATION__)) { + bucket.text.placedSymbols.at(*symbolInstance.getPlacedLeftTextIndex(__SOURCE_LOCATION__)).placedOrientation = horizontal; } - if (symbolInstance.getPlacedVerticalTextIndex()) { - bucket.text.placedSymbols.at(*symbolInstance.getPlacedVerticalTextIndex()).placedOrientation = vertical; + if (symbolInstance.getPlacedVerticalTextIndex(__SOURCE_LOCATION__)) { + bucket.text.placedSymbols.at(*symbolInstance.getPlacedVerticalTextIndex(__SOURCE_LOCATION__)).placedOrientation = vertical; } auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket.sdfIcon : bucket.icon; - if (symbolInstance.getPlacedIconIndex()) { - iconBuffer.placedSymbols.at(*symbolInstance.getPlacedIconIndex()).placedOrientation = horizontal; + if (symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)) { + iconBuffer.placedSymbols.at(*symbolInstance.getPlacedIconIndex(__SOURCE_LOCATION__)).placedOrientation = horizontal; } - if (symbolInstance.getPlacedVerticalIconIndex()) { - iconBuffer.placedSymbols.at(*symbolInstance.getPlacedVerticalIconIndex()).placedOrientation = vertical; + if (symbolInstance.getPlacedVerticalIconIndex(__SOURCE_LOCATION__)) { + iconBuffer.placedSymbols.at(*symbolInstance.getPlacedVerticalIconIndex(__SOURCE_LOCATION__)).placedOrientation = vertical; } } @@ -1192,8 +1192,8 @@ float Placement::zoomAdjustment(const float zoom) const { } const JointPlacement* Placement::getSymbolPlacement(const SymbolInstance& symbol) const { - assert(symbol.getCrossTileID() != 0); - auto found = placements.find(symbol.getCrossTileID()); + assert(symbol.getCrossTileID(__SOURCE_LOCATION__) != 0); + auto found = placements.find(symbol.getCrossTileID(__SOURCE_LOCATION__)); return (found != placements.end()) ? &found->second : nullptr; } @@ -1325,24 +1325,24 @@ void TilePlacement::placeLayers(const RenderLayerReferences& layers) { return a.status.minSectionLength > b.status.minSectionLength; } // Look at the anchor coordinates - if (a.symbol.get().getAnchor().point.y != b.symbol.get().getAnchor().point.y) { - return a.symbol.get().getAnchor().point.y < b.symbol.get().getAnchor().point.y; + if (a.symbol.get().getAnchor(__SOURCE_LOCATION__).point.y != b.symbol.get().getAnchor(__SOURCE_LOCATION__).point.y) { + return a.symbol.get().getAnchor(__SOURCE_LOCATION__).point.y < b.symbol.get().getAnchor(__SOURCE_LOCATION__).point.y; } - if (a.symbol.get().getAnchor().point.x != b.symbol.get().getAnchor().point.x) { - return a.symbol.get().getAnchor().point.x < b.symbol.get().getAnchor().point.x; + if (a.symbol.get().getAnchor(__SOURCE_LOCATION__).point.x != b.symbol.get().getAnchor(__SOURCE_LOCATION__).point.x) { + return a.symbol.get().getAnchor(__SOURCE_LOCATION__).point.x < b.symbol.get().getAnchor(__SOURCE_LOCATION__).point.x; } // Finally, looking at the key hashes. - return std::hash()(a.symbol.get().getKey()) < std::hash()(b.symbol.get().getKey()); + return std::hash()(a.symbol.get().getKey(__SOURCE_LOCATION__)) < std::hash()(b.symbol.get().getKey(__SOURCE_LOCATION__)); }); // Place intersections. for (const auto& intersection : intersections) { const SymbolInstance& symbol = intersection.symbol; const PlacementContext& ctx = intersection.ctx; currentIntersectionPriority = intersection.priority; - if (seenCrossTileIDs.count(symbol.getCrossTileID()) != 0u) continue; + if (seenCrossTileIDs.count(symbol.getCrossTileID(__SOURCE_LOCATION__)) != 0u) continue; JointPlacement placement = placeSymbol(symbol, ctx); if (shouldRetryPlacement(placement, ctx)) continue; - seenCrossTileIDs.insert(symbol.getCrossTileID()); + seenCrossTileIDs.insert(symbol.getCrossTileID(__SOURCE_LOCATION__)); } // Place the rest labels. populateIntersections = false; @@ -1437,8 +1437,8 @@ void TilePlacement::placeSymbolBucket(const BucketPlacementData& params, std::se bearing = static_cast(ctx.getTransformState().getBearing()) ](const SymbolInstance& symbol) noexcept->IntersectStatus { IntersectStatus result; - if (!symbol.getTextCollisionFeature().boxes.empty()) { - const auto& textCollisionBox = symbol.getTextCollisionFeature().boxes.front(); + if (!symbol.getTextCollisionFeature(__SOURCE_LOCATION__).boxes.empty()) { + const auto& textCollisionBox = symbol.getTextCollisionFeature(__SOURCE_LOCATION__).boxes.front(); Point offset{}; if (variableAnchor) { @@ -1447,8 +1447,8 @@ void TilePlacement::placeSymbolBucket(const BucketPlacementData& params, std::se offset = calculateVariableLayoutOffset(*variableAnchor, width, height, - symbol.getVariableTextOffset(), - symbol.getTextBoxScale(), + symbol.getVariableTextOffset(__SOURCE_LOCATION__), + symbol.getTextBoxScale(__SOURCE_LOCATION__), rotateTextWithMap, pitchTextWithMap, bearing); @@ -1456,8 +1456,8 @@ void TilePlacement::placeSymbolBucket(const BucketPlacementData& params, std::se result = collisionBoxIntersectsTileEdges(textCollisionBox, offset); } - if (!symbol.getIconCollisionFeature().boxes.empty()) { - const auto& iconCollisionBox = symbol.getIconCollisionFeature().boxes.front(); + if (!symbol.getIconCollisionFeature(__SOURCE_LOCATION__).boxes.empty()) { + const auto& iconCollisionBox = symbol.getIconCollisionFeature(__SOURCE_LOCATION__).boxes.front(); Point offset{}; if (variableAnchor && variableIconPlacement) { float width = iconCollisionBox.x2 - iconCollisionBox.x1; @@ -1465,8 +1465,8 @@ void TilePlacement::placeSymbolBucket(const BucketPlacementData& params, std::se offset = calculateVariableLayoutOffset(*variableAnchor, width, height, - symbol.getVariableTextOffset(), - symbol.getTextBoxScale(), + symbol.getVariableTextOffset(__SOURCE_LOCATION__), + symbol.getTextBoxScale(__SOURCE_LOCATION__), rotateTextWithMap, pitchTextWithMap, bearing); @@ -1480,7 +1480,7 @@ void TilePlacement::placeSymbolBucket(const BucketPlacementData& params, std::se }; for (const SymbolInstance& symbol : symbolInstances) { - if (!symbol.check("TilePlacement::placeSymbolBucket")) continue; + if (!symbol.check(__SOURCE_LOCATION__)) continue; auto intersectStatus = symbolIntersectsTileEdges(symbol); if (intersectStatus.flags == IntersectStatus::None) continue; intersections.emplace_back(symbol, ctx, intersectStatus, currentIntersectionPriority); @@ -1537,7 +1537,7 @@ void TilePlacement::newSymbolPlaced(const SymbolInstance& symbol, assert(box.isBox()); iconCollisionBox = box.box(); } - PlacedSymbolData symbolData{symbol.getKey(), + PlacedSymbolData symbolData{symbol.getKey(__SOURCE_LOCATION__), textCollisionBox, iconCollisionBox, placement.text, diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 7de0d633fb3..97eaa99f23d 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -253,7 +253,7 @@ void GeometryTile::onLayout(std::shared_ptr result, const uint64_t if (layoutResult) { for (const auto& data : layoutResult->layerRenderData) { if (data.second.bucket) { - data.second.bucket->check("GeometryTile::onLayout1 " __LINE_STRING__); + data.second.bucket->check(__SOURCE_LOCATION__); } } } @@ -263,7 +263,7 @@ void GeometryTile::onLayout(std::shared_ptr result, const uint64_t if (layoutResult) { for (const auto& data : layoutResult->layerRenderData) { if (data.second.bucket) { - data.second.bucket->check("GeometryTile::onLayout2 " __LINE_STRING__); + data.second.bucket->check(__SOURCE_LOCATION__); } } }