summaryrefslogtreecommitdiff
path: root/src/mbgl/text
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-25 13:02:46 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-25 15:11:41 +0200
commit735fc0a4dcbd82f4e63ee9154cc10e060bcd5ad5 (patch)
treec8581945ccdbf9bdedb421fefdd91e5cf8292757 /src/mbgl/text
parent313844b1da56b105cc2798a609b82d85d2286ba5 (diff)
downloadqtlocation-mapboxgl-735fc0a4dcbd82f4e63ee9154cc10e060bcd5ad5.tar.gz
[core][tile mode] Share seenCrossTileIDs across all placeLayer() calls
Thus we obviate lots of repeated operations for already placed symbols.
Diffstat (limited to 'src/mbgl/text')
-rw-r--r--src/mbgl/text/placement.cpp20
-rw-r--r--src/mbgl/text/placement.hpp2
2 files changed, 15 insertions, 7 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 049a72f63c..0436a3ccd5 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -107,13 +107,13 @@ Placement::~Placement() = default;
void Placement::placeLayers(const RenderLayerReferences& layers) {
for (auto it = layers.crbegin(); it != layers.crend(); ++it) {
- placeLayer(*it);
+ std::set<uint32_t> seenCrossTileIDs;
+ placeLayer(*it, seenCrossTileIDs);
}
commit();
}
-void Placement::placeLayer(const RenderLayer& layer) {
- std::set<uint32_t> seenCrossTileIDs;
+void Placement::placeLayer(const RenderLayer& layer, std::set<uint32_t>& seenCrossTileIDs) {
for (const BucketPlacementData& data : layer.getPlacementData()) {
Bucket& bucket = data.bucket;
bucket.place(*this, data, seenCrossTileIDs);
@@ -1159,7 +1159,7 @@ public:
explicit StaticPlacement(std::shared_ptr<const UpdateParameters> updateParameters_)
: Placement(std::move(updateParameters_), nullopt) {}
-private:
+protected:
void commit() override;
float symbolFadeChange(TimePoint) const override { return 1.0f; }
bool hasTransitions(TimePoint) const override { return false; }
@@ -1190,6 +1190,7 @@ private:
std::unordered_map<uint32_t, bool> locationCache;
optional<CollisionBoundaries> tileBorders;
+ std::set<uint32_t> seenCrossTileIDs;
bool onlyLabelsIntersectingTileBorders;
};
@@ -1197,10 +1198,17 @@ void TilePlacement::placeLayers(const RenderLayerReferences& layers) {
// In order to avoid label cut-offs, at first, place the labels,
// which cross tile boundaries.
onlyLabelsIntersectingTileBorders = true;
- StaticPlacement::placeLayers(layers);
+ seenCrossTileIDs.clear();
+ for (auto it = layers.crbegin(); it != layers.crend(); ++it) {
+ placeLayer(*it, seenCrossTileIDs);
+ }
// Place the rest labels.
onlyLabelsIntersectingTileBorders = false;
- StaticPlacement::placeLayers(layers);
+ for (auto it = layers.crbegin(); it != layers.crend(); ++it) {
+ placeLayer(*it, seenCrossTileIDs);
+ }
+
+ commit();
}
optional<CollisionBoundaries> TilePlacement::getAvoidEdges(const SymbolBucket& bucket, const mat4& posMatrix) {
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 396aad4425..e86135130a 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -139,7 +139,7 @@ public:
protected:
friend SymbolBucket;
void placeSymbolBucket(const BucketPlacementData&, std::set<uint32_t>& seenCrossTileIDs);
- void placeLayer(const RenderLayer&);
+ void placeLayer(const RenderLayer&, std::set<uint32_t>&);
virtual void commit();
// Implentation specific hooks, which get called during a symbol bucket placement.
virtual optional<CollisionBoundaries> getAvoidEdges(const SymbolBucket&, const mat4& /*posMatrix*/) {