summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-01-16 12:29:56 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-01-22 14:30:26 +0200
commitf70cadf2e0ebc9b6a1d46117cd3714df9dcf23b6 (patch)
treebb06954293a6e0f618ac7e4b343e18aceb12cd54 /src/mbgl
parent769a822fec2090fc37e00344dc63d5a1c2e32ac2 (diff)
downloadqtlocation-mapboxgl-f70cadf2e0ebc9b6a1d46117cd3714df9dcf23b6.tar.gz
[core] Cache showCollisionBoxes in Placement
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp8
-rw-r--r--src/mbgl/text/placement.cpp21
-rw-r--r--src/mbgl/text/placement.hpp4
3 files changed, 13 insertions, 20 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index c77eaca37e..5e5f2da3c3 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -399,9 +399,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
const RenderLayer& layer = *it;
usedSymbolLayers.insert(layer.getID());
- placement->placeLayer(layer,
- renderTreeParameters->transformParams.projMatrix,
- updateParameters->debugOptions & MapDebugOptions::Collision);
+ placement->placeLayer(layer, renderTreeParameters->transformParams.projMatrix);
}
placement->commit();
@@ -424,9 +422,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
const RenderLayer& layer = *it;
crossTileSymbolIndex.addLayer(layer, updateParameters->transformState.getLatLng().longitude());
- placement->placeLayer(layer,
- renderTreeParameters->transformParams.projMatrix,
- updateParameters->debugOptions & MapDebugOptions::Collision);
+ placement->placeLayer(layer, renderTreeParameters->transformParams.projMatrix);
}
placement->commit();
placementController.setPlacement(std::move(placement));
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 5673ff5041..edd6506c2c 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -99,7 +99,8 @@ Placement::Placement(std::shared_ptr<const UpdateParameters> updateParameters_,
commitTime(updateParameters->timePoint),
placementZoom(updateParameters->transformState.getZoom()),
collisionGroups(updateParameters->crossSourceCollisions),
- prevPlacement(std::move(prevPlacement_)) {
+ prevPlacement(std::move(prevPlacement_)),
+ showCollisionBoxes(updateParameters->debugOptions & MapDebugOptions::Collision) {
assert(prevPlacement || mapMode != MapMode::Continuous);
if (prevPlacement) {
prevPlacement->get()->prevPlacement = nullopt; // Only hold on to one placement back
@@ -108,16 +109,11 @@ Placement::Placement(std::shared_ptr<const UpdateParameters> updateParameters_,
Placement::Placement() : collisionIndex({}, MapMode::Static), collisionGroups(true) {}
-void Placement::placeLayer(const RenderLayer& layer, const mat4& projMatrix, bool showCollisionBoxes) {
+void Placement::placeLayer(const RenderLayer& layer, const mat4& projMatrix) {
std::set<uint32_t> seenCrossTileIDs;
for (const auto& item : layer.getPlacementData()) {
Bucket& bucket = item.bucket;
- BucketPlacementParameters params{
- item.tile,
- projMatrix,
- layer.baseImpl->source,
- item.featureIndex,
- showCollisionBoxes};
+ BucketPlacementParameters params{item.tile, projMatrix, layer.baseImpl->source, item.featureIndex};
bucket.place(*this, params, seenCrossTileIDs);
}
}
@@ -146,6 +142,7 @@ Point<float> calculateVariableLayoutOffset(style::SymbolAnchorType anchor,
void Placement::placeBucket(const SymbolBucket& bucket,
const BucketPlacementParameters& params,
std::set<uint32_t>& seenCrossTileIDs) {
+ assert(updateParameters);
const auto& layout = *bucket.layout;
const auto& renderTile = params.tile;
const auto& state = collisionIndex.getTransformState();
@@ -278,7 +275,7 @@ void Placement::placeBucket(const SymbolBucket& bucket,
fontSize,
layout.get<style::TextAllowOverlap>(),
pitchWithMap,
- params.showCollisionBoxes,
+ showCollisionBoxes,
avoidEdges,
collisionGroup.second,
textBoxes);
@@ -376,7 +373,7 @@ void Placement::placeBucket(const SymbolBucket& bucket,
fontSize,
allowOverlap,
pitchWithMap,
- params.showCollisionBoxes,
+ showCollisionBoxes,
avoidEdges,
collisionGroup.second,
textBoxes);
@@ -392,7 +389,7 @@ void Placement::placeBucket(const SymbolBucket& bucket,
fontSize,
iconAllowOverlap,
pitchWithMap,
- params.showCollisionBoxes,
+ showCollisionBoxes,
avoidEdges,
collisionGroup.second,
iconBoxes);
@@ -490,7 +487,7 @@ void Placement::placeBucket(const SymbolBucket& bucket,
fontSize,
layout.get<style::IconAllowOverlap>(),
pitchWithMap,
- params.showCollisionBoxes,
+ showCollisionBoxes,
avoidEdges,
collisionGroup.second,
iconBoxes);
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 04a0bc7f5d..0d224f67de 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -92,7 +92,6 @@ public:
const mat4& projMatrix;
std::string sourceId;
std::shared_ptr<FeatureIndex> featureIndex;
- bool showCollisionBoxes;
};
class Placement;
@@ -116,7 +115,7 @@ public:
Placement(std::shared_ptr<const UpdateParameters>, optional<Immutable<Placement>> prevPlacement = nullopt);
Placement();
- void placeLayer(const RenderLayer&, const mat4&, bool showCollisionBoxes);
+ void placeLayer(const RenderLayer&, const mat4&);
void commit();
void updateLayerBuckets(const RenderLayer&, const TransformState&, bool updateOpacities) const;
float symbolFadeChange(TimePoint now) const;
@@ -163,6 +162,7 @@ private:
std::unordered_map<uint32_t, RetainedQueryData> retainedQueryData;
CollisionGroups collisionGroups;
mutable optional<Immutable<Placement>> prevPlacement;
+ bool showCollisionBoxes = false;
// Used for debug purposes.
std::unordered_map<const CollisionFeature*, std::vector<ProjectedCollisionBox>> collisionCircles;