summaryrefslogtreecommitdiff
path: root/src/mbgl/layout
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2020-01-29 12:46:16 +0200
committerzmiao <miao.zhao@mapbox.com>2020-02-12 12:24:05 +0200
commit3e99c08ea610d791b21f1631308451687c464d98 (patch)
treec7f3e20ad9ddc161ab3378d37bde9aa31675da83 /src/mbgl/layout
parent4f18d5fa92df175ac30f856a9273a00349b56cc3 (diff)
downloadqtlocation-mapboxgl-3e99c08ea610d791b21f1631308451687c464d98.tar.gz
Enable parse within expression
Add geometry type checker
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r--src/mbgl/layout/layout.hpp3
-rw-r--r--src/mbgl/layout/pattern_layout.hpp9
-rw-r--r--src/mbgl/layout/symbol_feature.hpp14
-rw-r--r--src/mbgl/layout/symbol_layout.cpp69
-rw-r--r--src/mbgl/layout/symbol_layout.hpp11
5 files changed, 80 insertions, 26 deletions
diff --git a/src/mbgl/layout/layout.hpp b/src/mbgl/layout/layout.hpp
index 4e7c0c7aca..ae0eb5d5f3 100644
--- a/src/mbgl/layout/layout.hpp
+++ b/src/mbgl/layout/layout.hpp
@@ -21,7 +21,8 @@ public:
std::unique_ptr<FeatureIndex>&,
std::unordered_map<std::string, LayerRenderData>&,
const bool,
- const bool) = 0;
+ const bool,
+ const CanonicalTileID&) = 0;
virtual void prepareSymbols(const GlyphMap&, const GlyphPositions&, const ImageMap&, const ImagePositions&){};
diff --git a/src/mbgl/layout/pattern_layout.hpp b/src/mbgl/layout/pattern_layout.hpp
index 44729dea83..c6815e4cad 100644
--- a/src/mbgl/layout/pattern_layout.hpp
+++ b/src/mbgl/layout/pattern_layout.hpp
@@ -152,7 +152,12 @@ public:
return hasPattern;
}
- void createBucket(const ImagePositions& patternPositions, std::unique_ptr<FeatureIndex>& featureIndex, std::unordered_map<std::string, LayerRenderData>& renderData, const bool, const bool) override {
+ void createBucket(const ImagePositions& patternPositions,
+ std::unique_ptr<FeatureIndex>& featureIndex,
+ std::unordered_map<std::string, LayerRenderData>& renderData,
+ const bool,
+ const bool,
+ const CanonicalTileID& canonical) override {
auto bucket = std::make_shared<BucketType>(layout, layerPropertiesMap, zoom, overscaling);
for (auto & patternFeature : features) {
const auto i = patternFeature.i;
@@ -160,7 +165,7 @@ public:
const PatternLayerMap& patterns = patternFeature.patterns;
const GeometryCollection& geometries = feature->getGeometries();
- bucket->addFeature(*feature, geometries, patternPositions, patterns, i);
+ bucket->addFeature(*feature, geometries, patternPositions, patterns, i, canonical);
featureIndex->insert(geometries, i, sourceLayerID, bucketLeaderID);
}
if (bucket->hasData()) {
diff --git a/src/mbgl/layout/symbol_feature.hpp b/src/mbgl/layout/symbol_feature.hpp
index d0aced1b19..f536642709 100644
--- a/src/mbgl/layout/symbol_feature.hpp
+++ b/src/mbgl/layout/symbol_feature.hpp
@@ -12,16 +12,16 @@ namespace mbgl {
class SymbolFeature : public GeometryTileFeature {
public:
- SymbolFeature(std::unique_ptr<GeometryTileFeature> feature_) :
- feature(std::move(feature_)),
- geometry(feature->getGeometries().clone()) // we need a mutable copy of the geometry for mergeLines()
+ SymbolFeature(std::unique_ptr<GeometryTileFeature> feature_)
+ : feature(std::move(feature_)),
+ geometry(feature->getGeometries().clone()) // we need a mutable copy of the geometry for mergeLines()
{}
-
+
FeatureType getType() const override { return feature->getType(); }
- optional<Value> getValue(const std::string& key) const override { return feature->getValue(key); };
- const PropertyMap& getProperties() const override { return feature->getProperties(); };
+ optional<Value> getValue(const std::string& key) const override { return feature->getValue(key); }
+ const PropertyMap& getProperties() const override { return feature->getProperties(); }
FeatureIdentifier getID() const override { return feature->getID(); };
- const GeometryCollection& getGeometries() const override { return geometry; };
+ const GeometryCollection& getGeometries() const override { return feature->getGeometries(); }
friend bool operator < (const SymbolFeature& lhs, const SymbolFeature& rhs) {
return lhs.sortKey < rhs.sortKey;
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 61c3b4ad66..a4890c85d1 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -742,7 +742,12 @@ std::vector<float> SymbolLayout::calculateTileDistances(const GeometryCoordinate
return tileDistances;
}
-void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIndex>&, std::unordered_map<std::string, LayerRenderData>& renderData, const bool firstLoad, const bool showCollisionBoxes) {
+void SymbolLayout::createBucket(const ImagePositions&,
+ std::unique_ptr<FeatureIndex>&,
+ std::unordered_map<std::string, LayerRenderData>& renderData,
+ const bool firstLoad,
+ const bool showCollisionBoxes,
+ const CanonicalTileID& canonical) {
auto bucket = std::make_shared<SymbolBucket>(layout,
layerPaintProperties,
textSize,
@@ -796,8 +801,8 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn
}
for (auto& pair : bucket->paintProperties) {
- pair.second.iconBinders.populateVertexVectors(feature, iconBuffer.vertices.elements(),
- symbolInstance.dataFeatureIndex, {}, {});
+ pair.second.iconBinders.populateVertexVectors(
+ feature, iconBuffer.vertices.elements(), symbolInstance.dataFeatureIndex, {}, {}, canonical);
}
}
@@ -805,26 +810,61 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn
optional<std::size_t> lastAddedSection;
if (singleLine) {
optional<std::size_t> placedTextIndex;
- lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, symbolInstance.writingModes, placedTextIndex, symbolInstance.rightJustifiedGlyphQuads(), lastAddedSection);
+ lastAddedSection = addSymbolGlyphQuads(*bucket,
+ symbolInstance,
+ feature,
+ symbolInstance.writingModes,
+ placedTextIndex,
+ symbolInstance.rightJustifiedGlyphQuads(),
+ canonical,
+ lastAddedSection);
symbolInstance.placedRightTextIndex = placedTextIndex;
symbolInstance.placedCenterTextIndex = placedTextIndex;
symbolInstance.placedLeftTextIndex = placedTextIndex;
} else {
if (symbolInstance.rightJustifiedGlyphQuadsSize) {
- lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, symbolInstance.writingModes, symbolInstance.placedRightTextIndex, symbolInstance.rightJustifiedGlyphQuads(), lastAddedSection);
+ lastAddedSection = addSymbolGlyphQuads(*bucket,
+ symbolInstance,
+ feature,
+ symbolInstance.writingModes,
+ symbolInstance.placedRightTextIndex,
+ symbolInstance.rightJustifiedGlyphQuads(),
+ canonical,
+ lastAddedSection);
}
if (symbolInstance.centerJustifiedGlyphQuadsSize) {
- lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, symbolInstance.writingModes, symbolInstance.placedCenterTextIndex, symbolInstance.centerJustifiedGlyphQuads(), lastAddedSection);
+ lastAddedSection = addSymbolGlyphQuads(*bucket,
+ symbolInstance,
+ feature,
+ symbolInstance.writingModes,
+ symbolInstance.placedCenterTextIndex,
+ symbolInstance.centerJustifiedGlyphQuads(),
+ canonical,
+ lastAddedSection);
}
if (symbolInstance.leftJustifiedGlyphQuadsSize) {
- lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, symbolInstance.writingModes, symbolInstance.placedLeftTextIndex, symbolInstance.leftJustifiedGlyphQuads(), lastAddedSection);
+ lastAddedSection = addSymbolGlyphQuads(*bucket,
+ symbolInstance,
+ feature,
+ symbolInstance.writingModes,
+ symbolInstance.placedLeftTextIndex,
+ symbolInstance.leftJustifiedGlyphQuads(),
+ canonical,
+ lastAddedSection);
}
}
if (symbolInstance.writingModes & WritingModeType::Vertical && symbolInstance.verticalGlyphQuadsSize) {
- lastAddedSection = addSymbolGlyphQuads(*bucket, symbolInstance, feature, WritingModeType::Vertical, symbolInstance.placedVerticalTextIndex, symbolInstance.verticalGlyphQuads(), lastAddedSection);
+ lastAddedSection = addSymbolGlyphQuads(*bucket,
+ symbolInstance,
+ feature,
+ WritingModeType::Vertical,
+ symbolInstance.placedVerticalTextIndex,
+ symbolInstance.verticalGlyphQuads(),
+ canonical,
+ lastAddedSection);
}
assert(lastAddedSection); // True, as hasText == true;
- updatePaintPropertiesForSection(*bucket, feature, *lastAddedSection);
+ updatePaintPropertiesForSection(*bucket, feature, *lastAddedSection, canonical);
}
symbolInstance.releaseSharedData();
@@ -841,16 +881,16 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn
renderData.emplace(pair.first, LayerRenderData{bucket, pair.second});
}
}
-
}
void SymbolLayout::updatePaintPropertiesForSection(SymbolBucket& bucket,
const SymbolFeature& feature,
- std::size_t sectionIndex) {
+ std::size_t sectionIndex,
+ const CanonicalTileID& canonical) {
const auto& formattedSection = sectionOptionsToValue((*feature.formattedText).sectionAt(sectionIndex));
for (auto& pair : bucket.paintProperties) {
- pair.second.textBinders.populateVertexVectors(feature, bucket.text.vertices.elements(), feature.index, {}, {},
- formattedSection);
+ pair.second.textBinders.populateVertexVectors(
+ feature, bucket.text.vertices.elements(), feature.index, {}, {}, canonical, formattedSection);
}
}
@@ -860,6 +900,7 @@ std::size_t SymbolLayout::addSymbolGlyphQuads(SymbolBucket& bucket,
WritingModeType writingMode,
optional<size_t>& placedIndex,
const SymbolQuads& glyphQuads,
+ const CanonicalTileID& canonical,
optional<std::size_t> lastAddedSection) {
const Range<float> sizeData = bucket.textSizeBinder->getVertexSizeData(feature);
const bool hasFormatSectionOverrides = bucket.hasFormatSectionOverrides();
@@ -881,7 +922,7 @@ std::size_t SymbolLayout::addSymbolGlyphQuads(SymbolBucket& bucket,
for (const auto& symbolQuad : glyphQuads) {
if (hasFormatSectionOverrides) {
if (lastAddedSection && *lastAddedSection != symbolQuad.sectionIndex) {
- updatePaintPropertiesForSection(bucket, feature, *lastAddedSection);
+ updatePaintPropertiesForSection(bucket, feature, *lastAddedSection, canonical);
}
lastAddedSection = symbolQuad.sectionIndex;
}
diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp
index 52c912c8ae..740a69df9e 100644
--- a/src/mbgl/layout/symbol_layout.hpp
+++ b/src/mbgl/layout/symbol_layout.hpp
@@ -36,7 +36,12 @@ public:
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;
+ void createBucket(const ImagePositions&,
+ std::unique_ptr<FeatureIndex>&,
+ std::unordered_map<std::string, LayerRenderData>&,
+ const bool firstLoad,
+ const bool showCollisionBoxes,
+ const CanonicalTileID& canonical) override;
bool hasSymbolInstances() const override;
bool hasDependencies() const override;
@@ -97,11 +102,13 @@ private:
WritingModeType,
optional<size_t>& placedIndex,
const SymbolQuads&,
+ const CanonicalTileID& canonical,
optional<std::size_t> lastAddedSection = nullopt);
void updatePaintPropertiesForSection(SymbolBucket&,
const SymbolFeature&,
- std::size_t sectionIndex);
+ std::size_t sectionIndex,
+ const CanonicalTileID& canonical);
// Stores the layer so that we can hold on to GeometryTileFeature instances in SymbolFeature,
// which may reference data from this object.